4.0.0 - Shared BuildingState, Save / Load Helper
Summary
- Placed objects now get a PlaceableInstance component script attached by default which holds reference to the Placeable that created it. The PlaceableInstance has methods for serializing the data needed to reinstance the object between saves / loads using the
UIDfile path of the Placeable resource. - Moved shared references into BuildingState so concerned objects can reference properties in one central area seperate from the node heirarchy. Systems, UI, and component scripts should not need a direct reference to the BuildingSystem in most cases but can still indirectly access the System through BuildingState system property.
- Added object validation to most scripts to check if properties are properly defined during gameplay and some in the editor. These should help warn users when a reference is missing and needs to be defined.
- All demos load levels independently of the main scene and have save / load implemented. Temporarily storing level_state data between level switches can be seen in the Top Down demo.
Breaking Changes
- BuildingSignalBus has been replaced with BuildingState resource which holds all the signals from before but also has node references during gameplay that must be set before building. Use BuildingStateLevelSetter to set these values (placer, placed_parent, tile_map) or set them on load for your own world / level scripts - you can check the demo project for examples on how to do that.
- Anywhere that references the BuildingSystem now reference the shared BuildingState instead. Create a state on the BuildingSystem, save it to project, and assign it in GridTargetingSystem, PlaceableSelectionUI, BuildLog, GridPositioner, TileMapBuildingOverlay as needed.
- Settings have moved into Resource objects for BuildingSystem and GridTargetingSystem. You will have to create the resources and choose your settings again after upgrading. Reason for this change is settings resources are easier to share with UI menus than a direct node reference.
- GridPositioner2D (typically from grid_positioner.tscn) requires a reference to the BuildingState (from BuildingSystem) and TargetingSettings (from GridTargetingSystem) resources
- Placeable exclude_nodes property has been replaced with keep_script_paths. For any node on the preview_instances you want scripts to execute, set node paths to keep_script_paths. On the actual placed instance, all scripts always remain like in the original packed_scene of the Placeable.
PlaceableInstance (Component Node)
Building system will now automatically add a PlaceableInstance child node to any Placeable objects instanced into your game world. The PlaceableInstance maintains a resource reference to the Placeable it was instanced from, making it easy to recreate the instance in future loads to the scene between level switching or saving and loading. You can do this by calling save on each PlaceableInstance to get a dictionary of the necessary save data and the static method instance_from_save to put it back into a new instance of the game level.
The final save to JSON or other formats needs to be done by you of course. The PlaceableInstance save method gives you a serializable dictionary.
You can turn off adding PlaceableInstances in the building settings resource for your BuildingSystem.
Building State
Directly supersedes the building signal bus by maintaining stateful properties on the BuildingState itself. This makes it easy to know what the current and past builds, building results, pressed building actions, and current TileMap used by / for the BuildingSystem are. It could also be very easy to save the data to a game file if you need using ResourceSaver for instance.
Building System Changes
- Dependencies have been moved into the BuildingState. Before the system can run, these properties must be set on load. The State helps to share these references across all objects relating to the building system and referencing the BuildingState.
- All building system settings including input are now stored inside the BuildingSystemSettings resource.
- ChangeLevelSetup has been removed from BuildingSystem. To set the BuildingState up after loading your TileMap level, you can use BuildingStateLevelSetter to define the needed node references for each level that loads (alternatively, set the properties in your own level or world scripts)
BuildingSettings, GridTargetingSettings, BuildingInputActions
Settings for the BuildingSystem and GridTargetingSystem have been moved into these resource types to making sharing easier for any concerned objects (especially UI menus). Be sure to create one of each on the systems, save it to your project, and reference it wherever needed in other objects.
Rotation Changes
- Rotation degrees is now a slider selector between 0.0 and 360.0 degrees. Left rotations simply use the negative of this value.
- Made preview rotation values only go between single rotation values (rotation degrees will show -180 to 180) by setting the global_rotation_degrees value on the root node. For extremely high number of rotations this may help precision since there will only ever be 3 numbers to the left of the decimal point. Unit tested the changes to make sure rotations are accurate
Signal Changes
- tile_map_used_tiles_updated from BuildingState is now used_tile_changed
- BuildingState added signal mode_changed(building_mode : BuildingMode)
- BuildingState added signal positioner_changed(positioner : Node2D)
- BuildingState added signal mode_changed(building_mode : BuildingMode)
- BuildingSystem removed signal building_mode_changed(is_building: bool)
- BuildingState moved signal positioner_updated(positioner : Node2D) from BuildingSystem
- BuildingState added signal system_changed(system : BuildingSystem)
GridBuildingInventory
- Added save_state and load_state functions to serialize current slot amounts and item
UIDfile path references for saving and loading. - Added a state_loaded signal which emits when calling load_state.
- Added type_changed and count_changed signals to BaseItemStack. Currently unused but could be useful for UI item slot refreshing.
Bug Fixes
- Fixed a bug where preview instances were executing node scripts from the PackedScene. All scripts are properly removed by default on the preview. If you need to a keep a script, set the keep_script_paths property on the Placeable resource that needs it.
- Fixed a bug where the GridTargeterSystem would error when going out of bounds of the tile map. The positioner should be able to go to the edge tile of the tile map properly now and if targeting areas outside of the tile map bounds, then the targeting system hides the positioner from display.
- Fixed a missing reference to the rule indicator texture for rule_check_indicator_16x16.tscn and added validation checks whenever the instance is used to verify that the texture is not null for any RuleCheckIndicator
Files
Get Grid Building Plugin for Godot 4
Grid Building Plugin for Godot 4
Place Anything with Rotate, Flip, Stacking, and Drag Build
Status | In development |
Category | Assets |
Author | Chris' Tutorials |
Tags | 2D, City Builder, Godot, godot4, Metroidvania, Side Scroller, Tilemap, Top-Down, User Interface (UI) |
More posts
- 4.1.0 Manipulate with Move & Demolish Modes94 days ago
- Upcoming Grid Builder Updates for Godot 4.3Aug 18, 2024
- 4.0.3 Compatibility Fix for Godot 4.2.2Jun 09, 2024
- 4.0.2 Small Enhancements & Bug FixesJun 09, 2024
- 4.0.1 File Path HotfixJun 07, 2024
- 3.2.2 Bug FixesMar 06, 2024
- 3.2.1 - Input Mapping UpdatesJan 27, 2024
- 3.2.0 - Isometric Tilemap SupportJan 20, 2024
Leave a comment
Log in with itch.io to leave a comment.