// 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); }