Rework projectiles and fix some demon wall attacks
Still working on Demon Wall boss fight overall
This commit is contained in:
@@ -3,75 +3,30 @@ using Chickensoft.Introspection;
|
||||
using Godot;
|
||||
using Zennysoft.Game.Ma;
|
||||
using Zennysoft.Ma.Adapter;
|
||||
using Zennysoft.Ma.Adapter.Entity;
|
||||
|
||||
[Meta(typeof(IAutoNode))]
|
||||
public partial class EnemyProjectile : Node3D
|
||||
public partial class EnemyProjectile : RigidBody3D
|
||||
{
|
||||
public override void _Notification(int what) => this.Notify(what);
|
||||
|
||||
[Dependency] protected IMap _map => this.DependOn<IMap>();
|
||||
|
||||
[Dependency] protected IPlayer _player => this.DependOn<IPlayer>();
|
||||
|
||||
[Node] public Area3D ProjectileHitbox { get; set; }
|
||||
|
||||
[Node] public AnimationPlayer AnimationPlayer { get; set; }
|
||||
|
||||
[Export] public AttackDataResource AttackData { get; set; }
|
||||
|
||||
public void OnReady()
|
||||
[Node] private Area3D _area3D { get; set; }
|
||||
|
||||
public override void _Ready()
|
||||
{
|
||||
ProjectileHitbox.AreaEntered += Hitbox_AreaEntered;
|
||||
ProjectileHitbox.BodyEntered += ProjectileHitbox_BodyEntered1;
|
||||
ProjectileHitbox.BodyShapeEntered += ProjectileHitbox_BodyEntered;
|
||||
AnimationPlayer.AnimationFinished += AnimationPlayer_AnimationFinished;
|
||||
AnimationPlayer.Play("RESET");
|
||||
BodyEntered += Hitbox_AreaEntered;
|
||||
_area3D.AreaEntered += AreaEntered;
|
||||
}
|
||||
|
||||
private void AnimationPlayer_AnimationFinished(StringName animName)
|
||||
{
|
||||
if (animName != "Fire")
|
||||
return;
|
||||
ProjectileHitbox.SetDeferred(Area3D.PropertyName.Monitorable, false);
|
||||
ProjectileHitbox.SetDeferred(Area3D.PropertyName.Monitoring, false);
|
||||
AnimationPlayer.Stop();
|
||||
AnimationPlayer.Play("RESET");
|
||||
}
|
||||
|
||||
private void ProjectileHitbox_BodyEntered1(Node3D body)
|
||||
{
|
||||
ProjectileHitbox.SetDeferred(Area3D.PropertyName.Monitorable, false);
|
||||
ProjectileHitbox.SetDeferred(Area3D.PropertyName.Monitoring, false);
|
||||
AnimationPlayer.Stop();
|
||||
AnimationPlayer.Play("RESET");
|
||||
}
|
||||
|
||||
private void ProjectileHitbox_BodyEntered(Rid bodyRid, Node3D body, long bodyShapeIndex, long localShapeIndex)
|
||||
{
|
||||
AnimationPlayer.Stop();
|
||||
AnimationPlayer.Play("RESET");
|
||||
}
|
||||
|
||||
public bool Fire()
|
||||
{
|
||||
if (AnimationPlayer.IsPlaying())
|
||||
return false;
|
||||
|
||||
GlobalBasis = GetOwner<IEnemyModelView>().GetOwner<IEnemy>().GlobalBasis;
|
||||
ProjectileHitbox.SetDeferred(Area3D.PropertyName.Monitorable, true);
|
||||
ProjectileHitbox.SetDeferred(Area3D.PropertyName.Monitoring, true);
|
||||
AnimationPlayer.Play("Fire");
|
||||
return true;
|
||||
}
|
||||
|
||||
private void Hitbox_AreaEntered(Area3D area)
|
||||
private void AreaEntered(Area3D area)
|
||||
{
|
||||
if (area.GetOwner() is IPlayer player)
|
||||
{
|
||||
player.TakeDamage(new AttackData(AttackData.Damage, AttackData.ElementType));
|
||||
ProjectileHitbox.SetDeferred(Area3D.PropertyName.Monitorable, false);
|
||||
ProjectileHitbox.SetDeferred(Area3D.PropertyName.Monitoring, false);
|
||||
AnimationPlayer.Stop();
|
||||
AnimationPlayer.Play("RESET");
|
||||
CallDeferred(MethodName.QueueFree);
|
||||
}
|
||||
}
|
||||
|
||||
private void Hitbox_AreaEntered(Node area) => CallDeferred(MethodName.QueueFree);
|
||||
}
|
||||
Reference in New Issue
Block a user