public static Profile JoinLocalDuck(InputProfile input) { int num = 1; foreach (Profile profile in DuckNetwork.profiles) { if (profile.connection == DuckNetwork.localConnection) { ++num; } } string name = Network.activeNetwork.core.GetLocalName(); if (num > 1) { name = name + "(" + num.ToString() + ")"; } //Invoke the private method. Hope its not too slow Profile profile1 = (Profile)createProfile.Invoke(null, new object[] { DuckNetwork.localConnection, name, -1, input, false, false, true }); if (profile1 == null) { return((Profile)null); } profile1.networkStatus = !Network.isClient ? DuckNetStatus.Connected : DuckNetStatus.Connecting; // Our new OnNetworkConnecting which should bloody work TeamSelect2Edits.OnNetworkConnecting(profile1); DuckNetwork.SendNewProfile(profile1, DuckNetwork.localConnection, false); return(profile1); }
public static void Join(string id, string ip = "localhost") { if (DuckNetwork.core.status != DuckNetStatus.Disconnected) { return; } DuckNetwork.Reset(); foreach (Profile universalProfile in Profiles.universalProfileList) { universalProfile.team = null; } for (int index = 0; index < 8; ++index) { Teams.all[index].customData = null; } foreach (Profile profile in DuckNetwork.profiles) { profile.slotType = SlotType.Open; } DuckNetwork.core.error = null; DuckNetwork.core.localDuckIndex = -1; TeamSelect2.DefaultSettings(); Network.JoinServer(id, 1337, ip); DuckNetwork.localConnection.AttemptConnection(); DuckNetwork.core.attemptTimeout = 15f; DuckNetwork.core.status = DuckNetStatus.EstablishingCommunication; }
public override void Initialize() { DuckNetwork.ClosePauseMenu(); ConnectionStatusUI.Hide(); Network.Disconnect(); base.Initialize(); }
public override void Update() { if (DuckNetwork.status == DuckNetStatus.Disconnected && !this._attemptedConnection) { this._startedJoining = true; if (Profiles.active.Count == 0) { Profiles.DefaultPlayer1.team = Teams.Player1; } TeamSelect2.FillMatchmakingProfiles(); if (this._lobbyID == 0UL) { DuckNetwork.Join("duckGameServer"); } else { DuckNetwork.Join(this._lobbyID.ToString()); } this._attemptedConnection = true; } else if (DuckNetwork.status == DuckNetStatus.Disconnected && this._attemptedConnection) { Level.current = (Level) new ConnectionError("|RED|CONNECTION FAILED!"); } base.Update(); }
public override void Initialize() { DuckNetwork.ClosePauseMenu(); ConnectionStatusUI.Hide(); HUD.AddCornerMessage(HUDCorner.BottomRight, "@START@CONTINUE"); this._startCalled = true; base.Initialize(); }
public static void DoInvite() { bool _attemptingToInvite = (bool)typeof(TeamSelect2).GetField("_attemptingToInvite", BindingFlags.Instance | BindingFlags.Static | BindingFlags.NonPublic | BindingFlags.Public).GetValue(Level.current as TeamSelect2); if (!Network.isActive) { bool _didHost = (bool)typeof(TeamSelect2).GetField("_didHost", BindingFlags.Instance | BindingFlags.Static | BindingFlags.NonPublic | BindingFlags.Public).GetValue(Level.current as TeamSelect2); TeamSelect2.FillMatchmakingProfiles(); DuckNetwork.Host(8, NetworkLobbyType.FriendsOnly); (Level.current as TeamSelect2).PrepareForOnline(); _didHost = true; } _attemptingToInvite = true; }
public static bool HasPendingUnlocks() { if (Profiles.experienceProfile != null) { if (Profiles.experienceProfile.numLittleMen >= 7 && !Global.data.boughtHats.Contains("MOONWALK")) { Global.data.boughtHats += "|MOONWALK"; } if (Profiles.experienceProfile.xp >= DuckNetwork.GetLevel(999).xpRequired&& !Global.data.boughtHats.Contains("MAJESTY")) { Global.data.boughtHats += "|MAJESTY"; } } Unlockables._pendingUnlocks.Clear(); foreach (Unlockable unlock in Unlockables._unlocks) { if (unlock.locked) { if (unlock.CheckCondition()) { if (unlock.showScreen) { Unlockables._pendingUnlocks.Add(unlock); } else { unlock.DoUnlock(); } } else { unlock.DoLock(); } } } Steam.StoreStats(); return(Unlockables._pendingUnlocks.Count > 0); }
public override void Initialize() { if (this._text == "INCOMPATIBLE MOD SETUP!") { this._downloadModsMenu = new UIMenu("MODS REQUIRED!", Layer.HUD.camera.width / 2f, Layer.HUD.camera.height / 2f, 290f, conString: "@SELECT@SELECT"); this._downloadModsMenu.Add((UIComponent) new UIText("You're missing the mods required", Colors.DGBlue), true); this._downloadModsMenu.Add((UIComponent) new UIText("to join this game. Would you", Colors.DGBlue), true); this._downloadModsMenu.Add((UIComponent) new UIText("like to automatically subscribe to", Colors.DGBlue), true); this._downloadModsMenu.Add((UIComponent) new UIText("all required mods, restart and", Colors.DGBlue), true); this._downloadModsMenu.Add((UIComponent) new UIText("join the game?", Colors.DGBlue), true); this._downloadModsMenu.Add((UIComponent) new UIText("", Colors.DGBlue), true); this._downloadModsMenu.Add((UIComponent) new UIMenuItem("NO!", (UIMenuAction) new UIMenuActionCloseMenu((UIComponent)this._downloadModsMenu)), true); this._downloadModsMenu.Add((UIComponent) new UIMenuItem("YES!", (UIMenuAction) new UIMenuActionCloseMenuCallFunction((UIComponent)this._downloadModsMenu, new UIMenuActionCloseMenuCallFunction.Function(UIServerBrowser.SubscribeAndRestart))), true); this._downloadModsMenu.Close(); this._downloadModsMenu.Open(); MonoMain.pauseMenu = (UIComponent)this._downloadModsMenu; } DuckNetwork.ClosePauseMenu(); ConnectionStatusUI.Hide(); this._startCalled = true; HUD.AddCornerMessage(HUDCorner.BottomRight, "@START@CONTINUE"); base.Initialize(); }
public static NetMessage OnMessageFromNewClient(NetMessage m) { if (Network.isServer) { if (m is NMRequestJoin) { if (DuckNetwork.inGame) { return((NetMessage) new NMGameInProgress()); } NMRequestJoin nmRequestJoin = m as NMRequestJoin; // DevConsole.Log(DCSection.DuckNet, "|DGYELLOW|Join attempt from " + nmRequestJoin.name, -1); NMVersionMismatch.Type code = DuckNetwork.CheckVersion(nmRequestJoin.id); if (code != NMVersionMismatch.Type.Match) { // DevConsole.Log(DCSection.DuckNet, "|DGYELLOW|" + nmRequestJoin.name + " had a version mismatch.", -1); // return (NetMessage)new NMVersionMismatch(code, DG.version); return((NetMessage) new NMVersionMismatch(code, Assembly.GetEntryAssembly().GetName().Version.ToString())); } Type methodtype = typeof(DuckNetwork); MethodInfo createProfile = methodtype.GetMethod("CreateProfile", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static); // Profile profile = DuckNetwork.CreateProfile(m.connection, nmRequestJoin.name, -1, (InputProfile)null, nmRequestJoin.hasCustomHats, nmRequestJoin.wasInvited, false); Profile profile = (Profile)createProfile.Invoke(null, new object[] { m.connection, nmRequestJoin.name, -1, (InputProfile)null, nmRequestJoin.hasCustomHats, nmRequestJoin.wasInvited, false }); if (profile == null) { // DevConsole.Log(DCSection.DuckNet, "|DGYELLOW|" + nmRequestJoin.name + " could not join, server is full.", -1); return((NetMessage) new NMServerFull()); } profile.flippers = nmRequestJoin.flippers; profile.networkStatus = DuckNetStatus.WaitingForLoadingToBeFinished; _core.status = DuckNetStatus.Connected; TeamSelect2Edits.OnNetworkConnecting(profile); DuckNetwork.SendNewProfile(profile, m.connection, false); // More slots so we need bigger method to handle them Send.Message(new NMChangeSlotsEdits((byte)DuckNetwork.profiles[0].slotType, (byte)DuckNetwork.profiles[1].slotType, (byte)DuckNetwork.profiles[2].slotType, (byte)DuckNetwork.profiles[3].slotType, (byte)DuckNetwork.profiles[4].slotType, (byte)DuckNetwork.profiles[5].slotType, (byte)DuckNetwork.profiles[6].slotType, (byte)DuckNetwork.profiles[7].slotType), m.connection); TeamSelect2.SendMatchSettings(m.connection, true); return((NetMessage)null); } if (m is NMMessageIgnored) { return((NetMessage)null); } } else { if (m is NMRequestJoin) { // DevConsole.Log(DCSection.DuckNet, "|DGYELLOW|Another computer has requested a matchmaking connection.", -1); return((NetMessage) new NMGameInProgress()); } if (m is NMMessageIgnored) { return((NetMessage)null); } } return((NetMessage) new NMMessageIgnored()); }
// A lot of this code is ripped from DuckGame.DM.AddPoints // PlayHooky currently doesn't support calling the original method, and it's honestly a lot easier to patch this code than run before or after it anyway // Please don't sue me, Corptron or Adult Swim public static List <Profile> AddPointsHook(DM t) { List <Profile> profileList = new List <Profile>(); List <Team> teamList = new List <Team>(); List <Team> source = new List <Team>(); foreach (Team team in Teams.all) { foreach (Profile activeProfile in team.activeProfiles) { if (activeProfile.duck != null && !activeProfile.duck.dead) { if (activeProfile.duck.converted != null && activeProfile.duck.converted.profile.team != activeProfile.team) { if (!source.Contains(activeProfile.duck.converted.profile.team)) { source.Add(activeProfile.duck.converted.profile.team); } if (!teamList.Contains(activeProfile.duck.profile.team)) { teamList.Add(activeProfile.duck.profile.team); break; } break; } if (!source.Contains(team)) { source.Add(team); break; } break; } } } if (source.Count <= 1 && source.Count > 0) { source.AddRange((IEnumerable <Team>)teamList); byte winteam = 4; List <int> idxs = new List <int>(); GameMode.lastWinners.Clear(); bool hasSetVibePower = false; foreach (Team team in source) { foreach (Profile activeProfile in team.activeProfiles) { if (activeProfile.duck != null && !activeProfile.duck.dead) { FieldInfo fEditorTestMode = t.GetType().GetField("_editorTestMode", BindingFlags.NonPublic | BindingFlags.Instance); bool _editorTestMode = (bool)fEditorTestMode.GetValue(t); if (!_editorTestMode) { if (Teams.active.Count > 1 && Network.isActive && activeProfile.connection == DuckNetwork.localConnection) { DuckNetwork.GiveXP("Rounds Won", 1, 4, 4, 10, 20, 9999999); if (!hasSetVibePower) { Debug.Log("[DGBP] Local player won!"); RemoveVibePower(); hasSetVibePower = true; } } activeProfile.stats.lastWon = DateTime.Now; ++activeProfile.stats.matchesWon; } profileList.Add(activeProfile); Profile p = activeProfile; if (activeProfile.duck.converted != null) { p = activeProfile.duck.converted.profile; winteam = p.networkIndex; } GameMode.lastWinners.Add(activeProfile); PlusOne plusOne = new PlusOne(0.0f, 0.0f, p, false); plusOne.anchor = (Anchor)((Thing)activeProfile.duck); plusOne.anchor.offset = new Vec2(0.0f, -16f); idxs.Add((int)activeProfile.duck.netProfileIndex); Level.Add((Thing)plusOne); } } } if (Network.isActive && Network.isServer) { Send.Message((NetMessage) new NMAssignWin(idxs, winteam)); } ++source.First <Team>().score; if (!hasSetVibePower && Network.isActive) { Debug.Log("[DGBP] Remote player won!"); AddVibePower(); } } return(profileList); }
public static void Initialize() { Unlockables._unlocks.Add((Unlockable) new UnlockableHats("hatpack1", new List <Team>() { Teams.GetTeam("BAWB"), Teams.GetTeam("Frank"), Teams.GetTeam("Meeee") }, (Func <bool>)(() => Unlocks.IsUnlocked("HATTY1")), "Hat Pack 1", "Check out these nifty cool hats.")); Unlockables._unlocks.Add((Unlockable) new UnlockableHats("hatpack2", new List <Team>() { Teams.GetTeam("Pulpy"), Teams.GetTeam("Joey"), Teams.GetTeam("Cowboys") }, (Func <bool>)(() => Unlocks.IsUnlocked("HATTY2")), "Hat Pack 2", "More cool hats! WOW!")); bool futz = false; Unlockables._unlocks.Add((Unlockable) new UnlockableAchievement("gamerduck", (Func <bool>)(() => Global.data.timesSpawned > (futz ? 0 : 99)), "Duck Gamer", "Spawn 100 times.", "play100")); Unlockables._unlocks.Add((Unlockable) new UnlockableHat("chancyHat", Teams.GetTeam("Chancy"), (Func <bool>)(() => Unlocks.IsUnlocked("ULTIMATE")), "Chancy", "Got platinum on all challenges", "chancy")); Unlockables._unlocks.Add((Unlockable) new UnlockableAchievement("ritual", (Func <bool>)(() => Global.data.timesSpawned > (futz ? 1 : 999)), "Ritual", "Spawn 1000 times.", "play1000")); Unlockables._unlocks.Add((Unlockable) new UnlockableHat("skully", Teams.GetTeam("SKULLY"), (Func <bool>)(() => Global.data.kills > (futz ? 3 : 999)), "SKULLY", "Kill 1000 Ducks", "kill1000")); Unlockables._unlocks.Add((Unlockable) new UnlockableAchievement("endurance", (Func <bool>)(() => Global.data.longestMatchPlayed > (futz ? 5 : 49)), "Endurance", "Play through a 50 point match", "endurance")); Unlockables._unlocks.Add((Unlockable) new UnlockableAchievement("outgoing", (Func <bool>)(() => Global.data.onlineWins > (futz ? 0 : 9)), "Outgoing", "Win 10 online matches", "online10")); Unlockables._unlocks.Add((Unlockable) new UnlockableAchievement("basement", (Func <bool>)(() => Unlocks.IsUnlocked("BASEMENTKEY")), "Basement Dweller", "Unlock the basement", "basement")); Unlockables._unlocks.Add((Unlockable) new UnlockableAchievement("poweruser", (Func <bool>)(() => Global.data.customMapPlayCount.Count > (futz ? 0 : 9)), "Power User", "Play on 10 different custom maps", "editor")); Unlockables._unlocks.Add((Unlockable) new UnlockableAchievement("drawbreaker", (Func <bool>)(() => Global.data.drawsPlayed > (futz ? 0 : 9)), "Draw Breaker", "Break 10 draws", "drawbreaker")); Unlockables._unlocks.Add((Unlockable) new UnlockableAchievement("hotstuff", (Func <bool>)(() => (double)Profiles.MostTimeOnFire() > (futz ? 2.0 : 899.0)), "Hot Stuff", "Spend 15 minutes on fire with any one profile", "fire")); Unlockables._unlocks.Add((Unlockable) new UnlockableAchievement("myboy", (Func <bool>)(() => Profiles.experienceProfile != null && Profiles.experienceProfile.numLittleMen > 0), "That's My Boy", "Raise a little man.", "myboy")); Unlockables._unlocks.Add((Unlockable) new UnlockableAchievement("jukebox", (Func <bool>)(() => Profiles.experienceProfile != null && Profiles.experienceProfile.numLittleMen > 7), "Jukebox Hero", "Raise eight little men.", "jukebox")); Unlockables._unlocks.Add((Unlockable) new UnlockableAchievement("kingme", (Func <bool>)(() => Profiles.experienceProfile != null && Profiles.experienceProfile.xp >= DuckNetwork.GetLevel(999).xpRequired), "King Me", "Level up all the way.", "kingme")); Unlockables._unlocks.Add((Unlockable) new UnlockableHat("ballz", Teams.GetTeam("BALLZ"), (Func <bool>)(() => Global.data.ducksCrushed > (futz ? 0 : 49)), "BALLZ", "Crush 50 Ducks", "crate")); Unlockables._unlocks.Add((Unlockable) new UnlockableHat("hearts", Teams.GetTeam("Hearts"), (Func <bool>)(() => Global.data.matchesPlayed > (futz ? 0 : 49)), "<3", "Finish 50 whole matches.", "finish50")); Unlockables._unlocks.Add((Unlockable) new UnlockableHat("swackHat", Teams.GetTeam("SWACK"), (Func <bool>)(() => Global.data.matchesPlayed > 0), "SWACK", "Play through a match")); Unlockables._unlocks.Add((Unlockable) new UnlockableHat("BRODUCK", Teams.GetTeam("BRODUCK"), (Func <bool>)(() => Global.data.strafeDistance > (futz ? 0.25f : 10f)), "BRODUCK", "Strafe 10 Kilometers")); Unlockables._unlocks.Add((Unlockable) new UnlockableHat("astropal", Teams.GetTeam("astropal"), (Func <bool>)(() => Global.data.jetFuelUsed > (futz ? 5f : 200f)), "ASTROPAL", "Burn 200 gallons of rocket fuel.")); Unlockables._unlocks.Add((Unlockable) new UnlockableHat("eggpal", Teams.GetTeam("eggpal"), (Func <bool>)(() => Global.data.winsAsSwack > (futz ? 0 : 4)), "EGGPAL", "Win 5 rounds as SWACK")); Unlockables._unlocks.Add((Unlockable) new UnlockableHat("brad", Teams.GetTeam("brad"), (Func <bool>)(() => Global.data.disarms > (futz ? 0 : 99)), "BRAD DUNGEON", "Disarm 100 ducks.")); Unlockables._unlocks.Add((Unlockable) new UnlockableHat("brick", Teams.GetTeam("BRICK"), (Func <bool>)(() => Global.data.laserBulletsFired > (futz ? 0 : 149)), "BRICK", "Fire 150 laser bullets.")); Unlockables._unlocks.Add((Unlockable) new UnlockableHat("ducks", Teams.GetTeam("DUCKS"), (Func <bool>)(() => Global.data.quacks > 999), "DUCK", "Quack 1000 times.")); Unlockables._unlocks.Add((Unlockable) new UnlockableHat("funnyman", Teams.GetTeam("FUNNYMAN"), (Func <bool>)(() => Global.data.hatsStolen > 100), "FUNNYMAN", "Wear 100 different faces.")); Unlockables._unlocks.Add((Unlockable) new UnlockableHat("wizards", Teams.GetTeam("Wizards"), (Func <bool>)(() => Global.data.angleShots > 25), "Wizard", "Make 25 angle trick shots.")); string str1 = "CYCLOPS"; if (Teams.GetTeam(str1) != null) { Unlockables._unlocks.Add((Unlockable) new UnlockableHat(str1.ToLowerInvariant(), Teams.GetTeam(str1), (Func <bool>)(() => Global.data.boughtHats.Contains("CYCLOPS")), str1, Teams.GetTeam(str1).description)); } string str2 = "MOTHERS"; if (Teams.GetTeam(str2) != null) { Unlockables._unlocks.Add((Unlockable) new UnlockableHat(str2.ToLowerInvariant(), Teams.GetTeam(str2), (Func <bool>)(() => Global.data.boughtHats.Contains("MOTHERS")), str2, Teams.GetTeam(str2).description)); } string str3 = "BIG ROBO"; if (Teams.GetTeam(str3) != null) { Unlockables._unlocks.Add((Unlockable) new UnlockableHat(str3.ToLowerInvariant(), Teams.GetTeam(str3), (Func <bool>)(() => Global.data.boughtHats.Contains("BIG ROBO")), str3, Teams.GetTeam(str3).description)); } string str4 = "TINCAN"; if (Teams.GetTeam(str4) != null) { Unlockables._unlocks.Add((Unlockable) new UnlockableHat(str4.ToLowerInvariant(), Teams.GetTeam(str4), (Func <bool>)(() => Global.data.boughtHats.Contains("TINCAN")), str4, Teams.GetTeam(str4).description)); } string str5 = "WELDERS"; if (Teams.GetTeam(str5) != null) { Unlockables._unlocks.Add((Unlockable) new UnlockableHat(str5.ToLowerInvariant(), Teams.GetTeam(str5), (Func <bool>)(() => Global.data.boughtHats.Contains("WELDERS")), str5, Teams.GetTeam(str5).description)); } string str6 = "PONYCAP"; if (Teams.GetTeam(str6) != null) { Unlockables._unlocks.Add((Unlockable) new UnlockableHat(str6.ToLowerInvariant(), Teams.GetTeam(str6), (Func <bool>)(() => Global.data.boughtHats.Contains("PONYCAP")), str6, Teams.GetTeam(str6).description)); } string str7 = "TRICORNE"; if (Teams.GetTeam(str7) != null) { Unlockables._unlocks.Add((Unlockable) new UnlockableHat(str7.ToLowerInvariant(), Teams.GetTeam(str7), (Func <bool>)(() => Global.data.boughtHats.Contains("TRICORNE")), str7, Teams.GetTeam(str7).description)); } string str8 = "TWINTAIL"; if (Teams.GetTeam(str8) != null) { Unlockables._unlocks.Add((Unlockable) new UnlockableHat(str8.ToLowerInvariant(), Teams.GetTeam(str8), (Func <bool>)(() => Global.data.boughtHats.Contains("TWINTAIL")), str8, Teams.GetTeam(str8).description)); } string str9 = "MAJESTY"; if (Teams.GetTeam(str9) != null) { Unlockables._unlocks.Add((Unlockable) new UnlockableHat(str9.ToLowerInvariant(), Teams.GetTeam(str9), (Func <bool>)(() => Global.data.boughtHats.Contains("MAJESTY")), str9, "Max out your level (holy crap!!)")); } string str10 = "MOONWALK"; if (Teams.GetTeam(str10) != null) { Unlockables._unlocks.Add((Unlockable) new UnlockableHat(str10.ToLowerInvariant(), Teams.GetTeam(str10), (Func <bool>)(() => Global.data.boughtHats.Contains("MOONWALK")), str10, "Raise 8 little men.")); } Unlockables._unlocks.Add((Unlockable) new UnlockableHat("devtimes", Teams.GetTeam("CAPTAIN"), (Func <bool>)(() => ((int)Profile.CalculateLocalFlippers() & 16) != 0), "UR THE BEST", "Thank you for playing Duck Game <3")); Unlockables._unlocks.Add((Unlockable) new UnlockableHat("eyebob", Teams.GetTeam("eyebob"), (Func <bool>)(() => Global.data.giantLaserKills > 24), "CHARGE SHOT", "Get 25 Kills With the Giant Death Laser")); foreach (Unlockable unlock in Unlockables._unlocks) { unlock.Initialize(); if (unlock.CheckCondition()) { unlock.DoUnlock(); } } }
public void CreateInstance(int init, bool isHost) { NetworkDebugger._networkDrawingIndex = init; NetworkInstance networkInstance = new NetworkInstance() { network = new Network(NetworkDebugger._networkDrawingIndex) }; if (this._startLevel == null) { networkInstance.teamsCore = new TeamsCore(); networkInstance.teamsCore.Initialize(); } else { networkInstance.teamsCore = Teams.core; List <Team> teamList = new List <Team>((IEnumerable <Team>)Teams.core.extraTeams); Teams.core = new TeamsCore(); Teams.core.Initialize(); Teams.core.extraTeams = teamList; } if (this._startLayer != null) { networkInstance.layerCore = this._startLayer; this._startLayer = (LayerCore)null; } else { networkInstance.layerCore = new LayerCore(); networkInstance.layerCore.InitializeLayers(); } networkInstance.virtualCore = new VirtualTransitionCore(); networkInstance.virtualCore.Initialize(); if (this._startLevel == null) { networkInstance.profileCore = new ProfilesCore(); networkInstance.profileCore.Initialize(); networkInstance.profileCore.DefaultPlayer2.team = (Team)null; } else { networkInstance.profileCore = Profiles.core; Profiles.core = new ProfilesCore(); Profiles.core.Initialize(); } networkInstance.inputProfile = new InputProfileCore(); InputProfileCore core1 = InputProfile.core; InputProfile.core = networkInstance.inputProfile; Input.InitDefaultProfiles(); networkInstance.levelCore = new LevelCore(); LevelCore core2 = Level.core; Level.core = networkInstance.levelCore; networkInstance.crowdCore = new CrowdCore(); CrowdCore core3 = Crowd.core; Crowd.core = networkInstance.crowdCore; TeamsCore core4 = Teams.core; networkInstance.teamsCore.extraTeams = new List <Team>((IEnumerable <Team>)Teams.core.extraTeams); Teams.core = networkInstance.teamsCore; ProfilesCore core5 = Profiles.core; Profiles.core = networkInstance.profileCore; LayerCore core6 = Layer.core; Layer.core = networkInstance.layerCore; VirtualTransitionCore core7 = VirtualTransition.core; VirtualTransition.core = networkInstance.virtualCore; Network activeNetwork = Network.activeNetwork; Network.activeNetwork = networkInstance.network; networkInstance.network.DoInitialize(); networkInstance.duckNetworkCore = new DuckNetworkCore(); GameModeCore gameModeCore = new GameModeCore(); networkInstance.gameModeCore = gameModeCore; GameModeCore core8 = GameMode.core; GameMode.core = gameModeCore; networkInstance.connectionUICore = new ConnectionStatusUICore(); ConnectionStatusUICore core9 = ConnectionStatusUI.core; ConnectionStatusUI.core = networkInstance.connectionUICore; networkInstance.consoleCore = new DevConsoleCore(); DevConsoleCore core10 = DevConsole.core; DevConsole.core = networkInstance.consoleCore; DuckNetworkCore core11 = DuckNetwork.core; DuckNetwork.core = networkInstance.duckNetworkCore; DuckNetwork.Initialize(); networkInstance.monoCore = new MonoMainCore(); MonoMainCore core12 = MonoMain.core; MonoMain.core = networkInstance.monoCore; if (isHost) { foreach (Profile profile in Profiles.all) { if (profile.team != null) { NetworkDebugger.inputProfiles[Persona.Number(profile.persona)] = InputProfile.defaultProfiles[Persona.Number(profile.persona)]; } } DuckNetwork.Host(4, NetworkLobbyType.Public); if (this._startLevel != null) { Level.current = this._startLevel; this._startLevel.NetworkDebuggerPrepare(); this._startLevel = (Level)null; } else { Level.current = (Level) new TeamSelect2(); } } else { Level.current = (Level) new JoinServer(0UL); } networkInstance.joined = true; if (init >= NetworkDebugger._instances.Count) { NetworkDebugger._instances.Add(networkInstance); } else { NetworkDebugger._instances[init] = networkInstance; } base.Initialize(); InputProfile.core = core1; Network.activeNetwork = activeNetwork; DuckNetwork.core = core11; Teams.core = core4; Profiles.core = core5; Layer.core = core6; VirtualTransition.core = core7; Level.core = core2; DevConsole.core = core10; Crowd.core = core3; GameMode.core = core8; ConnectionStatusUI.core = core9; MonoMain.core = core12; }
public static void Initialize() { RockScoreboard rockScore = (RockScoreboard)Level.current; /* * FieldInfo matchesPlayed = globaldatatype.GetField("matchesPlayed", BindingFlags.Static | BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance); * FieldInfo longestMatchPlayed = globaldatatype.GetField("longestMatchPlayed", BindingFlags.Static | BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance); * FieldInfo onlineWins = globaldatatype.GetField("onlineWins", BindingFlags.Static | BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance); * FieldInfo winsAsSwack = globaldatatype.GetField("winsAsSwack", BindingFlags.Static | BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance); */ MethodInfo globalWinMatch = type.GetMethod("WinMatch", BindingFlags.Static | BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance); Type pedestal = ass.GetType("DuckGame.Pedestal"); Type ginormoboard = ass.GetType("DuckGame.GinormoBoard"); Type boardmode = ass.GetType("DuckGame.BoardMode"); var boardmode1 = boardmode.GetField("Wins", BindingFlags.Static | BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance).GetValue(null); var boardmode2 = boardmode.GetField("Points", BindingFlags.Static | BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance).GetValue(null); Type music = ass.GetType("DuckGame.Music"); PropertyInfo musicvolume = music.GetProperty("volume", BindingFlags.Static | BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance); MethodInfo musicvolumeset = musicvolume.GetSetMethod(); MethodInfo musicplay = music.GetMethod("Play", BindingFlags.Static | BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance, null, new Type[] { typeof(string), typeof(bool), typeof(float) }, null); Type options = ass.GetType("DuckGame.Options"); var optionsdata = options.GetField("_data", BindingFlags.Static | BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance).GetValue(null); Type optionsdatavolume = ass.GetType("DuckGame.OptionsData"); dynamic ayylmao = optionsdatavolume.GetProperty("musicVolume", BindingFlags.Static | BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance).GetValue(optionsdata); FieldInfo didSkip = ass.GetType("DuckGame.HighlightLevel").GetField("didSkip", BindingFlags.Static | BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance); Type distancemarker = ass.GetType("DuckGame.DistanceMarker"); FieldInfo _inputsField = inputtype.GetField("_inputs", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static); dynamic _inputs = _inputsField.GetValue(Level.current as RockScoreboard); FieldInfo _afterHighlightsField = inputtype.GetField("_afterHighlights", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static); dynamic _afterHighlights = _afterHighlightsField.GetValue(Level.current as RockScoreboard); FieldInfo _skipFadeField = inputtype.GetField("_skipFade", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static); dynamic _skipFade = _skipFadeField.GetValue(Level.current as RockScoreboard); FieldInfo _weatherField = inputtype.GetField("_weather", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static); dynamic _weather = _weatherField.GetValue(Level.current as RockScoreboard); FieldInfo _sunshineField = inputtype.GetField("_sunshineTarget", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static); dynamic _sunshineTarget = _sunshineField.GetValue(Level.current as RockScoreboard); FieldInfo _screenField = inputtype.GetField("_screenTarget", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static); dynamic _screenTarget = _screenField.GetValue(Level.current as RockScoreboard); FieldInfo _pixelField = inputtype.GetField("_pixelTarget", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static); dynamic _pixelTarget = _pixelField.GetValue(Level.current as RockScoreboard); FieldInfo _sunLayerField = inputtype.GetField("_sunLayer", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static); dynamic _sunLayer = _sunLayerField.GetValue(Level.current as RockScoreboard); FieldInfo sunThingField = inputtype.GetField("sunThing", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static); dynamic sunThing = sunThingField.GetValue(Level.current as RockScoreboard); FieldInfo rainbowThingField = inputtype.GetField("rainbowThing", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static); dynamic rainbowThing = rainbowThingField.GetValue(Level.current as RockScoreboard); FieldInfo rainbowThing2Field = inputtype.GetField("rainbowThing2", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static); dynamic rainbowThing2 = rainbowThing2Field.GetValue(Level.current as RockScoreboard); FieldInfo _crowdField = inputtype.GetField("_crowd", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static); dynamic _crowd = _crowdField.GetValue(Level.current as RockScoreboard); FieldInfo _fieldField = inputtype.GetField("_field", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static); dynamic _field = _fieldField.GetValue(Level.current as RockScoreboard); FieldInfo _bleacherSeatsField = inputtype.GetField("_bleacherSeats", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static); dynamic _bleacherSeats = _bleacherSeatsField.GetValue(Level.current as RockScoreboard); FieldInfo _bleachersField = inputtype.GetField("_bleachers", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static); dynamic _bleachers = _bleachersField.GetValue(Level.current as RockScoreboard); FieldInfo _intermissionTextField = inputtype.GetField("_intermissionText", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static); dynamic _intermissionText = _intermissionTextField.GetValue(Level.current as RockScoreboard); FieldInfo _winnerPostField = inputtype.GetField("_winnerPost", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static); dynamic _winnerPost = _winnerPostField.GetValue(Level.current as RockScoreboard); FieldInfo _winnerBannerField = inputtype.GetField("_winnerBanner", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static); dynamic _winnerBanner = _winnerBannerField.GetValue(Level.current as RockScoreboard); FieldInfo _fontField = inputtype.GetField("_font", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static); dynamic _font = _fontField.GetValue(Level.current as RockScoreboard); FieldInfo _modeField = inputtype.GetField("_mode", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static); dynamic _mode = _modeField.GetValue(Level.current as RockScoreboard); FieldInfo _intermissionSlideField = inputtype.GetField("_intermissionSlide", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static); dynamic _intermissionSlide = _intermissionSlideField.GetValue(Level.current as RockScoreboard); FieldInfo _tieField = inputtype.GetField("_tie", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static); dynamic _tie = _tieField.GetValue(Level.current as RockScoreboard); FieldInfo _highestSlotField = inputtype.GetField("_highestSlot", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static); dynamic _highestSlot = _highestSlotField.GetValue(Level.current as RockScoreboard); FieldInfo _fieldWidthField = inputtype.GetField("_fieldWidth", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static); dynamic _fieldWidth = _fieldWidthField.GetValue(Level.current as RockScoreboard); FieldInfo _matchOverField = inputtype.GetField("_matchOver", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static); dynamic _matchOver = _matchOverField.GetValue(Level.current as RockScoreboard); FieldInfo _winningTeamField = inputtype.GetField("_winningTeam", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static); dynamic _winningTeam = _winningTeamField.GetValue(Level.current as RockScoreboard); FieldInfo _stateField = inputtype.GetField("_state", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static); dynamic _state = _stateField.GetValue(Level.current as RockScoreboard); FieldInfo _scoreBoardField = inputtype.GetField("_scoreBoard", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static); dynamic _scoreBoard = _scoreBoardField.GetValue(Level.current as RockScoreboard); FieldInfo _wallField = inputtype.GetField("_wall", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static); dynamic _wall = _wallField.GetValue(Level.current as RockScoreboard); FieldInfo _fieldForegroundField = inputtype.GetField("_fieldForeground", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static); dynamic _fieldForeground = _fieldForegroundField.GetValue(Level.current as RockScoreboard); FieldInfo _fieldForeground2Field = inputtype.GetField("_fieldForeground2", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static); dynamic _fieldForeground2 = _fieldForeground2Field.GetValue(Level.current as RockScoreboard); FieldInfo _bottomRightField = typeof(Level).GetField("_bottomRight", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static); dynamic _bottomRight = _bottomRightField.GetValue(Level.current as RockScoreboard); if (Network.isActive && Network.isServer) { int num = 0; foreach (Profile profile in DuckNetwork.profiles) { if (profile.connection != null) { InputObject inputObject = new InputObject(); inputObject.profileNumber = (sbyte)num; Level.Add((Thing)inputObject); _inputs.Add(inputObject); ++num; } } } didSkip.SetValue(Level.current as RockScoreboard, false); if (_afterHighlights) { _skipFade = true; } _weather = new RockWeather(Level.current as RockScoreboard); _weather.Start(); Level.Add((Thing)_weather); for (int index = 0; index < 350; ++index) { _weather.Update(); } if (RockScoreboard._sunEnabled) { float num = 9f / 16f; _sunshineTarget = new RenderTarget2D(DuckGame.Graphics.width / 12, (int)((double)DuckGame.Graphics.width * (double)num) / 12, false); _screenTarget = new RenderTarget2D(DuckGame.Graphics.width, (int)((double)DuckGame.Graphics.width * (double)num), false); _pixelTarget = new RenderTarget2D(160, (int)(320.0 * (double)num / 2.0), false); _sunLayer = new Layer("SUN LAYER", 99999, (Camera)null, false, new Vec2()); Layer.Add(_sunLayer); Thing thing = (Thing) new SpriteThing(150f, 120f, new Sprite("sun", 0.0f, 0.0f)); thing.z = -9999f; thing.depth = -0.99f; thing.layer = _sunLayer; thing.xscale = 1f; thing.yscale = 1f; thing.collisionSize = new Vec2(1f, 1f); thing.collisionOffset = new Vec2(0.0f, 0.0f); Level.Add(thing); sunThing = thing; SpriteThing spriteThing1 = new SpriteThing(150f, 80f, new Sprite("rainbow", 0.0f, 0.0f)); spriteThing1.alpha = 0.15f; spriteThing1.z = -9999f; spriteThing1.depth = -0.99f; spriteThing1.layer = _sunLayer; spriteThing1.xscale = 1f; spriteThing1.yscale = 1f; spriteThing1.color = new Color(100, 100, 100); spriteThing1.collisionSize = new Vec2(1f, 1f); spriteThing1.collisionOffset = new Vec2(0.0f, 0.0f); Level.Add((Thing)spriteThing1); rainbowThing = (Thing)spriteThing1; rainbowThing.visible = false; SpriteThing spriteThing2 = new SpriteThing(150f, 80f, new Sprite("rainbow", 0.0f, 0.0f)); spriteThing2.z = -9999f; spriteThing2.depth = -0.99f; spriteThing2.layer = _sunLayer; spriteThing2.xscale = 1f; spriteThing2.yscale = 1f; spriteThing2.color = new Color((int)byte.MaxValue, (int)byte.MaxValue, (int)byte.MaxValue, 90); spriteThing2.collisionSize = new Vec2(1f, 1f); spriteThing2.collisionOffset = new Vec2(0.0f, 0.0f); Level.Add((Thing)spriteThing2); rainbowThing2 = (Thing)spriteThing2; rainbowThing2.visible = false; } List <Team> allRandomized = Teams.allRandomized; if (RockScoreboard.returnLevel == null && !Network.isActive) { allRandomized[0].Join(Profiles.DefaultPlayer1, true); allRandomized[1].Join(Profiles.DefaultPlayer2, true); allRandomized[0].score = 10; allRandomized[1].score = 2; Teams.Player3.score = 3; Teams.Player4.score = 4; } _crowd = new Crowd(); Level.Add((Thing)_crowd); Crowd.mood = Mood.Calm; _field = new FieldBackground("FIELD", 9999); Layer.Add((Layer)_field); _bleacherSeats = new Sprite("bleacherSeats", 0.0f, 0.0f); _bleachers = RockWeather.weather != Weather.Snowing ? new Sprite("bleacherBack", 0.0f, 0.0f) : new Sprite("bleacherBackSnow", 0.0f, 0.0f); _bleachers.center = new Vec2((float)(_bleachers.w / 2), (float)(_bleachers.height - 3)); _intermissionText = new Sprite("rockThrow/intermission", 0.0f, 0.0f); _winnerPost = new Sprite("rockThrow/winnerPost", 0.0f, 0.0f); _winnerBanner = new Sprite("rockThrow/winnerBanner", 0.0f, 0.0f); _font = new BitmapFont("biosFont", 8, -1); List <Team> teamList1 = new List <Team>(); foreach (Team team in Teams.all) { if (team.activeProfiles.Count > 0) { teamList1.Add(team); } } foreach (Team team in teamList1) { team.rockScore = team.score; if (RockScoreboard.wallMode) { team.score = Math.Min(team.score, GameMode.winsPerSet); } } if (_mode == ScoreBoardMode.ShowScores) { _intermissionSlide = 1f; DuckGame.Graphics.fade = 1f; Layer.Game.fade = 0.0f; Layer.Background.fade = 0.0f; Crowd.UpdateFans(); int num1 = 0; Stack <Depth> depthStack = new Stack <Depth>(); for (int index = 0; index < 8; ++index) { depthStack.Push(new Depth((float)index * 0.02f)); } int num2 = 0; foreach (Team team in teamList1) { Depth depth = depthStack.Pop(); float num3 = 223f; float ypos = 0.0f; float num4 = 26f; if (num1 == 1) { num4 = 24f; } else if (num1 == 2) { num4 = 27f; } else if (num1 == 3) { num4 = 32f; } float num5 = (float)(158.0 - num1 * num4); int prevScoreboardScore = team.prevScoreboardScore; int num6 = GameMode.winsPerSet * 2; int num7 = team.score; if (RockScoreboard.wallMode && num7 > GameMode.winsPerSet) { num7 = GameMode.winsPerSet; } rockScore._slots.Add(new Slot3D()); if (num7 >= GameMode.winsPerSet && num7 == num2) { _tie = true; } else if (num7 >= GameMode.winsPerSet && num7 > num2) { _tie = false; num2 = num7; _highestSlot = rockScore._slots[rockScore._slots.Count - 1]; } List <Profile> profileList = new List <Profile>(); Profile profile1 = (Profile)null; bool flag = false; foreach (Profile activeProfile in team.activeProfiles) { if (flag) { profile1 = activeProfile; flag = false; } if (activeProfile.wasRockThrower) { activeProfile.wasRockThrower = false; flag = true; } profileList.Add(activeProfile); } if (profile1 == null) { profile1 = team.activeProfiles[0]; } profileList.Remove(profile1); profileList.Insert(0, profile1); profile1.wasRockThrower = true; byte num8 = (byte)(rockScore._slots.Count - 1); int num9 = 0; foreach (Profile profile2 in profileList) { if (profile2 == profile1) { rockScore._slots[(int)num8].duck = (Duck) new RockThrowDuck(num3 - (float)(num9 * 10), ypos - 16f, profile2); rockScore._slots[(int)num8].duck.planeOfExistence = num8; rockScore._slots[(int)num8].duck.ignoreGhosting = true; rockScore._slots[(int)num8].duck.forceMindControl = true; Level.Add((Thing)rockScore._slots[(int)num8].duck); rockScore._slots[(int)num8].duck.connection = DuckNetwork.localConnection; TeamHat equipment = rockScore._slots[rockScore._slots.Count - 1].duck.GetEquipment(typeof(TeamHat)) as TeamHat; if (equipment != null) { equipment.ignoreGhosting = true; } rockScore._slots[rockScore._slots.Count - 1].duck.z = num5; rockScore._slots[rockScore._slots.Count - 1].duck.depth = depth; rockScore._slots[rockScore._slots.Count - 1].ai = new DuckAI(profile2.inputProfile); if (Network.isActive && profile2.connection != DuckNetwork.localConnection) { rockScore._slots[rockScore._slots.Count - 1].ai._manualQuack = rockScore.GetNetInput((sbyte)profile2.networkIndex); } rockScore._slots[rockScore._slots.Count - 1].duck.derpMindControl = false; rockScore._slots[rockScore._slots.Count - 1].duck.mindControl = (InputProfile)rockScore._slots[rockScore._slots.Count - 1].ai; rockScore._slots[rockScore._slots.Count - 1].rock = new ScoreRock((float)((double)num3 + 18.0 + (double)prevScoreboardScore / (double)num6 * (double)_fieldWidth), ypos, profile2); rockScore._slots[rockScore._slots.Count - 1].rock.planeOfExistence = num8; rockScore._slots[rockScore._slots.Count - 1].rock.ignoreGhosting = true; Level.Add((Thing)rockScore._slots[rockScore._slots.Count - 1].rock); rockScore._slots[rockScore._slots.Count - 1].rock.z = num5; rockScore._slots[rockScore._slots.Count - 1].rock.depth = rockScore._slots[rockScore._slots.Count - 1].duck.depth + 1; rockScore._slots[rockScore._slots.Count - 1].rock.grounded = true; rockScore._slots[rockScore._slots.Count - 1].duck.isRockThrowDuck = true; } else { Duck duck = (Duck) new RockThrowDuck(num3 - (float)(num9 * 12), ypos - 16f, profile2); duck.forceMindControl = true; duck.planeOfExistence = num8; duck.ignoreGhosting = true; Level.Add((Thing)duck); duck.depth = depth; duck.z = num5; duck.derpMindControl = false; DuckAI duckAi = new DuckAI(profile2.inputProfile); if (Network.isActive && profile2.connection != DuckNetwork.localConnection) { duckAi._manualQuack = rockScore.GetNetInput((sbyte)profile2.networkIndex); } duck.mindControl = (InputProfile)duckAi; duck.isRockThrowDuck = true; duck.connection = DuckNetwork.localConnection; rockScore._slots[rockScore._slots.Count - 1].subDucks.Add(duck); rockScore._slots[rockScore._slots.Count - 1].subAIs.Add(duckAi); } ++num9; } rockScore._slots[rockScore._slots.Count - 1].slotIndex = num1; rockScore._slots[rockScore._slots.Count - 1].startX = num3; ++num1; } for (int index = 0; index < 4; ++index) { Block block = new Block(-50f, 0.0f, 1200f, 32f, PhysicsMaterial.Default); block.planeOfExistence = (byte)index; Level.Add((Thing)block); } if (!_tie && num2 > 0) { _matchOver = true; } if (_tie) { GameMode.showdown = true; } } else { if (Teams.active.Count > 1 && !_afterHighlights) { setGlobalStat("matchesPlayed", getGlobalStat("matchesPlayed") + 1); //matchesPlayed.SetValue(globaldata, matchesPlayed.GetValue(globaldata) + 1); globalWinMatch.Invoke(null, new Team[] { Teams.winning[0] }); if (Network.isActive) { foreach (Profile activeProfile in Teams.winning[0].activeProfiles) { if (activeProfile.connection == DuckNetwork.localConnection) { DuckNetwork.GiveXP("Won Match", 0, 10, 4, 9999999, 9999999, 9999999); break; } } } if (GameMode.winsPerSet > (int)getGlobalStat("longestMatchPlayed")) { setGlobalStat("longestMatchPlayed", getGlobalStat("longestMatchPlayed")); } //longestMatchPlayed.SetValue(globaldata, GameMode.winsPerSet); } _intermissionSlide = 0.0f; teamList1.Sort((Comparison <Team>)((a, b) => { if (a.score == b.score) { return(0); } return(a.score >= b.score ? -1 : 1); })); float num1 = (float)(160.0 - (double)(teamList1.Count * 42 / 2) + 21.0); foreach (Team team in Teams.all) { team.prevScoreboardScore = 0; } List <List <Team> > source = new List <List <Team> >(); foreach (Team team in teamList1) { int score = team.score; bool flag = false; for (int index = 0; index < source.Count; ++index) { if (source[index][0].score < score) { source.Insert(index, new List <Team>()); source[index].Add(team); flag = true; break; } if (source[index][0].score == score) { source[index].Add(team); flag = true; break; } } if (!flag) { source.Add(new List <Team>()); source.Last <List <Team> >().Add(team); } } _winningTeam = teamList1[0]; rockScore.controlMessage = 1; _state = ScoreBoardState.None; Crowd.mood = Mood.Dead; bool flag1 = false; if (!_afterHighlights) { int place = 0; int num2 = 0; foreach (List <Team> teamList2 in source) { foreach (Team team in teamList2) { Level.Add((Thing)Activator.CreateInstance(pedestal, new object[] { num1 + (num2 * 42), 150f, team, place })); ++num2; } ++place; } if (_winningTeam.activeProfiles.Count > 1) { ++_winningTeam.wins; } else { ++_winningTeam.activeProfiles[0].wins; } foreach (Profile activeProfile in _winningTeam.activeProfiles) { ++activeProfile.stats.trophiesWon; activeProfile.stats.trophiesSinceLastWin = activeProfile.stats.trophiesSinceLastWinCounter; activeProfile.stats.trophiesSinceLastWinCounter = 0; if (Network.isActive && activeProfile.connection == DuckNetwork.localConnection && !flag1) { flag1 = true; setGlobalStat("onlineWins", getGlobalStat("onlineWins") + 1); //onlineWins.SetValue(globaldata, onlineWins.GetValue(globaldata)+1); if (activeProfile.team.name == "SWACK") { setGlobalStat("winsAsSwack", getGlobalStat("winsAsSwack") + 1); } //winsAsSwack.SetValue(globaldata, winsAsSwack.GetValue(globaldata) + 1); } if (!Network.isActive && activeProfile.team.name == "SWACK") { setGlobalStat("winsAsSwack", getGlobalStat("winsAsSwack") + 1); } //winsAsSwack.SetValue(globaldata, winsAsSwack.GetValue(globaldata) + 1); } MonoMain.LogPlay(); foreach (Team team in teamList1) { foreach (Profile activeProfile in team.activeProfiles) { ++activeProfile.stats.trophiesSinceLastWinCounter; ++activeProfile.stats.gamesPlayed; } } Main.lastLevel = ""; } } _bottomRight = new Vec2(1000f, 1000f); rockScore.lowestPoint = 1000f; _scoreBoard = Activator.CreateInstance(ginormoboard, new object[] { 300f, -320f, _mode == ScoreBoardMode.ShowScores ? boardmode2 : boardmode1 }); // _scoreBoard = new GinormoBoard(300f, -320f, _mode == ScoreBoardMode.ShowScores ? boardmode.Points : BoardMode.Wins); _scoreBoard.z = -130f; Level.Add((Thing)_scoreBoard); rockScore.backgroundColor = new Color(0, 0, 0); musicvolumeset.Invoke(null, new object[] { ayylmao }); if (_mode != ScoreBoardMode.ShowWinner && !_afterHighlights) { musicplay.Invoke(null, new object[] { "SportsTime", true, 0.0f }); } Level.current.camera.y = 0.0f; _field.ypos = 0.0f; Sprite s1 = RockWeather.weather != Weather.Snowing ? (RockWeather.weather != Weather.Raining ? new Sprite("fieldNoise", 0.0f, 0.0f) : new Sprite("fieldNoiseRain", 0.0f, 0.0f)) : new Sprite("fieldNoiseSnow", 0.0f, 0.0f); s1.scale = new Vec2(4f, 4f); s1.depth = (Depth)0.5f; s1.y -= 16f; _field.AddSprite(s1); Sprite s2 = new Sprite("fieldWall", 0.0f, 0.0f); s2.scale = new Vec2(4f, 4f); s2.depth = (Depth)0.5f; s2.y -= 16f; _wall = new WallLayer("FIELDWALL", 80); if (RockScoreboard.wallMode) { _wall.AddWallSprite(s2); } Layer.Add((Layer)_wall); _fieldForeground = new FieldBackground("FIELDFOREGROUND", 80); _fieldForeground.fieldHeight = -13f; Layer.Add((Layer)_fieldForeground); _fieldForeground2 = new FieldBackground("FIELDFOREGROUND2", 70); _fieldForeground2.fieldHeight = -15f; Layer.Add((Layer)_fieldForeground2); if (_mode != ScoreBoardMode.ShowWinner) { Sprite s3 = new Sprite("rockThrow/chairSeat", 0.0f, 0.0f); s3.CenterOrigin(); s3.x = 300f; s3.y = 20f; s3.scale = new Vec2(1.2f, 1.2f); _fieldForeground.AddSprite(s3); Sprite s4 = new Sprite("rockThrow/tableTop", 0.0f, 0.0f); s4.CenterOrigin(); s4.x = 450f; s4.y = 14f; s4.scale = new Vec2(1.2f, 1.4f); _fieldForeground2.AddSprite(s4); int num = -95; Sprite spr1 = new Sprite("rockThrow/chairBottomBack", 0.0f, 0.0f); Thing thing1 = (Thing) new SpriteThing(300f, -10f, spr1); thing1.center = new Vec2((float)(spr1.w / 2), (float)(spr1.h / 2)); thing1.z = (float)(106 + num); thing1.depth = (Depth)0.5f; thing1.layer = Layer.Background; Level.Add(thing1); Sprite spr2 = new Sprite("rockThrow/chairBottom", 0.0f, 0.0f); Thing thing2 = (Thing) new SpriteThing(300f, -6f, spr2); thing2.center = new Vec2((float)(spr2.w / 2), (float)(spr2.h / 2)); thing2.z = (float)(120 + num); thing2.depth = (Depth)0.8f; thing2.layer = Layer.Background; Level.Add(thing2); Sprite spr3 = new Sprite("rockThrow/chairFront", 0.0f, 0.0f); Thing thing3 = (Thing) new SpriteThing(300f, -9f, spr3); thing3.center = new Vec2((float)(spr3.w / 2), (float)(spr3.h / 2)); thing3.z = (float)(122 + num); thing3.depth = (Depth)0.9f; thing3.layer = Layer.Background; Level.Add(thing3); Sprite spr4 = new Sprite("rockThrow/tableBottomBack", 0.0f, 0.0f); Thing thing4 = (Thing) new SpriteThing(450f, -7f, spr4); thing4.center = new Vec2((float)(spr4.w / 2), (float)(spr4.h / 2)); thing4.z = (float)(106 + num); thing4.depth = (Depth)0.5f; thing4.layer = Layer.Background; Level.Add(thing4); Sprite spr5 = new Sprite("rockThrow/tableBottom", 0.0f, 0.0f); Thing thing5 = (Thing) new SpriteThing(450f, -7f, spr5); thing5.center = new Vec2((float)(spr5.w / 2), (float)(spr5.h / 2)); thing5.z = (float)(120 + num); thing5.depth = (Depth)0.8f; thing5.layer = Layer.Background; Level.Add(thing5); Sprite spr6 = new Sprite("rockThrow/keg", 0.0f, 0.0f); Thing thing6 = (Thing) new SpriteThing(460f, -24f, spr6); thing6.center = new Vec2((float)(spr6.w / 2), (float)(spr6.h / 2)); thing6.z = (float)(120 + num - 4); thing6.depth = -0.4f; thing6.layer = Layer.Game; Level.Add(thing6); Sprite spr7 = new Sprite("rockThrow/cup", 0.0f, 0.0f); Thing thing7 = (Thing) new SpriteThing(445f, -21f, spr7); thing7.center = new Vec2((float)(spr7.w / 2), (float)(spr7.h / 2)); thing7.z = (float)(120 + num - 6); thing7.depth = -0.5f; thing7.layer = Layer.Game; Level.Add(thing7); Sprite spr8 = new Sprite("rockThrow/cup", 0.0f, 0.0f); Thing thing8 = (Thing) new SpriteThing(437f, -20f, spr8); thing8.center = new Vec2((float)(spr8.w / 2), (float)(spr8.h / 2)); thing8.z = (float)(120 + num); thing8.depth = -0.3f; thing8.layer = Layer.Game; Level.Add(thing8); Sprite spr9 = new Sprite("rockThrow/cup", 0.0f, 0.0f); Thing thing9 = (Thing) new SpriteThing(472f, -20f, spr9); thing9.center = new Vec2((float)(spr9.w / 2), (float)(spr9.h / 2)); thing9.z = (float)(120 + num - 7); thing9.depth = -0.5f; thing9.layer = Layer.Game; thing9.angleDegrees = 80f; Level.Add(thing9); } for (int index = 0; index < 3; ++index) { dynamic distanceMarker = Activator.CreateInstance(distancemarker, new object[] { (float)(230 + index * 175), -25f, (int)Math.Round(index * GameMode.winsPerSet / 2.0) }); distanceMarker.z = 0.0f; distanceMarker.depth = (Depth)0.34f; distanceMarker.layer = Layer.Background; Level.Add((Thing)distanceMarker); } Sprite spr = RockWeather.weather != Weather.Snowing ? new Sprite("bleacherBack", 0.0f, 0.0f) : new Sprite("bleacherBackSnow", 0.0f, 0.0f); for (int index = 0; index < 24; ++index) { SpriteThing spriteThing = new SpriteThing((float)(100 + index * (spr.w + 13)), (float)(spr.h + 15), spr); spriteThing.center = new Vec2((float)(spr.w / 2), (float)(spr.h - 1)); spriteThing.collisionOffset = new Vec2(spriteThing.collisionOffset.x, (float)-spr.h); spriteThing.z = 0.0f; spriteThing.depth = (Depth)0.33f; spriteThing.layer = Layer.Background; Level.Add((Thing)spriteThing); } SpriteThing spriteThing3 = new SpriteThing(600f, 0.0f, new Sprite("blackSquare", 0.0f, 0.0f)); spriteThing3.z = -90f; spriteThing3.centery = 7f; spriteThing3.depth = (Depth)0.1f; spriteThing3.layer = Layer.Background; spriteThing3.xscale = 100f; spriteThing3.yscale = 7f; Level.Add((Thing)spriteThing3); _weather.Update(); _inputsField.SetValue(Level.current as RockScoreboard, _inputs); _afterHighlightsField.SetValue(Level.current as RockScoreboard, _afterHighlights); _skipFadeField.SetValue(Level.current as RockScoreboard, _skipFade); _weatherField.SetValue(Level.current as RockScoreboard, _weather); _sunshineField.SetValue(Level.current as RockScoreboard, _sunshineTarget); _screenField.SetValue(Level.current as RockScoreboard, _screenTarget); _pixelField.SetValue(Level.current as RockScoreboard, _pixelTarget); _sunLayerField.SetValue(Level.current as RockScoreboard, _sunLayer); sunThingField.SetValue(Level.current as RockScoreboard, sunThing); rainbowThingField.SetValue(Level.current as RockScoreboard, rainbowThing); rainbowThing2Field.SetValue(Level.current as RockScoreboard, rainbowThing2); _crowdField.SetValue(Level.current as RockScoreboard, _crowd); _fieldField.SetValue(Level.current as RockScoreboard, _field); _bleacherSeatsField.SetValue(Level.current as RockScoreboard, _bleacherSeats); _bleachersField.SetValue(Level.current as RockScoreboard, _bleachers); _intermissionTextField.SetValue(Level.current as RockScoreboard, _intermissionText); _winnerPostField.SetValue(Level.current as RockScoreboard, _winnerPost); _winnerBannerField.SetValue(Level.current as RockScoreboard, _winnerBanner); _fontField.SetValue(Level.current as RockScoreboard, _font); _modeField.SetValue(Level.current as RockScoreboard, _mode); _intermissionSlideField.SetValue(Level.current as RockScoreboard, _intermissionSlide); _tieField.SetValue(Level.current as RockScoreboard, _tie); _highestSlotField.SetValue(Level.current as RockScoreboard, _highestSlot); _fieldWidthField.SetValue(Level.current as RockScoreboard, _fieldWidth); _matchOverField.SetValue(Level.current as RockScoreboard, _matchOver); _winningTeamField.SetValue(Level.current as RockScoreboard, _winningTeam); _stateField.SetValue(Level.current as RockScoreboard, _state); _scoreBoardField.SetValue(Level.current as RockScoreboard, _scoreBoard); _wallField.SetValue(Level.current as RockScoreboard, _wall); _fieldForegroundField.SetValue(Level.current as RockScoreboard, _fieldForeground); _fieldForeground2Field.SetValue(Level.current as RockScoreboard, _fieldForeground2); _bottomRightField.SetValue(Level.current as RockScoreboard, _bottomRight); }
public void OnSessionEnded(DuckNetErrorInfo error) { if (!this.open) { return; } if (UIMatchmakingBox._state == MatchmakingState.Disconnect) { if (this._tryHostingLobby != null) { this._tries = 0; } this._tryHostingLobby = (Lobby)null; if (this._quit) { HUD.CloseAllCorners(); this.Close(); this._openOnClose.Open(); } else if (this._tryConnectLobby != null) { DuckNetwork.Join(this._tryConnectLobby.id.ToString()); this.ChangeState(MatchmakingState.Connecting); } else { this.ChangeState(MatchmakingState.SearchForLobbies); } } else { if (error != null) { if (error.error == DuckNetError.VersionMismatch) { if (error.tooNew) { this._newStatusList.Add("|DGRED|Their version was older."); } else { this._newStatusList.Add("|DGRED|Their version was newer."); } if (this._tryConnectLobby != null) { this._permenantBlacklist.Add(new BlacklistServer() { lobby = this._tryConnectLobby.id, cooldown = 15f }); } } else if (error.error == DuckNetError.FullServer) { this._newStatusList.Add("|DGRED|Failed (FULL SERVER)"); } else if (error.error == DuckNetError.ConnectionTimeout) { this._newStatusList.Add("|DGRED|Failed (TIMEOUT)"); } else if (error.error == DuckNetError.GameInProgress) { this._newStatusList.Add("|DGRED|Failed (IN PROGRESS)"); } else { this._newStatusList.Add("|DGRED|Unknown connection error."); if (this._tryConnectLobby != null) { this._permenantBlacklist.Add(new BlacklistServer() { lobby = this._tryConnectLobby.id, cooldown = 15f }); } } } else { this._newStatusList.Add("|DGRED|Connection timeout."); if (this._tryConnectLobby != null) { this._permenantBlacklist.Add(new BlacklistServer() { lobby = this._tryConnectLobby.id, cooldown = 15f }); } } if (this._tryConnectLobby != null) { this._failedAttempts.Add(new BlacklistServer() { lobby = this._tryConnectLobby.id, cooldown = 15f }); } DevConsole.Log("|PURPLE|MATCHMAKING |DGGREEN|Connection failure, continuing search.", Color.White); this._tryConnectLobby = (Lobby)null; this.ChangeState(MatchmakingState.SearchForLobbies); } }
static bool Prefix(TeamSelect2 __instance) { // TO IMPLEMENT //++Global.data.bootedSinceUpdate; //Global.Save(); // TO IMPLEMENT List <DuckPersona> personas = Persona.all as List <DuckPersona>; // Get the private fields by reflection Type teamselect2type = typeof(TeamSelect2); dynamic littleFont = teamselect2type.GetField("_littleFont", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(__instance); dynamic countdownScreen = teamselect2type.GetField("_countdownScreen", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(__instance); dynamic countdown = teamselect2type.GetField("_countdown", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(__instance); dynamic profiles = teamselect2type.GetField("_profiles", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(__instance); dynamic font = teamselect2type.GetField("_font", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(__instance); dynamic buttons = teamselect2type.GetField("_buttons", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(__instance); dynamic beam = teamselect2type.GetField("_beam", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(__instance); dynamic configGroup = teamselect2type.GetField("_configGroup", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(__instance); dynamic multiplayerMenu = teamselect2type.GetField("_multiplayerMenu", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(__instance); dynamic modifierMenu = teamselect2type.GetField("_modifierMenu", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(__instance); dynamic levelSelectMenu = teamselect2type.GetField("_levelSelectMenu", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(__instance); dynamic playOnlineGroup = teamselect2type.GetField("_playOnlineGroup", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(__instance); dynamic playOnlineMenu = teamselect2type.GetField("_playOnlineMenu", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(__instance); dynamic hostGameMenu = teamselect2type.GetField("_hostGameMenu", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(__instance); dynamic browseGamesMenu = teamselect2type.GetField("_browseGamesMenu", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(__instance); dynamic miniHostGameMenu = teamselect2type.GetField("_miniHostGameMenu", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(__instance); dynamic joinGameMenu = teamselect2type.GetField("_joinGameMenu", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(__instance); dynamic filtersMenu = teamselect2type.GetField("_filtersMenu", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(__instance); dynamic filterModifierMenu = teamselect2type.GetField("_filterModifierMenu", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(__instance); dynamic matchmaker = teamselect2type.GetField("_matchmaker", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(__instance); dynamic hostGameSettingsMenu = teamselect2type.GetField("_hostGameSettingsMenu", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(__instance); dynamic hostGameModifierMenu = teamselect2type.GetField("_hostGameModifierMenu", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(__instance); dynamic createGame = teamselect2type.GetField("_createGame", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(__instance); dynamic hostGame = teamselect2type.GetField("_hostGame", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(__instance); // End of getting fields TeamSelect2.customLevels = TeamSelect2.prevCustomLevels = 0; if (!Network.isActive) { Level.core.gameInProgress = false; } if (!Level.core.gameInProgress) { Main.ResetMatchStuff(); Main.ResetGameStuff(); DuckNetwork.ClosePauseMenu(); } else { ConnectionStatusUI.Hide(); if (Network.isServer) { if (Steam.lobby != null) { Steam.lobby.SetLobbyData("started", "false"); Steam.lobby.joinable = true; } DuckNetwork.inGame = false; foreach (Profile profile in DuckNetwork.profiles) { if (profile.connection == null && profile.slotType != SlotType.Reserved) { profile.slotType = SlotType.Closed; } } } } if (Network.isActive && Network.isServer) { DuckNetwork.ChangeSlotSettings(); } littleFont = new BitmapFont("smallBiosFontUI", 7, 5); countdownScreen = new Sprite("title/wideScreen", 0.0f, 0.0f); __instance.backgroundColor = Color.Black; DuckNetwork.levelIndex = (byte)0; if (Network.isActive && Network.isServer) { GhostManager.context.SetGhostIndex((NetIndex16)32); } countdown = new SpriteMap("countdown", 32, 32, false); countdown.center = new Vec2(16f, 16f); Profile defaultProfile1 = Profiles.all.FirstOrDefault <Profile>((Func <Profile, bool>)(x => { if (x.team != null) { return(x.persona == Persona.Duck1); } return(false); })) ?? Profiles.DefaultPlayer1; Profile defaultProfile2 = Profiles.all.FirstOrDefault <Profile>((Func <Profile, bool>)(x => { if (x.team != null) { return(x.persona == Persona.Duck2); } return(false); })) ?? Profiles.DefaultPlayer2; Profile defaultProfile3 = Profiles.all.FirstOrDefault <Profile>((Func <Profile, bool>)(x => { if (x.team != null) { return(x.persona == Persona.Duck3); } return(false); })) ?? Profiles.DefaultPlayer3; Profile defaultProfile4 = Profiles.all.FirstOrDefault <Profile>((Func <Profile, bool>)(x => { if (x.team != null) { return(x.persona == Persona.Duck4); } return(false); })) ?? Profiles.DefaultPlayer4; Profile defaultProfile5 = Profiles.all.FirstOrDefault <Profile>((Func <Profile, bool>)(x => { if (x.team != null) { return(x.persona == personas[4]); } return(false); })) ?? Profiles.core.all.ElementAt(4); Profile defaultProfile6 = Profiles.all.FirstOrDefault <Profile>((Func <Profile, bool>)(x => { if (x.team != null) { return(x.persona == personas[5]); } return(false); })) ?? Profiles.core.all.ElementAt(5); Profile defaultProfile7 = Profiles.all.FirstOrDefault <Profile>((Func <Profile, bool>)(x => { if (x.team != null) { return(x.persona == personas[6]); } return(false); })) ?? Profiles.core.all.ElementAt(6); Profile defaultProfile8 = Profiles.all.FirstOrDefault <Profile>((Func <Profile, bool>)(x => { if (x.team != null) { return(x.persona == personas[7]); } return(false); })) ?? Profiles.core.all.ElementAt(7); float xpos = 1f; ProfileBox2 profileBox2_1 = new ProfileBox2(xpos, 1f, InputProfile.Get("MPPlayer1"), defaultProfile1, __instance, 0); profiles.Add(profileBox2_1); Level.Add((Thing)profileBox2_1); ProfileBox2 profileBox2_2 = new ProfileBox2(xpos + 119f, 1f, InputProfile.Get("MPPlayer2"), defaultProfile2, __instance, 1); profiles.Add(profileBox2_2); Level.Add((Thing)profileBox2_2); ProfileBox2 profileBox2_3 = new ProfileBox2(xpos + 238f, 1f, InputProfile.Get("MPPlayer3"), defaultProfile3, __instance, 2); profiles.Add(profileBox2_3); Level.Add((Thing)profileBox2_3); ProfileBox2 profileBox2_4 = new ProfileBox2(xpos, 62f, InputProfile.Get("MPPlayer4"), defaultProfile4, __instance, 3); profiles.Add(profileBox2_4); Level.Add((Thing)profileBox2_4); ProfileBox2 profileBox2_5 = new ProfileBox2(xpos + 238f, 62f, InputProfile.Get("MPPlayer5"), defaultProfile5, __instance, 4); profiles.Add(profileBox2_5); Level.Add((Thing)profileBox2_5); ProfileBox2 profileBox2_6 = new ProfileBox2(xpos, 121f, InputProfile.Get("MPPlayer6"), defaultProfile6, __instance, 5); profiles.Add(profileBox2_6); Level.Add((Thing)profileBox2_6); ProfileBox2 profileBox2_7 = new ProfileBox2(xpos + 119f, 121f, InputProfile.Get("MPPlayer7"), defaultProfile7, __instance, 6); profiles.Add(profileBox2_7); Level.Add((Thing)profileBox2_7); ProfileBox2 profileBox2_8 = new ProfileBox2(xpos + 238f, 121f, InputProfile.Get("MPPlayer8"), defaultProfile8, __instance, 7); profiles.Add(profileBox2_8); Level.Add((Thing)profileBox2_8); Saxaphone spicySax = new Saxaphone(160f, 100f); spicySax.infinite = true; Level.Add(spicySax); if (Network.isActive) { __instance.PrepareForOnline(); } else { __instance.BuildPauseMenu(false); } font = new BitmapFont("biosFont", 8, -1); font.scale = new Vec2(1f, 1f); buttons = new SpriteMap("buttons", 14, 14, false); buttons.CenterOrigin(); buttons.depth = (Depth)0.9f; Music.Play("CharacterSelect", true, 0.0f); beam = new TeamBeam(101f, 0.0f); Level.Add((Thing)beam); beam = new TeamBeam(219f, 0.0f); Level.Add((Thing)beam); TeamSelect2.UpdateModifierStatus(); configGroup = new UIComponent(Layer.HUD.camera.width / 2f, Layer.HUD.camera.height / 2f, 0.0f, 0.0f); multiplayerMenu = new UIMenu("@LWING@MATCH SETTINGS@RWING@", Layer.HUD.camera.width / 2f, Layer.HUD.camera.height / 2f, 190f, -1f, "@DPAD@ADJUST @SELECT@SELECT", (InputProfile)null, false); modifierMenu = new UIMenu("MODIFIERS", Layer.HUD.camera.width / 2f, Layer.HUD.camera.height / 2f, 240f, -1f, "@DPAD@ADJUST @QUACK@BACK", (InputProfile)null, false); levelSelectMenu = (UIMenu) new LevelSelectCompanionMenu(Layer.HUD.camera.width / 2f, Layer.HUD.camera.height / 2f, multiplayerMenu); foreach (UnlockData unlock in Unlocks.GetUnlocks(UnlockType.Modifier)) { if (unlock.unlocked) { modifierMenu.Add((UIComponent) new UIMenuItemToggle(unlock.shortName, (UIMenuAction)null, new FieldBinding((object)unlock, "enabled", 0.0f, 1f, 0.1f), new Color(), (FieldBinding)null, (List <string>)null, false, false), true); } else { modifierMenu.Add((UIComponent) new UIMenuItem("@TINYLOCK@LOCKED", (UIMenuAction)null, UIAlign.Center, Color.Red, false), true); } } modifierMenu.Add((UIComponent) new UIText(" ", Color.White, UIAlign.Center, 0.0f, (InputProfile)null), true); modifierMenu.Add((UIComponent) new UIMenuItem("OK", (UIMenuAction) new UIMenuActionOpenMenu((UIComponent)modifierMenu, (UIComponent)multiplayerMenu), UIAlign.Center, new Color(), true), true); modifierMenu.Close(); foreach (MatchSetting matchSetting in TeamSelect2.matchSettings) { if (!(matchSetting.id == "workshopmaps") || Network.available) { multiplayerMenu.AddMatchSetting(matchSetting, false, true); } } multiplayerMenu.Add((UIComponent) new UIText(" ", Color.White, UIAlign.Center, 0.0f, (InputProfile)null), true); multiplayerMenu.Add((UIComponent) new UIModifierMenuItem((UIMenuAction) new UIMenuActionOpenMenu((UIComponent)multiplayerMenu, (UIComponent)modifierMenu), UIAlign.Center, new Color(), false), true); multiplayerMenu.Add((UIComponent) new UICustomLevelMenu((UIMenuAction) new UIMenuActionOpenMenu((UIComponent)multiplayerMenu, (UIComponent)levelSelectMenu), UIAlign.Center, new Color(), false), true); multiplayerMenu.Add((UIComponent) new UIText(" ", Color.White, UIAlign.Center, 0.0f, (InputProfile)null), true); multiplayerMenu.Add((UIComponent) new UIMenuItem("OK", (UIMenuAction) new UIMenuActionCloseMenu(configGroup), UIAlign.Center, new Color(), true), true); multiplayerMenu.Close(); configGroup.Add((UIComponent)multiplayerMenu, false); configGroup.Add((UIComponent)modifierMenu, false); configGroup.Add((UIComponent)levelSelectMenu, false); configGroup.Close(); Level.Add((Thing)configGroup); playOnlineGroup = new UIComponent(Layer.HUD.camera.width / 2f, Layer.HUD.camera.height / 2f, 0.0f, 0.0f); playOnlineMenu = new UIMenu("@PLANET@PLAY ONLINE@PLANET@", Layer.HUD.camera.width / 2f, Layer.HUD.camera.height / 2f, 190f, -1f, "@DPAD@ADJUST @SELECT@SELECT", (InputProfile)null, false); hostGameMenu = new UIMenu("@LWING@CREATE GAME@RWING@", Layer.HUD.camera.width / 2f, Layer.HUD.camera.height / 2f, 190f, -1f, "@DPAD@ADJUST @SELECT@SELECT", (InputProfile)null, false); browseGamesMenu = (UIMenu) new UIServerBrowser(playOnlineMenu, "SERVER BROWSER", Layer.HUD.camera.width, Layer.HUD.camera.height, 550f, -1f, "@DPAD@@SELECT@JOIN @SHOOT@REFRESH @QUACK@BACK", (InputProfile)null); miniHostGameMenu = new UIMenu("@LWING@HOST GAME@RWING@", Layer.HUD.camera.width / 2f, Layer.HUD.camera.height / 2f, 190f, -1f, "@DPAD@ADJUST @SELECT@SELECT", (InputProfile)null, false); joinGameMenu = new UIMenu("@LWING@FIND GAME@RWING@", Layer.HUD.camera.width / 2f, Layer.HUD.camera.height / 2f, 190f, -1f, "@DPAD@ADJUST @SELECT@SELECT", (InputProfile)null, false); filtersMenu = new UIMenu("@LWING@FILTERS@RWING@", Layer.HUD.camera.width / 2f, Layer.HUD.camera.height / 2f, 190f, -1f, "@SELECT@SELECT @GRAB@TYPE", (InputProfile)null, false); filterModifierMenu = new UIMenu("@LWING@FILTER MODIFIERS@RWING@", Layer.HUD.camera.width / 2f, Layer.HUD.camera.height / 2f, 240f, -1f, "@DPAD@ADJUST @SELECT@SELECT", (InputProfile)null, false); matchmaker = new UIMatchmakingBox(joinGameMenu, Layer.HUD.camera.width / 2f, Layer.HUD.camera.height / 2f, 190f, -1f); hostGameSettingsMenu = new UIMenu("@LWING@SETTINGS@RWING@", Layer.HUD.camera.width / 2f, Layer.HUD.camera.height / 2f, 190f, -1f, "@DPAD@ADJUST @SELECT@SELECT", (InputProfile)null, false); hostGameModifierMenu = new UIMenu("@LWING@MODIFIERS@RWING@", Layer.HUD.camera.width / 2f, Layer.HUD.camera.height / 2f, 240f, -1f, "@DPAD@ADJUST @SELECT@SELECT", (InputProfile)null, false); if ((string)typeof(ModLoader).GetProperty("modHash", BindingFlags.NonPublic | BindingFlags.Static).GetValue(null, null) != "nomods") { playOnlineMenu.Add((UIComponent) new UIMenuItem("FIND GAME", (UIMenuAction) new UIMenuActionCloseMenuCallFunction((UIComponent)playOnlineMenu, new UIMenuActionCloseMenuCallFunction.Function(__instance.OpenNoModsFindGame)), UIAlign.Center, new Color(), false), true); playOnlineMenu.Add((UIComponent) new UIMenuItem("CREATE GAME", (UIMenuAction) new UIMenuActionCloseMenuCallFunction((UIComponent)playOnlineMenu, new UIMenuActionCloseMenuCallFunction.Function(__instance.OpenNoModsCreateGame)), UIAlign.Center, new Color(), false), true); } else { playOnlineMenu.Add((UIComponent) new UIMenuItem("FIND GAME", (UIMenuAction) new UIMenuActionOpenMenu((UIComponent)playOnlineMenu, (UIComponent)joinGameMenu), UIAlign.Center, new Color(), false), true); playOnlineMenu.Add((UIComponent) new UIMenuItem("CREATE GAME", (UIMenuAction) new UIMenuActionOpenMenu((UIComponent)playOnlineMenu, (UIComponent)hostGameMenu), UIAlign.Center, new Color(), false), true); } playOnlineMenu.Add((UIComponent) new UIMenuItem("BROWSE GAMES", (UIMenuAction) new UIMenuActionOpenMenu((UIComponent)playOnlineMenu, (UIComponent)browseGamesMenu), UIAlign.Center, new Color(), false), true); playOnlineMenu.Add((UIComponent) new UIText(" ", Color.White, UIAlign.Center, 0.0f, (InputProfile)null), true); playOnlineMenu.Add((UIComponent) new UIMenuItem("CANCEL", (UIMenuAction) new UIMenuActionCloseMenuCallFunction(playOnlineGroup, new UIMenuActionCloseMenuCallFunction.Function(__instance.ClosedOnline)), UIAlign.Center, new Color(), true), true); playOnlineMenu.Close(); playOnlineGroup.Add((UIComponent)playOnlineMenu, false); foreach (MatchSetting onlineSetting in TeamSelect2.onlineSettings) { if (!onlineSetting.filterOnly) { hostGameMenu.AddMatchSetting(onlineSetting, false, true); } } hostGameMenu.Add((UIComponent) new UIText(" ", Color.White, UIAlign.Center, 0.0f, (InputProfile)null), true); hostGameMenu.Add((UIComponent) new UIMenuItem("CREATE GAME", (UIMenuAction) new UIMenuActionCloseMenuSetBoolean(playOnlineGroup, createGame), UIAlign.Center, new Color(), false), true); hostGameMenu.Add((UIComponent) new UIMenuItem("BACK", (UIMenuAction) new UIMenuActionOpenMenu((UIComponent)hostGameMenu, (UIComponent)playOnlineMenu), UIAlign.Center, new Color(), true), true); hostGameMenu.Close(); browseGamesMenu.Close(); playOnlineGroup.Add((UIComponent)browseGamesMenu, false); playOnlineGroup.Add((UIComponent)hostGameMenu, false); miniHostGameMenu.AddMatchSetting(TeamSelect2.GetOnlineSetting("type"), false, true); miniHostGameMenu.Add((UIComponent) new UIText(" ", Color.White, UIAlign.Center, 0.0f, (InputProfile)null), true); miniHostGameMenu.Add((UIComponent) new UIMenuItem("HOST GAME", (UIMenuAction) new UIMenuActionCloseMenuSetBoolean((UIComponent)miniHostGameMenu, hostGame), UIAlign.Center, new Color(), false), true); miniHostGameMenu.Add((UIComponent) new UIMenuItem("CANCEL", (UIMenuAction) new UIMenuActionCloseMenu((UIComponent)miniHostGameMenu), UIAlign.Center, new Color(), true), true); miniHostGameMenu.Close(); Level.Add((Thing)miniHostGameMenu); foreach (MatchSetting onlineSetting in TeamSelect2.onlineSettings) { if (!onlineSetting.createOnly) { joinGameMenu.AddMatchSetting(onlineSetting, true, true); } } joinGameMenu.Add((UIComponent) new UIText(" ", Color.White, UIAlign.Center, 0.0f, (InputProfile)null), true); joinGameMenu.Add((UIComponent) new UIMenuItem("FIND GAME", (UIMenuAction) new UIMenuActionOpenMenu((UIComponent)joinGameMenu, (UIComponent)matchmaker), UIAlign.Center, new Color(), false), true); joinGameMenu.Add((UIComponent) new UIMenuItem("BACK", (UIMenuAction) new UIMenuActionOpenMenu((UIComponent)joinGameMenu, (UIComponent)playOnlineMenu), UIAlign.Center, new Color(), true), true); joinGameMenu.Close(); playOnlineGroup.Add((UIComponent)joinGameMenu, false); foreach (MatchSetting matchSetting in TeamSelect2.matchSettings) { if (!(matchSetting.id == "workshopmaps") || Network.available) { filtersMenu.AddMatchSetting(matchSetting, true, true); } } filtersMenu.Add((UIComponent) new UIText(" ", Color.White, UIAlign.Center, 0.0f, (InputProfile)null), true); filtersMenu.Add((UIComponent) new UIModifierMenuItem((UIMenuAction) new UIMenuActionOpenMenu((UIComponent)filtersMenu, (UIComponent)filterModifierMenu), UIAlign.Center, new Color(), false), true); filtersMenu.Add((UIComponent) new UIText(" ", Color.White, UIAlign.Center, 0.0f, (InputProfile)null), true); filtersMenu.Add((UIComponent) new UIMenuItem("|DGBLUE|CLEAR FILTERS", (UIMenuAction) new UIMenuActionCallFunction(new UIMenuActionCallFunction.Function(__instance.ClearFilters)), UIAlign.Center, new Color(), false), true); filtersMenu.Add((UIComponent) new UIMenuItem("BACK", (UIMenuAction) new UIMenuActionOpenMenu((UIComponent)filtersMenu, (UIComponent)joinGameMenu), UIAlign.Center, new Color(), true), true); filtersMenu.Close(); playOnlineGroup.Add((UIComponent)filtersMenu, false); foreach (UnlockData unlock in Unlocks.GetUnlocks(UnlockType.Modifier)) { filterModifierMenu.Add((UIComponent) new UIMenuItemToggle(unlock.shortName, (UIMenuAction)null, new FieldBinding((object)unlock, "enabled", 0.0f, 1f, 0.1f), new Color(), new FieldBinding((object)unlock, "filtered", 0.0f, 1f, 0.1f), (List <string>)null, false, false), true); } filterModifierMenu.Add((UIComponent) new UIText(" ", Color.White, UIAlign.Center, 0.0f, (InputProfile)null), true); filterModifierMenu.Add((UIComponent) new UIMenuItem("BACK", (UIMenuAction) new UIMenuActionOpenMenu((UIComponent)filterModifierMenu, (UIComponent)filtersMenu), UIAlign.Center, new Color(), true), true); filterModifierMenu.Close(); playOnlineGroup.Add((UIComponent)filterModifierMenu, false); foreach (MatchSetting matchSetting in TeamSelect2.matchSettings) { if (!(matchSetting.id == "workshopmaps") || Network.available) { hostGameSettingsMenu.AddMatchSetting(matchSetting, false, true); } } hostGameSettingsMenu.Add((UIComponent) new UIText(" ", Color.White, UIAlign.Center, 0.0f, (InputProfile)null), true); hostGameSettingsMenu.Add((UIComponent) new UIModifierMenuItem((UIMenuAction) new UIMenuActionOpenMenu((UIComponent)hostGameSettingsMenu, (UIComponent)hostGameModifierMenu), UIAlign.Center, new Color(), false), true); hostGameSettingsMenu.Add((UIComponent) new UIText(" ", Color.White, UIAlign.Center, 0.0f, (InputProfile)null), true); hostGameSettingsMenu.Add((UIComponent) new UIMenuItem("BACK", (UIMenuAction) new UIMenuActionOpenMenu((UIComponent)hostGameSettingsMenu, (UIComponent)hostGameMenu), UIAlign.Center, new Color(), true), true); hostGameSettingsMenu.Close(); playOnlineGroup.Add((UIComponent)hostGameSettingsMenu, false); foreach (UnlockData unlock in Unlocks.GetUnlocks(UnlockType.Modifier)) { hostGameModifierMenu.Add((UIComponent) new UIMenuItemToggle(unlock.shortName, (UIMenuAction)null, new FieldBinding((object)unlock, "enabled", 0.0f, 1f, 0.1f), new Color(), (FieldBinding)null, (List <string>)null, false, false), true); } hostGameModifierMenu.Add((UIComponent) new UIText(" ", Color.White, UIAlign.Center, 0.0f, (InputProfile)null), true); hostGameModifierMenu.Add((UIComponent) new UIMenuItem("BACK", (UIMenuAction) new UIMenuActionOpenMenu((UIComponent)hostGameModifierMenu, (UIComponent)hostGameSettingsMenu), UIAlign.Center, new Color(), true), true); hostGameModifierMenu.Close(); playOnlineGroup.Add((UIComponent)hostGameModifierMenu, false); matchmaker.Close(); playOnlineGroup.Add((UIComponent)matchmaker, false); playOnlineGroup.Close(); Level.Add((Thing)playOnlineGroup); Graphics.fade = 0.0f; Layer l = new Layer("HUD2", -85, new Camera(), false, new Vec2()); l.camera.width /= 2f; l.camera.height /= 2f; Layer.Add(l); Layer hud = Layer.HUD; Layer.HUD = l; Editor.gamepadMode = true; Layer.HUD = hud; // Start of setting private fields teamselect2type.GetField("_littleFont", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(__instance, littleFont); teamselect2type.GetField("_countdownScreen", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(__instance, countdownScreen); teamselect2type.GetField("_countdown", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(__instance, countdown); teamselect2type.GetField("_profiles", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(__instance, profiles); teamselect2type.GetField("_font", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(__instance, font); teamselect2type.GetField("_buttons", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(__instance, buttons); teamselect2type.GetField("_beam", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(__instance, beam); teamselect2type.GetField("_configGroup", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(__instance, configGroup); teamselect2type.GetField("_multiplayerMenu", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(__instance, multiplayerMenu); teamselect2type.GetField("_modifierMenu", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(__instance, modifierMenu); teamselect2type.GetField("_levelSelectMenu", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(__instance, levelSelectMenu); teamselect2type.GetField("_playOnlineGroup", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(__instance, playOnlineGroup); teamselect2type.GetField("_playOnlineMenu", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(__instance, playOnlineMenu); teamselect2type.GetField("_hostGameMenu", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(__instance, hostGameMenu); teamselect2type.GetField("_browseGamesMenu", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(__instance, browseGamesMenu); teamselect2type.GetField("_miniHostGameMenu", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(__instance, miniHostGameMenu); teamselect2type.GetField("_joinGameMenu", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(__instance, joinGameMenu); teamselect2type.GetField("_filtersMenu", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(__instance, filtersMenu); teamselect2type.GetField("_filterModifierMenu", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(__instance, filterModifierMenu); teamselect2type.GetField("_matchmaker", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(__instance, matchmaker); teamselect2type.GetField("_hostGameSettingsMenu", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(__instance, hostGameSettingsMenu); teamselect2type.GetField("_hostGameModifierMenu", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(__instance, hostGameModifierMenu); teamselect2type.GetField("_createGame", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(__instance, createGame); teamselect2type.GetField("_hostGame", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(__instance, hostGame); // End of setting private fields if (DuckNetwork.ShowUserXPGain() || !Unlockables.HasPendingUnlocks()) { return(false); } MonoMain.pauseMenu = (UIComponent) new UIUnlockBox(Unlockables.GetPendingUnlocks().ToList <Unlockable>(), Layer.HUD.camera.width / 2f, Layer.HUD.camera.height / 2f, 190f, -1f); return(false); }
public override void Draw() { if (this._downloadModsMenu.open) { this._downloadModsMenu.DoDraw(); } if (this.open) { this.scrollBarTop = (int)((double)this._box.y - (double)this._box.halfHeight + 1.0 + 16.0); this.scrollBarBottom = (int)((double)this._box.y + (double)this._box.halfHeight - 1.0 - 16.0); this.scrollBarScrollableHeight = this.scrollBarBottom - this.scrollBarTop; if (this.fixView) { Layer.HUD.camera.width *= 2f; Layer.HUD.camera.height *= 2f; this.fixView = false; } DuckGame.Graphics.DrawRect(new Vec2(this._box.x - this._box.halfWidth, this._box.y - this._box.halfHeight), new Vec2((float)((double)this._box.x + (double)this._box.halfWidth - 12.0 - 2.0), this._box.y + this._box.halfHeight), Color.Black, new Depth(0.4f)); DuckGame.Graphics.DrawRect(new Vec2((float)((double)this._box.x + (double)this._box.halfWidth - 12.0), this._box.y - this._box.halfHeight), new Vec2(this._box.x + this._box.halfWidth, this._box.y + this._box.halfHeight), Color.Black, new Depth(0.4f)); Rectangle r = this.ScrollBarBox(); DuckGame.Graphics.DrawRect(r, this._draggingScrollbar || r.Contains(Mouse.position) ? Color.LightGray : Color.Gray, new Depth(0.5f)); if (this._lobbies.Count == 0) { this._fancyFont.Draw("No games found!", new Vec2(this._box.x - this._box.halfWidth + 10f, (float)((double)this._box.y - (double)this._box.halfHeight + 0.0) + 2f), Color.Yellow, new Depth(0.5f)); } this._lobbies = this._lobbies.OrderByDescending <UIServerBrowser.LobbyData, bool>((Func <UIServerBrowser.LobbyData, bool>)(x => x.canJoin)).ToList <UIServerBrowser.LobbyData>(); for (int index1 = 0; index1 < this._maxLobbiesToShow; ++index1) { int index2 = this._scrollItemOffset + index1; if (index2 < this._lobbies.Count) { float x1 = this._box.x - this._box.halfWidth; float y = this._box.y - this._box.halfHeight + (float)(36 * index1); if (this._hoverIndex == index2) { DuckGame.Graphics.DrawRect(new Vec2(x1, y), new Vec2((float)((double)x1 + (double)this._box.width - 14.0), y + 36f), Color.White * 0.6f, new Depth(0.4f)); } else if ((index2 & 1) != 0) { DuckGame.Graphics.DrawRect(new Vec2(x1, y), new Vec2((float)((double)x1 + (double)this._box.width - 14.0), y + 36f), Color.White * 0.1f, new Depth(0.4f)); } UIServerBrowser.LobbyData lobby = this._lobbies[index2]; if (lobby != null) { this._noImage.texture = this.defaultImage; this._noImage.scale = new Vec2(1f, 1f); List <Tex2D> tex2DList = new List <Tex2D>(); string name = lobby.name; string text1 = "|WHITE||GRAY|\n"; if (lobby.workshopItems.Count > 0) { WorkshopItem workshopItem1 = lobby.workshopItems[0]; if (workshopItem1.data != null) { lobby.workshopItems = lobby.workshopItems.OrderByDescending <WorkshopItem, int>((Func <WorkshopItem, int>)(x => x.data == null ? 0 : x.data.votesUp)).ToList <WorkshopItem>(); if (!lobby.downloadedWorkshopItems) { lobby.hasFirstMod = true; lobby.hasRestOfMods = true; bool flag = true; foreach (WorkshopItem workshopItem2 in lobby.workshopItems) { ulong id = workshopItem2.id; if (ModLoader.accessibleMods.FirstOrDefault <Mod>((Func <Mod, bool>)(x => (long)x.configuration.workshopID == (long)id)) == null) { if (flag) { lobby.hasFirstMod = false; } else { lobby.hasRestOfMods = false; } } flag = false; } lobby.downloadedWorkshopItems = true; } string str1 = !lobby.hasFirstMod ? "|RED|Requires " + workshopItem1.name : "|DGGREEN|Requires " + workshopItem1.name; string str2 = lobby.hasRestOfMods ? "|DGGREEN|" : "|RED|"; if (lobby.workshopItems.Count == 2) { str1 = str1 + str2 + " +" + (lobby.workshopItems.Count - 1).ToString() + " other mod."; } else if (lobby.workshopItems.Count > 2) { str1 = str1 + str2 + " +" + (lobby.workshopItems.Count - 1).ToString() + " other mods."; } text1 = str1 + "\n|GRAY|"; if (!UIServerBrowser._previewMap.ContainsKey(workshopItem1.id)) { if (workshopItem1.data.previewPath != null) { if (workshopItem1.data.previewPath != "") { try { WebClient webClient = new WebClient(); string str3 = this.PreviewPathForWorkshopItem(workshopItem1.id); DuckFile.CreatePath(str3); if (System.IO.File.Exists(str3)) { DuckFile.Delete(str3); } webClient.DownloadFileAsync(new Uri(workshopItem1.data.previewPath), str3); webClient.DownloadFileCompleted += new AsyncCompletedEventHandler(this.Completed); UIServerBrowser._clientMap[(object)webClient] = workshopItem1.id; } catch (Exception ex) { } } } UIServerBrowser._previewMap[workshopItem1.id] = (Tex2D)null; } else { Tex2D preview = UIServerBrowser._previewMap[workshopItem1.id]; if (preview != null) { tex2DList.Add(preview); } } } } if (lobby.wallMode == "1") { text1 += "Wall Mode. "; } if (lobby.requiredWins != "") { text1 = text1 + "First to " + lobby.requiredWins.ToString() + " "; } if (lobby.restsEvery != "") { text1 = text1 + "rests every " + lobby.restsEvery.ToString() + ". "; } if (lobby.customLevels != "" && lobby.customLevels != "0") { text1 = text1 + lobby.customLevels.ToString() + " Custom Levels. "; } DuckGame.Graphics.DrawRect(new Vec2(x1 + 2f, y + 2f), new Vec2((float)((double)x1 + 36.0 - 2.0), (float)((double)y + 36.0 - 2.0)), Color.Gray, new Depth(0.5f), false, 2f); if (tex2DList.Count > 0) { Vec2 zero = Vec2.Zero; for (int index3 = 0; index3 < 4; ++index3) { if (index3 < tex2DList.Count) { this._noImage.texture = tex2DList[index3]; if (tex2DList.Count > 1) { this._noImage.scale = new Vec2(16f / (float)this._noImage.texture.width); } else { this._noImage.scale = new Vec2(32f / (float)this._noImage.texture.width); } if (this._noImage.texture.width != this._noImage.texture.height) { if (this._noImage.texture.width > this._noImage.texture.height) { this._noImage.scale = new Vec2(32f / (float)this._noImage.texture.height); DuckGame.Graphics.Draw(this._noImage, x1 + 2f + zero.x, y + 2f + zero.y, new Rectangle((float)(this._noImage.texture.width / 2 - this._noImage.texture.height / 2), 0.0f, (float)this._noImage.texture.height, (float)this._noImage.texture.height), new Depth(0.5f)); } else { DuckGame.Graphics.Draw(this._noImage, x1 + 2f + zero.x, y + 2f + zero.y, new Rectangle(0.0f, 0.0f, (float)this._noImage.texture.width, (float)this._noImage.texture.width), new Depth(0.5f)); } } else { DuckGame.Graphics.Draw(this._noImage, x1 + 2f + zero.x, y + 2f + zero.y, new Depth(0.5f)); } zero.x += 16f; if ((double)zero.x >= 32.0) { zero.x = 0.0f; zero.y += 16f; } } } } else { DuckGame.Graphics.Draw(this._noImage, x1 + 2f, y + 2f, new Depth(0.5f)); } string text2 = name; if (lobby.maxPlayers != "") { text2 = text2 + " (" + lobby.lobby.users.Count.ToString() + "/" + lobby.numSlots.ToString() + ")"; } if (!lobby.canJoin) { string str = text2 + " |DGRED|("; if (lobby.version != DG.version) { switch (DuckNetwork.CheckVersion(lobby.version)) { case NMVersionMismatch.Type.Older: str += "They have an older version."; break; case NMVersionMismatch.Type.Newer: str += "They have a newer version."; break; default: str += "They have a different version."; break; } } else if (lobby.started == "true") { str += "This game is in progress."; } else if (lobby.numSlots != "" && lobby.lobby.users.Count >= Convert.ToInt32(lobby.numSlots)) { str += "Lobby is full."; } else if (lobby.type != "2") { str += "This game is not public."; } else if (lobby.hasLocalMods) { str += "This game is using non-workshop mods."; } text2 = str + ")"; DuckGame.Graphics.DrawRect(new Vec2(x1, y), new Vec2((float)((double)x1 + (double)this._box.width - 14.0), y + 36f), Color.Black * 0.5f, new Depth(0.99f)); } this._fancyFont.maxWidth = 1000; this._fancyFont.Draw(text2, new Vec2((float)((double)x1 + 36.0 + 10.0), y + 2f), Color.Yellow, new Depth(0.5f)); if (lobby.version == DG.version) { this._fancyFont.Draw(lobby.version, new Vec2((float)((double)x1 + 430.0 + 10.0), y + 2f), Colors.DGGreen * 0.35f, new Depth(0.5f)); } else { this._fancyFont.Draw(lobby.version, new Vec2((float)((double)x1 + 430.0 + 10.0), y + 2f), Colors.DGRed * 0.35f, new Depth(0.5f)); } DuckGame.Graphics.Draw(this._steamIcon, x1 + 36f, y + 2.5f, new Depth(0.5f)); this._fancyFont.Draw(text1, new Vec2(x1 + 36f, y + 6f + (float)this._fancyFont.characterHeight), Color.LightGray, new Depth(0.5f)); } } else { break; } } if (Mouse.available && !this._gamepadMode) { this._cursor.depth = new Depth(1f); this._cursor.scale = new Vec2(1f, 1f); this._cursor.position = Mouse.position; this._cursor.frame = 0; if (Editor.hoverTextBox) { this._cursor.frame = 5; this._cursor.position.y -= 4f; this._cursor.scale = new Vec2(0.5f, 1f); } this._cursor.Draw(); } } base.Draw(); }
public override void Update() { if (this.open) { if (this._showWarning) { this._selectionChanged = true; if (Input.Pressed("QUACK")) { SFX.Play("consoleCancel"); this._showWarning = false; } else if (Input.Pressed("GRAB")) { SFX.Play("death"); this._showedWarning = true; this._showWarning = false; if (Level.core.gameInProgress) { Main.ResetGameStuff(); Main.ResetMatchStuff(); Level.core.gameInProgress = false; Send.Message((NetMessage) new NMResetGameSettings()); } } } else { int slot = this._slot; if (Input.Pressed("LEFT") && (this._slot == 1 || this._slot == 3)) { --this._slot; } if (Input.Pressed("RIGHT") && (this._slot == 0 || this._slot == 2)) { ++this._slot; } if (Input.Pressed("UP") && (this._slot == 2 || this._slot == 3)) { this._slot -= 2; } if (Input.Pressed("DOWN") && (this._slot == 0 || this._slot == 1)) { this._slot += 2; } UISlotEditor.hoveringSlot = this._slot; if (this._slot != slot) { this._selectionChanged = true; } if (this._slot == 0) { this._rectPosition = new Vec2(0.0f, 0.0f); } else if (this._slot == 1) { this._rectPosition = new Vec2(178f, 0.0f); } else if (this._slot == 2) { this._rectPosition = new Vec2(0.0f, 90f); } else if (this._slot == 3) { this._rectPosition = new Vec2(178f, 90f); } if (this._selectionChanged) { if (DuckNetwork.profiles[this._slot].connection != null && DuckNetwork.profiles[this._slot].connection != DuckNetwork.localConnection) { HUD.CloseCorner(HUDCorner.TopLeft); HUD.AddCornerControl(HUDCorner.TopLeft, "@GRAB@KICK"); } else { HUD.CloseCorner(HUDCorner.TopLeft); } if (DuckNetwork.profiles[this._slot].connection != DuckNetwork.localConnection) { HUD.CloseCorner(HUDCorner.BottomLeft); HUD.AddCornerControl(HUDCorner.BottomLeft, "TOGGLE MODE@SELECT@"); } else { HUD.CloseCorner(HUDCorner.BottomLeft); } this._selectionChanged = false; } if (Input.Pressed("SELECT") && DuckNetwork.profiles[this._slot].connection != DuckNetwork.localConnection) { if (!this._showedWarning && Level.core.gameInProgress) { this._showWarning = true; SFX.Play("pause"); HUD.CloseAllCorners(); HUD.AddCornerControl(HUDCorner.BottomLeft, "YEAH OK!@GRAB@"); HUD.AddCornerControl(HUDCorner.BottomRight, "@QUACK@CANCEL"); } else { int num = (int)(DuckNetwork.profiles[this._slot].slotType + 1); if (DuckNetwork.profiles[this._slot].reservedUser != null && num == 5) { ++num; } if (DuckNetwork.profiles[this._slot].reservedUser == null && num >= 5 || DuckNetwork.profiles[this._slot].reservedUser != null && num > 6) { num = 0; } DuckNetwork.profiles[this._slot].slotType = (SlotType)num; DuckNetwork.ChangeSlotSettings(); SFX.Play("menuBlip01"); } } else if (Input.Pressed("GRAB") && DuckNetwork.profiles[this._slot].connection != DuckNetwork.localConnection) { DuckNetwork.Kick(DuckNetwork.profiles[this._slot]); } else if (Input.Pressed("QUACK")) { SFX.Play("consoleCancel"); new UIMenuActionOpenMenu((UIComponent)this, (UIComponent)this._closeMenu).Activate(); } } } base.Update(); }
public override void Update() { if (this._pressWait > 0) { --this._pressWait; } if (this._editModMenu.open) { if (!UIMenu.globalUILock && (Input.Pressed("QUACK") || Keyboard.Pressed(Keys.Escape))) { this._editModMenu.Close(); this.Open(); return; } } else if (this.open) { if (this._transferItem != null && !this._needsUpdateNotes) { if (!this._transferring) { if (this._transferItem.result == SteamResult.OK) { WorkshopItemData dat = new WorkshopItemData(); if (this._selectedMod.configuration.workshopID == 0UL) { this._selectedMod.configuration.SetWorkshopID(this._transferItem.id); dat.name = this._selectedMod.configuration.displayName; dat.description = this._selectedMod.configuration.description; dat.visibility = RemoteStoragePublishedFileVisibility.Private; dat.tags = new List <string>(); dat.tags.Add("Mod"); } else { dat.changeNotes = this._updateTextBox.text; } string pathString = this._selectedMod.configuration.directory + "/content/"; DuckFile.CreatePath(pathString); string path1 = pathString + "screenshot.png"; if (!File.Exists(path1)) { File.Delete(path1); Tex2D screenshot = this._selectedMod.screenshot; Stream stream = (Stream)DuckFile.Create(path1); ((Texture2D)screenshot.nativeObject).SaveAsPng(stream, screenshot.width, screenshot.height); stream.Dispose(); } dat.previewPath = path1; string str = DuckFile.workshopDirectory + (object)this._transferItem.id + "/content"; if (Directory.Exists(str)) { Directory.Delete(str, true); } DuckFile.CreatePath(str); UIModManagement.DirectoryCopy(this._selectedMod.configuration.directory, str + "/" + this._selectedMod.configuration.name, true); if (Directory.Exists(str + this._selectedMod.configuration.name + "/build")) { Directory.Delete(str + this._selectedMod.configuration.name + "/build", true); } if (Directory.Exists(str + this._selectedMod.configuration.name + "/.vs")) { Directory.Delete(str + this._selectedMod.configuration.name + "/.vs", true); } if (File.Exists(str + this._selectedMod.configuration.name + "/" + this._selectedMod.configuration.name + "_compiled.dll")) { string path2 = str + this._selectedMod.configuration.name + "/" + this._selectedMod.configuration.name + "_compiled.dll"; File.SetAttributes(path2, FileAttributes.Normal); File.Delete(path2); } if (File.Exists(str + this._selectedMod.configuration.name + "/" + this._selectedMod.configuration.name + "_compiled.hash")) { string path2 = str + this._selectedMod.configuration.name + "/" + this._selectedMod.configuration.name + "_compiled.hash"; File.SetAttributes(path2, FileAttributes.Normal); File.Delete(path2); } dat.contentFolder = str; this._transferItem.ApplyWorkshopData(dat); if (this._transferItem.needsLegal) { Steam.ShowWorkshopLegalAgreement("312530"); } this._transferring = true; this._transferItem.ResetProcessing(); } } else if (this._transferItem.finishedProcessing) { Steam.OverlayOpenURL("http://steamcommunity.com/sharedfiles/filedetails/?id=" + (object)this._transferItem.id); Directory.Delete(DuckFile.workshopDirectory + (object)this._transferItem.id + "/", true); this._transferItem.ResetProcessing(); this._transferItem = (WorkshopItem)null; this._transferring = false; } base.Update(); return; } if (this._gamepadMode) { if (this._hoverIndex < 0) { this._hoverIndex = 0; } } else { this._hoverIndex = -1; for (int index = 0; index < this._maxModsToShow && this._scrollItemOffset + index < this._mods.Count; ++index) { if (new Rectangle((float)(int)(this._box.x - this._box.halfWidth), (float)(int)(this._box.y - this._box.halfHeight + (float)(36 * index)), (float)((int)this._box.width - 14), 36f).Contains(Mouse.position)) { this._hoverIndex = this._scrollItemOffset + index; break; } } } if (this._transferItem != null) { if (this._updateTextBox != null) { Editor.hoverTextBox = false; this._updateTextBox.position = new Vec2((float)((double)this._box.x - (double)this._box.halfWidth + 16.0), (float)((double)this._box.y - (double)this._box.halfHeight + 48.0)); this._updateTextBox.size = new Vec2(this._box.width - 32f, this._box.height - 80f); this._updateTextBox._maxLines = (int)((double)this._updateTextBox.size.y / (double)this._fancyFont.characterHeight); this._updateTextBox.Update(); float stringWidth = DuckGame.Graphics.GetStringWidth(this._updateButtonText, scale: 2f); float height = DuckGame.Graphics.GetStringHeight(this._updateButtonText) * 2f; this._updateButton = new Rectangle(this._box.x - stringWidth / 2f, (float)((double)this._box.y + (double)this._box.halfHeight - 24.0), stringWidth, height); if (this._updateButton.Contains(Mouse.position) && Mouse.left == InputState.Pressed) { this._needsUpdateNotes = false; this._updateTextBox.LoseFocus(); } else if (Keyboard.Pressed(Keys.Escape)) { this._needsUpdateNotes = false; this._transferItem = (WorkshopItem)null; this._updateTextBox.LoseFocus(); new UIMenuActionOpenMenu((UIComponent)this, (UIComponent)this._editModMenu).Activate(); return; } } } else if (this._hoverIndex != -1) { this._selectedMod = this._mods[this._hoverIndex]; if (Input.Pressed("SHOOT")) { if (this._selectedMod != null && this._selectedMod.configuration != null) { if (this._selectedMod.configuration.disabled) { this._selectedMod.configuration.Enable(); } else { this._selectedMod.configuration.Disable(); } this.modsChanged = true; SFX.Play("rockHitGround", 0.8f); } } else if (Input.Pressed("SELECT") && this._pressWait == 0 && this._gamepadMode || !this._gamepadMode && Mouse.left == InputState.Pressed) { if (this._selectedMod != null) { this._editModMenu.title = this._selectedMod.configuration.loaded ? "|YELLOW|" + this._selectedMod.configuration.displayName : "|YELLOW|" + this._selectedMod.configuration.name; this._editModMenu.Remove((UIComponent)this._deleteOrUnsubItem); this._editModMenu.Remove((UIComponent)this._uploadItem); this._editModMenu.Remove((UIComponent)this._visitItem); if (!this._selectedMod.configuration.isWorkshop && this._selectedMod.configuration.loaded) { this._uploadItem.text = this._selectedMod.configuration.workshopID == 0UL ? "UPLOAD" : "UPDATE"; this._editModMenu.Insert((UIComponent)this._uploadItem, 1, true); } if (!this._selectedMod.configuration.isWorkshop && !this._selectedMod.configuration.loaded) { this._deleteOrUnsubItem.text = "DELETE"; this._editModMenu.Insert((UIComponent)this._deleteOrUnsubItem, 1, true); } else if (this._selectedMod.configuration.isWorkshop) { this._deleteOrUnsubItem.text = "UNSUBSCRIBE"; this._editModMenu.Insert((UIComponent)this._deleteOrUnsubItem, 1, true); } if (this._selectedMod.configuration.isWorkshop) { this._editModMenu.Insert((UIComponent)this._visitItem, 1, true); } this._disableOrEnableItem.text = this._selectedMod.configuration.disabled ? "ENABLE" : "DISABLE"; this._editModMenu.dirty = true; SFX.Play("rockHitGround", 0.8f); new UIMenuActionOpenMenu((UIComponent)this, (UIComponent)this._editModMenu).Activate(); return; } Steam.OverlayOpenURL("http://steamcommunity.com/workshop/browse/?appid=312530&searchtext=&childpublishedfileid=0&browsesort=trend§ion=readytouseitems&requiredtags%5B%5D=Mod"); } } else { this._selectedMod = (Mod)null; } if (this._gamepadMode) { this._draggingScrollbar = false; if (Input.Pressed("DOWN")) { ++this._hoverIndex; } else if (Input.Pressed("UP")) { --this._hoverIndex; } if (Input.Pressed("STRAFE")) { this._hoverIndex -= 10; } else if (Input.Pressed("RAGDOLL")) { this._hoverIndex += 10; } if (this._hoverIndex < 0) { this._hoverIndex = 0; } if ((double)(this._oldPos - Mouse.positionScreen).lengthSq > 200.0) { this._gamepadMode = false; } } else { if (!this._draggingScrollbar) { if (Mouse.left == InputState.Pressed && this.ScrollBarBox().Contains(Mouse.position)) { this._draggingScrollbar = true; this._oldPos = Mouse.position; } if ((double)Mouse.scroll > 0.0) { this._scrollItemOffset += 5; this._hoverIndex += 5; } else if ((double)Mouse.scroll < 0.0) { this._scrollItemOffset -= 5; this._hoverIndex -= 5; if (this._hoverIndex < 0) { this._hoverIndex = 0; } } } else if (Mouse.left != InputState.Down) { this._draggingScrollbar = false; } else { Vec2 vec2 = Mouse.position - this._oldPos; this._oldPos = Mouse.position; this.scrollBarOffset += (int)vec2.y; if (this.scrollBarOffset > this.scrollBarScrollableHeight) { this.scrollBarOffset = this.scrollBarScrollableHeight; } else if (this.scrollBarOffset < 0) { this.scrollBarOffset = 0; } this._scrollItemOffset = (int)((double)(this._mods.Count - this._maxModsToShow) * (double)((float)this.scrollBarOffset / (float)this.scrollBarScrollableHeight)); } if (Input.Pressed("ANY")) { this._gamepadMode = true; this._oldPos = Mouse.positionScreen; } } if (this._scrollItemOffset < 0) { this._scrollItemOffset = 0; } else if (this._scrollItemOffset > Math.Max(0, this._mods.Count - this._maxModsToShow)) { this._scrollItemOffset = Math.Max(0, this._mods.Count - this._maxModsToShow); } if (this._hoverIndex >= this._mods.Count) { this._hoverIndex = this._mods.Count - 1; } else if (this._hoverIndex >= this._scrollItemOffset + this._maxModsToShow) { this._scrollItemOffset += this._hoverIndex - (this._scrollItemOffset + this._maxModsToShow) + 1; } else if (this._hoverIndex >= 0 && this._hoverIndex < this._scrollItemOffset) { this._scrollItemOffset -= this._scrollItemOffset - this._hoverIndex; } this.scrollBarOffset = this._scrollItemOffset == 0 ? 0 : (int)Lerp.FloatSmooth(0.0f, (float)this.scrollBarScrollableHeight, (float)this._scrollItemOffset / (float)(this._mods.Count - this._maxModsToShow)); if (!Editor.hoverTextBox && !UIMenu.globalUILock && (Input.Pressed("QUACK") || Keyboard.Pressed(Keys.Escape))) { if (this.modsChanged) { this.Close(); MonoMain.pauseMenu = DuckNetwork.OpenModsRestartWindow(this._openOnClose); } else { new UIMenuActionOpenMenu((UIComponent)this, (UIComponent)this._openOnClose).Activate(); } this.modsChanged = false; return; } } if (this._showingMenu) { HUD.CloseAllCorners(); this._showingMenu = false; } base.Update(); }
protected override List <Profile> AddPoints() { List <Profile> profileList = new List <Profile>(); List <Team> teamList = new List <Team>(); List <Team> source = new List <Team>(); foreach (Team team in Teams.all) { foreach (Profile activeProfile in team.activeProfiles) { if (activeProfile.duck != null && !activeProfile.duck.dead) { if (activeProfile.duck.converted != null && activeProfile.duck.converted.profile.team != activeProfile.team) { if (!source.Contains(activeProfile.duck.converted.profile.team)) { source.Add(activeProfile.duck.converted.profile.team); } if (!teamList.Contains(activeProfile.duck.profile.team)) { teamList.Add(activeProfile.duck.profile.team); break; } break; } if (!source.Contains(team)) { source.Add(team); break; } break; } } } if (source.Count <= 1 && source.Count > 0) { source.AddRange((IEnumerable <Team>)teamList); byte winteam = 4; List <int> idxs = new List <int>(); GameMode.lastWinners.Clear(); foreach (Team team in source) { foreach (Profile activeProfile in team.activeProfiles) { if (activeProfile.duck != null && !activeProfile.duck.dead) { if (!this._editorTestMode) { if (Teams.active.Count > 1 && Network.isActive && activeProfile.connection == DuckNetwork.localConnection) { DuckNetwork.GiveXP("Rounds Won", 1, 4, firstCap: 10, secondCap: 20); } activeProfile.stats.lastWon = DateTime.Now; ++activeProfile.stats.matchesWon; } profileList.Add(activeProfile); Profile p = activeProfile; if (activeProfile.duck.converted != null) { p = activeProfile.duck.converted.profile; winteam = p.networkIndex; } GameMode.lastWinners.Add(activeProfile); PlusOne plusOne = new PlusOne(0.0f, 0.0f, p); plusOne.anchor = (Anchor)(Thing)activeProfile.duck; plusOne.anchor.offset = new Vec2(0.0f, -16f); idxs.Add((int)activeProfile.duck.netProfileIndex); Level.Add((Thing)plusOne); } } } if (Network.isActive && Network.isServer) { Send.Message((NetMessage) new NMAssignWin(idxs, winteam)); } ++source.First <Team>().score; } return(profileList); }
public static void OnMessage(NetMessage m) { if (m is NMJoinDuckNetwork) { // DevConsole.Log(DCSection.DuckNet, "|DGYELLOW|Join message", -1); if (DuckNetwork.status == DuckNetStatus.Disconnected) { return; } } if (m == null) { Main.codeNumber = 13371; } UIMatchmakingBox.pulseNetwork = true; if (DuckNetwork.GetProfiles(m.connection).Count == 0 && m.connection != Network.host) { Main.codeNumber = 13372; NetMessage msg = DuckNetwork.OnMessageFromNewClient(m); if (msg == null) { return; } Send.Message(msg, m.connection); } else { if (DuckNetwork.HandleCoreConnectionMessages(m) || DuckNetwork.status == DuckNetStatus.Disconnecting) { return; } Main.codeNumber = 13373; foreach (Profile profile in DuckNetwork.GetProfiles(m.connection)) { if (profile.networkStatus == DuckNetStatus.Disconnecting || profile.networkStatus == DuckNetStatus.Disconnected || profile.networkStatus == DuckNetStatus.Failure) { return; } } Main.codeNumber = m.typeIndex; if (Network.isServer) { if (m is NMLateJoinDuckNetwork) { if (!(Level.current is TeamSelect2)) { Send.Message(new NMGameInProgress(), NetMessagePriority.ReliableOrdered, m.connection); } else { NMLateJoinDuckNetwork lateJoinDuckNetwork = m as NMLateJoinDuckNetwork; // DevConsole.Log(DCSection.DuckNet, "|DGYELLOW|Late join attempt from " + lateJoinDuckNetwork.name, -1); // Profile profile = DuckNetwork.CreateProfile(m.connection, lateJoinDuckNetwork.name, (int)lateJoinDuckNetwork.duckIndex, (InputProfile)null, false, false, false); Profile profile = (Profile)createProfile.Invoke(null, new object[] { m.connection, lateJoinDuckNetwork.name, (int)lateJoinDuckNetwork.duckIndex, null, false, false, false }); if (profile != null) { profile.networkStatus = DuckNetStatus.Connected; TeamSelect2Edits.OnNetworkConnecting(profile); DuckNetwork.SendNewProfile(profile, m.connection, true); } else { Send.Message(new NMServerFull(), NetMessagePriority.ReliableOrdered, m.connection); } } } else if (m is NMJoinedDuckNetwork) { foreach (Profile profile in DuckNetwork.GetProfiles(m.connection)) { // DevConsole.Log(DCSection.DuckNet, "|LIME|" + profile.name + " Has joined the DuckNet", -1); Send.Message(new NMSwitchLevel("@TEAMSELECT", DuckNetwork.levelIndex, (ushort)0, false, 0U), m.connection); } } else if (m is NMClientLoadedLevel) { if ((m as NMClientLoadedLevel).levelIndex == DuckNetwork.levelIndex) { m.connection.wantsGhostData = (m as NMClientLoadedLevel).levelIndex; } else { ;// DevConsole.Log(DCSection.DuckNet, "|DGRED|" + m.connection.identifier + " LOADED WRONG LEVEL! (" + DuckNetwork.levelIndex + " VS " + (m as NMClientLoadedLevel).levelIndex + ")", -1); } } else if (m is NMSetTeam) { NMSetTeam nmSetTeam = m as NMSetTeam; if (nmSetTeam.duck < 0 || nmSetTeam.duck >= 8) { return; } Profile profile = DuckNetwork.profiles[nmSetTeam.duck]; if (profile.connection == null || profile.team == null) { return; } profile.team = Teams.all[nmSetTeam.team]; if (!DuckNetwork.OnTeamSwitch(profile)) { return; } Send.MessageToAllBut(new NMSetTeam(nmSetTeam.duck, nmSetTeam.team), NetMessagePriority.ReliableOrdered, m.connection); } else { if (!(m is NMSpecialHat)) { return; } NMSpecialHat nmSpecialHat = m as NMSpecialHat; Team t = Team.Deserialize(nmSpecialHat.GetData()); foreach (Profile profile in DuckNetwork.profiles) { if ((long)profile.steamID == (long)nmSpecialHat.link) { if (t != null) { Team.MapFacade(profile.steamID, t); } else { Team.ClearFacade(profile.steamID); } Send.MessageToAllBut(new NMSpecialHat(t, profile.steamID), NetMessagePriority.ReliableOrdered, m.connection); } } } } else if (m is NMSpecialHat) { NMSpecialHat nmSpecialHat = m as NMSpecialHat; Team t = Team.Deserialize(nmSpecialHat.GetData()); foreach (Profile profile in DuckNetwork.profiles) { if ((long)profile.steamID == (long)nmSpecialHat.link) { if (t != null) { Team.MapFacade(profile.steamID, t); } else { Team.ClearFacade(profile.steamID); } } } } else if (m is NMJoinDuckNetwork) { NMRemoteJoinDuckNetwork remoteJoinDuckNetwork = m as NMRemoteJoinDuckNetwork; if (remoteJoinDuckNetwork == null) { // DevConsole.Log(DCSection.DuckNet, "|LIME|Connection with host was established!", -1); NMJoinDuckNetwork nmJoinDuckNetwork = m as NMJoinDuckNetwork; _core.status = DuckNetStatus.Connected; if (DuckNetwork.profiles[nmJoinDuckNetwork.duckIndex].connection == DuckNetwork.localConnection) { DuckNetwork.profiles[nmJoinDuckNetwork.duckIndex].networkStatus = DuckNetStatus.Connected; } else { // Profile profile = DuckNetwork.CreateProfile(DuckNetwork.localConnection, Network.activeNetwork.core.GetLocalName(), (int)nmJoinDuckNetwork.duckIndex, UIMatchmakingBox.matchmakingProfiles.Count > 0 ? UIMatchmakingBox.matchmakingProfiles[0].inputProfile : InputProfile.DefaultPlayer1, Teams.core.extraTeams.Count > 0, false, false); Profile profile = (Profile)createProfile.Invoke(null, new object[] { DuckNetwork.localConnection, Network.activeNetwork.core.GetLocalName(), (int)nmJoinDuckNetwork.duckIndex, UIMatchmakingBox.matchmakingProfiles.Count > 0 ? UIMatchmakingBox.matchmakingProfiles[0].inputProfile : InputProfile.DefaultPlayer1, Teams.core.extraTeams.Count > 0, false, false }); _core.localDuckIndex = nmJoinDuckNetwork.duckIndex; profile.flippers = Profile.CalculateLocalFlippers(); profile.networkStatus = DuckNetStatus.WaitingForLoadingToBeFinished; } } else { NetworkConnection networkConnection = remoteJoinDuckNetwork.connection; Main.codeNumber = 133701; if (remoteJoinDuckNetwork.identifier == "SERVER") { Main.codeNumber = 133702; // Profile profile1 = DuckNetwork.CreateProfile(networkConnection, remoteJoinDuckNetwork.name, (int)remoteJoinDuckNetwork.duckIndex, (InputProfile)null, remoteJoinDuckNetwork.hasCustomHats, false, false); Profile profile1 = (Profile)createProfile.Invoke(null, new object[] { networkConnection, remoteJoinDuckNetwork.name, (int)remoteJoinDuckNetwork.duckIndex, null, remoteJoinDuckNetwork.hasCustomHats, false, false }); profile1.flippers = remoteJoinDuckNetwork.flippers; profile1.team = Teams.all[remoteJoinDuckNetwork.team]; if (_core.hostDuckIndex == -1) { _core.hostDuckIndex = remoteJoinDuckNetwork.duckIndex; } Main.codeNumber = 133703; bool flag = false; foreach (Profile profile2 in DuckNetwork.GetProfiles(networkConnection)) { if (profile2 != profile1) { profile1.networkStatus = profile2.networkStatus; flag = true; break; } } Main.codeNumber = 133704; if (flag) { return; } profile1.networkStatus = DuckNetStatus.WaitingForLoadingToBeFinished; } else { Main.codeNumber = 133705; bool flag = false; DuckNetStatus duckNetStatus = DuckNetStatus.NeedsNotificationWhenReadyForData; foreach (Profile profile in DuckNetwork.GetProfiles(networkConnection)) { if (profile.connection.identifier == remoteJoinDuckNetwork.identifier) { networkConnection = profile.connection; flag = true; duckNetStatus = profile.networkStatus; break; } } Main.codeNumber = 133706; if (!flag) { networkConnection = Network.activeNetwork.core.AttemptConnection(remoteJoinDuckNetwork.identifier); if (networkConnection == null) { DuckNetwork.RaiseError(new DuckNetErrorInfo() { error = DuckNetError.InvalidConnectionInformation, message = "Invalid connection information (" + remoteJoinDuckNetwork.identifier + ")" }); return; } } Main.codeNumber = 133707; // Profile profile1 = DuckNetwork.CreateProfile(networkConnection, remoteJoinDuckNetwork.name, remoteJoinDuckNetwork.duckIndex, (InputProfile)null, remoteJoinDuckNetwork.hasCustomHats, false, false); Profile profile1 = (Profile)createProfile.Invoke(null, new object[] { networkConnection, remoteJoinDuckNetwork.name, remoteJoinDuckNetwork.duckIndex, (InputProfile)null, remoteJoinDuckNetwork.hasCustomHats, false, false }); profile1.team = Teams.all[remoteJoinDuckNetwork.team]; profile1.networkStatus = duckNetStatus; profile1.flippers = remoteJoinDuckNetwork.flippers; } } } else if (m is NMEndOfDuckNetworkData) { Send.Message(new NMJoinedDuckNetwork(), m.connection); foreach (Profile profile in DuckNetwork.profiles) { if (profile.connection == DuckNetwork.localConnection) { Send.Message(new NMProfileInfo(profile.networkIndex, profile.stats.unloyalFans, profile.stats.loyalFans)); } } } else if (m is NMEndOfGhostData) { if ((m as NMEndOfGhostData).levelIndex == DuckNetwork.levelIndex) { // DevConsole.Log(DCSection.DuckNet, "|DGGREEN|Received Host Level Information (" + (m as NMEndOfGhostData).levelIndex + ").", -1); Level.current.TransferComplete(m.connection); DuckNetwork.SendToEveryone(new NMLevelDataReady(DuckNetwork.levelIndex)); foreach (Profile profile in DuckNetwork.GetProfiles(DuckNetwork.localConnection)) { profile.connection.loadingStatus = (m as NMEndOfGhostData).levelIndex; } } else { ;// DevConsole.Log(DCSection.DuckNet, "|DGRED|Recieved data for wrong level.", -1); } } else if (m is NMSetTeam) { NMSetTeam nmSetTeam = m as NMSetTeam; if (nmSetTeam.duck < 0 || nmSetTeam.duck >= 8) { return; } Profile profile = DuckNetwork.profiles[nmSetTeam.duck]; if (profile.connection == null || profile.team == null) { return; } profile.team = Teams.all[nmSetTeam.team]; } else { if (!(m is NMTeamSetDenied)) { return; } NMTeamSetDenied nmTeamSetDenied = m as NMTeamSetDenied; if (nmTeamSetDenied.duck < 0 || nmTeamSetDenied.duck >= 8) { return; } Profile profile = DuckNetwork.profiles[nmTeamSetDenied.duck]; if (profile.connection != DuckNetwork.localConnection || profile.team == null || Teams.all.IndexOf(profile.team) != nmTeamSetDenied.team) { return; } openTeamSwitchDialogue.Invoke(null, new[] { profile }); } } }
public override void Update() { this._scroll += 0.1f; if ((double)this._scroll > 9.0) { this._scroll = 0.0f; } this._dots += 0.01f; if ((double)this._dots > 1.0) { this._dots = 0.0f; } if (this.open) { foreach (BlacklistServer failedAttempt in this._failedAttempts) { failedAttempt.cooldown = Lerp.Float(failedAttempt.cooldown, 0.0f, Maths.IncFrameTimer()); } if (this._signalCrossLocal.currentAnimation == "idle") { if (UIMatchmakingBox.pulseLocal) { this._signalCrossLocal.SetAnimation("flicker"); UIMatchmakingBox.pulseLocal = false; } } else if (this._signalCrossLocal.finished) { this._signalCrossLocal.SetAnimation("idle"); } if (this._signalCrossNetwork.currentAnimation == "idle") { if (UIMatchmakingBox.pulseNetwork) { this._signalCrossNetwork.SetAnimation("flicker"); UIMatchmakingBox.pulseNetwork = false; } } else if (this._signalCrossNetwork.finished) { this._signalCrossNetwork.SetAnimation("idle"); } if (Network.connections.Count > 0 && UIMatchmakingBox._state != MatchmakingState.Connecting) { this.ChangeState(MatchmakingState.Connecting); DevConsole.Log("|PURPLE|MATCHMAKING |DGGREEN|Network appears to be connecting...", Color.White); } if (DuckNetwork.status == DuckNetStatus.Connected) { if (this._tryHostingLobby != null) { (Level.current as TeamSelect2).CloseAllDialogs(); Level.current = (Level) new TeamSelect2(); DevConsole.Log("|PURPLE|MATCHMAKING |DGGREEN|Finished! (HOST).", Color.White); return; } if (Level.current is TeamSelect2) { (Level.current as TeamSelect2).CloseAllDialogs(); Level.current = (Level) new ConnectingScreen(); DevConsole.Log("|PURPLE|MATCHMAKING |DGGREEN|Finished! (CLIENT).", Color.White); return; } Network.Disconnect(); this.ChangeState(MatchmakingState.SearchForLobbies); DevConsole.Log("|PURPLE|MATCHMAKING |DGGREEN|Last minute connection error.", Color.White); return; } switch (UIMatchmakingBox._state) { case MatchmakingState.ConnectToMoon: Steam.AddLobbyStringFilter("started", "true", SteamLobbyComparison.Equal); Steam.SearchForLobby((User)null); Steam.RequestGlobalStats(); UIMatchmakingBox.pulseLocal = true; this.ChangeState(MatchmakingState.ConnectingToMoon); break; case MatchmakingState.ConnectingToMoon: if (Steam.lobbySearchComplete) { if (this.searchTryIndex == 0) { this._totalInGameLobbies = Steam.lobbiesFound; if (this._totalInGameLobbies < 0) { this._totalInGameLobbies = 0; } ++this.searchTryIndex; Steam.AddLobbyStringFilter("started", "false", SteamLobbyComparison.Equal); Steam.SearchForLobby((User)null); break; } UIMatchmakingBox.pulseNetwork = true; this._totalLobbiesFound = Steam.lobbiesFound; List <User> users = Steam.GetSearchLobbyAtIndex(0).users; this._newStatusList.Add("|DGGREEN|Connected to Moon!"); this._newStatusList.Add(""); this._newStatusList.Add("|DGYELLOW|Searching for companions."); this.ChangeState(MatchmakingState.SearchForLobbies); break; } break; case MatchmakingState.SearchForLobbies: if (this._triesSinceSearch == 3) { Steam.AddLobbyStringFilter("started", "true", SteamLobbyComparison.Equal); Steam.SearchForLobby((User)null); this.ChangeState(MatchmakingState.CheckingTotalGames); return; } if (this._tries > 0 && this._tryHostingLobby == null) { DuckNetwork.Host(TeamSelect2.GetSettingInt("maxplayers"), NetworkLobbyType.Public); this._tryHostingLobby = (Network.activeNetwork.core as NCSteam).lobby; if (!this.triedHostingAlready) { this._newStatusList.Add("|DGYELLOW|Searching even harder."); } else { this._newStatusList.Add("|DGYELLOW|Searching."); } this.triedHostingAlready = true; DevConsole.Log("|PURPLE|MATCHMAKING |DGYELLOW|Opened lobby while searching.", Color.White); this._tryHostingWait = 5f + Rando.Float(2f); } foreach (MatchSetting matchSetting in TeamSelect2.matchSettings) { if (matchSetting.value is int) { if (matchSetting.filtered) { Steam.AddLobbyNumericalFilter(matchSetting.id, (int)matchSetting.value, (SteamLobbyComparison)matchSetting.filterMode); } else if (!matchSetting.filtered) { Steam.AddLobbyNearFilter(matchSetting.id, (int)matchSetting.defaultValue); } } if (matchSetting.value is bool) { if (matchSetting.filtered) { Steam.AddLobbyNumericalFilter(matchSetting.id, (bool)matchSetting.value ? 1 : 0, (SteamLobbyComparison)matchSetting.filterMode); } else if (!matchSetting.filtered) { Steam.AddLobbyNearFilter(matchSetting.id, (bool)matchSetting.defaultValue ? 1 : 0); } } } foreach (MatchSetting onlineSetting in TeamSelect2.onlineSettings) { if (onlineSetting.value is int) { if (onlineSetting.filtered) { Steam.AddLobbyNumericalFilter(onlineSetting.id, (int)onlineSetting.value, (SteamLobbyComparison)onlineSetting.filterMode); } else if (!onlineSetting.filtered) { Steam.AddLobbyNearFilter(onlineSetting.id, (int)onlineSetting.defaultValue); } } if (onlineSetting.value is bool) { if (onlineSetting.id == "modifiers") { if (onlineSetting.filtered) { Steam.AddLobbyStringFilter(onlineSetting.id, (bool)onlineSetting.value ? "true" : "false", SteamLobbyComparison.Equal); } } else if (onlineSetting.filtered) { Steam.AddLobbyNumericalFilter(onlineSetting.id, (bool)onlineSetting.value ? 1 : 0, (SteamLobbyComparison)onlineSetting.filterMode); } else if (!onlineSetting.filtered) { Steam.AddLobbyNearFilter(onlineSetting.id, (bool)onlineSetting.defaultValue ? 1 : 0); } } } Steam.AddLobbyStringFilter("started", "false", SteamLobbyComparison.Equal); Steam.AddLobbyStringFilter("beta", "2.0", SteamLobbyComparison.Equal); Steam.AddLobbyStringFilter("dev", DG.devBuild ? "true" : "false", SteamLobbyComparison.Equal); Steam.AddLobbyStringFilter("modhash", ModLoader.modHash, SteamLobbyComparison.Equal); if (!Steam.waitingForGlobalStats) { this._globalKills = (long)Steam.GetDailyGlobalStat("kills"); } Steam.RequestGlobalStats(); UIMatchmakingBox.pulseLocal = true; this.ChangeState(MatchmakingState.Searching); ++this._triesSinceSearch; ++this._tries; break; case MatchmakingState.CheckingTotalGames: if (Steam.lobbySearchComplete) { this._totalInGameLobbies = Steam.lobbiesFound; if (this._totalInGameLobbies < 0) { this._totalInGameLobbies = 0; } this.ChangeState(MatchmakingState.SearchForLobbies); this._triesSinceSearch = 0; break; } break; case MatchmakingState.Searching: if (Steam.lobbySearchComplete) { this._totalLobbiesFound = Steam.lobbiesFound; if (this._tryHostingLobby != null) { --this._totalLobbiesFound; } List <Lobby> lobbyList = new List <Lobby>(); DevConsole.Log("|PURPLE|MATCHMAKING |LIME|found " + (object)Math.Max(this._totalLobbiesFound, 0) + " lobbies.", Color.White); for (int index1 = 0; index1 < 2; ++index1) { int num1 = index1 != 0 ? lobbyList.Count : Steam.lobbiesFound; for (int index2 = 0; index2 < num1; ++index2) { Lobby lobby = index1 != 0 ? lobbyList[index2] : Steam.GetSearchLobbyAtIndex(index2); if (this._tryHostingLobby == null || (long)lobby.id != (long)this._tryHostingLobby.id) { if (index2 == Steam.lobbiesFound - 1) { this._failedAttempts.RemoveAll((Predicate <BlacklistServer>)(x => (double)x.cooldown <= 0.0)); } if (UIMatchmakingBox.nonPreferredServers.Contains(lobby.id) && index1 == 0) { lobbyList.Add(lobby); DevConsole.Log("|PURPLE|MATCHMAKING |DGRED|Skipping " + (object)lobby.id + " (NOT PREFERRED)", Color.White); } else if (this.IsBlacklisted(lobby.id)) { DevConsole.Log("|PURPLE|MATCHMAKING |DGRED|Skipping " + (object)lobby.id + " (BLACKLISTED)", Color.White); } else { if (this._tryHostingLobby != null) { int num2 = -1; try { string lobbyData = lobby.GetLobbyData("randomID"); if (lobbyData != "") { num2 = Convert.ToInt32(lobbyData); } } catch { } if (num2 == -1) { DevConsole.Log("|PURPLE|MATCHMAKING |DGYELLOW|Bad lobby seed.", Color.White); num2 = Rando.Int(2147483646); } if (num2 >= this._tryHostingLobby.randomID) { DevConsole.Log("|PURPLE|MATCHMAKING |DGYELLOW|Lobby beats own lobby, Attempting join.", Color.White); } else { DevConsole.Log("|PURPLE|MATCHMAKING |DGYELLOW|Skipping lobby (Chose to keep hosting).", Color.White); NCSteam.UpdateRandomID(this._tryHostingLobby); continue; } } this._tryConnectLobby = lobby; if (lobby.owner != null) { this._newStatusList.Add("|LIME|Trying to join " + lobby.owner.name + "."); } else { this._newStatusList.Add("|LIME|Trying to join server."); } this.ChangeState(MatchmakingState.Disconnect); break; } } } } if (this._tryConnectLobby == null) { DevConsole.Log("|PURPLE|MATCHMAKING |DGYELLOW|Found no valid lobbies.", Color.White); this.ChangeState(MatchmakingState.SearchForLobbies, 3f); break; } break; } break; case MatchmakingState.Waiting: this._stateWait -= Maths.IncFrameTimer(); if ((double)this._stateWait <= 0.0) { this._stateWait = 0.0f; this.OnStateChange(this._pendingState); break; } break; default: int state = (int)UIMatchmakingBox._state; break; } if (Input.Pressed("QUACK")) { this._quit = true; this.ChangeState(MatchmakingState.Disconnect); } } if (this._newStatusList.Count > 0) { this._newStatusWait -= 0.1f; if ((double)this._newStatusWait <= 0.0) { this._newStatusWait = 1f; while ((double)this._fancyFont.GetWidth(this._newStatusList[0]) > 98.0) { this._newStatusList[0] = this._newStatusList[0].Substring(0, this._newStatusList[0].Length - 1); } this._statusList.Add(this._newStatusList[0]); if (this._statusList.Count > 7) { this._statusList.RemoveAt(0); } this._newStatusList.RemoveAt(0); } } base.Update(); }
public static void Host(int maxPlayers, NetworkLobbyType lobbyType) { if (_core.status != DuckNetStatus.Disconnected) { return; } // DevConsole.Log(DCSection.DuckNet, "|LIME|Hosting new server. ", -1); // Rubbish fix for Update calling host with 4 max players. Need better way if (maxPlayers == 4 && lobbyType == NetworkLobbyType.FriendsOnly) { maxPlayers = 8; } DuckNetwork.Reset(); foreach (Profile universalProfile in Profiles.universalProfileList) { universalProfile.team = (Team)null; } _core.error = (DuckNetErrorInfo)null; TeamSelect2.DefaultSettings(); Network.HostServer(lobbyType, maxPlayers, "duckGameServer", 1337); DuckNetwork.localConnection.AttemptConnection(); foreach (Profile profile in DuckNetwork.profiles) { profile.slotType = lobbyType != NetworkLobbyType.Private ? (lobbyType != NetworkLobbyType.FriendsOnly ? SlotType.Open : SlotType.Friend) : SlotType.Invite; if ((int)profile.networkIndex >= maxPlayers) { profile.slotType = SlotType.Closed; } } int num = 1; _core.localDuckIndex = -1; foreach (MatchmakingPlayer matchmakingProfile in UIMatchmakingBox.matchmakingProfiles) { string name = Network.activeNetwork.core.GetLocalName(); if (num > 1) { name = name + "(" + num.ToString() + ")"; } if (_core.localDuckIndex == -1) { _core.localDuckIndex = (int)matchmakingProfile.duckIndex; _core.hostDuckIndex = (int)matchmakingProfile.duckIndex; } Profile profile = (Profile)createProfile.Invoke(null, new object[] { _core.localConnection, name, (int)matchmakingProfile.duckIndex, matchmakingProfile.inputProfile, false, false, false }); if (num > 1) { profile.slotType = SlotType.Local; } profile.networkStatus = DuckNetStatus.Connected; if (matchmakingProfile.team != null) { if (matchmakingProfile.team.customData != null) { profile.team = Teams.all[(int)matchmakingProfile.duckIndex]; Team.MapFacade(profile.steamID, matchmakingProfile.team); } else { profile.team = matchmakingProfile.team; } } ++num; } _core.localConnection.isHost = true; _core.status = DuckNetStatus.Connecting; }
public override void Activate() { DuckNetwork.OpenMatchSettingsInfo(); base.Activate(); }
public static void UpdateLevelChangeReplace() { Type type = typeof(Level); Assembly assembly = Assembly.GetAssembly(type); Type HUDtype = assembly.GetType("DuckGame.HUD"); dynamic HUDClearCorners = HUDtype.GetMethod("ClearCorners", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static); Type ConnectionStatusUIType = assembly.GetType("DuckGame.ConnectionStatusUI"); dynamic ConnectionStatusUIShow = ConnectionStatusUIType.GetMethod("Show", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static); dynamic ConnectionStatusUIHide = ConnectionStatusUIType.GetMethod("Hide", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static); FieldInfo _readyForTransitionField = type.GetField("_readyForTransition", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static); dynamic _readyForTransition = _readyForTransitionField.GetValue(Level.current); if (Level.core.nextLevel != null) { FieldInfo _sentLevelChangeField = type.GetField("_sentLevelChange", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static); dynamic _sentLevelChange = _sentLevelChangeField.GetValue(Level.current); FieldInfo _networkStatusField = type.GetField("_networkStatus", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static); dynamic _networkStatus = _networkStatusField.GetValue(Level.current); if (Level.core.currentLevel is IHaveAVirtualTransition && Level.core.nextLevel is IHaveAVirtualTransition && !(Level.core.nextLevel is TeamSelect2)) { VirtualTransition.GoVirtual(); } if (Network.isActive && Level.activeLevel != null && !_sentLevelChange) { // DevConsole.Log(DCSection.GhostMan, "|DGYELLOW|Performing level swap (" + (object)DuckNetwork.levelIndex + ")", -1); GhostManager.context.Clear(); foreach (Profile profile in Profiles.active) { if (profile.connection != null) { profile.connection.manager.Reset(); } } if (Level.core.currentLevel is TeamSelect2 && !(Level.core.nextLevel is TeamSelect2)) { DuckNetwork.ClosePauseMenu(); } if (!(Level.core.currentLevel is TeamSelect2) && Level.core.nextLevel is TeamSelect2) { DuckNetwork.ClosePauseMenu(); } if (Network.isServer) { ++DuckNetwork.levelIndex; DuckNetwork.compressedLevelData = (MemoryStream)null; // DevConsole.Log(DCSection.GhostMan, "|DGYELLOW|Incrementing level index (" + (object)((int)DuckNetwork.levelIndex - 1) + "->" + (object)DuckNetwork.levelIndex + ")", -1); uint varChecksum = 0; bool varNeedsChecksum = false; string lev = ""; if (!(Level.core.currentLevel is TeamSelect2) && Level.core.nextLevel is TeamSelect2) { lev = "@TEAMSELECT"; } else if (Level.core.nextLevel is GameLevel) { GameLevel nextLevel = Level.core.nextLevel as GameLevel; if (nextLevel.customLevel) { varNeedsChecksum = true; varChecksum = nextLevel.checksum; DuckNetwork.compressedLevelData = new MemoryStream(nextLevel.compressedData, 0, nextLevel.compressedData.Length, false, true); } lev = nextLevel.level; } else if (!(Level.core.nextLevel is TeamSelect2) && !(Level.core.nextLevel is GameLevel) && !(Level.core.nextLevel is RockScoreboard)) { lev = "@ROCKINTRO"; // This need correcting at some point and probably will break things. Must get the internal type } else if (Level.core.nextLevel is RockScoreboard) { GhostManager.context.SetGhostIndex((NetIndex16)1); lev = (Level.core.nextLevel as RockScoreboard).mode != ScoreBoardMode.ShowScores ? (!(Level.core.nextLevel as RockScoreboard).afterHighlights ? "@ROCKTHROW|SHOWWINNER" : "@ROCKTHROW|SHOWEND") : "@ROCKTHROW|SHOWSCORE"; } if (lev != "") { foreach (Profile profile in DuckNetwork.profiles) { if (profile.connection != null) { profile.connection.manager.ClearAllMessages(); if (Level.core.nextLevel is GameLevel && (Level.core.nextLevel as GameLevel).level == "RANDOM") { Send.Message((NetMessage) new NMSwitchLevelRandom(lev, DuckNetwork.levelIndex, (ushort)(int)GhostManager.context.currentGhostIndex, (Level.core.nextLevel as GameLevel).seed), NetMessagePriority.ReliableOrdered, profile.connection); } else { Send.Message((NetMessage) new NMSwitchLevel(lev, DuckNetwork.levelIndex, (ushort)(int)GhostManager.context.currentGhostIndex, varNeedsChecksum, varChecksum), NetMessagePriority.ReliableOrdered, profile.connection); } } } } } _sentLevelChange = true; } if (!VirtualTransition.active) { Level.InitChanceGroups(); DamageManager.ClearHits(); Layer.ResetLayers(); HUDClearCorners.Invoke(null, null); if (Level.core.currentLevel != null) { Level.core.currentLevel.Terminate(); } Level.core.currentLevel = Level.core.nextLevel; Level.core.nextLevel = (Level)null; Layer.lighting = false; SequenceItem.sequenceItems.Clear(); GC.Collect(1, GCCollectionMode.Optimized); foreach (Profile profile in Profiles.active) { profile.duck = (Duck)null; } SFX.StopAllSounds(); if (Level.core.currentLevel is RockScoreboard) { LevelEdits.DoInitialize(); } else { Level.core.currentLevel.DoInitialize(); } if (MonoMain.pauseMenu != null) { Level.core.currentLevel.AddThing((Thing)MonoMain.pauseMenu); } if (Network.isActive && DuckNetwork.duckNetUIGroup != null && DuckNetwork.duckNetUIGroup.open) { Level.core.currentLevel.AddThing((Thing)DuckNetwork.duckNetUIGroup); } if (Recorder.globalRecording != null) { Recorder.globalRecording.UpdateAtlasFile(); } _networkStatus = NetLevelStatus.WaitingForDataTransfer; if (!(Level.core.currentLevel is IOnlyTransitionIn) && Level.core.currentLevel is IHaveAVirtualTransition && (!(Level.core.currentLevel is TeamSelect2) && VirtualTransition.isVirtual)) { if (_readyForTransition) { VirtualTransition.GoUnVirtual(); DuckGame.Graphics.fade = 1f; } else { Level.current._waitingOnTransition = true; if (Network.isActive) { ConnectionStatusUIShow.Invoke(null, null); } } } } } if (!Level.current._waitingOnTransition || !_readyForTransition) { return; } Level.current._waitingOnTransition = false; VirtualTransition.GoUnVirtual(); if (!Network.isActive) { return; } ConnectionStatusUIHide.Invoke(null, null); }