Posted December 25, 2018 by EverhoodDev
#dev
During the last 2 weeks,Everhood underhood code has undergone a huge change.In fact, it's not the same code, all the logic of the game has been rewritten with a clean ,modular,editable and debuggable code.
What does this mean ? Well,it means that you can expect very very big things like :
Some behaviours have been improved ,like the field of view of the player
The game saver has also been improved.
After all the code reimplemented,we will start to create new exiciting game content !
And that its all!Before finishing this mini update ,I would like to end with a unity C# tip for all the gamedev colleagues!
During this awesome 2 weeks of refactoring ,I have learned how extension methods are a very handful way to create cleaner code.
What are extension methods?
Extension methods are a powerful way to create more cleaner,readable and efective code.They are used to extend a Unity classes like GameObject() class.
Lets see an example of an extension method used in Everhood :
This GameObject() extension is used to set the layer of a gameobject with an option to include the childrens.
As you can see,the class and the method are both static.
If you look at SetLayer parameters ,the first parameters is using "this GameObject" this is the key part to extend a class.
In sumuary ,to create a extension method , both class and methods have to be static and you'll have to use "this" in each extension methods.
After that ,You can call this method in every GameObjects!
Et voila !Soo fresh right?
//Jordi
Official email: everhood.contact@gmail.com
Newsletter: https://mailchi.mp/061b366aac4d/everhood
Discord Channel: https://discord.gg/fwEed4F
Wishlist us here so you don't miss any news: