public void ReplaceHat(TeamHat teamHat, TeamHat newHat) { if (teamHat == null || teamSpawnsDone.ContainsKey(teamHat) || Level.current == null ) { //|| !(Level.current is GameLevel //|| Level.current is Editor // || Level.current is TeamSelect2)) //throw new Exception("DUCKZ!" + Level.current.ToString()); return; } //throw new Exception("Attempted to replace a hat! " + teamHat.team.hat.texture.textureName); if (teamHat.isServerForObject) { Level.Add(newHat); Duck d = teamHat.equippedDuck; if (d != null) { d.Equip(newHat, false); d.Fondle(newHat); TeamSelect2 lobby = Level.current as TeamSelect2; if (lobby != null) { ProfileBox2 box = lobby.GetBox(d.PlayerIndex()); box._hatSelector.hat = newHat; } } } Level.Remove(teamHat); teamSpawnsDone.Add(teamHat, null); }
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); }