4.1.0 Manipulate with Move & Demolish Modes


This update adds the ability to move, rotate, flip, and demolish objects that already exist or have already been placed into the game level through the new ManipulationSystem. The target highlighter provides an easy visual way of understanding which objects can be manipulated and which ones cannot. To mark an object as valid for various manipulations, attach a Manipulatable node to the base scene as a child of the root. There are 2 new Assigner nodes added to make referencing needed level assets easier for the system. There are also various improvements like making the RuleCheckIndicatorManager separate from the BuildingSystem as a Node2D that rests under your grid positioner stack instead of being instanced at runtime.

For quick setup, see the templates in the addons/grid_building/templates directory. The systems and grid_positioner_stack are set up with default resources you can use to quickly get started in your gameplay scene that needs the Grid Building Systems. Be sure to add the action_names of the actions resources (see BuildingSystem and ManipulationSystem for those names) to your Project Settings and assign keys. placement_selection_ui.tscn and build_log.tscn from the grid_building/ui folder serve as easy UI templates. You will need to create object scenes to place (add a Manipulatable node if you want them to be moved, demolished, rotated, etc) and create placeable resources assigned to the placement_selection_ui to place them into the scene. See the complete video guide above for more details.

Breaking Changes

  • BuildingState, GridTargetingState, and ManipulationState (new) resources require a UserState to be assigned in each. In most cases, create one and share it between the states if the same user will be the controller of all 3 systems (in almost all cases this will be true).
  • BuildingInputActions has been split into two different resources BuildingControlActions and ModeInputActions. You will need to create and set new resources in the BuildingSystem inspector and reference the resource for objects that use the respective actions.
  • Placeable keep_script_paths has been replaced by BuildingSettings preview_kept_script_types. This defaults to keeping Manipulatable scripts, but you can add any number of types to this list defined by their global class_name. These are the scripts that will remain in build mode preview copies.
  • In order to rotate an object, even in build mode, you will need to add a ManipulationSystem scene and set up the necessary resources

This update adds some important new features to the Grid Builder plugin including the ability to move and demolish existing objects in the scene.  An object should have a Manipulatable component assigned to it in order for the ManipulationSystem to be able to move or demolish it. This is a Node you can add as a child of another node like any other. The new manipulation system uses the PlacementValidator to determine if a new move for an already existing object is still valid during gameplay.

GridPositioner as ShapeCast2D

  • Used now to check collisions under the positioner and acquiring current mouse target within the Node2D game world.
  • Still used by the GridTargetingSystem for grid position snapping against TileMapLayer or TileMap.
  • The collision mask should be set to either a targeting only layer that marks your objects as targetable (and therefore highlightable, etc by TargetHighlighter and selectable in the ManipulationSystem for moving, etc) or you can use another placement specific area layer (like 'UsedSpace' not necessarily reflecting actual object collisions in all cases)

Building State Updates

  • Action signals are now emitted as Success or Failure to be consistent with the Manipulation state. Validation results are included as part of the BuildActionData emitted on Success or Failure rather than as a separate Signal
  • Removed Signals: validation_ran, object_placed, action_failed
  • Added Signals: success, failed
  • No longer handles rotation, move, scale actions. Look to ManipulationState and ManipulationSystem for that.

Important New Classes

Manipulation System

New system handles move and demolish requests for already existing scene objects. An object must have a Manipulatable component

Manipulatable

Add this to any scene you want to be able to be moved and/or demolished by the manipulation system. A scene node that does not have manipulatable is by default unmovable and cannot be demolished.

Manipulation State

Holds the active manipulation data and manipulatable node reference for manipulation actions occurring.

Target Highlighter

Optional node that highlights the current manipulation target or otherwise the target under the cursor to show various conditions including that an object is or is not valid for current manipulation operation (Move or Demolish), to change the color of the current manipulation or build to show that is it is a temporary copy (Defaults as partially transparent blue color tint)

Placement Validator

  • PlacementValidator has been decoupled from the BuildingSystem so it can be shared with the ManipulationSystem as well. Some methods of PlacementValidator have been rewritten and the PlacementValidator now manages the RuleCheckIndicator manager directly instead of the BuildingSystem
  • Now is responsible for creating and managing the RuleCheckIndicatorManager. This lets the manager be shared across multiple systems through the PlacementValidation resource for functions like retesting a moved object through the ManipulationSystem.
  • Renamed validation_finished signal to finished

Placeable

  • Removed unused valid_changed signal

BuildingRule

  • Added virtual function execute to allow a rule to execute code after a validation is finished successfully on all needed rules.
  • BuildingRules no longer have access to building_state or targeting_state. They don't need the callbacks since execute function exists now.

GridBuilderState

  • Added automatic unreferencing of freed nodes to runtime node properties set in each state. If a node object is deleted from the scene tree, it will set the reference to null to avoid 'previously freed' errors when passing the reference into called function parameters.

Build Log Updates

  • Exported strings have been combined into singular strings where names are replaced with %s
  • Validation messages print on build state success or fail rather than separately

Quality of Life Updates

  • Updated all resources in Grid Builder to be categorized as GridBuilderResource to make finding them easier in the add resources menu
  • Updated Nodes in the plugin to be categorized as GridBuildingNode and subcategories GridBuildingSystem and GridBuilderComponent. It should be easier to locate grid building based nodes in the add node menu now.

Summary

  • Added ManipulationSystem which handles Moving and Demolishing  actions for existing objects in the game scene
  • The moving system targets objects that have a PlaceableInstance node attached. By default BuildingSystem will add a PlaceableInstance to any object instanced by the Build Mode that does not already have one. If you want all instances of an object type to save the Placeable reference, be movable, or demolishable - then add a PlaceableInstance node to the original packed scene. If you want only Player / GridBuilding placed instances to have those features, then no action is needed.

Removed

With the new TileMapLayer nodes, you can attach a simple script that toggles visibility on or off when the mode on the ModeState changes (reference the ModeState, connect to mode_changed signal). The previous methods did not really add any functionality and were unnecessarily complicated so they've been removed from the current version of the plugin.

  • GridOverlayDrawerComponent
  • TileMapBuildingOverlay

Files

grid_building_4.1_with_demo.zip 3.9 MB
88 days ago

Get Grid Building Plugin for Godot 4

Buy Now$40.00 USD or more

Leave a comment

Log in with itch.io to leave a comment.