//////////////// public void AddPermaBuff(int buffId) { if (this.PermaBuffsById.Add(buffId)) { PlayerDataProtocol.SyncToEveryone(this.PermaBuffsById, this.HasBuffIds, this.EquipSlotsToItemTypes); } }
private void CheckArmorEquipHooks(Player player) { bool equipChange = false; for (int i = 0; i < player.armor.Length; i++) { Item item = player.armor[i]; if (item != null && !item.IsAir) { bool hadAnEquip = this.EquipSlotsToItemTypes.ContainsKey(i); if (hadAnEquip) { if (item.type != this.EquipSlotsToItemTypes[i]) { ExtendedPlayerHooks.OnArmorUnequip(player, i, this.EquipSlotsToItemTypes[i]); ExtendedPlayerHooks.OnArmorEquip(player, i, item); this.EquipSlotsToItemTypes[i] = item.type; equipChange = true; } } else { this.EquipSlotsToItemTypes[i] = item.type; ExtendedPlayerHooks.OnArmorEquip(player, i, item); equipChange = true; } } else { if (this.EquipSlotsToItemTypes.ContainsKey(i)) { ExtendedPlayerHooks.OnArmorUnequip(player, i, this.EquipSlotsToItemTypes[i]); this.EquipSlotsToItemTypes.Remove(i); equipChange = true; } } } if (equipChange) { if (Main.netMode == 1) { if (this.CanUpdateData) { this.CanUpdateData = false; Timers.SetTimer("ModHelpersPlayerDataAntiHammer", 60 * 3, () => { this.CanUpdateData = true; return(false); }); PlayerDataProtocol.SyncToEveryone(this.PermaBuffsById, this.HasBuffIds, this.EquipSlotsToItemTypes); } } } }
public void RemovePermaBuff(int buffId) { if (!this.PermaBuffsById.Contains(buffId)) { return; } if (this.PermaBuffsById.Remove(buffId)) { PlayerDataProtocol.SyncToEveryone(this.PermaBuffsById, this.HasBuffIds, this.EquipSlotsToItemTypes); } }
public void OnEnterWorldClient(HamstarHelpersMod mymod, Player player) { if (this.HasUID) { PacketProtocol.QuickSendToServer <PlayerIdProtocol>(); } PlayerDataProtocol.SyncToEveryone(this.PermaBuffsById, this.HasBuffIds, this.EquipSlotsToItemTypes); PacketProtocol.QuickRequestToServer <ModSettingsProtocol>(); PacketProtocol.QuickRequestToServer <WorldDataProtocol>(); mymod.ControlPanel.LoadModListAsync(); }
//////////////// private void CheckBuffHooks(Player player) { bool buffChange = false; // Add new buffs for (int i = 0; i < player.buffTime.Length; i++) { if (player.buffTime[i] > 0) { int buffId = player.buffType[i]; if (!this.HasBuffIds.Contains(buffId)) { this.HasBuffIds.Add(buffId); buffChange = true; } } } // Remove old buffs + fire hooks foreach (int buffId in this.HasBuffIds.ToArray()) { if (player.FindBuffIndex(buffId) == -1) { this.HasBuffIds.Remove(buffId); buffChange = true; ExtendedPlayerHooks.OnBuffExpire(player, buffId); } } if (buffChange) { if (Main.netMode == 1) { if (this.CanUpdateData) { this.CanUpdateData = false; Timers.SetTimer("ModHelpersPlayerDataAntiHammer", 60 * 3, () => { this.CanUpdateData = true; return(false); }); PlayerDataProtocol.SyncToEveryone(this.PermaBuffsById, this.HasBuffIds, this.EquipSlotsToItemTypes); } } } }
public void OnCurrentClientEnterWorld(Player player) { var mymod = ModHelpersMod.Instance; if (!this.HasLoadedOldUID) { LogHelpers.Alert("No (old) UID for " + player.name + " (" + player.whoAmI + ") to send to server"); this.HasLoadedOldUID = true; // Ugly failsafe; don't really know why data from ModPlayer.Load isn't available here } // Send PlayerOldIdProtocol.QuickSendToServer(); PlayerDataProtocol.SyncToEveryone(this.PermaBuffsById, this.HasBuffIds, this.EquipSlotsToItemTypes); // Receive WorldDataProtocol.QuickRequest(); }