2024-03-19 17:42:38 +03:00
|
|
|
using Characters;
|
2024-02-19 21:00:36 +03:00
|
|
|
using UnityEngine;
|
|
|
|
using System;
|
|
|
|
using System.Collections;
|
|
|
|
using Mirror;
|
|
|
|
|
|
|
|
namespace Debuffs
|
|
|
|
{
|
|
|
|
public class DebuffBase
|
|
|
|
{
|
|
|
|
public event Action<DebuffBase, Pawn> OnDebuffStart;
|
|
|
|
public event Action<DebuffBase, Pawn> OnDebuffEnd;
|
|
|
|
|
|
|
|
protected float duration = 5f;
|
|
|
|
|
|
|
|
public float Duration => duration;
|
|
|
|
|
|
|
|
public virtual void Enable(Pawn pawn) { }
|
|
|
|
public virtual void Disable(Pawn pawn) { }
|
|
|
|
|
|
|
|
public virtual IEnumerator Act(Pawn pawn)
|
|
|
|
{
|
|
|
|
OnDebuffStart?.Invoke(this, pawn);
|
|
|
|
|
|
|
|
yield return new WaitForSeconds(duration);
|
|
|
|
|
|
|
|
OnDebuffEnd?.Invoke(this, pawn);
|
|
|
|
}
|
|
|
|
|
|
|
|
public DebuffBase() { }
|
|
|
|
|
|
|
|
public DebuffBase(float duration)
|
|
|
|
{
|
|
|
|
this.duration = duration;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public static class DebuffSerializer
|
|
|
|
{
|
|
|
|
public static void WriteDebuff(this NetworkWriter writer, DebuffBase value)
|
|
|
|
{
|
|
|
|
writer.WriteFloat(value.Duration);
|
|
|
|
}
|
|
|
|
|
|
|
|
public static DebuffBase ReadDebuff(this NetworkReader reader)
|
|
|
|
{
|
|
|
|
return new TaserDebuff(reader.ReadFloat());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|