Class that keeps track of the costs, so you can request how much a block of commands did cost in total. More...
#include <script_accounting.hpp>
Public Member Functions | |
ScriptAccounting () | |
Creating instance of this class starts counting the costs of commands from zero. | |
~ScriptAccounting () | |
Restore the ScriptAccounting that was on top when we created this instance. | |
Money | GetCosts () |
Get the current value of the costs. | |
void | ResetCosts () |
Reset the costs to zero. | |
Private Attributes | |
Money | last_costs |
The last cost we did return. |
Class that keeps track of the costs, so you can request how much a block of commands did cost in total.
Works in both Execute as in Test mode. ai game Example:
{ local costs = ScriptAccounting(); BuildRoad(from_here, to_here); BuildRoad(from_there, to_there); print("Costs for route is: " + costs.GetCosts()); }
Definition at line 31 of file script_accounting.hpp.
ScriptAccounting::ScriptAccounting | ( | ) |
Creating instance of this class starts counting the costs of commands from zero.
Saves the current value of GetCosts so we can return to the old value when the instance gets deleted.
Definition at line 25 of file script_accounting.cpp.
References ScriptObject::GetDoCommandCosts(), last_costs, and ScriptObject::SetDoCommandCosts().
ScriptAccounting::~ScriptAccounting | ( | ) |
Restore the ScriptAccounting that was on top when we created this instance.
So basically restore the value of GetCosts to what it was before we created this instance.
Definition at line 31 of file script_accounting.cpp.
References last_costs, and ScriptObject::SetDoCommandCosts().
Money ScriptAccounting::GetCosts | ( | ) |
Get the current value of the costs.
Definition at line 15 of file script_accounting.cpp.
References ScriptObject::GetDoCommandCosts().
void ScriptAccounting::ResetCosts | ( | ) |
Reset the costs to zero.
Definition at line 20 of file script_accounting.cpp.
References ScriptObject::SetDoCommandCosts().