Class PlacementActionHistory
- Namespace
- GridPlacement.GDScript
- Assembly
- MoonBark.GridPlacement.GDScript.dll
Persistent action history for placement and manipulation events.\n\nStores [PlacementActionData] and [ManipulationData] entries in a serializable [Resource] so the action log survives UI close / scene changes. Supports [ResourceSaver]/[ResourceLoader] round-trips out of the box because all state is [member action_entries] — an exported [Dictionary] whose keys are timestamps and values are one of the two data types.\n\nUsage: var history := PlacementActionHistory.new() history.add_entry(data) ResourceSaver.save(history, "user://action_history.res") var loaded := ResourceLoader.load("user://action_history.res") as PlacementActionHistory
class PlacementActionHistory extends Resource
Properties
action_entries
Ordered entries. Keys are monotonically increasing frame-time integers; values are [PlacementActionData] or [ManipulationData]. Exported for [ResourceSaver] serialization (supported in Godot 4.4+).
@export var action_entries: Dictionary = {}
auto_dump_path
Auto-dump path. When non-empty, the history is written to this path on [method dump_to_disk].
@export var auto_dump_path: String = ""
entries
var entries: Array = []
sorted_keys
var sorted_keys = action_entries.keys()
all
var all = get_entries()
start
var start = maxi(0, all.size() - p_count)
result
var result = ResourceSaver.save(self, p_path)
loaded
var loaded: Resource = ResourceLoader.load(p_path, "", ResourceLoader.CACHE_MODE_REPLACE)
history
var history = loaded as PlacementActionHistory
lines
var lines: Array[String] = []
line
var line = " - "
pad
var pad: PlacementActionData = entry
tdd
var tdd: TerrainDemolishData = entry
md
var md: ManipulationData = entry
text
var text = "\n".join(lines)
file
var file = FileAccess.open(p_path, FileAccess.WRITE)
Methods
add_entry
func add_entry(p_data: Variant) -> void:
Parameters
p_data
Returns
get_entries
func get_entries() -> Array:
Returns
get_recent_entries
func get_recent_entries(p_count: int = 20) -> Array:
Parameters
p_count
Returns
clear
func clear() -> void:
Returns
save_to_file
func save_to_file(p_path: String) -> Error:
Parameters
p_path
Returns
load_from_file
func load_from_file(p_path: String) -> Error:
Parameters
p_path
Returns
dump_to_disk
func dump_to_disk() -> Error:
Returns
dump_to_text
func dump_to_text(p_path: String) -> String:
Parameters
p_path
Returns
Events
entry_added
Emitted whenever a new entry is added.
signal entry_added(data: Variant)