Skip to content

Commit

Permalink
Effector: Thing -> IAutoUpdate
Browse files Browse the repository at this point in the history
  • Loading branch information
timotheyca committed May 10, 2019
1 parent 3431688 commit 3b08a57
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 12 deletions.
2 changes: 1 addition & 1 deletion ogtdglib/src/Effects/Effect.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public void Step()
/// </summary>
/// <param name="effect"></param>
/// <returns></returns>
public static Thing Apply(Effect effect)
public static IAutoUpdate Apply(Effect effect)
{
return new Effector(effect);
}
Expand Down
15 changes: 4 additions & 11 deletions ogtdglib/src/Effects/Effector.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,33 +4,26 @@
namespace OgtDgLib.Effects
{
[PublicAPI]
internal sealed class Effector : Thing
internal sealed class Effector : IAutoUpdate
{
public StateBinding EffectBinding = new StateBinding(nameof(ItsEffect));
public Effect ItsEffect;

internal Effector(Effect itsEffect)
{
ItsEffect = itsEffect;
owner = ItsEffect.Owner;
}

public override void Initialize()
{
Step();
AutoUpdatables.Add(this);
}

private void Step()
{
ItsEffect.Step();
}

public override void Update()
public void Update()
{
if (!ItsEffect.Decayed)
ItsEffect.Step();
else
Level.Remove(this);
Step();
}
}
}

0 comments on commit 3b08a57

Please sign in to comment.