示例#1
0
 public static bool Prefix(HatSelector __instance, ref int __result)
 {
     if (Network.isActive)
     {
         __result = Maths.Clamp(__instance.profileBoxNumber, 0, 7);
         return(false);
     }
     if (__instance.inputProfile.name == "MPPlayer1")
     {
         __result = 0;
         return(false);
     }
     if (__instance.inputProfile.name == "MPPlayer2")
     {
         __result = 1;
         return(false);
     }
     if (__instance.inputProfile.name == "MPPlayer3")
     {
         __result = 2;
         return(false);
     }
     if (__instance.inputProfile.name == "MPPlayer4")
     {
         __result = 3;
         return(false);
     }
     if (__instance.inputProfile.name == "MPPlayer5")
     {
         __result = 4;
         return(false);
     }
     if (__instance.inputProfile.name == "MPPlayer6")
     {
         __result = 5;
         return(false);
     }
     if (__instance.inputProfile.name == "MPPlayer7")
     {
         __result = 6;
         return(false);
     }
     if (__instance.inputProfile.name == "MPPlayer8")
     {
         __result = 7;
         return(false);
     }
     __result = 0;
     return(false);
 }
示例#2
0
        public Team FilterTeam(bool hardFilter = false)
        {
            Team        t           = null;
            Profile     _profile    = DuckNetwork.profiles[profileBoxNumber];
            TeamSelect2 current     = Level.current as TeamSelect2;
            ProfileBox2 box         = current.GetBox((byte)profileBoxNumber);
            HatSelector hatSelector = box._hatSelector;

            if (!Network.isActive)
            {
                t = AllTeams()[(int)_desiredTeamSelection];
            }
            int index = (int)_desiredTeamSelection;

            if (index >= AllTeams().Count)
            {
                index = ControllerNumber();
            }
            if (_profile != null && _profile.connection == DuckNetwork.localConnection && !hardFilter)
            {
                if (index >= Teams.core.teams.Count)
                {
                    Team allTeam = AllTeams()[index];
                    index = ControllerNumber();
                }
                t = AllTeams()[index];
            }
            Team allTeam1;

            if (_profile.connection == DuckNetwork.localConnection)
            {
                if (index >= Teams.core.teams.Count)
                {
                    Team allTeam2 = AllTeams()[index];
                    allTeam1 = AllTeams()[ControllerNumber()];
                    Team.MapFacade(localID, allTeam2);
                    Send.Message((NetMessage) new NMSpecialHat(allTeam2, localID));
                }
                else
                {
                    allTeam1 = AllTeams()[index];
                    Team.ClearFacade(_profile.steamID);
                    Send.Message((NetMessage) new NMSpecialHat((Team)null, localID));
                }
            }
            else
            {
                allTeam1 = AllTeams()[index];
            }
            t = allTeam1;

            if (hardFilter == true)
            {
                if (Network.isActive && box.duck != null)
                {
                    Send.Message(new NMSetTeam(box.duck.profile.networkIndex, (byte)Teams.IndexOf(t)));
                }
                if (t.hasHat)
                {
                    if (box.duck != null)
                    {
                        Hat equipment = box.duck.GetEquipment(typeof(Hat)) as Hat;
                        Hat hat       = (Hat) new TeamHat(0.0f, 0.0f, t);
                        Level.Add((Thing)hat);
                        box.duck.Equip((Equipment)hat, false, false);
                        box.duck.Fondle((Thing)hat);
                        if (hatSelector.hat != null)
                        {
                            Level.Remove((Thing)hatSelector.hat);
                        }
                        hatSelector.hat = hat;
                        if (equipment != null)
                        {
                            Level.Remove((Thing)equipment);
                        }
                    }
                    else if (hatSelector.hat != null)
                    {
                        Level.Remove((Thing)hatSelector.hat);
                    }
                }
                else
                {
                    if (hatSelector.hat != null)
                    {
                        Level.Remove((Thing)hatSelector.hat);
                    }
                    hatSelector.hat = (Hat)null;
                    if (box.duck != null)
                    {
                        Hat equipment = box.duck.GetEquipment(typeof(Hat)) as Hat;
                        if (equipment != null)
                        {
                            box.duck.Unequip((Equipment)equipment, false);
                            Level.Remove((Thing)equipment);
                        }
                    }
                }
                if (_desiredTeamSelection <= 7)
                {
                    _desiredTeamSelection = 0;
                }
            }
            return(t);
        }