class_name PlatformerMove extends Move ## Task that can be performed by a platformer actor # ----------------------------------------------------------------------------------------------- # ## Actor controller the move belongs to var platformer_actor_controller : PlatformerActorController ## Actor ability definition informing the move about the actor's speed, jump height etc. var actor_abilities : PlatformerActorAbilities \ setget _set_actor_abilities, _get_actor_abilities # ----------------------------------------------------------------------------------------------- # ## Whether the lookup for the actor abilities component has taken place already ## @remarks ## Used to avoid looking it up over and over in move-derived classes var _actor_abilities_queried : bool # ----------------------------------------------------------------------------------------------- # ## Initialzes the move when it is accessed by an actor controller for the first time ## @param new_actor_controller ActorController that is making use of the move func _initialize_derived() -> void: if platformer_actor_controller == null: platformer_actor_controller = actor_controller # ----------------------------------------------------------------------------------------------- # ## Retrieves the actor physics component when the property is read from ## @returns The actor physics component used by the actor, if any func _get_actor_abilities() -> PlatformerActorAbilities: if not _actor_abilities_queried: actor_abilities = platformer_actor_controller.actor_abilities if actor_abilities == null: printerr("WARNING: actor abilities accessed, but ability node wasn't found") _actor_abilities_queried = true return actor_abilities # ----------------------------------------------------------------------------------------------- # ## Complains if the user tries to directly assign the actor physics component ## @param new_actor_physics_component New component that will not be assigned func _set_actor_abilities( new_actor_abilities : PlatformerActorAbilities ) -> void: if new_actor_abilities != actor_abilities: printerr("ERROR: The ability definition component cannot be assigned to")