Page 1 of 1

cash trickler dependent on power?

Posted: Tue Nov 08, 2011 10:50 am
by twarpie
Can anyone think of a way to make a cash trickler depent on power?

I'm trying to make a PROC replacement with a cash trickler (like in the GreenFields maps of DraLUSAD), but it needs to stop 'trickling' if the base is low on power.

Just adding the 'RequiresPower' trait doesn't stop the trickler.

Re: cash trickler dependent on power?

Posted: Wed Nov 09, 2011 10:44 am
by twarpie
twarpie wrote: Can anyone think of a way to make a cash trickler depent on power?
As I could not find a way, I copied CashTrickler.cs -> PoweredCashTrickler.cs and added the following lines (inspired by / copied from ProvidesRadar.cs):

Code: Select all

[..]
public void Tick(Actor self)
{
   // Check if powered: no trickling if disabled
   if &#40;self.TraitsImplementing<IDisable>&#40;&#41;.Any&#40;d => d.Disabled&#41;&#41;
      return;
&#91;..&#93;
Trickling is now disabled in case of low power by adding a PoweredCashTrickler line to the structure's yaml.

PoweredCashTrickler could probably extend CashTrickler and override the Tick(..) method, but I was unsure how that would work with the CashTricklerInfo bits.

edit: in case someone is interested, added patch.

Posted: Wed Nov 09, 2011 6:05 pm
by BaronOfStuff
Good stuff, can see some use for this.

Posted: Fri Nov 11, 2011 11:01 am
by twarpie
Second version of patch: removed extra class, added field to CashTricklerInfo: RequiresPower.

Add a line to CashTrickler traits in map.yaml:

Code: Select all

&#91;..&#93;
   CashTrickler&#58;
      RequiresPower&#58; True
&#91;..&#93;
Cleaner approach?