return e.(GetResourceField(res_type));
}
+bool SetResourceExplicit(entity e, int res_type, float amount)
+{
+ .float res_field = GetResourceField(res_type);
+ if (e.(res_field) != amount)
+ {
+ e.(res_field) = amount;
+ return true;
+ }
+ return false;
+}
+
void SetResource(entity e, int res_type, float amount)
{
bool forbid = MUTATOR_CALLHOOK(SetResource, e, res_type, amount);
amount_wasted = amount - max_amount;
amount = max_amount;
}
- .float res_field = GetResourceField(res_type);
- if (e.(res_field) != amount)
+ bool changed = SetResourceExplicit(e, res_type, amount);
+ if (changed)
{
- e.(res_field) = amount;
MUTATOR_CALLHOOK(ResourceAmountChanged, e, res_type, amount);
}
if (amount_wasted == 0)
TakeResource(receiver, res_type, amount);
}
-void GiveOrTakeResource(entity receiver, int res_type, float amount)
-{
- if(amount < 0)
- {
- TakeResource(receiver, res_type, amount * -1);
- }
- else
- {
- GiveResource(receiver, res_type, amount);
- }
-}
-
-void GiveOrTakeResourceWithLimit(entity receiver, int res_type, float amount, float limit)
-{
- if(amount < 0)
- {
- TakeResourceWithLimit(receiver, res_type, amount * -1, limit);
- }
- else
- {
- GiveResourceWithLimit(receiver, res_type, amount, limit);
- }
-}
-
int GetResourceType(.float res_field)
{
switch (res_field)