Day 4 – Revenge on prefabs
Yesterday's attempt at creating characters using the prefab system left me unsatisfied. The main problem was that I could not specify default components or derive them from the input asset files. Moreover, the asset files were very verbose.
Implementing the PrefabData trait by myself instead of using the simple derived methods solved both of these issues. All desired components are now generated by the loading system, instead of through separate systems that have to be maintained. This simplified the asset file layout for two different entities from this
( data: CharacterPrefab( glyph: Glyph('@'), variant: PlayerCharacter(PlayerCharacter), ), ), ( data: CharacterPrefab( glyph: Glyph('a'), position: Position(x: 12, y: 17), variant: NonPlayerCharacter( name: Named(name: "Austin"), ), ), )
where the first entity is missing a Position component and both are missing UiText and UiTransform components to render and place the glyph, to this
( data: CharacterPrefab( glyph: '@', variant: PlayerCharacter, ), ), ( data: CharacterPrefab( glyph: 'a', position: Position(x: 12, y: 17), variant: NonPlayerCharacter( name: "Austin", ), ), )
where all needed components exist for both entities.
Moving on I added a simple prefab loader for the area that the game starts with. With that in place there is no longer any hard coded determination of how to create the play area and its characters (well, except the paths to the asset files themselves). It's easy (if repetitive) to change the play area and deployed characters. So I added our friends in the Waypoint crew!
The prefab system is still a bit verbose and unintuitive but I now have some ideas of how to implement my actual content in it.
Today's code is available here. The new character loading system is here.
Files
Windy City Politics
More posts
- Day 11 – A mostly finished inklingJul 11, 2019
- Day 7 – Gronking dialogue graphsJul 07, 2019
- Day 5 – Dialogue systemsJul 04, 2019
- Day 3 – Crying with prefabsJul 02, 2019
- Day 2 – Menu creationJul 01, 2019
- Day 1 – Joining a jamJun 30, 2019
Leave a comment
Log in with itch.io to leave a comment.