Jump to content

RequestResource override


Recommended Posts

I was thinking life would be a lot easier if I could override calls to RequestResource in parts using/creating electric charge. I could then finally track charge in things which don't expose any methods to query changes. My question is, has anyone tried doing this or similar? Would putting overrides for the 6 RequestResource variants into a class and tacking them onto parts which use charge (via AddModule) work? Or would the overrides only function via the module they were added as?

Basically the idea is to tack an API of sorts onto things using charge so I can track what is being used or generated and by what. Saving effort writing pull requests for mods and nagging Squad to add methods to things like reaction wheels or the lab.

Link to comment
Share on other sites

RequestResource is a method native to the Part class. You can't modify it's function to a random part by adding a PartModule.

Basically, you should really only need to change the "module = Part" line to a new class extending Part where you overloaded RequestResource. You can do it through ModuleManager, it's easy, and yes it works.

Link to comment
Share on other sites

I'd thought about using MM before but I was thinking of adding to Part, it didn't occur to me to extend Part itself and add MM rules to make everything use it. It'd mean an awful lot of MM work when the game loads if used as a 'change everything' approach but it'd certainly be less effort at first.

Or is it possible to use the presence of a RESOURCE line in a config file as a switch for MM?

Thanks Chris.

Link to comment
Share on other sites

Most excellent Greys, I spent tonight flicking around in C# documentation trying to put together a model of how I wanted things to fit together in my head. What you've built looks good, no license hangups and you're looking at extending it to cover more of Part functionality. It's almost like someone asked me what would make life easier right now ;)

This would be fine for the in flight part of Fusebox but editor scenes will need to be handled differently. Unless I start running a sim for those. Welp, I was going to re-write most of it anyway but not tonight, 2am and my cat is saying 'bed time'. I'll knock out a test or mock up tomorrow.

Link to comment
Share on other sites

This thread is quite old. Please consider starting a new thread rather than reviving this one.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...