BuildingState

BuildingState

Core state data for buildings in the grid system Contains pure C# data without Godot dependencies for unit testing Separates building logic from runtime visualization

Project: GridPlacement v6.0
Layer: Godot
Source: Godot/Core/State/Building/BuildingState.cs
Namespace: GridBuilding.Core.State.Building
Kind: class

Parsing Method: AST-based (Roslyn) - NOT regex

⚠️ IMPORTANT: This documentation was generated using AST parsing, not regex.

Properties

BuildingId

Unique identifier for this building instance

BuildingType

Type identifier for the building (e.g., “house”, “farm”, “workshop”)

GridPosition

Position of the building in grid coordinates

Status

Current status of the building

Health

Current health of the building (0-100)

MaxHealth

Maximum health of the building

CustomData

Custom data storage for building-specific properties

Tags

Tags for categorizing and filtering buildings

CreatedTime

Unix timestamp when this building was created

LastUpdated

Unix timestamp when this building was last updated

OwnerId

ID of the player/user who owns this building

Flags

Various flags for building behavior

HealthPercentage

Health as a percentage (0.0 to 1.0)

IsOperational

Whether the building is currently operational

IsUnderConstruction

Whether the building is currently under construction

IsDamaged

Whether the building is currently damaged

IsDestroyed

Whether the building is destroyed

Age

Age of the building in seconds

IsInitialized

True once the building has been initialized (has a valid ID and type)

IsReady

True when the building is ready to be used (operational and healthy)

HasError

True if the building has encountered an error condition (destroyed or invalid state)

LastError

Optional human-readable description of the last error, if any

Methods

UpdateTimestamp

Updates the last updated timestamp

Returns: void

SetCustomData

Sets a custom data value (data operation only)

Returns: void

Parameters:

  • string key
  • object value

GetCustomData

Gets a custom data value

Returns: T

Parameters:

  • string key
  • T defaultValue

HasCustomData

Checks if custom data exists

Returns: bool

Parameters:

  • string key

RemoveCustomData

Removes custom data

Returns: bool

Parameters:

  • string key

AddTag

Adds a tag to the building (data operation only)

Returns: void

Parameters:

  • string tag

RemoveTag

Removes a tag from the building (data operation only)

Returns: bool

Parameters:

  • string tag

HasTag

Checks if the building has a specific tag

Returns: bool

Parameters:

  • string tag

ApplyDamage

Applies damage to the building (data operation only) Note: Business logic for status changes should be handled by BuildingService

Returns: void

Parameters:

  • int damage

SetHealth

Sets health directly (data operation only)

Returns: void

Parameters:

  • int health

SetStatus

Sets the building status (data operation only)

Returns: void

Parameters:

  • BuildingStatus status

Create

Creates a new building state with default values

Returns: BuildingState

Parameters:

  • string buildingType
  • CoreVector2I gridPosition

CreateFromTemplate

Creates a building state from template data

Returns: BuildingState

Parameters:

  • BuildingState template
  • CoreVector2I gridPosition