BehaviorPanel ​
Inherits: VBoxContainer
The Behaviour tab: what the NPC selected in the 3D viewport does, and the place to change it. It shows the behaviour script of the NPC and where it comes from (its definition or its own), the day as a strip of 24 hours, the schedules with their tasks and conditions (a colour per schedule, the same as the lines in the viewport), the reactions and the fallback, and who else uses the script. Choosing a schedule or a task in the list makes it bright in the viewport (BehaviorGizmoPlugin asks this panel what to draw). The list works like the lists of the Behavior Scripts editor: right click a row for Edit, Add Task, Add Condition, Delete, Move Up and Move Down (double click edits), and the same windows open (the new schedule window, the schedule window, the task windows, the condition window). The strip of the day can be dragged to set the time of a schedule. Everything changes only the script that is this NPC's own (a script of the definition is shared); each change is saved and is one step of Undo.
Variables ​
Methods ​
Dictionary | get_draw_state( npc: NPC ) |
void | load_npc( npc: NPC ) |
void | clear() |
void | reload() |
void | tick() |
bool | is_editable() |
void | set_tool( mode: BehaviorEditing.Mode ) |
void | make_own() |
void | use_definitions_script() |
void | set_override_id( data: UniqueEntityData, script_id: int ) |
BehaviorTask | chosen_task() |
TaskSchedule | chosen_schedule() |
bool | add_point_at( world: Vector3 ) |
bool | pick_target( unique_id: int, target_name: String ) |
void | remove_last_point() |
void | add_schedule_made( schedule: TaskSchedule ) |
void | request_add_task() |
void | add_task_made( task: BehaviorTask, schedule_index: int ) |
void | delete_entry( entry: Dictionary ) |
void | move_entry( entry: Dictionary, delta: int ) |
void | finish_edit( action_name: String, before: Dictionary ) |
void | apply_state( state: Dictionary, save: bool = true ) |
bool | build_menu( entry: Dictionary ) |
void | edit_entry( entry: Dictionary ) |
void | request_add_condition( entry: Dictionary ) |
void | add_condition_made( condition: EntityCondition, schedule_index: int, task_index: int ) |
Array | problems_of( schedule_index: int, task_index: int ) |
void | advance_walker( seconds: float, round_seconds: float ) |
void | request_add_reaction() |
void | add_reaction_made( reaction: BehaviorReaction ) |
void | add_reaction_condition_made( condition: EntityCondition, reaction_index: int ) |
void | save_chosen_as_template( template_name: String, description: String ) |
Signals ​
draw_state_changed() ​
The viewport has to draw again
Enumerations ​
enum MenuID ​
What the items of the right click menu do (the ids of the menus of the Behavior Scripts editor, plus Add Task)
- EDIT =
0 - ADD_CONDITION =
1 - DELETE =
2 - MOVE_UP =
3 - MOVE_DOWN =
4 - ADD_TASK =
5
Constants ​
StringNOT_OWN ="Make this NPC's own behaviour first (the shared script would change for ever...
Variable descriptions ​
EditorPlugin plugin = null ​
No description yet.
DialogManager dialog_manager = null ​
The windows that choose a task and edit it (set by the plugin; the same manager the editors use)
EditorUndoRedoManager undo_redo = null ​
Where the editor's undo history is (set by the plugin; without it a change is made and saved but cannot be undone)
BehaviorEditing.Mode tool_mode = BehaviorEditing.Mode.NONE ​
What a click in the viewport does (BehaviorEditing.Mode; BehaviorTool does the click)
NPC current_npc = null ​
No description yet.
ModularBehaviorScript current_script = null ​
No description yet.
int focus_schedule = -1 ​
The schedule and the task chosen in the list (-1 = none)
int focus_task = -1 ​
No description yet.
bool show_paths = true ​
No description yet.
bool only_focus = false ​
No description yet.
bool check_paths = true ​
Phase 4: draw the real walk, the places that cannot be reached; the result of the checks of the whole script (BehaviorCheck.check_script); the walker
Dictionary check_result = ​
No description yet.
float ghost_time = -1.0 ​
The time of the walker in the round of the chosen schedule, in seconds (-1 = no walker)
bool walker_playing = false ​
No description yet.
int focus_reaction = -1 ​
Phase 5: the reaction chosen in the list (-1 = none), the buttons and windows of reactions and templates
Button add_reaction_button ​
No description yet.
Button template_button ​
No description yet.
Button save_template_button ​
No description yet.
BehaviorTemplateDialog template_dialog ​
No description yet.
SaveTemplateDialog save_template_dialog ​
No description yet.
ConfirmationDialog delete_template_dialog ​
No description yet.
Label title_label ​
No description yet.
Label source_label ​
No description yet.
Label users_label ​
No description yet.
Tree tree ​
No description yet.
BehaviorTimeStrip strip ​
No description yet.
RichTextLabel details ​
No description yet.
CheckBox show_check ​
No description yet.
CheckBox only_check ​
No description yet.
CheckBox paths_check ​
No description yet.
CheckBox walker_check ​
No description yet.
Button play_button ​
No description yet.
HSlider walk_slider ​
No description yet.
OptionButton speed_option ​
No description yet.
Label walk_label ​
No description yet.
Button open_button ​
No description yet.
Button refresh_button ​
No description yet.
Button own_button ​
No description yet.
Button shared_button ​
No description yet.
Button add_schedule_button ​
No description yet.
Button add_task_button ​
No description yet.
Dictionary tool_buttons = ​
BehaviorEditing.Mode -> Button
Button remove_point_button ​
No description yet.
CheckBox relative_check ​
No description yet.
Label status_label ​
No description yet.
PopupMenu context_menu ​
No description yet.
NewScheduleDialog new_schedule_dialog ​
No description yet.
ScheduleEditDialog schedule_edit_dialog ​
No description yet.
ConditionalEditDialog condition_dialog ​
No description yet.
Method descriptions ​
Dictionary get_draw_state( npc: NPC ) ​
The answer to the gizmo: what to draw for this NPC (empty when nothing)
void load_npc( npc: NPC ) ​
An NPC is selected in the viewport (null = none): the tab shows its behaviour
void clear() ​
Nothing (or something else than an NPC) is selected
void reload() ​
Reads the script of the NPC again from the database
void tick() ​
Called now and then by the plugin: an NPC that was moved draws its routes from its new place
bool is_editable() ​
Can the script be changed? Only when it is this NPC's own: a script of the definition is shared by every NPC that has it
void set_tool( mode: BehaviorEditing.Mode ) ​
What a click in the viewport does (NONE = nothing)
void make_own() ​
Copies the script into a new record for this NPC alone (an empty one when it has no script) and gives it to the NPC. The record is a script of the database: it stays there when the NPC is deleted
void use_definitions_script() ​
Follows the script of the definition again (the own script stays in the database)
void set_override_id( data: UniqueEntityData, script_id: int ) ​
Sets the script the placed NPC follows instead of its definition's (0 = the definition's), saves it and shows it
BehaviorTask chosen_task() ​
The task chosen in the list (null when none)
TaskSchedule chosen_schedule() ​
The schedule chosen in the list (null when none)
bool add_point_at( world: Vector3 ) ​
A click on the ground with the tool on: adds what the tool adds there. False when nothing was added
bool pick_target( unique_id: int, target_name: String ) ​
A click on an NPC or an object with Pick target on: it becomes the target of the chosen task
void remove_last_point() ​
Takes the last point off the chosen patrol
void add_schedule_made( schedule: TaskSchedule ) ​
A schedule made in the New Schedule window goes at the end of the script and is chosen
void request_add_task() ​
The task window opens for the chosen schedule: the task that is made goes in it
void add_task_made( task: BehaviorTask, schedule_index: int ) ​
A task made in the task window goes at the end of its schedule and is chosen
void delete_entry( entry: Dictionary ) ​
Takes a row of the list off the script ("kind": schedule, task or condition)
void move_entry( entry: Dictionary, delta: int ) ​
Moves a schedule or a task of the list up (-1) or down (+1)
void finish_edit( action_name: String, before: Dictionary ) ​
A window changed the script: it is saved, the list and the viewport show it, and it is one step of Undo (before is what BehaviorEditing.capture found before)
void apply_state( state: Dictionary, save: bool = true ) ​
Puts the script back as a state of BehaviorEditing.capture (Undo and Redo, and a cancelled drag)
bool build_menu( entry: Dictionary ) ​
Fills the menu for a kind of row. False when the row has no menu (the reactions, the fallback)
void edit_entry( entry: Dictionary ) ​
The window that edits a row opens (the schedule window, the task window or the condition window); what it changes is one step of Undo
void request_add_condition( entry: Dictionary ) ​
The condition window opens to add a condition to a schedule (activation) or a task (execution)
void add_condition_made( condition: EntityCondition, schedule_index: int, task_index: int ) ​
A condition made in the condition window goes to a schedule (task_index -1) or to one of its tasks
Array problems_of( schedule_index: int, task_index: int ) ​
The problems found for a schedule (task -1) or for one of its tasks
void advance_walker( seconds: float, round_seconds: float ) ​
Moves the walker on by this many seconds of the round (it goes round again at the end)
void request_add_reaction() ​
The window that makes a reaction opens
void add_reaction_made( reaction: BehaviorReaction ) ​
A reaction made in its window goes at the end of the reactions and is chosen
void add_reaction_condition_made( condition: EntityCondition, reaction_index: int ) ​
A condition made in the condition window goes to a reaction
void save_chosen_as_template( template_name: String, description: String ) ​
Saves the chosen schedule as a template of the database