Skip to content

LocalEventEditing ​

Inherits: RefCounted

What the Local Events tab does to a world scene, without any editor object (so it can be tested headless): making a rule and putting it in the LocalEvents container, the rows of a rule (its causes, conditions and effects) and what they point at, the things of the scene a row can point at, and the state of a rule for Undo. LocalEventPanel is the tab, LocalEventTool picks targets with the mouse.

Methods ​

Node3Dcontainer_of( world_scene: Node, create: bool = false ) static
LocalEventmake_rule( rule_name: String, at: Vector3 = Vector3.ZERO ) static
LocalEventadd_rule( world_scene: Node, rule: LocalEvent ) static
LocalEventduplicate_rule( rule: LocalEvent ) static
Stringcopy_name( base: String ) static
Array[LocalEvent]rules_of( world_scene: Node ) static
voidapply_recipe( rule: LocalEvent, recipe: Dictionary ) static
Arrayunits_of( rule: LocalEvent, side: int ) static
Resourcemake_unit( entry: Dictionary ) static
intadd_unit( rule: LocalEvent, side: int, unit: Resource ) static
boolremove_unit( rule: LocalEvent, side: int, index: int ) static
intmove_unit( rule: LocalEvent, side: int, index: int, delta: int ) static
Dictionarytarget_info( unit: Resource ) static
inttarget_of( unit: Resource ) static
boolset_target( unit: Resource, id: int ) static
boolset_place( unit: Resource, place: Vector3 ) static
Array[Dictionary]targets_in( scene_root: Node ) static
Dictionarydescribe( node: Node ) static
boolfits( candidate: Dictionary, info: Dictionary ) static
Dictionaryfind_target( scene_root: Node, unit: Resource ) static
Dictionarycapture( rule: LocalEvent ) static
boolsame( a: Dictionary, b: Dictionary ) static
voidrestore( rule: LocalEvent, state: Dictionary ) static

Constants ​

  • String CONTAINER = "LocalEvents" - The name of the container of the world scene the rules are kept in
  • Dictionary TARGET_PROPERTIES = { - The properties that hold a target of a trigger, condition or action, and the kind of thing each one points at ("interactable" is refined by the class: a switch, a door ...)

Method descriptions ​

Node3D container_of( world_scene: Node, create: bool = false ) ​

The container of the rules in a world scene (made when create; null when there is none)

LocalEvent make_rule( rule_name: String, at: Vector3 = Vector3.ZERO ) ​

A new rule: a node with an empty event (it is not in the scene yet: see add_rule)

LocalEvent add_rule( world_scene: Node, rule: LocalEvent ) ​

Puts a rule in the LocalEvents container of the scene (made when it is missing) and gives it a number. Returns it

LocalEvent duplicate_rule( rule: LocalEvent ) ​

A copy of a rule (it gets its own number when it is added to the scene)

String copy_name( base: String ) ​

No description yet.

Array[LocalEvent] rules_of( world_scene: Node ) ​

The rules of a world scene, in the order of their numbers

void apply_recipe( rule: LocalEvent, recipe: Dictionary ) ​

Makes a rule from a recipe of the palette (the pieces are in place, the targets are empty)

Array units_of( rule: LocalEvent, side: int ) ​

The list of a side of a rule: triggers (When), conditions (If) or actions (Then)

Resource make_unit( entry: Dictionary ) ​

Makes the trigger, condition or action of a palette entry

int add_unit( rule: LocalEvent, side: int, unit: Resource ) ​

No description yet.

bool remove_unit( rule: LocalEvent, side: int, index: int ) ​

No description yet.

int move_unit( rule: LocalEvent, side: int, index: int, delta: int ) ​

Moves a row up (-1) or down (+1) inside its side. Returns the new index, -1 when it cannot move

Dictionary target_info( unit: Resource ) ​

What a row points at: {"property", "kind", "sub"} (kind: interactable, trigger_area, entity, spawner, local_event, ground; sub: switch, door, trap, container, destructible for an interactable), {} when it points at nothing

int target_of( unit: Resource ) ​

The number a row points at (0 = nothing yet); for a place the answer is 0

bool set_target( unit: Resource, id: int ) ​

Points a row at a thing (its number)

bool set_place( unit: Resource, place: Vector3 ) ​

Points a row at a place of the world

Array[Dictionary] targets_in( scene_root: Node ) ​

The things a row can point at: [{"node", "id", "name", "kind", "sub"}] (the objects, NPCs, trigger areas, spawners and rules of the scene that have a number)

Dictionary describe( node: Node ) ​

What a node of the scene is for the rows: {"node", "id", "name", "kind", "sub"}, {} when it is nothing a row can point at

bool fits( candidate: Dictionary, info: Dictionary ) ​

Is a thing of the scene one a row wants (its info from target_info)? A switch row takes a switch; an "any object" row takes every object; an object of an unknown kind is taken (the definition may be missing)

Dictionary find_target( scene_root: Node, unit: Resource ) ​

The thing of the scene a row points at (an entry of targets_in), {} when it is not there

Dictionary capture( rule: LocalEvent ) ​

What a rule is now, to put it back later: a deep copy of its event, its name, whether it is on, its note and its place, and a text that says whether two states are the same

bool same( a: Dictionary, b: Dictionary ) ​

No description yet.

void restore( rule: LocalEvent, state: Dictionary ) ​

Puts a rule back as capture found it (with a copy: the state stays as it was)