Drag and Drop + Zoooooooom
Refactored inventory drag & drop to use new global drag & drop management Enabled Drag & Drop from inventory panel to action bar Enabled gear and consumable item binding Fixed stat modifier behavior to allow it to be toggled Fixed Switch behavior to make it bindable Added lambda multiplier to aether drive so that stat mod can target it
This commit is contained in:
parent
82c8041765
commit
7cfc5cd04f
21 changed files with 352 additions and 323 deletions
|
|
@ -34,7 +34,7 @@ public class StatModifierData : BehaviorData
|
|||
}
|
||||
|
||||
[Order(-4)]
|
||||
public class StatModifier : Behavior, IInitializableBehavior, IDisposable
|
||||
public class StatModifier : Behavior, IInitializableBehavior, IDisposable, IAlwaysUpdatedBehavior
|
||||
{
|
||||
private StatModifierData _data;
|
||||
|
||||
|
|
@ -42,6 +42,9 @@ public class StatModifier : Behavior, IInitializableBehavior, IDisposable
|
|||
|
||||
private static Type[] _statObjects;
|
||||
|
||||
private bool _applied;
|
||||
private bool _executed;
|
||||
|
||||
private static Type[] StatObjects => _statObjects = _statObjects ?? typeof(BehaviorData).GetAllChildClasses()
|
||||
.Concat(typeof(EquippableItemData).GetAllChildClasses()).ToArray();
|
||||
|
||||
|
|
@ -83,19 +86,41 @@ public class StatModifier : Behavior, IInitializableBehavior, IDisposable
|
|||
}
|
||||
}
|
||||
|
||||
public override bool Execute(float dt)
|
||||
private void ApplyModifier()
|
||||
{
|
||||
_applied = true;
|
||||
foreach (var stat in _stats)
|
||||
(_data.Type == StatModifierType.Constant
|
||||
? stat.GetConstantModifiers(Entity)
|
||||
: stat.GetScaleModifiers(Entity))[this] = Evaluate(_data.Modifier);
|
||||
}
|
||||
|
||||
private void RemoveModifier()
|
||||
{
|
||||
_applied = false;
|
||||
foreach (var stat in _stats)
|
||||
(_data.Type == StatModifierType.Constant ? stat.GetConstantModifiers(Entity) : stat.GetScaleModifiers(Entity)).Remove(this);
|
||||
}
|
||||
|
||||
public override bool Execute(float dt)
|
||||
{
|
||||
_executed = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
foreach (var stat in _stats)
|
||||
(_data.Type == StatModifierType.Constant ? stat.GetConstantModifiers(Entity) : stat.GetScaleModifiers(Entity)).Remove(this);
|
||||
if(_applied)
|
||||
RemoveModifier();
|
||||
}
|
||||
|
||||
public void Update(float delta)
|
||||
{
|
||||
if(_executed && !_applied)
|
||||
ApplyModifier();
|
||||
if(!_executed && _applied)
|
||||
RemoveModifier();
|
||||
_executed = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue