60 lines
2.0 KiB
GDScript3
60 lines
2.0 KiB
GDScript3
class_name Modifier_Receiver
|
|
extends Node2D
|
|
|
|
# This may be stupid but we're going to have two kinds of callbacks here.
|
|
# It's going to be up to the parent/actor/kinematicbody2d/whatever to know
|
|
# what conditions have to be met before being able to call that interactible's
|
|
# function.
|
|
# This is a nice and generic interface that I might be able to use for
|
|
# things like opening doors in a level, opening chests/flipping switches etc.
|
|
|
|
# This node can keep an array of various interactibles within a level
|
|
# and provide several helper functions for managing them perhaps.
|
|
|
|
export var enabled :bool = true
|
|
|
|
export var callable_state_machine :NodePath
|
|
var request_push_state_modifier: FuncRef
|
|
|
|
export var debug_receiver :bool = false
|
|
|
|
|
|
|
|
|
|
|
|
# Declare member variables here. Examples:
|
|
# var a = 2
|
|
# var b = "text"
|
|
|
|
##NOTE:
|
|
## Call function should be implemented as two parameters, one expecting a modifier
|
|
## and the other expecting a boolean as to whether its being added
|
|
|
|
# Called when the node enters the scene tree for the first time.
|
|
func _ready():
|
|
assert(callable_state_machine != null)
|
|
|
|
## FuncRef to request state machine change state
|
|
request_push_state_modifier = funcref(get_node(callable_state_machine), 'push_state_modifier')
|
|
assert(request_push_state_modifier.is_valid())
|
|
|
|
|
|
# Switching to a new model that starts with Hitbox
|
|
func register_modifier(modifier: StateModifier):
|
|
if enabled:
|
|
request_push_state_modifier.call_func(modifier)
|
|
# if modifier_collection.has(modifier) == false:
|
|
# print("New Modifier Registered " + modifier.name)
|
|
# modifier_collection.append(modifier)
|
|
# if call_function.is_valid():
|
|
# call_function.call_func(modifier, true)
|
|
|
|
func remove_modifier(modifier):
|
|
print("Modifier Removal not implemented here." + modifier.name)
|
|
# if modifier_collection.has(modifier):
|
|
# var modifier_index = modifier_collection.rfind(modifier)
|
|
# if modifier_index != -1:
|
|
# modifier_collection.remove(modifier_index)
|
|
# if call_function.is_valid():
|
|
# call_function.call_func(modifier, false)
|