Skip to content

BehaviorRoute ​

Inherits: RefCounted

The map of a behaviour script, without any editor object: what each task is on the ground (a route, a point, an area, a link to a person or an object), the lines to draw for it, and the texts the Behaviour tab shows (a title and a summary of a task, the kind and the time of a schedule, who uses a script). BehaviorGizmoPlugin draws the lines in the 3D viewport and BehaviorPanel shows the texts; this class only answers, so it can be tested without an editor.

Description ​

A task is described by a Dictionary: kind "route" (points, one after the other), "point" (one place), "area" (a centre and a radius), "link" (a line to the thing with a unique id) or "none" (nothing on the ground) points the places (route, point) closed a route that goes round (the loop pattern) center, radius the area target_id the unique id of a link facing a direction the NPC faces on arrival (point) label what the shape is ("Patrol", "Move to", "Wander" ...)

Methods ​

Colorcolor_of( schedule_index: int ) static
Stringschedule_kind( schedule: TaskSchedule ) static
Stringtask_title( task: BehaviorTask ) static
Stringtask_summary( task: BehaviorTask ) static
Dictionarytime_band( schedule: TaskSchedule ) static
Stringtime_text( schedule: TaskSchedule ) static
Stringschedule_summary( schedule: TaskSchedule ) static
Stringfallback_text( script: ModularBehaviorScript ) static
Dictionaryscript_users( script_id: int ) static
Stringtrigger_text( reaction: BehaviorReaction ) static
intreaction_target_index( reaction: BehaviorReaction, script: ModularBehaviorScript ) static
Stringreaction_action_text( reaction: BehaviorReaction, script: ModularBehaviorScript ) static
Stringreaction_summary( reaction: BehaviorReaction, script: ModularBehaviorScript ) static
Vector3place_shift( task: BehaviorTask, origin: Vector3 ) static
Dictionarytask_shape( task: BehaviorTask, origin: Vector3 ) static
Array[Dictionary]schedule_shapes( schedule: TaskSchedule, origin: Vector3 ) static
Dictionarybuild_lines( script: ModularBehaviorScript, origin: Vector3, to_local: Callable, find_target: Callable, focus_schedule: int = -1, focus_task: int = -1, only_focus: bool = false ) static
Variantfind_unique_position( scene_root: Node, unique_id: int ) static

Constants ​

  • Array[Color] SCHEDULE_COLORS = [ - One colour per schedule (the first schedule is the first colour); more schedules than colours use them again
  • float MARK = 0.3 - The size of the mark of a point, in metres
  • float LIFT = 0.15 - How high over the point the lines are drawn (so they are not inside the ground)
  • int CIRCLE_SEGMENTS = 40 - The number of segments of the circle of an area
  • Array[int] WORKING_TRIGGERS = [ - The triggers that really fire (BehaviorReaction._connect_trigger_signals connects these; the others are in the list of the window but nothing connects them yet)

Method descriptions ​

Color color_of( schedule_index: int ) ​

No description yet.

String schedule_kind( schedule: TaskSchedule ) ​

The kind of a schedule, as a word

String task_title( task: BehaviorTask ) ​

The name of a task: the one it gives itself, else its class without "Task" ("PatrolTask" -> "Patrol")

String task_summary( task: BehaviorTask ) ​

One line about a task: what it does and where (the numbers the user would otherwise read in the tree)

Dictionary time_band( schedule: TaskSchedule ) ​

The time of day a schedule is for: {"start": hour, "end": hour} from its Time of Day condition, {} when it has none (it is for any time)

String time_text( schedule: TaskSchedule ) ​

The time of a schedule as text: "08:00 to 18:00", "all day" (a Time of Day of a whole day) or "any time" (no Time of Day)

String schedule_summary( schedule: TaskSchedule ) ​

One line about a schedule

String fallback_text( script: ModularBehaviorScript ) ​

The fallback of a script, as text

Dictionary script_users( script_id: int ) ​

Who uses a script: {"definitions": [names of the NPC definitions that have it], "uniques": the number of placed NPCs that have it as their own}

String trigger_text( reaction: BehaviorReaction ) ​

What starts a reaction, as words ("the player comes within 10 m")

int reaction_target_index( reaction: BehaviorReaction, script: ModularBehaviorScript ) ​

The schedule a reaction switches to (an index of the script's schedules; -1 when it is not a switch or the schedule is not there). Like the game: the name first, then the number

String reaction_action_text( reaction: BehaviorReaction, script: ModularBehaviorScript ) ​

What a reaction does, as words ("switch to Greet, back 2 s after it is over")

String reaction_summary( reaction: BehaviorReaction, script: ModularBehaviorScript ) ​

One line about a reaction: its name, what starts it and what it does

Vector3 place_shift( task: BehaviorTask, origin: Vector3 ) ​

What is added to the places a task stores to get places of the world: where the NPC is placed for a task with relative places, nothing for any other

Dictionary task_shape( task: BehaviorTask, origin: Vector3 ) ​

What a task is on the ground (see the top of the file). origin is where the NPC is placed: what "where it stands" means

Array[Dictionary] schedule_shapes( schedule: TaskSchedule, origin: Vector3 ) ​

The shapes of the tasks of a schedule, in order (a wander schedule with no task shows the circle of its radius)

Dictionary build_lines( script: ModularBehaviorScript, origin: Vector3, to_local: Callable, find_target: Callable, focus_schedule: int = -1, focus_task: int = -1, only_focus: bool = false ) ​

The lines to draw for a script, by the name of the material they are drawn with ("s0" ... "s7" the bright colour of a schedule, "d0" ... "d7" its dim one, "focus" the task being looked at, "link" the lines to people and objects). origin is where the NPC is placed. to_local turns a world point into the space of the drawing; find_target answers with the world position of a unique id (a Vector3, or null when the thing is not in the scene). focus_schedule / focus_task are the ones the tab has chosen (-1 = none: every schedule is bright); only_focus leaves out the other schedules

Variant find_unique_position( scene_root: Node, unique_id: int ) ​

The world position of a placed NPC or object by its unique id, looked for in a scene (null when none has it)