-
-
Notifications
You must be signed in to change notification settings - Fork 102
Write Svelto.ECS code at the speed of something fast with refactoring tools
EntityViews are classes that hold only Entity Components. Entity Components in Svelto.ECS are always interfaces that must be implemented, but the Engine and EntityView doesn't need to know the implementation. For this reason, without even implementing the component yet, I can just start to type the logic in the engine like if it were declared:
Even if PlayerEntityView is still an empty class, I start to use the fields I need. Since an EntityView can hold only components, the field must be a component interface.
Hoping you use an IDE that supports refactoring, the IDE will immediately warn you that the field you are trying to access actually doesn't exist. This is where the refactoring tools can help you speeding up the writing of the code. For example, using Jetbrains rider (but it's the same with Visual Studio) you can create the field automatically like this:
this would add the component field in the EntityView like:
since the IPlayerInputComponent interface doesn't exist yet, I name it and use on the spot. Then I use again the refactoring tool:
this will create an empty interface, so that now the code would look like:
the inputComponent field now exists, but it's empty so the input field is not defined yet, but I know I need it.
Yes that's right, I would use again the refactoring tool:
so that the IPlayerInputComponent interface will be filled with the right properties. As long as I don't run the code, I can build it without needing to implement the Entity Component IPlayerInputComponent interface yet. Honestly, once you get in this flow, you will notice how fast can be coding with Svelto.ECS using the IDE refactoring tools.





