Skip to content

Commit

Permalink
Prefer non mod qualified version of GetX generic methods.
Browse files Browse the repository at this point in the history
  • Loading branch information
JavidPack committed Sep 11, 2018
1 parent 360418e commit bb70c30
Show file tree
Hide file tree
Showing 31 changed files with 41 additions and 41 deletions.
2 changes: 1 addition & 1 deletion ExampleMod/Backgrounds/ExampleSurfaceBgStyle.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ public class ExampleSurfaceBgStyle : ModSurfaceBgStyle
{
public override bool ChooseBgStyle()
{
return !Main.gameMenu && Main.LocalPlayer.GetModPlayer<ExamplePlayer>(mod).ZoneExample;
return !Main.gameMenu && Main.LocalPlayer.GetModPlayer<ExamplePlayer>().ZoneExample;
}

// Use this to keep far Backgrounds like the mountains.
Expand Down
2 changes: 1 addition & 1 deletion ExampleMod/Backgrounds/ExampleUgBgStyle.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ public class ExampleUgBgStyle : ModUgBgStyle
{
public override bool ChooseBgStyle()
{
return Main.LocalPlayer.GetModPlayer<ExamplePlayer>(mod).ZoneExample;
return Main.LocalPlayer.GetModPlayer<ExamplePlayer>().ZoneExample;
}

public override void FillTextureArray(int[] textureSlots)
Expand Down
4 changes: 2 additions & 2 deletions ExampleMod/Buffs/EtherealFlames.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@ public override void SetDefaults()

public override void Update(Player player, ref int buffIndex)
{
player.GetModPlayer<ExamplePlayer>(mod).eFlames = true;
player.GetModPlayer<ExamplePlayer>().eFlames = true;
}

public override void Update(NPC npc, ref int buffIndex)
{
npc.GetGlobalNPC<ExampleGlobalNPC>(mod).eFlames = true;
npc.GetGlobalNPC<ExampleGlobalNPC>().eFlames = true;
}
}
}
2 changes: 1 addition & 1 deletion ExampleMod/Buffs/ExampleLightPet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public override void SetDefaults()

public override void Update(Player player, ref int buffIndex)
{
player.GetModPlayer<ExamplePlayer>(mod).exampleLightPet = true;
player.GetModPlayer<ExamplePlayer>().exampleLightPet = true;
player.buffTime[buffIndex] = 18000;
bool petProjectileNotSpawned = player.ownedProjectileCounts[mod.ProjectileType("ExampleLightPet")] <= 0;
if (petProjectileNotSpawned && player.whoAmI == Main.myPlayer)
Expand Down
2 changes: 1 addition & 1 deletion ExampleMod/Buffs/ExamplePet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public override void SetDefaults()
public override void Update(Player player, ref int buffIndex)
{
player.buffTime[buffIndex] = 18000;
player.GetModPlayer<ExamplePlayer>(mod).examplePet = true;
player.GetModPlayer<ExamplePlayer>().examplePet = true;
bool petProjectileNotSpawned = player.ownedProjectileCounts[mod.ProjectileType("ExamplePet")] <= 0;
if (petProjectileNotSpawned && player.whoAmI == Main.myPlayer)
{
Expand Down
2 changes: 1 addition & 1 deletion ExampleMod/Buffs/Nullified.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public override void SetDefaults()

public override void Update(Player player, ref int buffIndex)
{
player.GetModPlayer<ExamplePlayer>(mod).nullified = true;
player.GetModPlayer<ExamplePlayer>().nullified = true;
}
}
}
2 changes: 1 addition & 1 deletion ExampleMod/Buffs/PurityWisp.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public override void SetDefaults()

public override void Update(Player player, ref int buffIndex)
{
ExamplePlayer modPlayer = player.GetModPlayer<ExamplePlayer>(mod);
ExamplePlayer modPlayer = player.GetModPlayer<ExamplePlayer>();
if (player.ownedProjectileCounts[mod.ProjectileType("PurityWisp")] > 0)
{
modPlayer.purityMinion = true;
Expand Down
2 changes: 1 addition & 1 deletion ExampleMod/Buffs/Undead.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public override void SetDefaults()

public override void Update(Player player, ref int buffIndex)
{
player.GetModPlayer<ExamplePlayer>(mod).badHeal = true;
player.GetModPlayer<ExamplePlayer>().badHeal = true;
}
}
}
2 changes: 1 addition & 1 deletion ExampleMod/Buffs/Undead2.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public override void Update(Player player, ref int buffIndex)
{
int extra = player.buffTime[buffIndex] / 60;
player.buffTime[buffIndex] -= extra;
player.GetModPlayer<ExamplePlayer>(mod).healHurt = extra + 1;
player.GetModPlayer<ExamplePlayer>().healHurt = extra + 1;
}

public override bool ReApply(Player player, int time, int buffIndex)
Expand Down
2 changes: 1 addition & 1 deletion ExampleMod/Commands/ScoreCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public override void Action(CommandCaller caller, string input, string[] args)
{
throw new UsageException("Could not find player: " + args[0]);
}
var modPlayer = Main.player[player].GetModPlayer<ExamplePlayer>(mod);
var modPlayer = Main.player[player].GetModPlayer<ExamplePlayer>();
if (args[1] == "get")
{
caller.Reply(args[0] + "'s score is " + modPlayer.score);
Expand Down
8 changes: 4 additions & 4 deletions ExampleMod/ExamplePlayer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ public override void UpdateBiomes()

public override bool CustomBiomesMatch(Player other)
{
ExamplePlayer modOther = other.GetModPlayer<ExamplePlayer>(mod);
ExamplePlayer modOther = other.GetModPlayer<ExamplePlayer>();
return ZoneExample == modOther.ZoneExample;
// If you have several Zones, you might find the &= operator or other logic operators useful:
// bool allMatch = true;
Expand All @@ -166,7 +166,7 @@ public override bool CustomBiomesMatch(Player other)

public override void CopyCustomBiomesTo(Player other)
{
ExamplePlayer modOther = other.GetModPlayer<ExamplePlayer>(mod);
ExamplePlayer modOther = other.GetModPlayer<ExamplePlayer>();
modOther.ZoneExample = ZoneExample;
}

Expand Down Expand Up @@ -684,7 +684,7 @@ public override void DrawEffects(PlayerDrawInfo drawInfo, ref float r, ref float
}
Player drawPlayer = drawInfo.drawPlayer;
Mod mod = ModLoader.GetMod("ExampleMod");
ExamplePlayer modPlayer = drawPlayer.GetModPlayer<ExamplePlayer>(mod);
ExamplePlayer modPlayer = drawPlayer.GetModPlayer<ExamplePlayer>();
if (modPlayer.reviveTime > 0)
{
Texture2D texture = mod.GetTexture("NPCs/PuritySpirit/Revive");
Expand All @@ -702,7 +702,7 @@ public override void DrawEffects(PlayerDrawInfo drawInfo, ref float r, ref float
}
Player drawPlayer = drawInfo.drawPlayer;
Mod mod = ModLoader.GetMod("ExampleMod");
ExamplePlayer modPlayer = drawPlayer.GetModPlayer<ExamplePlayer>(mod);
ExamplePlayer modPlayer = drawPlayer.GetModPlayer<ExamplePlayer>();
if (modPlayer.lockTime > 0)
{
int frame = 2;
Expand Down
2 changes: 1 addition & 1 deletion ExampleMod/ExampleWorld.cs
Original file line number Diff line number Diff line change
Expand Up @@ -440,7 +440,7 @@ public override void PostWorldGen()

public override void ResetNearbyTileEffects()
{
ExamplePlayer modPlayer = Main.LocalPlayer.GetModPlayer<ExamplePlayer>(mod);
ExamplePlayer modPlayer = Main.LocalPlayer.GetModPlayer<ExamplePlayer>();
modPlayer.voidMonolith = false;
exampleTiles = 0;
}
Expand Down
2 changes: 1 addition & 1 deletion ExampleMod/Items/Abomination/SixColorShield.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public override void SetDefaults()

public override void UpdateAccessory(Player player, bool hideVisual)
{
player.GetModPlayer<ExamplePlayer>(mod).elementShield = true;
player.GetModPlayer<ExamplePlayer>().elementShield = true;
}

public override Color? GetAlpha(Color lightColor)
Expand Down
2 changes: 1 addition & 1 deletion ExampleMod/Items/ExampleShield.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public override void UpdateAccessory(Player player, bool hideVisual)
player.magicDamage += 19f;
player.minionDamage += 19f;
player.endurance = 1f - 0.1f * (1f - player.endurance);
player.GetModPlayer<ExamplePlayer>(mod).exampleShield = true;
player.GetModPlayer<ExamplePlayer>().exampleShield = true;
}
else
{
Expand Down
2 changes: 1 addition & 1 deletion ExampleMod/Items/ExampleSoul.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public class SoulGlobalNPC : GlobalNPC
{
public override void NPCLoot(NPC npc)
{
if (Main.player[(int)Player.FindClosest(npc.position, npc.width, npc.height)].GetModPlayer<ExamplePlayer>(mod).ZoneExample)
if (Main.player[(int)Player.FindClosest(npc.position, npc.width, npc.height)].GetModPlayer<ExamplePlayer>().ZoneExample)
{
Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, mod.ItemType("ExampleSoul"), 1);
}
Expand Down
2 changes: 1 addition & 1 deletion ExampleMod/Items/Potion.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ public override bool UseItem(Item item, Player player)
{
if (item.healLife > 0)
{
if (player.GetModPlayer<ExamplePlayer>(mod).badHeal)
if (player.GetModPlayer<ExamplePlayer>().badHeal)
{
int heal = item.healLife;
int damage = player.statLifeMax2 - player.statLife;
Expand Down
4 changes: 2 additions & 2 deletions ExampleMod/NPCs/ExampleGlobalNPC.cs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public override void NPCLoot(NPC npc)
if (npc.lifeMax > 5 && npc.value > 0f)
{
Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, mod.ItemType("ExampleItem"));
if (Main.player[(int)Player.FindClosest(npc.position, npc.width, npc.height)].GetModPlayer<ExamplePlayer>(mod).ZoneExample)
if (Main.player[(int)Player.FindClosest(npc.position, npc.width, npc.height)].GetModPlayer<ExamplePlayer>().ZoneExample)
{
Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, mod.ItemType("BossItem"));
}
Expand Down Expand Up @@ -172,7 +172,7 @@ public override void DrawEffects(NPC npc, ref Color drawColor)

public override void EditSpawnRate(Player player, ref int spawnRate, ref int maxSpawns)
{
if (player.GetModPlayer<ExamplePlayer>(mod).ZoneExample)
if (player.GetModPlayer<ExamplePlayer>().ZoneExample)
{
spawnRate = (int)(spawnRate * 5f);
maxSpawns = (int)(maxSpawns * 5f);
Expand Down
2 changes: 1 addition & 1 deletion ExampleMod/NPCs/ExamplePerson.cs
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ public override void SetupShop(Chest shop, ref int nextSlot)
shop.item[nextSlot].SetDefaults(mod.ItemType("ExampleHealingPotion"));
nextSlot++;
}
if (Main.LocalPlayer.GetModPlayer<ExamplePlayer>(mod).ZoneExample)
if (Main.LocalPlayer.GetModPlayer<ExamplePlayer>().ZoneExample)
{
shop.item[nextSlot].SetDefaults(mod.ItemType("ExampleWings"));
nextSlot++;
Expand Down
6 changes: 3 additions & 3 deletions ExampleMod/NPCs/PuritySpirit/PuritySpirit.cs
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ public void FindPlayers()
targets.Clear();
for (int k = 0; k < 255; k++)
{
if (Main.player[k].active && Main.player[k].GetModPlayer<ExamplePlayer>(mod).heroLives > 0)
if (Main.player[k].active && Main.player[k].GetModPlayer<ExamplePlayer>().heroLives > 0)
{
targets.Add(k);
}
Expand Down Expand Up @@ -366,7 +366,7 @@ public void Initialize()
Player player = Main.player[k];
if (player.active && player.position.X > center.X - arenaWidth / 2 && player.position.X + player.width < center.X + arenaWidth / 2 && player.position.Y > center.Y - arenaHeight / 2 && player.position.Y + player.height < center.Y + arenaHeight / 2)
{
player.GetModPlayer<ExamplePlayer>(mod).heroLives = 3;
player.GetModPlayer<ExamplePlayer>().heroLives = 3;
if (Main.netMode == 2)
{
ModPacket netMessage = GetPacket(PuritySpiritMessageType.HeroPlayer);
Expand Down Expand Up @@ -1001,7 +1001,7 @@ public void HandlePacket(BinaryReader reader)
if (type == PuritySpiritMessageType.HeroPlayer)
{
Player player = Main.LocalPlayer;
player.GetModPlayer<ExamplePlayer>(mod).heroLives = 3;
player.GetModPlayer<ExamplePlayer>().heroLives = 3;
}
else if (type == PuritySpiritMessageType.TargetList)
{
Expand Down
2 changes: 1 addition & 1 deletion ExampleMod/NPCs/Sarcophagus.cs
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ public override void CustomBehavior(ref float ai)
target.AddBuff(BuffID.Darkness, 240, true);
if (target.FindBuffIndex(BuffID.Cursed) >= 0 || target.FindBuffIndex(BuffID.Slow) >= 0 || target.FindBuffIndex(BuffID.Darkness) >= 0)
{
target.GetModPlayer<ExamplePlayer>(mod).lockTime = 60;
target.GetModPlayer<ExamplePlayer>().lockTime = 60;
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion ExampleMod/Projectiles/ElementShield.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public override void AI()
projectile.Kill();
return;
}
ExamplePlayer modPlayer = player.GetModPlayer<ExamplePlayer>(mod);
ExamplePlayer modPlayer = player.GetModPlayer<ExamplePlayer>();
if (modPlayer.elementShields <= projectile.ai[0])
{
projectile.Kill();
Expand Down
2 changes: 1 addition & 1 deletion ExampleMod/Projectiles/Minions/PurityWisp.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public override void SetDefaults()
public override void CheckActive()
{
Player player = Main.player[projectile.owner];
ExamplePlayer modPlayer = player.GetModPlayer<ExamplePlayer>(mod);
ExamplePlayer modPlayer = player.GetModPlayer<ExamplePlayer>();
if (player.dead)
{
modPlayer.purityMinion = false;
Expand Down
2 changes: 1 addition & 1 deletion ExampleMod/Projectiles/Pets/ExampleLightPet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public override void SetDefaults()
public override void AI()
{
Player player = Main.player[projectile.owner];
ExamplePlayer modPlayer = player.GetModPlayer<ExamplePlayer>(mod);
ExamplePlayer modPlayer = player.GetModPlayer<ExamplePlayer>();
if (!player.active)
{
projectile.active = false;
Expand Down
2 changes: 1 addition & 1 deletion ExampleMod/Projectiles/Pets/ExamplePet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public override bool PreAI()
public override void AI()
{
Player player = Main.player[projectile.owner];
ExamplePlayer modPlayer = player.GetModPlayer<ExamplePlayer>(mod);
ExamplePlayer modPlayer = player.GetModPlayer<ExamplePlayer>();
if (player.dead)
{
modPlayer.examplePet = false;
Expand Down
2 changes: 1 addition & 1 deletion ExampleMod/Projectiles/PuritySpirit/NegativeWall.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public override void AI()
Player player = Main.player[k];
if (player.active && !player.dead && player.Hitbox.Intersects(projectile.Hitbox))
{
ExamplePlayer modPlayer = player.GetModPlayer<ExamplePlayer>(mod);
ExamplePlayer modPlayer = player.GetModPlayer<ExamplePlayer>();
if (modPlayer.purityDebuffCooldown <= 0)
{
modPlayer.PuritySpiritDebuff();
Expand Down
4 changes: 2 additions & 2 deletions ExampleMod/Projectiles/PuritySpirit/PurityBeam.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public override void AI()
projectile.ai[1] += 1f;
if (projectile.ai[1] == charge)
{
ExamplePlayer modPlayer = Main.LocalPlayer.GetModPlayer<ExamplePlayer>(mod);
ExamplePlayer modPlayer = Main.LocalPlayer.GetModPlayer<ExamplePlayer>();
if (modPlayer.heroLives > 0)
{
Main.PlaySound(SoundID.Zombie, -1, -1, 104);
Expand All @@ -60,7 +60,7 @@ public override void ModifyHitPlayer(Player target, ref int damage, ref bool cri
{
if (target.hurtCooldowns[1] <= 0)
{
ExamplePlayer modPlayer = target.GetModPlayer<ExamplePlayer>(mod);
ExamplePlayer modPlayer = target.GetModPlayer<ExamplePlayer>();
modPlayer.constantDamage = projectile.damage;
modPlayer.percentDamage = Main.expertMode ? 0.6f : 0.5f;
}
Expand Down
4 changes: 2 additions & 2 deletions ExampleMod/Projectiles/PuritySpirit/PuritySnake.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public override void AI()
}
if (projectile.localAI[0] % 10 == 0)
{
ExamplePlayer modPlayer = Main.LocalPlayer.GetModPlayer<ExamplePlayer>(mod);
ExamplePlayer modPlayer = Main.LocalPlayer.GetModPlayer<ExamplePlayer>();
if (modPlayer.heroLives > 0)
{
Main.PlaySound(SoundID.Item20);
Expand Down Expand Up @@ -93,7 +93,7 @@ public override void ModifyHitPlayer(Player target, ref int damage, ref bool cri
{
if (target.hurtCooldowns[1] <= 0)
{
ExamplePlayer modPlayer = target.GetModPlayer<ExamplePlayer>(mod);
ExamplePlayer modPlayer = target.GetModPlayer<ExamplePlayer>();
modPlayer.defenseEffect = 1f;
}
}
Expand Down
2 changes: 1 addition & 1 deletion ExampleMod/Projectiles/PuritySpirit/PuritySphere.cs
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ public override void AI()
}
if (timer == maxTimer)
{
ExamplePlayer modPlayer = Main.LocalPlayer.GetModPlayer<ExamplePlayer>(mod);
ExamplePlayer modPlayer = Main.LocalPlayer.GetModPlayer<ExamplePlayer>();
if (modPlayer.heroLives > 0)
{
Main.PlaySound(SoundID.Item12);
Expand Down
4 changes: 2 additions & 2 deletions ExampleMod/Projectiles/PuritySpirit/VoidWorld.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public override void AI()
projectile.localAI[0] += 1f;
if (!Main.dedServ && projectile.localAI[0] >= 180f && projectile.localAI[0] < 480f && Main.rand.Next(10) == 0)
{
ExamplePlayer modPlayer = Main.LocalPlayer.GetModPlayer<ExamplePlayer>(mod);
ExamplePlayer modPlayer = Main.LocalPlayer.GetModPlayer<ExamplePlayer>();
if (modPlayer.heroLives > 0)
{
Main.PlaySound(SoundID.Item14);
Expand Down Expand Up @@ -123,7 +123,7 @@ public override void ModifyHitPlayer(Player target, ref int damage, ref bool cri
{
if (target.hurtCooldowns[1] <= 0)
{
ExamplePlayer modPlayer = target.GetModPlayer<ExamplePlayer>(mod);
ExamplePlayer modPlayer = target.GetModPlayer<ExamplePlayer>();
modPlayer.constantDamage = projectile.damage;
modPlayer.percentDamage = Main.expertMode ? 1.2f : 1f;
}
Expand Down
2 changes: 1 addition & 1 deletion ExampleMod/Tiles/ExampleGlobalTile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ internal sealed class ExampleGlobalTile : GlobalTile
public override bool Drop(int i, int j, int type)
{
// Get mod player
var modPlayer = Main.LocalPlayer.GetModPlayer<ExamplePlayer>(mod);
var modPlayer = Main.LocalPlayer.GetModPlayer<ExamplePlayer>();

if (modPlayer.ZoneExample && (type == TileID.Tombstones))
return false;
Expand Down
2 changes: 1 addition & 1 deletion ExampleMod/Tiles/VoidMonolith.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public override void NearbyEffects(int i, int j, bool closer)
{
if (Main.tile[i, j].frameY >= 56)
{
ExamplePlayer modPlayer = Main.LocalPlayer.GetModPlayer<ExamplePlayer>(mod);
ExamplePlayer modPlayer = Main.LocalPlayer.GetModPlayer<ExamplePlayer>();
modPlayer.voidMonolith = true;
}
}
Expand Down

0 comments on commit bb70c30

Please sign in to comment.