Exemplo n.º 1
0
    /// <summary> Applies any statuses caused by energy deficit or excess </summary>
    public void RefreshEnergy()
    {
        var deficit = 0 - energy.current;

        if (deficit > 0)
        {
            using (var scope = new Hooks.Scope()) {
                this.hooks.ForEach <IOnEnergyDeficit_Unit>(scope, v => v.OnEnergyDeficit(deficit));
                tile.hooks.ForEach <IOnEnergyDeficit_Tile>(scope, v => v.OnEnergyDeficit(this, deficit));
                Game.hooks.ForEach <IOnEnergyDeficit_Game>(scope, v => v.OnEnergyDeficit(this, deficit));
            }
        }
        var excess = energy.current - energy.max;

        if (excess > 0)
        {
            using (var scope = new Hooks.Scope()) {
                this.hooks.ForEach <IOnEnergyExcess_Unit>(scope, v => v.OnEnergyExcess(excess));
                tile.hooks.ForEach <IOnEnergyExcess_Tile>(scope, v => v.OnEnergyExcess(this, excess));
                Game.hooks.ForEach <IOnEnergyExcess_Game>(scope, v => v.OnEnergyExcess(this, excess));
            }
        }
        energy.Clamp();
    }