This topic is to document problems, misunderstandings, and other things that we encountered while working on Evoli.
2019-04-28T22:00:00Z → 2019-05-04T22:00:00Z
Unclear how to implement a pause state
- Event readers in systems are error-prone because their position will not advance when switching states.
- The UI should reflect the current state (Pause or Play) and because of that we ended up adding a separate UI dispatcher that runs in
- It was hard based on this part of the documentation (https://amethyst.rs/book/master/concepts/state.html?highlight=event#event-handling) to find out how to do custom events. If we follow the documentation blindly, the game won’t work because it is necessary to do a custom
State::updateimplementation. The section doesn’t explain how the custom events are received, just putting a derive in there seems kind of magical…
Related topic: Best practices for communication between state and systems
Implementing a Spawner system
- The spawner system reads a
CreaturePrefabsresource that contains prefabs for every type of creature in the game.
- This required to rework the way we define the different factions as we can’t put entities inside prefabs.
- The book section about prefabs is also very incomplete. To figure out how to do most things, we had to look at the prefab_custom example inside the Amethyst repository.
- To define specialized behavior for creatures, we can’t really put everything in the prefabs as they are meant to be generic and only define components that apply to most creatures. We need to figure out a way to add more specialized components on top of the prefab while keeping the generic spawner system.
Moving the faction definition to prefabs
- A custom
PrefabDataimplementation can be used to allow us to go back to our old faction data model. Creatures store the faction as a string and we use a hash map to look up the matching faction entity.
- In order to store the faction definition in a prefab, the same lookup is used. However, the prefab data needs to be sorted and factions can only reference enemy factions that came before them. So cyclic dependencies are not possible.