init
This commit is contained in:
@@ -0,0 +1,49 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Linq;
|
||||
using Sirenix.OdinInspector;
|
||||
using UnityEngine;
|
||||
using VOID.Generic.Dict;
|
||||
using VOID.Generic.Objects.Unit;
|
||||
|
||||
namespace VOID.Generic.Status.Effect
|
||||
{
|
||||
[TypeRegistryItem("Change Sub Attribute - Amount")]
|
||||
public class PointChangeSubAttributeEffect : BasicEffect
|
||||
{
|
||||
# region Editor
|
||||
|
||||
// Disallow setting via editor weapon-related attributes - those will be managed automatically by weapon data
|
||||
private IEnumerable GetSubAttributeTypes() => Enum.GetValues(typeof(SubAttributeType)).Cast<SubAttributeType>()
|
||||
.Where(aubAttributeType => aubAttributeType is not SubAttributeType.DamageMin and not SubAttributeType.DamageMax
|
||||
and not SubAttributeType.CriticalDamageChance and not SubAttributeType.CriticalDamageMultiplier)
|
||||
.Select(subAttributeType => new ValueDropdownItem(Enum.GetName(typeof(SubAttributeType), subAttributeType), (int)subAttributeType));
|
||||
|
||||
# endregion
|
||||
|
||||
public int pointModificator => _pointModificator;
|
||||
public SubAttributeType subAttributeType => _subAttributeType;
|
||||
[SerializeField, Required] private int _pointModificator;
|
||||
[SerializeField, Required, ValueDropdown(nameof(GetSubAttributeTypes))] private SubAttributeType _subAttributeType;
|
||||
|
||||
public override void OnApply()
|
||||
{
|
||||
if (forObject is not UnitObject forUnit) return;
|
||||
|
||||
forUnit.unitDataCalculator.Queue(_subAttributeType);
|
||||
}
|
||||
|
||||
public override void OnEnd()
|
||||
{
|
||||
if (forObject is not UnitObject forUnit) return;
|
||||
|
||||
forUnit.unitDataCalculator.Queue(_subAttributeType);
|
||||
}
|
||||
|
||||
public override void OnTurnSelfEnd() {}
|
||||
public override void OnTurnSelfStart() {}
|
||||
public override void OnCancel() => OnEnd();
|
||||
|
||||
public override string GetSimpleDescription() => $"{(_pointModificator >= 0f ? "+" : "-")}{Mathf.Abs(_pointModificator)} {_subAttributeType}";
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user