Initial commit
This commit is contained in:
commit
3b96451047
71 changed files with 2302 additions and 0 deletions
44
addons/walkabout/characters/character_behavior.gd
Normal file
44
addons/walkabout/characters/character_behavior.gd
Normal file
|
@ -0,0 +1,44 @@
|
|||
@tool
|
||||
@icon("character_behavior.svg")
|
||||
class_name WBCharacterBehavior
|
||||
extends Node
|
||||
## Controls/puppets a parent character.
|
||||
|
||||
|
||||
## Whether the behavior is currently active.
|
||||
@export var active: bool:
|
||||
set(value):
|
||||
var last_value := active
|
||||
active = value
|
||||
if active:
|
||||
if not is_node_ready():
|
||||
await ready
|
||||
for child in get_parent().get_children():
|
||||
if child != self and child is WBCharacterBehavior:
|
||||
child.active = false
|
||||
if active:
|
||||
_activate()
|
||||
else:
|
||||
_deactivate()
|
||||
|
||||
|
||||
## The character being controlled.
|
||||
var character: WBCharacter:
|
||||
get():
|
||||
return get_parent() as WBCharacter
|
||||
|
||||
|
||||
## Enables the behavior.
|
||||
func enable() -> void:
|
||||
active = true
|
||||
|
||||
## Disables the behavior.
|
||||
func disable() -> void:
|
||||
active = false
|
||||
|
||||
|
||||
func _activate() -> void:
|
||||
pass
|
||||
|
||||
func _deactivate() -> void:
|
||||
pass
|
Loading…
Add table
Add a link
Reference in a new issue