All cooldown handlers come with their IDs as static fields
This commit is contained in:
1 parent
1092ff07c9
commit
3f04f286d6
36 files changed
+98
-97
No files matched your search
@@ -3866,7 +3866,6 @@ namespace CalamityMod.CalPlayer
|
||||
Cooldown durability = Cooldowns.Find(cooldown => cooldown.GetType() == typeof(DivingPlatesBreaking));
|
||||
durability.TimeLeft = abyssalDivingSuitPlateHits;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5573,9 +5572,6 @@ namespace CalamityMod.CalPlayer
|
||||
projTypeJustHitBy = proj.type;
|
||||
|
||||
Cooldowns.Add(new GlobalDodge(EvolutionReflectCooldown, player));
|
||||
// Send a Calamity dodge cooldown packet.
|
||||
if (Main.netMode == NetmodeID.MultiplayerClient && player.whoAmI == Main.myPlayer)
|
||||
SyncCooldown(false);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ using Terraria.ModLoader;
|
||||
|
||||
namespace CalamityMod.CalPlayer
|
||||
{
|
||||
public partial class CalamityPlayer : ModPlayer
|
||||
public partial class CalamityPlayer : ModPlayer
|
||||
{
|
||||
#region Standard Syncs
|
||||
internal const int GlobalSyncPacketTimer = 15;
|
||||
@@ -18,7 +18,6 @@ namespace CalamityMod.CalPlayer
|
||||
SyncAdrenaline(false);
|
||||
SyncMoveSpeed(false);
|
||||
SyncDefenseDamage(false);
|
||||
SyncCooldown(false);
|
||||
}
|
||||
|
||||
private void EnterWorldSync()
|
||||
@@ -151,40 +150,6 @@ namespace CalamityMod.CalPlayer
|
||||
player.SendPacket(packet, server);
|
||||
}
|
||||
|
||||
internal void SyncCooldown(bool server, string cooldownID = "")
|
||||
{
|
||||
//If no specific sync id is provided, sync all of the player's cooldowns. Ideally this doesn't happen though. Ideally. Do we even need it frankly? Like i guess we could call it on death but idk if it needs to be synced every frames since its
|
||||
//Already being synced when it gets created and then when it expires
|
||||
if (cooldownID == "")
|
||||
{
|
||||
foreach (string key in Cooldown.IDtoType.Keys)
|
||||
{
|
||||
ModPacket packet = mod.GetPacket();
|
||||
packet.Write((byte)CalamityModMessageType.CooldownSync);
|
||||
packet.Write(player.whoAmI);
|
||||
packet.Write(key);
|
||||
int timer = 0;
|
||||
if (Cooldowns.Exists(cooldown => cooldown.GetType() == Cooldown.IDtoType[key]))
|
||||
timer = Cooldowns.Find(cooldown => cooldown.GetType() == Cooldown.IDtoType[key]).TimeLeft;
|
||||
packet.Write(timer);
|
||||
player.SendPacket(packet, server);
|
||||
}
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
ModPacket packet = mod.GetPacket();
|
||||
packet.Write((byte)CalamityModMessageType.CooldownSync);
|
||||
packet.Write(player.whoAmI);
|
||||
packet.Write(cooldownID);
|
||||
int timer = 0;
|
||||
if (Cooldowns.Exists(cooldown => cooldown.GetType() == Cooldown.IDtoType[cooldownID]))
|
||||
timer = Cooldowns.Find(cooldown => cooldown.GetType() == Cooldown.IDtoType[cooldownID]).TimeLeft;
|
||||
packet.Write(timer);
|
||||
player.SendPacket(packet, server);
|
||||
}
|
||||
}
|
||||
|
||||
private void SyncDeathCount(bool server)
|
||||
{
|
||||
ModPacket packet = mod.GetPacket(256);
|
||||
@@ -334,24 +299,6 @@ namespace CalamityMod.CalPlayer
|
||||
SyncDefenseDamage(true);
|
||||
}
|
||||
|
||||
internal void HandleCooldowns(BinaryReader reader)
|
||||
{
|
||||
string syncID = reader.ReadString();
|
||||
int timer = reader.ReadInt32();
|
||||
Type cooldownType = Cooldown.IDtoType[syncID];
|
||||
|
||||
// If this cooldown is present, edit the existing cooldown's timer.
|
||||
if (Cooldowns.Exists(cooldown => cooldown.GetType() == cooldownType))
|
||||
Cooldowns.Find(cooldown => cooldown.GetType() == cooldownType).TimeLeft = timer;
|
||||
|
||||
// Otherwise create a new cooldown with this timer.
|
||||
else if (timer > 0)
|
||||
Cooldowns.Add((Cooldown)Activator.CreateInstance(cooldownType, timer, player));
|
||||
|
||||
if (Main.netMode == NetmodeID.Server)
|
||||
SyncCooldown(true);
|
||||
}
|
||||
|
||||
internal void HandleRightClick(BinaryReader reader)
|
||||
{
|
||||
mouseRight = reader.ReadBoolean();
|
||||
|
||||
+1
-3
@@ -15,7 +15,6 @@ using CalamityMod.Items.Dyes.HairDye;
|
||||
using CalamityMod.Items.VanillaArmorChanges;
|
||||
using CalamityMod.Localization;
|
||||
using CalamityMod.NPCs;
|
||||
using CalamityMod.NPCs.Abyss;
|
||||
using CalamityMod.NPCs.AdultEidolonWyrm;
|
||||
using CalamityMod.NPCs.AquaticScourge;
|
||||
using CalamityMod.NPCs.AstrumAureus;
|
||||
@@ -53,7 +52,6 @@ using CalamityMod.Skies;
|
||||
using CalamityMod.TileEntities;
|
||||
using CalamityMod.UI;
|
||||
using CalamityMod.UI.CalamitasEnchants;
|
||||
using CalamityMod.UI.CooldownIndicators;
|
||||
using CalamityMod.Waters;
|
||||
using CalamityMod.World;
|
||||
using Microsoft.Xna.Framework;
|
||||
@@ -75,7 +73,7 @@ using Terraria.UI;
|
||||
|
||||
namespace CalamityMod
|
||||
{
|
||||
public class CalamityMod : Mod
|
||||
public class CalamityMod : Mod
|
||||
{
|
||||
// CONSIDER -- I have been advised by Jopo that Mods should never contain static variables
|
||||
// TODO -- 1.4 fixes the crit reforge price calculation bug, so GetWeaponCrit everywhere can go.
|
||||
|
||||
@@ -6,6 +6,7 @@ namespace CalamityMod.Cooldowns
|
||||
{
|
||||
public class AquaticHeartIceShield : CooldownHandler
|
||||
{
|
||||
public static string ID => "AquaticHeartIceShield";
|
||||
public AquaticHeartIceShield(CooldownInstance? c) : base(c) { }
|
||||
|
||||
public override bool ShouldDisplay => true;
|
||||
|
||||
@@ -4,6 +4,7 @@ namespace CalamityMod.Cooldowns
|
||||
{
|
||||
public class BloodflareFrenzy : CooldownHandler
|
||||
{
|
||||
public static string ID => "BloodflareFrenzy";
|
||||
public BloodflareFrenzy(CooldownInstance? c) : base(c) { }
|
||||
|
||||
public override bool ShouldDisplay => true;
|
||||
|
||||
@@ -5,6 +5,7 @@ namespace CalamityMod.Cooldowns
|
||||
{
|
||||
public class BloodflareRangedSet : CooldownHandler
|
||||
{
|
||||
public static string ID => "BloodflareRangedSet";
|
||||
public BloodflareRangedSet(CooldownInstance? c) : base(c) { }
|
||||
|
||||
public override bool ShouldDisplay => true;
|
||||
|
||||
@@ -8,6 +8,7 @@ namespace CalamityMod.Cooldowns
|
||||
{
|
||||
public class BrimflameFrenzy : CooldownHandler
|
||||
{
|
||||
public static string ID => "BrimflameFrenzy";
|
||||
public BrimflameFrenzy(CooldownInstance? c) : base(c) { }
|
||||
|
||||
public override bool ShouldDisplay => true;
|
||||
|
||||
@@ -4,6 +4,8 @@ namespace CalamityMod.Cooldowns
|
||||
{
|
||||
public class ChaosState : CooldownHandler
|
||||
{
|
||||
public static string ID => "ChaosState";
|
||||
|
||||
public override bool ShouldDisplay => CalamityConfig.Instance.VanillaCooldownDisplay && instance.player.chaosState;
|
||||
public override string DisplayName => "Teleportation Cooldown";
|
||||
public override string Texture => "CalamityMod/Cooldowns/ChaosState" + skinTexture;
|
||||
|
||||
+31
-31
@@ -1,5 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace CalamityMod.Cooldowns
|
||||
{
|
||||
@@ -47,37 +46,38 @@ namespace CalamityMod.Cooldowns
|
||||
// TODO -- CooldownHandlers should be ILoadable in 1.4
|
||||
|
||||
// Vanilla cooldowns represented by the interface
|
||||
Cooldown potionSickness = Register("PotionSickness", new PotionSickness(null));
|
||||
Cooldown chaosState = Register("ChaosState", new ChaosState(null));
|
||||
Cooldown globalDodge = Register("GlobalDodge", new GlobalDodge(null));
|
||||
Cooldown potionSickness = Register(PotionSickness.ID, new PotionSickness(null));
|
||||
Cooldown chaosState = Register(ChaosState.ID, new ChaosState(null));
|
||||
Cooldown globalDodge = Register(GlobalDodge.ID, new GlobalDodge(null));
|
||||
|
||||
// Calamity cooldowns
|
||||
Cooldown aquaticHeartIceShield = Register("AquaticHeartIceShield", new AquaticHeartIceShield(null));
|
||||
Cooldown bloodflareFrenzy = Register("BloodflareFrenzy", new BloodflareFrenzy(null));
|
||||
Cooldown bloodflareRanged = Register("BloodflareRangedSet", new BloodflareRangedSet(null));
|
||||
Cooldown brimflameFrenzy = Register("BrimflameFrenzy", new BrimflameFrenzy(null));
|
||||
Cooldown counterScarf = Register("CounterScarf", new CounterScarf(null));
|
||||
Cooldown divineBless = Register("DivineBless", new DivineBless(null));
|
||||
Cooldown divingPlatesBreaking = Register("DivingPlatesBreaking", new DivingPlatesBreaking(null));
|
||||
Cooldown divingPlatesBroken = Register("DivingPlatesBroken", new DivingPlatesBroken(null));
|
||||
Cooldown draconicElixir = Register("DraconicElixir", new DraconicElixir(null));
|
||||
Cooldown evasionScarf = Register("EvasionScarf", new EvasionScarf(null));
|
||||
Cooldown fleshTotem = Register("FleshTotem", new FleshTotem(null));
|
||||
Cooldown godSlayerDash = Register("GodSlayerDash", new GodSlayerDash(null));
|
||||
Cooldown inkBomb = Register("InkBomb", new InkBomb(null));
|
||||
Cooldown lionHeartShield = Register("LionHeartShield", new LionHeartShield(null));
|
||||
Cooldown nebulousCore = Register("NebulousCore", new NebulousCore(null));
|
||||
Cooldown omegaBlue = Register("OmegaBlue", new OmegaBlue(null));
|
||||
Cooldown permafrostConcoction = Register("PermafrostConcoction", new PermafrostConcoction(null));
|
||||
Cooldown plagueBlackout = Register("PlagueBlackout", new PlagueBlackout(null));
|
||||
Cooldown prismaticLaser = Register("PrismaticLaser", new PrismaticLaser(null));
|
||||
Cooldown profanedSoulArtifact = Register("ProfanedSoulArtifact", new ProfanedSoulArtifact(null));
|
||||
Cooldown relicOfResilience = Register("RelicOfResilience", new RelicOfResilience(null));
|
||||
Cooldown rogueBooster = Register("RogueBooster", new RogueBooster(null));
|
||||
Cooldown sandCloak = Register("SandCloak", new SandCloak(null));
|
||||
Cooldown silvaRevive = Register("SilvaRevive", new SilvaRevive(null));
|
||||
Cooldown tarragonCloak = Register("TarragonCloak", new TarragonCloak(null));
|
||||
Cooldown universeSplitter = Register("UniverseSplitter", new UniverseSplitter(null));
|
||||
Cooldown aquaticHeartIceShield = Register(AquaticHeartIceShield.ID, new AquaticHeartIceShield(null));
|
||||
Cooldown bloodflareFrenzy = Register(BloodflareFrenzy.ID, new BloodflareFrenzy(null));
|
||||
Cooldown bloodflareRanged = Register(BloodflareRangedSet.ID, new BloodflareRangedSet(null));
|
||||
Cooldown brimflameFrenzy = Register(BrimflameFrenzy.ID, new BrimflameFrenzy(null));
|
||||
Cooldown counterScarf = Register(CounterScarf.ID, new CounterScarf(null));
|
||||
Cooldown divineBless = Register(DivineBless.ID, new DivineBless(null));
|
||||
Cooldown divingPlatesBreaking = Register(DivingPlatesBreaking.ID, new DivingPlatesBreaking(null));
|
||||
Cooldown divingPlatesBroken = Register(DivingPlatesBroken.ID, new DivingPlatesBroken(null));
|
||||
Cooldown draconicElixir = Register(DraconicElixir.ID, new DraconicElixir(null));
|
||||
Cooldown evasionScarf = Register(EvasionScarf.ID, new EvasionScarf(null));
|
||||
Cooldown fleshTotem = Register(FleshTotem.ID, new FleshTotem(null));
|
||||
Cooldown godSlayerDash = Register(GodSlayerDash.ID, new GodSlayerDash(null));
|
||||
Cooldown inkBomb = Register(InkBomb.ID, new InkBomb(null));
|
||||
Cooldown lionHeartShield = Register(LionHeartShield.ID, new LionHeartShield(null));
|
||||
Cooldown nebulousCore = Register(NebulousCore.ID, new NebulousCore(null));
|
||||
Cooldown omegaBlue = Register(OmegaBlue.ID, new OmegaBlue(null));
|
||||
Cooldown permafrostConcoction = Register(PermafrostConcoction.ID, new PermafrostConcoction(null));
|
||||
Cooldown plagueBlackout = Register(PlagueBlackout.ID, new PlagueBlackout(null));
|
||||
Cooldown prismaticLaser = Register(PrismaticLaser.ID, new PrismaticLaser(null));
|
||||
Cooldown profanedSoulArtifact = Register(ProfanedSoulArtifact.ID, new ProfanedSoulArtifact(null));
|
||||
Cooldown relicOfResilience = Register(RelicOfResilience.ID, new RelicOfResilience(null));
|
||||
Cooldown rogueBooster = Register(RogueBooster.ID, new RogueBooster(null));
|
||||
Cooldown sandCloak = Register(SandCloak.ID, new SandCloak(null));
|
||||
Cooldown silvaRevive = Register(SilvaRevive.ID, new SilvaRevive(null));
|
||||
Cooldown tarragonCloak = Register(TarragonCloak.ID, new TarragonCloak(null));
|
||||
Cooldown tarragonImmunity = Register(TarragonImmunity.ID, new TarragonImmunity(null));
|
||||
Cooldown universeSplitter = Register(UniverseSplitter.ID, new UniverseSplitter(null));
|
||||
}
|
||||
|
||||
public static void Unload()
|
||||
|
||||
@@ -10,6 +10,7 @@ namespace CalamityMod.Cooldowns
|
||||
{
|
||||
public class CooldownHandler
|
||||
{
|
||||
public static string ID => null;
|
||||
public CooldownInstance instance;
|
||||
|
||||
public CooldownHandler(CooldownInstance? c)
|
||||
|
||||
@@ -6,6 +6,7 @@ namespace CalamityMod.Cooldowns
|
||||
{
|
||||
public class CounterScarf : CooldownHandler
|
||||
{
|
||||
public static string ID => "CounterScarf";
|
||||
public CounterScarf(CooldownInstance? c) : base(c) { }
|
||||
|
||||
public override bool ShouldDisplay => true;
|
||||
|
||||
@@ -7,6 +7,7 @@ namespace CalamityMod.Cooldowns
|
||||
{
|
||||
public class DivineBless : CooldownHandler
|
||||
{
|
||||
public static string ID => "DivineBless";
|
||||
public DivineBless(CooldownInstance? c) : base(c) { }
|
||||
|
||||
public override bool ShouldDisplay => true;
|
||||
|
||||
@@ -14,6 +14,7 @@ namespace CalamityMod.Cooldowns
|
||||
private static Color ringColorLerpStart = new Color(160, 174, 174);
|
||||
private static Color ringColorLerpEnd = new Color(192, 11, 107);
|
||||
|
||||
public static string ID => "DivingPlatesBreaking";
|
||||
public DivingPlatesBreaking(CooldownInstance? c) : base(c) { }
|
||||
|
||||
public override bool CanTickDown => !instance.player.Calamity().abyssalDivingSuit;
|
||||
@@ -57,6 +58,7 @@ namespace CalamityMod.Cooldowns
|
||||
private static Color ringColorLerpStart = new Color(91, 121, 150);
|
||||
private static Color ringColorLerpEnd = new Color(30, 50, 77);
|
||||
|
||||
public static string ID => "DivingPlatesBroken";
|
||||
public DivingPlatesBroken(CooldownInstance? c) : base(c) { }
|
||||
|
||||
public override bool ShouldDisplay => true;
|
||||
|
||||
@@ -6,6 +6,7 @@ namespace CalamityMod.Cooldowns
|
||||
{
|
||||
public class DraconicElixir : CooldownHandler
|
||||
{
|
||||
public static string ID => "DraconicElixir";
|
||||
public DraconicElixir(CooldownInstance? c) : base(c) { }
|
||||
|
||||
public override bool ShouldDisplay => true;
|
||||
|
||||
@@ -7,6 +7,7 @@ namespace CalamityMod.Cooldowns
|
||||
// TODO -- Why do the two scarves not use the same cooldown? They're both called "Scarf Cooldown".
|
||||
public class EvasionScarf : CooldownHandler
|
||||
{
|
||||
public static string ID => "EvasionScarf";
|
||||
public EvasionScarf(CooldownInstance? c) : base(c) { }
|
||||
|
||||
public override bool ShouldDisplay => true;
|
||||
|
||||
@@ -4,6 +4,8 @@ namespace CalamityMod.Cooldowns
|
||||
{
|
||||
public class FleshTotem : CooldownHandler
|
||||
{
|
||||
public static string ID => "FleshTotem";
|
||||
|
||||
public override bool ShouldDisplay => true;
|
||||
public override string DisplayName => "Contact Damage Halving Cooldown";
|
||||
public override string Texture => "CalamityMod/Cooldowns/" + skinTexture;
|
||||
|
||||
@@ -4,6 +4,8 @@ namespace CalamityMod.Cooldowns
|
||||
{
|
||||
public class GlobalDodge : CooldownHandler
|
||||
{
|
||||
public static string ID => "GlobalDodge";
|
||||
|
||||
public override bool ShouldDisplay => true;
|
||||
public override string DisplayName => "Dodge Cooldown";
|
||||
public override string Texture => "CalamityMod/Cooldowns/" + skinTexture;
|
||||
|
||||
@@ -4,6 +4,7 @@ namespace CalamityMod.Cooldowns
|
||||
{
|
||||
public class GodSlayerDash : CooldownHandler
|
||||
{
|
||||
public static string ID => "GodSlayerDash";
|
||||
public GodSlayerDash(CooldownInstance? c) : base(c) { }
|
||||
|
||||
public override bool ShouldDisplay => true;
|
||||
|
||||
@@ -4,6 +4,7 @@ namespace CalamityMod.Cooldowns
|
||||
{
|
||||
public class InkBomb : CooldownHandler
|
||||
{
|
||||
public static string ID => "InkBomb";
|
||||
public InkBomb(CooldownInstance? c) : base(c) { }
|
||||
|
||||
public override bool ShouldDisplay => true;
|
||||
|
||||
@@ -4,6 +4,7 @@ namespace CalamityMod.Cooldowns
|
||||
{
|
||||
public class LionHeartShield : CooldownHandler
|
||||
{
|
||||
public static string ID => "LionHeartShield";
|
||||
public LionHeartShield(CooldownInstance? c) : base(c) { }
|
||||
|
||||
public override bool ShouldDisplay => true;
|
||||
|
||||
@@ -5,6 +5,7 @@ namespace CalamityMod.Cooldowns
|
||||
{
|
||||
public class NebulousCore : CooldownHandler
|
||||
{
|
||||
public static string ID => "NebulousCore";
|
||||
public NebulousCore(CooldownInstance? c) : base(c) { }
|
||||
|
||||
public override bool ShouldDisplay => true;
|
||||
|
||||
@@ -10,6 +10,7 @@ namespace CalamityMod.Cooldowns
|
||||
{
|
||||
public class OmegaBlue : CooldownHandler
|
||||
{
|
||||
public static string ID => "OmegaBlue";
|
||||
public OmegaBlue(CooldownInstance? c) : base(c) { }
|
||||
|
||||
public override bool ShouldDisplay => true;
|
||||
|
||||
@@ -5,6 +5,7 @@ namespace CalamityMod.Cooldowns
|
||||
{
|
||||
public class PermafrostConcoction : CooldownHandler
|
||||
{
|
||||
public static string ID => "PermafrostConcoction";
|
||||
public PermafrostConcoction(CooldownInstance? c) : base(c) { }
|
||||
|
||||
public override bool ShouldDisplay => true;
|
||||
|
||||
@@ -6,6 +6,7 @@ namespace CalamityMod.Cooldowns
|
||||
{
|
||||
public class PlagueBlackout : CooldownHandler
|
||||
{
|
||||
public static string ID => "PlagueBlackout";
|
||||
public PlagueBlackout(CooldownInstance? c) : base(c) => instance.duration = 1500;
|
||||
|
||||
public override bool ShouldDisplay => instance.timeLeft <= 1500;
|
||||
|
||||
@@ -4,6 +4,7 @@ namespace CalamityMod.Cooldowns
|
||||
{
|
||||
public class PotionSickness : CooldownHandler
|
||||
{
|
||||
public static string ID => "PotionSickness";
|
||||
public PotionSickness(CooldownInstance? c) : base(c) { }
|
||||
|
||||
public override bool ShouldDisplay => CalamityConfig.Instance.VanillaCooldownDisplay && instance.player.potionDelay > 0;
|
||||
|
||||
@@ -6,6 +6,7 @@ namespace CalamityMod.Cooldowns
|
||||
{
|
||||
public class PrismaticLaser : CooldownHandler
|
||||
{
|
||||
public static string ID => "PrismaticLaser";
|
||||
public PrismaticLaser(CooldownInstance? c) : base(c) { }
|
||||
|
||||
public override bool ShouldDisplay => true;
|
||||
|
||||
@@ -4,6 +4,7 @@ namespace CalamityMod.Cooldowns
|
||||
{
|
||||
public class ProfanedSoulArtifact : CooldownHandler
|
||||
{
|
||||
public static string ID => "ProfanedSoulArtifact";
|
||||
public ProfanedSoulArtifact(CooldownInstance? c) : base(c) { }
|
||||
|
||||
public override bool ShouldDisplay => true;
|
||||
|
||||
@@ -5,6 +5,7 @@ namespace CalamityMod.Cooldowns
|
||||
{
|
||||
public class RelicOfResilience : CooldownHandler
|
||||
{
|
||||
public static string ID => "RelicOfResilience";
|
||||
public RelicOfResilience(CooldownInstance? c) : base(c) { }
|
||||
|
||||
public override bool ShouldDisplay => true;
|
||||
|
||||
@@ -4,6 +4,8 @@ namespace CalamityMod.Cooldowns
|
||||
{
|
||||
public class RogueBooster : CooldownHandler
|
||||
{
|
||||
public static string ID => "RogueBooster";
|
||||
|
||||
public override bool ShouldDisplay => true;
|
||||
public override string DisplayName => "Rogue Booster Cooldown";
|
||||
public override string Texture => "CalamityMod/Cooldowns/" + skinTexture;
|
||||
|
||||
@@ -4,6 +4,7 @@ namespace CalamityMod.Cooldowns
|
||||
{
|
||||
public class SandCloak : CooldownHandler
|
||||
{
|
||||
public static string ID => "SandCloak";
|
||||
public SandCloak(CooldownInstance? c) : base(c) { }
|
||||
|
||||
public override bool ShouldDisplay => true;
|
||||
|
||||
@@ -5,6 +5,7 @@ namespace CalamityMod.Cooldowns
|
||||
{
|
||||
public class SilvaRevive : CooldownHandler
|
||||
{
|
||||
public static string ID => "SilvaRevive";
|
||||
public SilvaRevive(CooldownInstance? c) : base(c) { }
|
||||
|
||||
public override bool ShouldDisplay => true;
|
||||
|
||||
@@ -4,6 +4,7 @@ namespace CalamityMod.Cooldowns
|
||||
{
|
||||
public class TarragonCloak : CooldownHandler
|
||||
{
|
||||
public static string ID => "TarragonCloak";
|
||||
public TarragonCloak(CooldownInstance? c) : base(c) { }
|
||||
|
||||
public override bool ShouldDisplay => true;
|
||||
|
||||
@@ -4,6 +4,7 @@ namespace CalamityMod.Cooldowns
|
||||
{
|
||||
public class TarragonImmunity : CooldownHandler
|
||||
{
|
||||
public static string ID => "TarragonImmunity";
|
||||
public TarragonImmunity(CooldownInstance? c) : base(c) { }
|
||||
|
||||
public override bool ShouldDisplay => true;
|
||||
|
||||
@@ -6,6 +6,7 @@ namespace CalamityMod.Cooldowns
|
||||
{
|
||||
public class UniverseSplitter : CooldownHandler
|
||||
{
|
||||
public static string ID => "UniverseSplitter";
|
||||
public UniverseSplitter(CooldownInstance? c) : base(c) { }
|
||||
|
||||
public override bool ShouldDisplay => true;
|
||||
|
||||
@@ -137,9 +137,6 @@ namespace CalamityMod.ILEditing
|
||||
{
|
||||
CalamityPlayer calPlayer = p.Calamity();
|
||||
calPlayer.Cooldowns.Add(new GlobalDodgeCooldown(CalamityPlayer.BeltDodgeCooldown, p));
|
||||
|
||||
if (Main.netMode == NetmodeID.MultiplayerClient)
|
||||
calPlayer.SyncCooldown(false, "GlobalDodge");
|
||||
});
|
||||
}
|
||||
#endregion Removal of Black Belt Dodge RNG
|
||||
|
||||
@@ -13,6 +13,7 @@ namespace CalamityMod
|
||||
{
|
||||
public static partial class CalamityUtils
|
||||
{
|
||||
#region Damage
|
||||
// These functions factor in TML 0.11 allDamage to get the player's total damage boost which affects the specified class.
|
||||
public static float MeleeDamage(this Player player) => player.allDamage + player.meleeDamage - 1f;
|
||||
public static float RangedDamage(this Player player) => player.allDamage + player.rangedDamage - 1f;
|
||||
@@ -21,9 +22,12 @@ namespace CalamityMod
|
||||
public static float ThrownDamage(this Player player) => player.allDamage + player.thrownDamage - 1f;
|
||||
public static float RogueDamage(this Player player) => player.allDamage + player.thrownDamage + player.Calamity().throwingDamage - 2f;
|
||||
public static float AverageDamage(this Player player) => player.allDamage + (player.meleeDamage + player.rangedDamage + player.magicDamage + player.minionDamage + player.Calamity().throwingDamage - 5f) / 5f;
|
||||
#endregion
|
||||
|
||||
public static bool IsUnderwater(this Player player) => Collision.DrownCollision(player.position, player.width, player.height, player.gravDir);
|
||||
public static bool StandingStill(this Player player, float velocity = 0.05f) => player.velocity.Length() < velocity;
|
||||
|
||||
#region Location & Biomes
|
||||
public static bool IsUnderwater(this Player player) => Collision.DrownCollision(player.position, player.width, player.height, player.gravDir);
|
||||
public static bool InSpace(this Player player)
|
||||
{
|
||||
float x = Main.maxTilesX / 4200f;
|
||||
@@ -72,6 +76,8 @@ namespace CalamityMod
|
||||
return player.Calamity().ZoneAbyss;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
public static bool InventoryHas(this Player player, params int[] items)
|
||||
{
|
||||
return player.inventory.Any(item => items.Contains(item.type));
|
||||
@@ -88,6 +94,7 @@ namespace CalamityMod
|
||||
return hasItem;
|
||||
}
|
||||
|
||||
#region Immunity Frames
|
||||
/// <summary>
|
||||
/// Gives the player the specified number of immunity frames (or "iframes" for short).<br />If the player already has more iframes than you want to give them, this function does nothing.
|
||||
/// </summary>
|
||||
@@ -117,6 +124,10 @@ namespace CalamityMod
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Removes all immunity frames (or "iframes" for short) from the specified player immediately.
|
||||
/// </summary>
|
||||
/// <param name="player">The player whose iframes should be removed.</param>
|
||||
public static void RemoveAllIFrames(this Player player)
|
||||
{
|
||||
player.immune = false;
|
||||
@@ -125,8 +136,9 @@ namespace CalamityMod
|
||||
for (int i = 0; i < player.hurtCooldowns.Length; ++i)
|
||||
player.hurtCooldowns[i] = 0;
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
||||
#region Rage and Adrenaline
|
||||
/// <summary>
|
||||
/// Returns the damage multiplier Adrenaline Mode provides for the given player.
|
||||
/// </summary>
|
||||
@@ -161,6 +173,19 @@ namespace CalamityMod
|
||||
if (mp.adrenalineModeActive)
|
||||
damageMult += trueMelee ? mp.GetAdrenalineDamage() * rageAndAdrenalineTrueMeleeDamageMult : mp.GetAdrenalineDamage();
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Cooldowns
|
||||
public static bool HasCooldown(this Player p, string id)
|
||||
{
|
||||
if (p is null)
|
||||
return false;
|
||||
CalamityPlayer modPlayer = p.Calamity();
|
||||
if (modPlayer is null)
|
||||
return false;
|
||||
|
||||
return modPlayer.Cooldowns.ContainsKey(id);
|
||||
}
|
||||
|
||||
public static IList<CooldownInstance> GetDisplayedCooldowns(this Player p)
|
||||
{
|
||||
@@ -173,7 +198,9 @@ namespace CalamityMod
|
||||
ret.Add(instance);
|
||||
return ret;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Debuffs
|
||||
public static void Inflict246DebuffsPvp(Player target, int buff, float timeBase = 2f)
|
||||
{
|
||||
if (Main.rand.NextBool(4))
|
||||
@@ -203,6 +230,7 @@ namespace CalamityMod
|
||||
target.AddBuff(BuffID.Frostburn, (int)(150 * multiplier));
|
||||
target.AddBuff(BuffID.OnFire, (int)(180 * multiplier));
|
||||
}
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
/// Checks if the player is ontop of solid ground. May also check for solid ground for X tiles in front of them
|
||||
|
||||
Reference in new issue
Block a user