stunnable targets on hit
This commit is contained in:
@@ -130,11 +130,16 @@ public partial class Enemy : CharacterBody3D,
|
||||
Events.Subscribe<KnockbackDone>(Tag.RequestTag(TagsManager, "events.combat.knockback_received"), OnKnockbackReceived);
|
||||
Events.Subscribe(Tag.RequestTag(TagsManager, "events.combat.death"), OnDeath);
|
||||
Events.Subscribe(Tag.RequestTag(TagsManager, "events.enemy.request_projectile"), ProjectileTokenRequested);
|
||||
|
||||
}
|
||||
|
||||
private bool IsStunned()
|
||||
{
|
||||
return Tags.CombinedTags.HasTag(Tag.RequestTag(TagsManager, "status.stunned"));
|
||||
}
|
||||
|
||||
private void ProjectileTokenRequested(EventData obj)
|
||||
{
|
||||
if (IsStunned()) return;
|
||||
// TODO: replace with token manager
|
||||
Events.Raise(new EventData<OnProjectileSpawned>
|
||||
{
|
||||
@@ -154,24 +159,34 @@ public partial class Enemy : CharacterBody3D,
|
||||
{
|
||||
// Only trigger gameplay-related effects on specific frames
|
||||
if(Engine.GetPhysicsFrames() % 10 == 0) ProcessGameplay(delta);
|
||||
|
||||
var targetPlanar = new Vector3(Target.GlobalPosition.X, GlobalPosition.Y, Target.GlobalPosition.Z);
|
||||
LookAt(targetPlanar);
|
||||
|
||||
if (!IsStunned())
|
||||
{
|
||||
var targetPlanar = new Vector3(Target.GlobalPosition.X, GlobalPosition.Y, Target.GlobalPosition.Z);
|
||||
LookAt(targetPlanar);
|
||||
}
|
||||
|
||||
var inputs = new MovementInputs(
|
||||
Velocity: Velocity,
|
||||
TargetLocation: Target.GlobalPosition,
|
||||
isOnFloor: IsOnFloor(),
|
||||
gravity: GetGravity(),
|
||||
delta: delta
|
||||
IsOnFloor: IsOnFloor(),
|
||||
IsStunned: IsStunned(),
|
||||
Gravity: GetGravity(),
|
||||
Delta: delta
|
||||
);
|
||||
Velocity = ComputeVelocity(inputs);
|
||||
|
||||
Velocity += ComputeKnockback();
|
||||
MoveAndSlide();
|
||||
}
|
||||
|
||||
public void ProcessGameplay(double delta)
|
||||
{
|
||||
if (IsStunned())
|
||||
{
|
||||
GD.Print("Cannot attack, stunned!");
|
||||
return;
|
||||
}
|
||||
// if (_hitAbilityHandle == null) return;
|
||||
|
||||
var bodies = DamageBox.GetOverlappingBodies();
|
||||
|
||||
@@ -64,7 +64,7 @@ InitialStack = SubResource("Resource_8x1id")
|
||||
Cues = []
|
||||
metadata/_custom_type_script = "uid://b83hf13nj37k3"
|
||||
|
||||
[sub_resource type="ViewportTexture" id="ViewportTexture_4oy82"]
|
||||
[sub_resource type="ViewportTexture" id="ViewportTexture_46wn3"]
|
||||
viewport_path = NodePath("SubViewport")
|
||||
|
||||
[sub_resource type="Resource" id="Resource_on7rt"]
|
||||
@@ -141,7 +141,7 @@ metadata/_custom_type_script = "uid://dps0oef50noil"
|
||||
|
||||
[node name="CHealthBar" parent="." unique_id=1635725931 instance=ExtResource("7_ykkxn")]
|
||||
transform = Transform3D(0.3, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.70000005, 0)
|
||||
texture = SubResource("ViewportTexture_4oy82")
|
||||
texture = SubResource("ViewportTexture_46wn3")
|
||||
|
||||
[node name="CMovement" parent="." unique_id=1699571730 instance=ExtResource("7_vaeds")]
|
||||
RMovement = SubResource("Resource_on7rt")
|
||||
|
||||
@@ -141,7 +141,7 @@ InitialStack = SubResource("Resource_hgi6f")
|
||||
Cues = []
|
||||
metadata/_custom_type_script = "uid://b83hf13nj37k3"
|
||||
|
||||
[sub_resource type="ViewportTexture" id="ViewportTexture_xabdf"]
|
||||
[sub_resource type="ViewportTexture" id="ViewportTexture_rlvdp"]
|
||||
viewport_path = NodePath("SubViewport")
|
||||
|
||||
[sub_resource type="Resource" id="Resource_6d4gl"]
|
||||
@@ -177,7 +177,6 @@ collision_layer = 16
|
||||
collision_mask = 273
|
||||
script = ExtResource("1_ha67n")
|
||||
EnemyHeight = 2.0
|
||||
LaunchProjectileAbility = ExtResource("2_rlvdp")
|
||||
RKnockback = ExtResource("3_ymgar")
|
||||
RMovement = ExtResource("4_0f52b")
|
||||
|
||||
@@ -222,7 +221,7 @@ metadata/_custom_type_script = "uid://dps0oef50noil"
|
||||
|
||||
[node name="CHealthBar" parent="." unique_id=1278247727 instance=ExtResource("9_6ew2r")]
|
||||
transform = Transform3D(0.4, 0, 0, 0, 1, 0, 0, 0, 1, 0, 2.2, 0)
|
||||
texture = SubResource("ViewportTexture_xabdf")
|
||||
texture = SubResource("ViewportTexture_rlvdp")
|
||||
|
||||
[node name="CMovement" parent="." unique_id=1080640834 node_paths=PackedStringArray("WallInFrontRayCast") instance=ExtResource("10_d3cra")]
|
||||
RMovement = SubResource("Resource_6d4gl")
|
||||
|
||||
Reference in New Issue
Block a user