static public bool TestModTypes(out int infractions, out int totalCases) { infractions = 0; totalCases = System.Enum.GetNames(typeof(ProjModType)).Length; for (int i = 1; i < totalCases; i++) { ProjMod projMod = GetProjModFromType((ProjModType)i); if (projMod == null) { Debug.LogWarning($"Infraction {++infractions}:\nUnsupported case '{(ProjModType)i}'"); } else if (projMod.Clone().GetType() != projMod.GetType()) { Debug.LogWarning($"Infraction {++infractions}:\nMissing Clone constructor for '{(ProjModType)i}'"); } //else if ("Your mom is gay"!="true") //Debug.LogComeback("No u"); } if (infractions > 0) { return(false); } return(true); }
void RunDataTests() { Debug.Log("===================\nStarting Tests!"); System.DateTime startTime = System.DateTime.Now; System.DateTime equipmentTime = System.DateTime.Now; if (!EquipmentManager.TestAllWeapons(out int infractions, out int totalCases)) { Debug.LogError($"Weapons Set-up: Failed {infractions}/{totalCases} cases\nTimeElapsed: {System.DateTime.Now.Subtract(equipmentTime).TotalMilliseconds}ms"); } else { Debug.Log($"Weapons Set-up: Passed {totalCases} cases\nTimeElapsed: {System.DateTime.Now.Subtract(equipmentTime).TotalMilliseconds}ms"); } System.DateTime projModTime = System.DateTime.Now; if (!ProjMod.TestModTypes(out infractions, out totalCases)) { Debug.LogError($"ProjMod Set-up: Failed {infractions}/{totalCases} cases\nTimeElapsed: {System.DateTime.Now.Subtract(projModTime).TotalMilliseconds} ms"); } else { Debug.Log($"ProjMod Set-up: Passed {totalCases} cases\nTimeElapsed: {System.DateTime.Now.Subtract(projModTime).TotalMilliseconds}ms"); } double elapsedTime = System.DateTime.Now.Subtract(startTime).TotalMilliseconds; Debug.Log("Tests complete! Elapsed time: " + elapsedTime + "ms\n==================="); }
public bool RemoveProjMod(ProjMod mod) { foreach (ProjMod pm in mods) { if (pm.GetType() == mod.GetType()) { mods.Remove(pm); return(true); } } return(false); }
public void Detonate() { if (Detonated) { return; } projectile.scale *= 4; projectile.damage *= 2; this.Detonated = true; projectile.velocity = Vector2.Zero; Frame = 9; projectile.timeLeft = 180; if (ProjMod.IsGuardianProjectile(projectile.whoAmI)) { TerraGuardian tg = ProjMod.GuardianProj[projectile.whoAmI]; Rectangle ExplosionRange = new Rectangle((int)projectile.position.X - (int)(48 * projectile.scale), (int)projectile.position.Y - (int)(48 * projectile.scale) , (int)(96 * projectile.scale), (int)(96 * projectile.scale)); for (int t = 0; t < 255; t++) { if (Main.player[t].active && tg.IsPlayerHostile(Main.player[t]) && Main.player[t].getRect().Intersects(ExplosionRange)) { double dmg = Main.player[t].Hurt(Terraria.DataStructures.PlayerDeathReason.ByCustomReason(" didn't survived a electric explosion."), projectile.damage, projectile.direction, true); if (dmg > 0) { Main.player[t].AddBuff(Terraria.ID.BuffID.Electrified, 5 * 60); } } if (t < 200 && Main.npc[t].active && tg.IsNpcHostile(Main.npc[t]) && !Main.npc[t].dontTakeDamage && Main.npc[t].getRect().Intersects(ExplosionRange)) { double dmg = Main.npc[t].StrikeNPC(projectile.damage, projectile.knockBack, projectile.direction); if (dmg > 0) { Main.npc[t].AddBuff(Terraria.ID.BuffID.Electrified, 5 * 60); } } } foreach (TerraGuardian othertg in MainMod.ActiveGuardians.Values) { if (tg.IsGuardianHostile(othertg) && othertg.HitBox.Intersects(ExplosionRange)) { int dmg = othertg.Hurt(projectile.damage, projectile.direction, false, false, " didn't survived a electric explosion."); if (dmg > 0) { othertg.AddBuff(Terraria.ID.BuffID.Electrified, 5 * 60); } } } } projectile.friendly = projectile.hostile = false; }
public ProjMod(ProjMod pm) { type = pm.type; priority = pm.priority; proj = pm.proj; }
public void AddNewProjMod(ProjModType type) { AddNewProjMod(ProjMod.GetProjModFromType(type)); }
public void AddNewProjMod(ProjMod mod) { mods.Add((ProjMod)mod.Clone()); mods[mods.Count - 1].Initialize(null); }
protected ProjectileContainer(ProjectileContainer other) { stats = other.stats; graphics = other.graphics; mods = ProjMod.CloneList(other.mods); }
public ProjectileContainer(ProjectileStats _stats, ProjectileGraphics _graphics, List <ProjMod> _mods) { stats = _stats; graphics = _graphics; mods = ProjMod.CloneList(_mods); }