yavl / teeworlds-infcroya

InfCroya - InfClass with battle royale elements for Teeworlds 0.7+ (WIP)
https://www.teeworlds.com
Other
4 stars 0 forks source link

Optimization of class.cpp and its children. #6

Open teoman002 opened 5 years ago

teoman002 commented 5 years ago

class.cpp is for croyaplayer.cpp, what character.cpp is for player.cpp, however class.cpp is just a helper class containing no information about the character, which means the character has to be passed to each helper method of hunter.cpp.

This introduced problems with hunter implementation:

What can be improved?

yavl commented 5 years ago
* It is not yet possible, to tell the class.cpp constructor to initialize a character on creation, because a class instance is not created with every new character instance.

IClass should only be used as a base class thus it cannot contain CCharacter instances.

* InfC classes had always direct access to its character. In contrast to that, InfCroya has no direct access, it needs pointer. That makes porting a lot harder.

In 0.6 infc, each class was defined inside CCharacter in many different places and not only there, which was terrible in my opinion.

* I wanted to give class.cpp a Tick() method, which handles double jumps. Instead I had to write it into croyaplayer.cpp, because class.cpp didn't run the Tick() method properly, neither did hunter. Maybe here I made a mistake in the implementation.

This is how should it be done to "fix" the issue. Create a IClass::Tick(CCharacter* pChr) virtual function that will be called from inside CroyaPlayer::Tick(). I will try make one now.

For some complicated classes I think it will be acceptable to write class features outside of IClass child class (example)

teoman002 commented 5 years ago

Thanks for your commit showing me, how the code is intended! :)

yavl commented 4 years ago

todo fix bugs, make code in src/infcroya/* cleaner, document newly added classes in headers (comment out) for future easy contributions/forks