Skip to content

Commit

Permalink
feat: removed base effect
Browse files Browse the repository at this point in the history
  • Loading branch information
Chillu1 committed Jul 29, 2023
1 parent 6535f0e commit 7455532
Show file tree
Hide file tree
Showing 15 changed files with 32 additions and 44 deletions.
4 changes: 2 additions & 2 deletions ModiBuff/Assets/Examples/SimpleSolo/BlockEffect.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ namespace ModiBuff.Examples.SimpleSolo
/// <summary>
/// Example simple custom effect implementation
/// </summary>
public sealed class BlockEffect : BaseEffect
public sealed class BlockEffect : IEffect
{
private readonly int _blockAmount;

public BlockEffect(int blockAmount) => _blockAmount = blockAmount;

public override void Effect(IUnit target, IUnit source)
public void Effect(IUnit target, IUnit source)
{
#if DEBUG
if (target is not IBlockOwner)
Expand Down
4 changes: 2 additions & 2 deletions ModiBuff/Assets/Examples/SimpleSolo/FullBlockEffect.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ namespace ModiBuff.Examples.SimpleSolo
/// <summary>
/// Full example of a custom effect implementation
/// </summary>
public sealed class FullBlockEffect : BaseEffect, ITargetEffect, IEventTrigger, IStackEffect, IStateEffect
public sealed class FullBlockEffect : IEffect, ITargetEffect, IEventTrigger, IStackEffect, IStateEffect
{
private readonly int _baseBlock;
private readonly StackBlockEffectType _stackEffect;
Expand All @@ -31,7 +31,7 @@ private FullBlockEffect(int block, StackBlockEffectType stackEffect, Targeting t
public void SetTargeting(Targeting targeting) => _targeting = targeting;
public void SetEventBased() => _isEventBased = true;

public override void Effect(IUnit target, IUnit source)
public void Effect(IUnit target, IUnit source)
{
#if DEBUG && !MODIBUFF_PROFILE
if (target is not IBlockOwner)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
namespace ModiBuff.Core
{
public sealed class AttackActionEffect : BaseEffect, IEventTrigger, IEffect
public sealed class AttackActionEffect : IEventTrigger, IEffect
{
private bool _isEventBased;

public void SetEventBased() => _isEventBased = true;

public override void Effect(IUnit target, IUnit source)
public void Effect(IUnit target, IUnit source)
{
((IAttacker)source).Attack(target, !_isEventBased);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
namespace ModiBuff.Core
{
public sealed class HealActionEffect : BaseEffect, IEventTrigger, IEffect
public sealed class HealActionEffect : IEventTrigger, IEffect
{
private bool _isEventBased;

public void SetEventBased() => _isEventBased = true;

public override void Effect(IUnit target, IUnit source)
public void Effect(IUnit target, IUnit source)
{
((IHealer)source).Heal((IHealable)target, !_isEventBased);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
namespace ModiBuff.Core
{
public sealed class SelfAttackActionEffect : BaseEffect, IEventTrigger, IEffect
public sealed class SelfAttackActionEffect : IEventTrigger, IEffect
{
private bool _isEventBased;

public void SetEventBased() => _isEventBased = true;

public override void Effect(IUnit target, IUnit source)
public void Effect(IUnit target, IUnit source)
{
((IAttacker)target).Attack(target, !_isEventBased);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

namespace ModiBuff.Core
{
public sealed class AddDamageEffect : BaseEffect, ITargetEffect, IStackEffect, IStateEffect, IRevertEffect, IEffect
public sealed class AddDamageEffect : ITargetEffect, IStackEffect, IStateEffect, IRevertEffect, IEffect
{
public bool IsRevertible { get; }

Expand All @@ -29,7 +29,7 @@ private AddDamageEffect(float damage, bool revertible, StackEffectType stackEffe

public void SetTargeting(Targeting targeting) => _targeting = targeting;

public override void Effect(IUnit target, IUnit source)
public void Effect(IUnit target, IUnit source)
{
if (IsRevertible)
_totalAddedDamage += _damage + _extraDamage;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace ModiBuff.Core
{
public sealed class ApplierEffect : BaseEffect, ITargetEffect, IEffect, IStackEffect
public sealed class ApplierEffect : ITargetEffect, IStackEffect, IEffect
{
private readonly int _modifierId;
private Targeting _targeting;
Expand All @@ -25,7 +25,7 @@ public ApplierEffect(string modifierName)

public void SetTargeting(Targeting targeting) => _targeting = targeting;

public override void Effect(IUnit target, IUnit source)
public void Effect(IUnit target, IUnit source)
{
switch (_targeting)
{
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace ModiBuff.Core
{
public sealed class DamageEffect : BaseEffect, ITargetEffect, IEventTrigger, IStackEffect, IStateEffect, IEffect
public sealed class DamageEffect : ITargetEffect, IEventTrigger, IStackEffect, IStateEffect, IEffect
{
private readonly float _baseDamage;
private readonly StackEffectType _stackEffect;
Expand All @@ -27,7 +27,7 @@ private DamageEffect(float damage, StackEffectType stackEffect, Targeting target
public void SetTargeting(Targeting targeting) => _targeting = targeting;
public void SetEventBased() => _isEventBased = true;

public override void Effect(IUnit target, IUnit source)
public void Effect(IUnit target, IUnit source)
{
#if DEBUG && !MODIBUFF_PROFILE
if (target is not IDamagable)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
namespace ModiBuff.Core
{
public sealed class EventEffect : BaseEffect, IRevertEffect, IEffect
public sealed class EventEffect : IRevertEffect, IEffect
{
//Always revert event effect?
public bool IsRevertible => true;
Expand All @@ -22,7 +22,7 @@ public EventEffect(IEffect[] effects, EffectOnEvent effectOnEvent)
_effectOnEvent = effectOnEvent;
}

public override void Effect(IUnit target, IUnit source)
public void Effect(IUnit target, IUnit source)
{
var eventOwner = (IEventOwner)target;
for (int i = 0; i < _effects.Length; i++)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

namespace ModiBuff.Core
{
public sealed class HealEffect : BaseEffect, ITargetEffect, IEventTrigger, IStateEffect, IStackEffect, IRevertEffect, IEffect
public sealed class HealEffect : ITargetEffect, IEventTrigger, IStateEffect, IStackEffect, IRevertEffect, IEffect
{
public bool IsRevertible { get; }

Expand Down Expand Up @@ -31,7 +31,7 @@ private HealEffect(float heal, bool revertible, StackEffectType stack, Targeting
public void SetTargeting(Targeting targeting) => _targeting = targeting;
public void SetEventBased() => _isEventBased = true;

public override void Effect(IUnit target, IUnit source)
public void Effect(IUnit target, IUnit source)
{
if (IsRevertible)
_totalHeal = _heal + _extraHeal;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
namespace ModiBuff.Core
{
public class RemoveEffect : BaseEffect, IRemoveEffect, IModifierIdOwner, IShallowClone<RemoveEffect>
public sealed class RemoveEffect : IRemoveEffect, IModifierIdOwner, IShallowClone<RemoveEffect>
{
private IRevertEffect[] _revertibleEffects;
private int _id;
Expand All @@ -18,7 +18,7 @@ public void SetRevertibleEffects(IRevertEffect[] revertibleEffects)
_revertibleEffects = revertibleEffects;
}

public override void Effect(IUnit target, IUnit source)
public void Effect(IUnit target, IUnit source)
{
//Debug.Log("RemoveEffect Effect, modifier id: " + _modifier.Id);
for (int i = 0; i < _revertibleEffects.Length; i++)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
namespace ModiBuff.Core
{
public sealed class StatusEffectEffect : BaseEffect, IStateEffect, IStackEffect, IRevertEffect, IEffect
public sealed class StatusEffectEffect : IStateEffect, IStackEffect, IRevertEffect, IEffect
{
public bool IsRevertible { get; }

Expand All @@ -20,7 +20,7 @@ public StatusEffectEffect(StatusEffectType statusEffectType, float duration, boo
_stackEffect = stackEffect;
}

public override void Effect(IUnit target, IUnit source)
public void Effect(IUnit target, IUnit source)
{
if (IsRevertible)
_totalDuration = _duration + _extraDuration;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,14 @@ public interface IEffect
{
/// <param name="source">owner/acter</param>
void Effect(IUnit target, IUnit source);
}

void Effect(IList<IUnit> targets, IUnit source);
public static class EffectExtensions
{
public static void Effect(this IEffect effect, IList<IUnit> targets, IUnit source)
{
for (int i = 0; i < targets.Count; i++)
effect.Effect(targets[i], source);
}
}
}

0 comments on commit 7455532

Please sign in to comment.