2025-07-15 01:14:54 -04:00

45 lines
1.2 KiB
C#

using System.Collections;
using System.Collections.Generic;
using Unity.VisualScripting.YamlDotNet.Core.Tokens;
using UnityEngine;
public class Slow : Status
{
private float _previousSpeedModifier = 1f;
private float _speedModifier = 1f;
public override void Apply(float duration)
{
// reset slow duration
_duration = Mathf.Max(_duration, duration);
// slow entity
EntityLinked.SpeedStatusModifier /= _previousSpeedModifier;
Debug.Log(_speedModifier);
EntityLinked.SpeedStatusModifier *= _speedModifier;
}
public override void Unapply()
{
// bring entity to normal speed
EntityLinked.SpeedStatusModifier /= _speedModifier;
// stop effect
Destroy(this);
}
/// <summary>
/// A higher intensity results in a stronger slow.
/// Example: An intensity of 0.99 multiplies the entity's speed by 0.01 (which would result in a really low speed)
/// </summary>
public float Intensity
{
get => 1 - _speedModifier;
set
{
_previousSpeedModifier = _speedModifier;
_speedModifier = Mathf.Min(_speedModifier, 1 - value);
}
}
}