Fix game minute in PlayerStatistics
This commit is contained in:
@@ -10,6 +10,7 @@
|
|||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using OpenRA.Graphics;
|
||||||
using OpenRA.Traits;
|
using OpenRA.Traits;
|
||||||
|
|
||||||
namespace OpenRA.Mods.Common.Traits
|
namespace OpenRA.Mods.Common.Traits
|
||||||
@@ -20,7 +21,7 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
public object Create(ActorInitializer init) { return new PlayerStatistics(init.Self); }
|
public object Create(ActorInitializer init) { return new PlayerStatistics(init.Self); }
|
||||||
}
|
}
|
||||||
|
|
||||||
public class PlayerStatistics : ITick, IResolveOrder, INotifyCreated
|
public class PlayerStatistics : ITick, IResolveOrder, INotifyCreated, IWorldLoaded
|
||||||
{
|
{
|
||||||
PlayerResources resources;
|
PlayerResources resources;
|
||||||
PlayerExperience experience;
|
PlayerExperience experience;
|
||||||
@@ -58,6 +59,7 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
public int BuildingsDead;
|
public int BuildingsDead;
|
||||||
|
|
||||||
public int ArmyValue;
|
public int ArmyValue;
|
||||||
|
int replayTimestep;
|
||||||
|
|
||||||
public PlayerStatistics(Actor self) { }
|
public PlayerStatistics(Actor self) { }
|
||||||
|
|
||||||
@@ -84,7 +86,9 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
|
|
||||||
void ITick.Tick(Actor self)
|
void ITick.Tick(Actor self)
|
||||||
{
|
{
|
||||||
if (self.World.WorldTick % 1500 == 1)
|
var timestep = self.World.IsReplay ? replayTimestep : self.World.Timestep;
|
||||||
|
|
||||||
|
if (timestep * self.World.WorldTick % 60000 == 0)
|
||||||
{
|
{
|
||||||
UpdateEarnedThisMinute();
|
UpdateEarnedThisMinute();
|
||||||
UpdateArmyThisMinute();
|
UpdateArmyThisMinute();
|
||||||
@@ -116,6 +120,15 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
return;
|
return;
|
||||||
OrderCount++;
|
OrderCount++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void WorldLoaded(World w, WorldRenderer wr)
|
||||||
|
{
|
||||||
|
if (w.IsReplay)
|
||||||
|
replayTimestep = w.WorldActor.Trait<MapOptions>().GameSpeed.Timestep;
|
||||||
|
|
||||||
|
UpdateEarnedThisMinute();
|
||||||
|
UpdateArmyThisMinute();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[Desc("Attach this to a unit to update observer stats.")]
|
[Desc("Attach this to a unit to update observer stats.")]
|
||||||
|
|||||||
Reference in New Issue
Block a user