Would (should) it be possible for modders to override core game classes?

Discuss coding questions, pull requests, and implementation details.
Post Reply
DunnyOfPenwick
Posts: 4
Joined: Wed Apr 14, 2021 1:58 am

Would (should) it be possible for modders to override core game classes?

Post by DunnyOfPenwick »

Sometimes extensive changes might be required to implement a complex mod, and there might not be adequate delegate hooks in the core game code, or existing game code might interfere with the mod.

My experience with Unity is limited...would it be possible for modders to modify/extend core DFU classes?

For example, let's say I wanted to make changes to the logic of the CanSeeTarget() method of the EnemySenses class and there wasn't an existing hook, or I couldn't use it for some reason.

I might then create my own derived EnemySenses class and create my own CanSeeTarget() method, then call a DFU method to register my class. There might also be an 'isXregistered' method I could call beforehand.

If another mod has already registered a similar change, DFU could inform me of the conflict and possibly supply the name/id of the other mod in case a workaround is possible.

Whenever DFU would attempt to instantiate an EnemySenses object, it would first check to see if a class override is registered and instantiate that one instead.

Would this mechanism be possible? or maybe it would create too many problems?

l3lessed
Posts: 871
Joined: Mon Aug 12, 2019 4:32 pm
Contact:

Re: Would (should) it be possible for modders to override core game classes?

Post by l3lessed »

Technically, this is already possible. A developer already created a way using the modding system to override methods. This has been tested and works. You could build a whole new enemysenses method and use this to override the original. You need to ensure all the base objects and properties stay the same though, or you for sure will have crashes. Any time you override a base method like this it is risky though, so even if you maintain all original objects and properties because it can cause bugs in other code depending on the base method to function how it was designed originall.

viewtopic.php?f=14&t=4213
My Beth Mods: l3lessed Nexus Page

Daggerfall Unity mods: Combat Overhaul Mod

Enjoy the free work I'm doing? Consider lending your support.

Post Reply