Skip to content

BehaviorTimeStrip ​

Inherits: Control

The day of an NPC in one picture: 24 hours across, one bar per schedule in the colour the viewport draws it, from the hour its Time of Day condition starts to the hour it ends (a schedule with no time is for any time: a faint bar all along). The schedules are in the order the NPC checks them: the first whose time and conditions hold runs. The bar of the chosen schedule is bright. When it is editable the bars can be changed with the mouse: drag a bar to move its time, drag its left or right edge to stretch it, drag over an empty stretch of a row to make a time there (to the quarter hour), right click a row to make it any time. The strip only says what the user did (the signals); BehaviorPanel changes the script, saves it and makes it one step of Undo.

Variables ​

booleditablefalse
ModularBehaviorScriptbehaviornull
intfocus_schedule-1

Methods ​

voidset_script_data( new_script: ModularBehaviorScript, new_focus: int )
introw_at( y: float )
floathour_at( x: float )
voidbegin_drag( point: Vector2 )
voiddrag_to( x: float )
voidend_drag()

Signals ​

drag_started( schedule_index: int ) ​

A drag started on the row of a schedule

time_dragged( schedule_index: int, start: float, end: float ) ​

The time of the schedule being dragged is now from start to end (hours of the game day)

drag_finished( schedule_index: int ) ​

The drag ended

time_cleared( schedule_index: int ) ​

A right click: the schedule is for any time

Enumerations ​

enum DragKind ​

  • NONE = 0
  • START = 1
  • END = 2
  • MOVE = 3
  • CREATE = 4

Constants ​

  • float EDGE_HOURS = 0.75 - How close to an edge (in hours) a press is a drag of the edge
  • float QUARTER = 0.25
  • float ROW_HEIGHT = 16.0
  • float LABEL_WIDTH = 0.0
  • int HOURS = 24

Variable descriptions ​

bool editable = false ​

Can the bars be changed with the mouse?

ModularBehaviorScript behavior = null ​

No description yet.

int focus_schedule = -1 ​

No description yet.

Method descriptions ​

void set_script_data( new_script: ModularBehaviorScript, new_focus: int ) ​

No description yet.

int row_at( y: float ) ​

The row of the schedule at a height of the strip (-1 when none)

float hour_at( x: float ) ​

The hour at a place across the strip, to the quarter hour

void begin_drag( point: Vector2 ) ​

A press at a place of the strip: what is dragged depends on where (an edge, the bar, or an empty stretch)

void drag_to( x: float ) ​

The mouse is at a place across the strip while dragging

void end_drag() ​

No description yet.