ECS Chess MegaThread Main view of the Game What is ECS Chess? ECS Chess is an implementation of Chess using the new ECS-paradigm in Unity. It is an example of a full implementation of a game in ECS, to serve as an example for future reference, and as a test to determine the (current) viability of ECS when used to create a full game. Why this thread? This thread exists to prevent myself from spamming the forum with questions. By creating a single thread, and updating it, I can create a single place for all of my struggles while implementing. It also allows others to see the problems I run/ran into, and how these can be solved. Source The full source for the project can be found at https://github.com/frankvHoof93/ECSChess I currently do not take in any pull requests/submissions, as I'm still trying to wrap my head around the implementation of DOD that Unity uses, but I will open the repo up at a later point, to allow for people to implement 'best practices', visual additions etc. Current Progress: Currently the project contains systems to process raycasting (hover & click), and a system to process movement. (most of the) Archetypes currently in the Game Current Tasks: - Set up main game logic system (turns, win-conditions, etc.) - Fix visual elements (hover-visual, selection-visual, board-tiles, etc.) Later Tasks: - Animation (death, etc.) - Audio - Particle Effects - Move RayCast to Unity Physics (Instead of Bounds.IntersectRay()) Current Questions/Problems: The main problem I'm currently running into is: - Where do I put my 'main loop'-logic? (i.e. my GameWorld.Update()) By this I mean the code which either determines which Systems should/shouldn't run, or which holds/updates the 'main state-machine' for the game (and thus controls things like StartGame, GameOver, Next Turn, etc.) Current reasoning for implementation: I'm thinking I'll want a system which runs at the end of the frame, and tracks which actions were performed this frame, then updates a SingletonEntity, which holds the 'GameData' (such as state). However, this system would need to be able to get a list/array of all the components added/removed this frame, in order to work out what actually happened. Other things I'm currently trying to figure out: - How do I prevent a system from running for a single frame? The user can (generally) perform one of two actions in a single frame; a. Select a ChessPiece b. Move a ChessPiece (if movement is valid) Current reasoning for implementation: The way I'm currently looking to handle a mouse-click is to run the Movement-System first, and to prevent the SelectionSystem from running if a movement was performed. However, I can't disable a system from a Job (which is what the SelectionSystem ends up in), so I'm not sure how to (spawn an entity with a tag I guess?), and I also need to re-enable the system at the end of the frame, so that it can run again in the next frame (I'm guessing I want some sort of EndFrameSystem for this?) - How do I track if a component has been removed? I wish to visually indicate the moves a piece can make whenever a user hovers over or selects a piece. However, when doing this, I also need to remove any previous visuals when the hover/selection ends. Using SetFilterChanged on a query appears to work when a Component is added/changed, but not when it is removed. How do I track the removal of Components (such as Hovered)? - Does the current implementation for rendering have support for per-entity visual adaptations (i.e. MaterialPropertyBlocks)? (and if so, how do I use it?) It currently looks like I need to write my own rendersystem to get any support for MaterialPropertyBlocks and/or GPU-Instancing at this point in time. Is this correct? (I'm mainly looking at highlighting certain BoardTiles in certain colours here) I'm hoping people can help me answer these questions and/or increase my general understanding of how to actually create games using DOD (and not just tech-demos).