cash trickler dependent on power?

Information and discussion for custom maps and mods.
Post Reply
twarpie
Posts: 60
Joined: Sun Jun 26, 2011 3:10 pm

cash trickler dependent on power?

Post 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.

twarpie
Posts: 60
Joined: Sun Jun 26, 2011 3:10 pm

Re: cash trickler dependent on power?

Post 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.
Attachments
openra_poweredcashtrickler.patch.txt
(1.67 KiB) Downloaded 273 times

User avatar
BaronOfStuff
Posts: 438
Joined: Sun May 22, 2011 7:25 pm

Post by BaronOfStuff »

Good stuff, can see some use for this.

twarpie
Posts: 60
Joined: Sun Jun 26, 2011 3:10 pm

Post 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?
Attachments
openra_cashtrickler_requirespower.patch.txt
(934 Bytes) Downloaded 264 times

Post Reply