public Unit(Tile t, DMI.SpriteFamily family, float moveHz, float animHz) : base(t, true) { Sprite = new ImageSprite(family, moveHz, animHz); Movement = new TimerPeriodic(moveHz); _tmrAIUpdate = new TimerPeriodic(s_f32AIUpdateHz); _tmrAIUpdate.Trigger += delay => { if (AI != null) AI.Update(); }; Moved += prev => Sprite.Position = Tile.PositionRender; MutatedHealth += prev => { if (Dead) IFF = null; }; // Snap the initial position to our location. Sprite.PositionSnap = t.PositionRender; }
public PeriodicGameComponent(Game gm, float flUpdateHz) : base(gm) { Timer = new TimerPeriodic(flUpdateHz); Timer.Trigger += overrun => { UpdatePeriod(overrun); }; }