diff --git a/src/actors/players/playerE/PlayerE.gd b/src/actors/players/playerE/PlayerE.gd index 3923d7f..c492ea7 100644 --- a/src/actors/players/playerE/PlayerE.gd +++ b/src/actors/players/playerE/PlayerE.gd @@ -6,6 +6,8 @@ export var player_number: int = 1 onready var player_inventory :InventoryManager = InventoryManager.new() onready var stamina_component = $"%Stamina_Component" onready var health_component = $"%Health_Component" +onready var hitbox_component = $Hitbox_Component +onready var hurtbox_component = $Hurtbox_Component @@ -46,7 +48,7 @@ func _ready(): player_data.player_stamina = stamina_component.stamina else: ## puppets cannot get hurt, only network master. - $Hurtbox_Component.hurtbox_entered_function = '' + hurtbox_component.hurtbox_entered_function = '' # Set initial player position in world. global_position = LevelInfo.player_start_position @@ -66,12 +68,6 @@ func _process(delta): ## Update position and stamina in player data player_data.player_position = global_position.round() player_data.player_stamina = stamina_component.stamina - - ##TODO: well I'm not sure I like this but making a whole state receiver is silly - if state_damage_amount.has(movement_state_machine.current_state.name): - $Hitbox_Component.damage_amount = state_damage_amount[movement_state_machine.current_state.name] - else: - $Hitbox_Component.damage_amount = 10 match movement_state_machine.current_state.name: "idle": @@ -83,13 +79,20 @@ func _process(delta): var _selected_item = player_inventory.switch_secondary() if _selected_item: print("Switched Secondary item to: ", _selected_item.name) - + + # Adjust hitbox damage to current states or default + ##TODO: well I'm not sure I like this but making a whole state receiver is silly + if state_damage_amount.has(movement_state_machine.current_state.name): + hitbox_component.damage_amount = state_damage_amount[movement_state_machine.current_state.name] + else: + hitbox_component.damage_amount = 10 + func hit_Receiver(damage): - $Hurtbox_Component.set_hurtbox(false) + hurtbox_component.set_hurtbox(false) health_component.take_damage(damage) - if $Health_Component.health > 0: + if health_component.health > 0: movement_state_machine.change_to_known_state('hurt') #PlayerInfo.player_health = health_component.health player_data.player_health = health_component.health @@ -97,8 +100,9 @@ func hit_Receiver(damage): if health_component.health <= 0: return yield( get_tree().create_timer(2 + movement_state_machine.get_state_reference('hurt').timeout_seconds), "timeout") - $Hurtbox_Component.set_hurtbox(true) + hurtbox_component.set_hurtbox(true) +## Interactable Receiver callback function. Anything touched goes here. func touch_the_thing(the_thing: Interactable) -> bool: print("You see! a THING...", the_thing.name) if the_thing is HealthPickup: @@ -121,6 +125,7 @@ func touch_the_thing(the_thing: Interactable) -> bool: the_thing.trigger_interaction() return true + func enough_stamina_for(_state_name :String) -> bool: if state_stamina_cost.has(_state_name): if stamina_component.stamina >= state_stamina_cost[_state_name]: @@ -130,8 +135,6 @@ func enough_stamina_for(_state_name :String) -> bool: ## Return true by default because we don't have a cost for this move return true - - ##DONE: We need to find a way to 'use' the item. func use_primary_item() -> String: if player_inventory.primary_selection != null: # Have to make sure we even have a second