Some context: I have a family called enemies, which is pretty established, and I wanted to create a new enemy type called Wolf. Wolf is very different from the rest of the existing enemies, which are mostly human-based, so I needed to develop lots of new code to control and animate Wolf. But in the end I still want Wolf to be a member of the enemies family as there’s common enemies code that will apply to Wolf.
I wanted to avoid the existing enemies family code being called on Wolf during prototyping, as it would potentially throw everything off in the game and make prototyping a lot harder. So I chose to create a standalone object called Wolf to prototype. Even though it’s not part of the enemies family, Wolf has several identical behaviors and instance variables, like ‘health’ and ‘hitStrength’, and the Platform behavior.
Now that I’ve got Wolf working (yay!), I want to add it to the enemies family. But because it has the same instance variable names as enemies, I need to change them before C3 will let me add Wolf to the enemies family. I expect this will involve a) changing the names of those IV’s in Wolf (e.g., change ‘health’ to ‘health2’), b) adding Wolf to enemies, c) changing the Wolf logic to use the IV’s from enemies (e.g., change anything referencing ‘health2’ to ‘health’), and then d) deleting the Wolf-specific IV’s ((e.g., ‘health2’). I’m probably going to need to do something similar with the common behaviors as well.
This is just an example but it’s making me think there may be a better way.
My question is, what’s a good way to plan for such ‘merges’ of code, and is there something I should have done differently? C3’s editing logic is great because it checks for errors caused by duplicate IV and Platform names, and I wish there was an easier way to do this merge without having to pick through my code. Any suggestions?