Refactor Player class to use components, also use components in Enemy class types and fiddle with boss structure
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
using Chickensoft.AutoInject;
|
||||
using Chickensoft.Introspection;
|
||||
using Godot;
|
||||
using System;
|
||||
|
||||
namespace Zennysoft.Game.Ma;
|
||||
|
||||
@@ -9,16 +10,47 @@ public abstract partial class EnemyModelView : Node3D, IEnemyModelView
|
||||
{
|
||||
public override void _Notification(int what) => this.Notify(what);
|
||||
|
||||
public virtual void PlayActivateAnimation() => throw new System.NotImplementedException();
|
||||
private readonly string _idleName = "Idle";
|
||||
private readonly string _walkingName = "Walking";
|
||||
private readonly string _primaryAttackName = "Primary Attack";
|
||||
private readonly string _secondaryAttackName = "Secondary Attack";
|
||||
private readonly string _activateName = "Activate";
|
||||
private readonly string _parametersPlayback = "parameters/playback";
|
||||
|
||||
[Node] public AnimationTree AnimationTree { get; set; } = default!;
|
||||
|
||||
private AnimationNodeStateMachinePlayback _stateMachine;
|
||||
|
||||
public event EventHandler HitPlayer;
|
||||
|
||||
public void OnReady()
|
||||
{
|
||||
_stateMachine = (AnimationNodeStateMachinePlayback)AnimationTree.Get(_parametersPlayback);
|
||||
}
|
||||
|
||||
public virtual void PlayPrimaryAttackAnimation() => _stateMachine.Travel(_primaryAttackName);
|
||||
|
||||
public virtual void PlaySecondaryAttackAnimation() => _stateMachine.Travel(_secondaryAttackName);
|
||||
|
||||
public virtual void PlayPrimarySkillAnimation() => _stateMachine.Travel("Primary Skill");
|
||||
|
||||
public virtual void PlayIdleAnimation() => _stateMachine.Travel(_idleName);
|
||||
|
||||
public virtual void PlayWalkAnimation() => _stateMachine.Travel(_walkingName);
|
||||
|
||||
public virtual void PlayActivateAnimation() => _stateMachine.Travel(_activateName);
|
||||
|
||||
public virtual void PlayDeathAnimation() => throw new System.NotImplementedException();
|
||||
|
||||
public virtual void PlayHitAnimation() => throw new System.NotImplementedException();
|
||||
public virtual void PlayIdleAnimation() => throw new System.NotImplementedException();
|
||||
public virtual void PlayPrimaryAttackAnimation() => throw new System.NotImplementedException();
|
||||
public virtual void PlayPrimarySkillAnimation() => throw new System.NotImplementedException();
|
||||
public virtual void PlaySecondaryAttackAnimation() => throw new System.NotImplementedException();
|
||||
public virtual void PlayWalkAnimation() => throw new System.NotImplementedException();
|
||||
|
||||
[Signal]
|
||||
public delegate void HitPlayerEventHandler();
|
||||
protected virtual void OnPlayerHit()
|
||||
{
|
||||
HitPlayer?.Invoke(this, EventArgs.Empty);
|
||||
}
|
||||
|
||||
public override void _ExitTree()
|
||||
{
|
||||
AnimationTree.Get(_parametersPlayback).As<AnimationNodeStateMachinePlayback>().Stop();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user