Skip to content

Commit

Permalink
replace bad usages of Main.time with Main.GameUpdateCount
Browse files Browse the repository at this point in the history
  • Loading branch information
direwolf420 committed Jun 1, 2021
1 parent 898ca3c commit 6e8d151
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 23 deletions.
8 changes: 4 additions & 4 deletions AssPlayer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ private bool EligibleToReceiveSoulBuff(NPC npc)
private void SpawnSoulsWhenHarvesterIsAlive()
{
//ALWAYS GENERATE SOULS WHEN ONE IS ALIVE (otherwise he will never eat stuff when you aren't infront of dungeon walls)
if (Main.time % 30 == 4)
if (Main.GameUpdateCount % 30 == 4)
{
bool shouldDropSouls = false;
int index = 200;
Expand Down Expand Up @@ -365,7 +365,7 @@ private void UpdateTeleportHomeWhenLow()
//this code runs even when the accessory is not equipped
canTeleportHome = teleportHomeTimer <= 0;

if (!canTeleportHome && Main.time % 60 == 59)
if (!canTeleportHome && Main.GameUpdateCount % 60 == 59)
{
teleportHomeTimer--;
}
Expand All @@ -376,7 +376,7 @@ private void UpdateGetDefenseWhenLow()
//this code runs even when the accessory is not equipped
canGetDefense = getDefenseTimer <= 0;

if (!canGetDefense && Main.time % 60 == 59)
if (!canGetDefense && Main.GameUpdateCount % 60 == 59)
{
getDefenseTimer--;
}
Expand All @@ -394,7 +394,7 @@ private void Empower()
{
if (empoweringBuff)
{
if (Main.time % 60 == 0)
if (Main.GameUpdateCount % 60 == 0)
{
if (empoweringTimer < empoweringTimerMax)
{
Expand Down
2 changes: 1 addition & 1 deletion AssWorld.cs
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ private void LimitSoulCount()
{
if (Main.netMode != NetmodeID.MultiplayerClient)
{
if (Main.time % 30 == 15 && NPC.CountNPCS(ModContent.NPCType<DungeonSoul>()) > 10) //limit soul count in the world to 15
if (Main.GameUpdateCount % 30 == 15 && NPC.CountNPCS(ModContent.NPCType<DungeonSoul>()) > 10) //limit soul count in the world to 15
{
short oldest = 200;
int timeleftmin = int.MaxValue;
Expand Down
4 changes: 2 additions & 2 deletions Items/Accessories/Useful/SigilOfLastStand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public override void ModifyTooltips(List<TooltipLine> tooltips)
{
//create animating "..." effect after the Ready line
string dots = "";
int dotCount = ((int)Main.time % 120) / 30; //from 0 to 30, from 31 to 60, from 61 to 90
int dotCount = ((int)Main.GameUpdateCount % 120) / 30; //from 0 to 30, from 31 to 60, from 61 to 90

for (int i = 0; i < dotCount; i++)
{
Expand Down Expand Up @@ -107,7 +107,7 @@ public override void ModifyTooltips(List<TooltipLine> tooltips)
{
//create animating "..." effect after the Ready line
string dots = "";
int dotCount = ((int)Main.time % 120) / 30; //from 0 to 30, from 31 to 60, from 61 to 90
int dotCount = ((int)Main.GameUpdateCount % 120) / 30; //from 0 to 30, from 31 to 60, from 61 to 90

for (int i = 0; i < dotCount; i++)
{
Expand Down
2 changes: 1 addition & 1 deletion Items/Accessories/Useful/SigilOfPainSuppression.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public override void ModifyTooltips(List<TooltipLine> tooltips)
{
//create animating "..." effect after the Ready line
string dots = "";
int dotCount = ((int)Main.time % 120) / 30; //from 0 to 30, from 31 to 60, from 61 to 90
int dotCount = ((int)Main.GameUpdateCount % 120) / 30; //from 0 to 30, from 31 to 60, from 61 to 90

for (int i = 0; i < dotCount; i++)
{
Expand Down
2 changes: 1 addition & 1 deletion Items/Accessories/Useful/SigilOfRetreat.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public override void ModifyTooltips(List<TooltipLine> tooltips)
{
//create animating "..." effect after the Ready line
string dots = "";
int dotCount = ((int)Main.time % 120) / 30; //from 0 to 30, from 31 to 60, from 61 to 90
int dotCount = ((int)Main.GameUpdateCount % 120) / 30; //from 0 to 30, from 31 to 60, from 61 to 90

for (int i = 0; i < dotCount; i++)
{
Expand Down
20 changes: 10 additions & 10 deletions NPCs/DungeonBird/HarvesterBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ protected void UpdateStuck(bool closeToSoulvar, bool allowNoclipvar)
{
Vector2 between = new Vector2(0f, GetTarget().Center.Y - NPC.Center.Y);
//collideY isnt proper when its on ledges/halfbricks
if (Main.time % 30 == 0)
if (Main.GameUpdateCount % 30 == 0)
{
if ((NPC.collideX || (NPC.collideY || (NPC.velocity.Y == 0 || NPC.velocity.Y < 2f && NPC.velocity.Y > 0f))) &&
!closeToSoulvar)
Expand Down Expand Up @@ -359,7 +359,7 @@ protected void UpdateStuck(bool closeToSoulvar, bool allowNoclipvar)
}
}
}
if (Main.time % 30 == 0) //do these always
if (Main.GameUpdateCount % 30 == 0) //do these always
{
AI_X_Timer = NPC.Center.X;
AI_Y = NPC.Center.Y;
Expand Down Expand Up @@ -456,7 +456,7 @@ protected void UpdateOtherMovement(bool flag3var)
//might scrap it idk
if (Main.netMode != NetmodeID.MultiplayerClient)
{
if (Main.time % 60 == 1 && (NPC.velocity.X == 0f || (NPC.velocity.Y > -3f && NPC.velocity.Y < 3f)))
if (Main.GameUpdateCount % 60 == 1 && (NPC.velocity.X == 0f || (NPC.velocity.Y > -3f && NPC.velocity.Y < 3f)))
{
rndJump = (byte)Main.rand.Next(5, 8);
//if (rndJump >= 7)
Expand Down Expand Up @@ -719,7 +719,7 @@ protected void UpdateOtherMovement(bool flag3var)

if (/*npc.velocity.Y == 0f && */flag3var)
{
if (Main.time % 60 == 35)
if (Main.GameUpdateCount % 60 == 35)
{
NPC.velocity.Y = -rndJump - 0.5f;
}
Expand Down Expand Up @@ -762,7 +762,7 @@ protected void HarvesterAIGround(bool allowNoclip = true)

if (true/*&& AI_Timer < (float)aiFighterLimit*/)
{
if (Main.time % 60 == 0)
if (Main.GameUpdateCount % 60 == 0)
{
SelectTarget(restrictedSoulSearch);
}
Expand Down Expand Up @@ -860,7 +860,7 @@ protected void HarvesterAI(bool allowNoclip = true)
NPC.scale = defScale;
NPC.lifeMax = defLifeMax;

if (Main.time % 120 == 2)
if (Main.GameUpdateCount % 120 == 2)
{
if (NPC.timeLeft > 750) NPC.timeLeft = 750;

Expand Down Expand Up @@ -929,7 +929,7 @@ protected void HarvesterAI(bool allowNoclip = true)
NPC.noGravity = false;
NPC.noTileCollide = false;

if (Main.time % 30 == 0)
if (Main.GameUpdateCount % 30 == 0)
{
for (int k = 0; k < 256; k++)
{
Expand Down Expand Up @@ -1026,7 +1026,7 @@ protected void HarvesterAI(bool allowNoclip = true)

if (AI_State == STATE_DISTRIBUTE/*0*/)
{
if (Main.time % 20 == 0)
if (Main.GameUpdateCount % 20 == 0)
{
SelectTarget(restrictedSoulSearch);
}
Expand Down Expand Up @@ -1146,7 +1146,7 @@ protected void HarvesterAI(bool allowNoclip = true)
if (base.NPC.getRect().Intersects(npc.getRect()))
{
intersects = true;
//if (Main.time % 60 == 0) Main.NewText("intersects with " + k);
//if (Main.GameUpdateCount % 60 == 0) Main.NewText("intersects with " + k);
break;
}
}
Expand Down Expand Up @@ -1220,7 +1220,7 @@ protected void HarvesterAI(bool allowNoclip = true)
int randfactor = Main.rand.Next(2, 6);
//aitimer: from 0 to transformtime:
//rate: from 0 to 0.8 //((AI_X_Timer * 0.8f) / transformTime)
if (Main.time % 8 == 0 && Main.rand.NextFloat() < ((AI_X_Timer * 0.8f) / transformTime))
if (Main.GameUpdateCount % 8 == 0 && Main.rand.NextFloat() < ((AI_X_Timer * 0.8f) / transformTime))
{
SpawnBoneShort(NPC.Center + new Vector2(0f, -NPC.height / 4), new Vector2(Main.rand.NextFloat(-1f, 1f) * randfactor, -Main.rand.NextFloat() * randfactor), 0, 1.5f);
}
Expand Down
8 changes: 4 additions & 4 deletions PetPlayer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -255,12 +255,12 @@ public override void ResetEffects()
/// </summary>
public bool ThreeTimesUseTime()
{
double diff = Math.Abs(lastTime - Main.time);
uint diff = (uint)Math.Abs(Main.GameUpdateCount - lastTime);
if (diff > 40.0)
{
//19
resetSlots = false;
lastTime = Main.time;
lastTime = Main.GameUpdateCount;
return false; //step one
}

Expand All @@ -269,7 +269,7 @@ public bool ThreeTimesUseTime()
{
if (!resetSlots)
{
lastTime = Main.time;
lastTime = Main.GameUpdateCount;
resetSlots = true;
return false; //step two
}
Expand Down Expand Up @@ -508,7 +508,7 @@ public override void PreUpdate()
public int slimePetIndex = -1;
public uint slotsLast = 0;
private bool resetSlots = false;
private double lastTime = 0.0;
private uint lastTime = 0;

private const uint mask = 255;//0000 0000|0000 0000|0000 0000|1111 1111
public uint slots = 0; //0000 0000|0000 0000|0000 0000|0000 0000
Expand Down

0 comments on commit 6e8d151

Please sign in to comment.