Skip to content

[IDEA] Player::SetRole #450

Description

@ui2506

Goal Description

I suggest changing the Player::SetRole method to return the resulting PlayerRoleBase instead of void.

Currently:

public void SetRole(RoleTypeId newRole, RoleChangeReason reason = RoleChangeReason.RemoteAdmin, RoleSpawnFlags flags = RoleSpawnFlags.All)
{
    ReferenceHub.roleManager.ServerSetRole(newRole, reason, flags);
}
ev.Player.SetRole(RoleTypeId.Tutorial);
PlayerRoleBase roleBase = ev.Player.RoleBase;

It could be changed to:

public PlayerRoleBase SetRole(RoleTypeId newRole, RoleChangeReason reason = RoleChangeReason.RemoteAdmin, RoleSpawnFlags flags = RoleSpawnFlags.All)
{
    PlayerRoleManager manager = ReferenceHub.roleManager.ServerSetRole(newRole, reason, flags);

    return manager._curRole;
}

This would allow developers to immediately access the role that was assigned by SetRole, without having to retrieve it separately afterward.

Alternatively, SetRole could return the PlayerRoleManager itself if that is considered more useful for the API.

Notes

No response

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    ideaThis is an idea to do

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions