Effect system and snowpea
This commit is contained in:
parent
9b89ae98a6
commit
e797918e23
18 changed files with 353 additions and 16 deletions
|
|
@ -1,11 +1,12 @@
|
|||
using Godot;
|
||||
using System;
|
||||
|
||||
namespace Newlon.Systems.Effects;
|
||||
|
||||
public abstract partial class Effect : Resource
|
||||
{
|
||||
public abstract void Enter();
|
||||
public abstract void Process();
|
||||
public abstract void Exit();
|
||||
[Export] public float Duration;
|
||||
[Export] public Utility.EffectSlots Slot;
|
||||
public abstract void Enter(Node target);
|
||||
public abstract void Process(Node target);
|
||||
public abstract void Exit(Node target);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,5 +2,7 @@ namespace Newlon.Systems.Effects;
|
|||
|
||||
public interface IEffectHandler
|
||||
{
|
||||
|
||||
void GiveEffect(Effect what);
|
||||
void EndEffect(Effect what);
|
||||
void ProcessEffects();
|
||||
}
|
||||
35
scripts/systems/effects/SlownessEffect.cs
Normal file
35
scripts/systems/effects/SlownessEffect.cs
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
using Godot;
|
||||
using Newlon.Components;
|
||||
using System;
|
||||
|
||||
namespace Newlon.Systems.Effects;
|
||||
|
||||
public partial class SlownessEffect : Effect
|
||||
{
|
||||
[Export] public Color ColorOverride;
|
||||
[Export] public float Multiplier;
|
||||
|
||||
public override void Enter(Node target)
|
||||
{
|
||||
if(target is IEffectHandler handler)
|
||||
{
|
||||
if(target is ILocalTimescale timescalable)
|
||||
timescalable.LocalTimescale *= Multiplier;
|
||||
if(target is CanvasItem canvasItem)
|
||||
canvasItem.Modulate = ColorOverride;
|
||||
}
|
||||
}
|
||||
|
||||
public override void Exit(Node target)
|
||||
{
|
||||
if(target is ILocalTimescale timescalable)
|
||||
timescalable.LocalTimescale /= Multiplier;
|
||||
if(target is CanvasItem canvasItem)
|
||||
canvasItem.Modulate = Colors.White;
|
||||
}
|
||||
|
||||
public override void Process(Node target)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue