dimanche 18 juin 2017

Overriding method operations at runtime

I'm working on a game that has mods, and want to achieve the same effect that is achieved in Quake. When a mod folder contains a file with the same name as one in the stock code, the file is overwritten.
However I want to achieve something slightly different/better. I want to be able to do the previous action, but if the specific method is not implemented in the overwriting file, then use the default one that is provided in stock code.

I'm thinking of creating abstract classes that have all the abstract methods that people will need, and then storing the implementations in separate files. I don't however, know how to get this file to then "attach" itself to the abstract implementation like C/C++ does with headers and sources. Furthermore, how do I do this but also include the methods from my implementation, if they weren't specified in the secondary implantation.

So my question is, is there a way to overwrite the implementation of a class and its methods at runtime, given the location of the file containing the overriding classes/methods? And even better, (with a cherry on top), could I somehow seamlessly swap back and forth between implementations in the same runtime phase? (Probably asking for too much here)





Aucun commentaire:

Enregistrer un commentaire