Plants animation now supports timescale
This commit is contained in:
parent
5fe7cb7d68
commit
e7a9860a54
18 changed files with 141 additions and 60 deletions
|
|
@ -44,13 +44,15 @@ public partial class Entity : Node2D
|
|||
#region Brain
|
||||
public virtual void DisableBrain()
|
||||
{
|
||||
GetNode<AnimationPlayer>("AnimationPlayer").ProcessMode = ProcessModeEnum.Pausable;
|
||||
GetNode<AnimationPlayer>("AnimationPlayer").ProcessMode = ProcessModeEnum.Always;
|
||||
GetNode<AnimationTree>("AnimationTree").ProcessMode = ProcessModeEnum.Always;
|
||||
ProcessMode = ProcessModeEnum.Disabled;
|
||||
}
|
||||
|
||||
public virtual void EnableBrain()
|
||||
{
|
||||
GetNode<AnimationPlayer>("AnimationPlayer").ProcessMode = ProcessModeEnum.Inherit;
|
||||
GetNode<AnimationTree>("AnimationTree").ProcessMode = ProcessModeEnum.Inherit;
|
||||
ProcessMode = ProcessModeEnum.Inherit;
|
||||
}
|
||||
#endregion
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ public partial class AloeBehaviour : BaseBehaviour
|
|||
|
||||
public override void _Process(double delta)
|
||||
{
|
||||
_tree.Set("parameters/conditions/charged",_charge);
|
||||
_tree.Set("parameters/Tree/conditions/charged",_charge);
|
||||
|
||||
var checkPos = GetParent<Node2D>().GlobalPosition + Vector2.Right * Utility.TileWidth;
|
||||
if(_charge && PoolContainer.Instance.TryGetEntity(checkPos, out RuntimePlantData plantData))
|
||||
|
|
@ -25,7 +25,7 @@ public partial class AloeBehaviour : BaseBehaviour
|
|||
if((float)plantData.HP / (float)plantData.MaxHP < _hpTreshold)
|
||||
{
|
||||
_charge = false;
|
||||
_tree.Set("parameters/conditions/heal",true);
|
||||
_tree.Set("parameters/Tree/conditions/heal",true);
|
||||
_timer.Start();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,6 +13,6 @@ public partial class HpBasedBehaviour : BaseBehaviour
|
|||
|
||||
public void OnHPChanged(int amount,Node origin)
|
||||
{
|
||||
_tree.Set("parameters/blend_position",(float)_data.HP/_data.MaxHP);
|
||||
_tree.Set("parameters/Tree/blend_position",(float)_data.HP/_data.MaxHP);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,6 +11,6 @@ public partial class PeashooterBehaviour : BaseBehaviour
|
|||
{
|
||||
bool readyToShoot = _sight.EnemyDetected && _shootTimer.TimeLeft <= 0;
|
||||
|
||||
_tree.Set("parameters/conditions/ready",readyToShoot);
|
||||
_tree.Set("parameters/Tree/conditions/ready",readyToShoot);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ public partial class PotatomineBehaviour : BaseBehaviour
|
|||
private bool _primed = false;
|
||||
public void Prime()
|
||||
{
|
||||
_tree.Set("parameters/conditions/primed",true);
|
||||
_tree.Set("parameters/Tree/conditions/primed",true);
|
||||
|
||||
_hitbox.Monitorable = false;
|
||||
|
||||
|
|
@ -22,7 +22,7 @@ public partial class PotatomineBehaviour : BaseBehaviour
|
|||
public void OnAreaEntered(Area2D area)
|
||||
{
|
||||
if (_primed == false) return;
|
||||
_tree.Set("parameters/conditions/explode",true);
|
||||
_tree.Set("parameters/Tree/conditions/explode",true);
|
||||
_primed = false;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,20 +2,18 @@ using Godot;
|
|||
|
||||
namespace Newlon.Components.Plants.Behaviours;
|
||||
|
||||
public partial class SpikeweedBehaviour : Node
|
||||
public partial class SpikeweedBehaviour : BaseBehaviour
|
||||
{
|
||||
[Export] private AnimationTree _tree;
|
||||
|
||||
private int _inCount = 0;
|
||||
public void OnHitboxEntered(Area2D _area)
|
||||
{
|
||||
if (_inCount++ == 0)
|
||||
_tree.Set("parameters/blend_position",1);
|
||||
_tree.Set("parameters/Tree/blend_position",1);
|
||||
}
|
||||
|
||||
public void OnHitboxExited(Area2D _area)
|
||||
{
|
||||
if (--_inCount == 0)
|
||||
_tree.Set("parameters/blend_position",0);
|
||||
_tree.Set("parameters/Tree/blend_position",0);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,18 +2,11 @@ using Godot;
|
|||
|
||||
namespace Newlon.Components.Plants.Behaviours;
|
||||
|
||||
public partial class SunflowerBehaviour : Node
|
||||
public partial class SunflowerBehaviour : BaseBehaviour
|
||||
{
|
||||
private AnimationTree _tree;
|
||||
|
||||
public override void _Ready()
|
||||
{
|
||||
_tree = GetNode<AnimationTree>("../AnimationTree");
|
||||
}
|
||||
|
||||
public void Timeout()
|
||||
{
|
||||
_tree.Set("parameters/conditions/produce", true);
|
||||
_tree.Set("parameters/Tree/conditions/produce", true);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue