/// <summary>
        /// Works both for custom roles and impostors. Complicated.<br/>
        /// May be replaced with <see cref="IsTeamedWithNonCrew(GameData.PlayerInfo,GameData.PlayerInfo)"/> in future
        /// </summary>
        public static bool IsTeamedWith(this GameData.PlayerInfo me, GameData.PlayerInfo other)
        {
            BaseRole?role      = me.GetRole();
            BaseRole?theirRole = other.GetRole();

            return(role?.Team switch
            {
                Team.Alone => me.PlayerId == other.PlayerId,
                Team.Crewmate => true,
                Team.Impostor => other.GetTeam() == Team.Impostor,
                Team.SameRole => role == theirRole,
                _ => theirRole == null
                    ? me.IsImpostor == other.IsImpostor
                    : other.IsTeamedWith(me)
            });
Example #2
0
            public static void Postfix([HarmonyArgument(0)] ref GameData.PlayerInfo data, ref PlayerVoteArea __result)
            {
                BaseRole?role = data.GetRole();

                if (role?.PatchFilterFlags.HasFlag(PatchFilter.MeetingHud) ?? false)
                {
                    return;
                }

                if (PlayerControl.LocalPlayer.Data.CanSee(data) && data.HasRole())
                {
                    __result.NameText.color = role?.Color ?? Palette.ImpostorRed;
                    if (role != null)
                    {
                        __result.NameText.text = role.FormatName(data);
                    }
                }
            }
 /// <summary>
 /// True if <see cref="player"/> has permissions to kill <see cref="target"/><br/>
 /// or <see cref="player"/> is an Impostor and <see cref="target"/> is not
 /// </summary>
 public static bool CanKill(this GameData.PlayerInfo player, PlayerControl?target)
 => player.GetRole()?.CanKill(target) ?? player.IsImpostor && (target == null || target.GetTeam() != Team.Impostor);
 public static bool HasCustomRole(this GameData.PlayerInfo player)
 => player.GetRole() != null;
 public static bool Is <T>(this GameData.PlayerInfo player) where T : BaseRole
 => player.GetRole <T>() != null;
 /// <summary>
 /// Get a specific role if player has it, otherwise null
 /// </summary>
 public static T?GetRole <T>(this GameData.PlayerInfo player) where T : BaseRole
 => player.GetRole() as T;