Table of Contents

Class PlacementContext

Namespace
MoonBark.GridPlacement.Godot.Placement
Assembly
MoonBark.GridPlacement.Godot.dll

Main context for the MoonBark.GridPlacement system in Godot. Owns ECS systems, grid occupancy, and placement services.

Lifecycle

  1. Create: new PlacementContext()
  2. Configure: set Settings property if needed
  3. Initialize: call Initialize(EntityStore) with an ECS store
  4. Use: access services directly via ManipulationSystem, ExecutionSystem, PreviewSystem, etc.
  5. Cleanup: call DisposePlacementContext()

Design Notes

PlacementContext is a Godot Resource so it can be:

  • Created via object initializer: new PlacementContext { Settings = mySettings }
  • Saved as a .tres file for editor configuration
  • Shared across nodes via resource reference

ECS systems are accessed directly (no adapter layer). This is the primary API.

[ScriptPath("res://addons/grid_placement/placement/PlacementContext.cs")]
public class PlacementContext : Resource, IDisposable
Inheritance
GodotObject
RefCounted
Resource
PlacementContext
Implements
Inherited Members
Resource._GetRid()
Resource._ResetState()
Resource._SetupLocalToScene()
Resource.GetRid()
Resource.GetLocalScene()
Resource.SetupLocalToScene()
Resource.ResetState()
Resource.IsBuiltIn()
Resource.GenerateSceneUniqueId()
Resource.EmitChanged()
Resource.EmitSignalChanged()
Resource.EmitSignalSetupLocalToSceneRequested()
Resource.InvokeGodotClassMethod(in godot_string_name, NativeVariantPtrArgs, out godot_variant)
Resource.HasGodotClassMethod(in godot_string_name)
Resource.HasGodotClassSignal(in godot_string_name)
Resource.ResourceLocalToScene
Resource.ResourcePath
Resource.ResourceName
Resource.ResourceSceneUniqueId
Resource.Changed
Resource.SetupLocalToSceneRequested
RefCounted.InitRef()
RefCounted.Reference()
RefCounted.Unreference()
RefCounted.GetReferenceCount()
GodotObject.NotificationPostinitialize
GodotObject.NotificationPredelete
GodotObject.NotificationExtensionReloaded
GodotObject.IsInstanceValid(GodotObject)
GodotObject.WeakRef(GodotObject)
GodotObject.Dispose()
GodotObject.ToString()
GodotObject.ToSignal(GodotObject, StringName)
GodotObject._Get(StringName)
GodotObject._GetPropertyList()
GodotObject._IterGet(Variant)
GodotObject._IterInit(Array)
GodotObject._IterNext(Array)
GodotObject._PropertyCanRevert(StringName)
GodotObject._PropertyGetRevert(StringName)
GodotObject._Set(StringName, Variant)
GodotObject._ValidateProperty(Dictionary)
GodotObject.Free()
GodotObject.GetClass()
GodotObject.Set(StringName, Variant)
GodotObject.Get(StringName)
GodotObject.SetIndexed(NodePath, Variant)
GodotObject.GetIndexed(NodePath)
GodotObject.GetPropertyList()
GodotObject.GetMethodList()
GodotObject.PropertyCanRevert(StringName)
GodotObject.PropertyGetRevert(StringName)
GodotObject.GetInstanceId()
GodotObject.SetScript(Variant)
GodotObject.GetScript()
GodotObject.SetMeta(StringName, Variant)
GodotObject.RemoveMeta(StringName)
GodotObject.GetMeta(StringName, Variant)
GodotObject.HasMeta(StringName)
GodotObject.GetMetaList()
GodotObject.HasUserSignal(StringName)
GodotObject.RemoveUserSignal(StringName)
GodotObject.EmitSignal(StringName, params Variant[])
GodotObject.Call(StringName, params Variant[])
GodotObject.CallDeferred(StringName, params Variant[])
GodotObject.SetDeferred(StringName, Variant)
GodotObject.Callv(StringName, Array)
GodotObject.HasMethod(StringName)
GodotObject.GetMethodArgumentCount(StringName)
GodotObject.HasSignal(StringName)
GodotObject.GetSignalList()
GodotObject.GetSignalConnectionList(StringName)
GodotObject.GetIncomingConnections()
GodotObject.Disconnect(StringName, Callable)
GodotObject.IsConnected(StringName, Callable)
GodotObject.HasConnections(StringName)
GodotObject.IsBlockingSignals()
GodotObject.NotifyPropertyListChanged()
GodotObject.CanTranslateMessages()
GodotObject.Tr(StringName, StringName)
GodotObject.GetTranslationDomain()
GodotObject.SetTranslationDomain(StringName)
GodotObject.IsQueuedForDeletion()
GodotObject.CancelFree()
GodotObject.EmitSignalScriptChanged()
GodotObject.EmitSignalPropertyListChanged()
GodotObject.NativeInstance
GodotObject.ScriptChanged
GodotObject.PropertyListChanged

Constructors

PlacementContext()

Creates a new PlacementContext with default settings.

public PlacementContext()

Properties

CursorNode

Returns the cursor node registered via RegisterCursor(object).

public Cursor2D? CursorNode { get; }

Property Value

Cursor2D

EntityStore

The ECS entity store. Available after Initialize() is called.

public EntityStore? EntityStore { get; }

Property Value

EntityStore

Events

Backend events for external subscribers (EntityPlaced, PreviewUpdated, etc).

public IEcsBackendEvents Events { get; }

Property Value

IEcsBackendEvents

ExecutionSystem

The execution system for placing entities.

public PlacementExecutionSystem? ExecutionSystem { get; set; }

Property Value

PlacementExecutionSystem

GridOccupancy

The grid occupancy system for TileMap sync. Available after Initialize() is called.

public IGridOccupancy? GridOccupancy { get; }

Property Value

IGridOccupancy

InputBridge

The placement input bridge. Available after Initialize() is called.

public IPlacementInputBridge? InputBridge { get; }

Property Value

IPlacementInputBridge

LevelContext

The level context for resolving TileMapLayer targets.

public LevelContext? LevelContext { get; set; }

Property Value

LevelContext

ManipulationSystem

The manipulation system for move/rotate/demolish operations.

public ManipulationSystem? ManipulationSystem { get; set; }

Property Value

ManipulationSystem

ModeService

The mode service for controlling placement modes. Available after Initialize() is called.

public IModeService? ModeService { get; }

Property Value

IModeService

OccupancySystem

The occupancy system for grid queries.

public GridOccupancySystem? OccupancySystem { get; set; }

Property Value

GridOccupancySystem

PlacementView

public IPlacementView? PlacementView { get; set; }

Property Value

IPlacementView

PreviewSystem

The preview system for placement preview.

public PlacementPreviewSystem? PreviewSystem { get; set; }

Property Value

PlacementPreviewSystem

SceneSyncManager

The scene sync manager for ECS-to-Godot node synchronization. Set by PlacementRuntimeCoordinator during initialization.

public PlacementSceneAdapter? SceneSyncManager { get; set; }

Property Value

PlacementSceneAdapter

Settings

Settings resource for the placement system. Configure before calling Initialize(), or use EnsureUpdateLoop() at runtime.

[Export(PropertyHint.None, "")]
public PlacementSettings? Settings { get; set; }

Property Value

PlacementSettings

TargetingService

The targeting service for grid position queries. Available after Initialize() is called.

public ITargetingService? TargetingService { get; }

Property Value

ITargetingService

TerrainProvider

The terrain provider for validation.

public ITerrainProvider? TerrainProvider { get; set; }

Property Value

ITerrainProvider

Methods

DisposePlacementContext()

Disposes of the placement context and releases all resources.

public void DisposePlacementContext()

Initialize(EntityStore)

Initializes the placement context with an ECS entity store. Creates and wires ECS systems directly (no adapter layer).

public void Initialize(EntityStore store)

Parameters

store EntityStore

The ECS entity store to use. Must not be null.

Exceptions

InvalidOperationException

Thrown if already initialized.

RegisterCursor(object)

Registers a cursor node for placement input. The registered cursor is stored so PlacementInputController can retrieve it via reflection and wire its signals.

public void RegisterCursor(object cursor)

Parameters

cursor object

The cursor node (typically a Cursor2D).

SelectPlaceable(Placeable)

Selects a placeable for placement.

public void SelectPlaceable(Placeable placeable)

Parameters

placeable Placeable

The placeable to select.