Ludeon Forums

RimWorld => Mods => Help => Topic started by: jpwrunyan on April 28, 2014, 04:15:30 PM

Title: How to implement electricity usage as a requirement for function
Post by: jpwrunyan on April 28, 2014, 04:15:30 PM
Hello all,

I am just dabbling with some simple modifications to the base game and already have a question. The first simple thing I wanted to do was make both the research bench and the orbital transmitter require electricity. That was easy. The problem is that even without electricity these two components appear to function as normal. If the research bench loses power, the character continues to blissfully progress onwards.

I suspect that this is hard-coded behavior, am I right? If not, could someone kindly tell me if I need to do something more to make objects that *consume* electricity actually *require* it in order to function?

FYI Here is the code I added to the components in question (the rest of their definition xml is unchanged):

<comps>
  <li>
    <compClass>CompPowerTrader</compClass>
    <startElectricalFires>true</startElectricalFires>
    <basePowerConsumption>100</basePowerConsumption>
  </li>
</comps>


PS startElectricalFires determines whether getting hit with rain outside causes the unit to short out, right?
Title: Re: How to implement electricity usage as a requirement for function
Post by: Architect on April 28, 2014, 04:21:44 PM
You're right about the electrical fires. As for the research bench, i'm pretty confident that it is hard coded behavior. However, it should be perfectly possible to throw together a quick assembly so that it requires power, though i can at least look into it if you want?
Title: Re: How to implement electricity usage as a requirement for function
Post by: Cala13er on April 28, 2014, 04:37:23 PM
Quote from: Architect on April 28, 2014, 04:21:44 PM
You're right about the electrical fires. As for the research bench, i'm pretty confident that it is hard coded behavior. However, it should be perfectly possible to throw together a quick assembly so that it requires power, though i can at least look into it if you want?

Don't worry, it's possible. Very easy mind that. :) Been working on research benches as part of an upcoming Full conversion mod I have planned after v2.0.0
Title: Re: How to implement electricity usage as a requirement for function
Post by: jpwrunyan on April 28, 2014, 06:27:10 PM
Thanks guys. Right now I mostly want to make easy modifications that are supported by the .xml. I'm assuming that in the future any component that has electrical usage will by default require it in order to function or else have an .xml tag that specifies how the component should work when powered/not powered. I'm also assuming (and looking forward to)  eventually having dynamic electrical usage in addition to static. So if you had, for example, an electric fence, it would drain your power more when something steps into it (since it's basically just an exposed power conduit). Anyway, I was just thinking of fun stuff I could do with electricity but it will have to wait. I have more questions but will post them in a separate thread when the time comes (ie: when I finish the component and it inevitably doesn't work).
Title: Re: How to implement electricity usage as a requirement for function
Post by: WorldOfIllusion on April 28, 2014, 08:19:34 PM
It seems that the WorkGiver_Researcher just checks if there is a research table, and the research table itself simply needs to exist (powered or not) for research to be done.
To change this, you'd probably need to add some new AI + modify Building_ResearchBench class to check if its powered.
Title: Re: How to implement electricity usage as a requirement for function
Post by: jpwrunyan on April 28, 2014, 09:10:02 PM
Thanks again. Personally that is well beyond what I want to tackle at the moment.