feat: shared creature root, enemy definitions, defend duty, and player downing
This commit is contained in:
@@ -44,8 +44,15 @@ func _resolve_references() -> void:
|
||||
func _physics_process(delta: float) -> void:
|
||||
if not _references_resolved:
|
||||
_resolve_references()
|
||||
if simulation_manager != null and simulation_manager.has_method("update_player_combatant"):
|
||||
simulation_manager.update_player_combatant(player.global_position)
|
||||
attack_timer = maxf(attack_timer - delta, 0.0)
|
||||
dash_timer = maxf(dash_timer - delta, 0.0)
|
||||
if _player_is_downed():
|
||||
attack_timer = 0.0
|
||||
dash_timer = 0.0
|
||||
dashing = false
|
||||
return
|
||||
if dashing:
|
||||
player.velocity = dash_velocity
|
||||
if dash_timer <= 0.0:
|
||||
@@ -58,6 +65,14 @@ func _physics_process(delta: float) -> void:
|
||||
_perform_dash()
|
||||
|
||||
|
||||
func _player_is_downed() -> bool:
|
||||
return (
|
||||
simulation_manager != null
|
||||
and simulation_manager.has_method("player_is_downed")
|
||||
and simulation_manager.player_is_downed()
|
||||
)
|
||||
|
||||
|
||||
func _perform_attack() -> void:
|
||||
attack_timer = attack_cooldown_seconds
|
||||
_play_swing()
|
||||
|
||||
@@ -492,7 +492,7 @@ func _create_task_glyph_mesh(action_id: StringName) -> PrimitiveMesh:
|
||||
var crate := BoxMesh.new()
|
||||
crate.size = Vector3(0.34, 0.22, 0.34)
|
||||
return crate
|
||||
SimulationIds.ACTION_PATROL:
|
||||
SimulationIds.ACTION_PATROL, SimulationIds.ACTION_DEFEND:
|
||||
var shield := CylinderMesh.new()
|
||||
shield.top_radius = 0.2
|
||||
shield.bottom_radius = 0.2
|
||||
@@ -532,7 +532,7 @@ func _get_task_glyph_color(action_id: StringName) -> Color:
|
||||
return Color(0.58, 0.34, 0.16, 1.0)
|
||||
SimulationIds.ACTION_DEPOSIT_FOOD:
|
||||
return Color(0.95, 0.72, 0.32, 1.0)
|
||||
SimulationIds.ACTION_PATROL:
|
||||
SimulationIds.ACTION_PATROL, SimulationIds.ACTION_DEFEND:
|
||||
return Color(0.36, 0.58, 0.95, 1.0)
|
||||
SimulationIds.ACTION_STUDY:
|
||||
return Color(0.62, 0.46, 0.9, 1.0)
|
||||
|
||||
@@ -25,6 +25,11 @@ func _ready() -> void:
|
||||
|
||||
|
||||
func _physics_process(delta: float) -> void:
|
||||
if _is_player_downed():
|
||||
velocity.x = move_toward(velocity.x, 0.0, acceleration * delta)
|
||||
velocity.z = move_toward(velocity.z, 0.0, acceleration * delta)
|
||||
move_and_slide()
|
||||
return
|
||||
var input := Input.get_vector("move_left", "move_right", "move_forward", "move_backward")
|
||||
|
||||
var forward := -camera_rig.global_transform.basis.z
|
||||
@@ -55,6 +60,14 @@ func _physics_process(delta: float) -> void:
|
||||
rotation.y = lerp_angle(rotation.y, target_angle, rotation_speed * delta)
|
||||
|
||||
|
||||
func _is_player_downed() -> bool:
|
||||
return (
|
||||
simulation_manager != null
|
||||
and simulation_manager.has_method("player_is_downed")
|
||||
and simulation_manager.player_is_downed()
|
||||
)
|
||||
|
||||
|
||||
func _unhandled_input(event: InputEvent) -> void:
|
||||
if event.is_action_pressed("interact"):
|
||||
try_interact()
|
||||
|
||||
Reference in New Issue
Block a user