[Fix] Refactor project
This commit is contained in:
@@ -38,8 +38,9 @@ namespace YachtDice.Modifiers.Runtime
|
||||
get
|
||||
{
|
||||
int count = 0;
|
||||
for (int i = 0; i < _instances.Count; i++)
|
||||
if (_instances[i].IsActive) count++;
|
||||
foreach (var t in _instances)
|
||||
if (t.IsActive) count++;
|
||||
|
||||
return count;
|
||||
}
|
||||
}
|
||||
@@ -62,7 +63,7 @@ namespace YachtDice.Modifiers.Runtime
|
||||
{
|
||||
if (!_instances.Contains(instance)) return;
|
||||
|
||||
bool wasActive = instance.IsActive;
|
||||
var wasActive = instance.IsActive;
|
||||
instance.IsActive = false;
|
||||
_instances.Remove(instance);
|
||||
_activeCacheDirty = true;
|
||||
@@ -98,9 +99,9 @@ namespace YachtDice.Modifiers.Runtime
|
||||
|
||||
public void ConsumeChargesOnActive()
|
||||
{
|
||||
bool changed = false;
|
||||
var changed = false;
|
||||
|
||||
for (int i = _instances.Count - 1; i >= 0; i--)
|
||||
for (var i = _instances.Count - 1; i >= 0; i--)
|
||||
{
|
||||
var inst = _instances[i];
|
||||
if (!inst.IsActive) continue;
|
||||
@@ -115,20 +116,18 @@ namespace YachtDice.Modifiers.Runtime
|
||||
}
|
||||
}
|
||||
|
||||
if (changed)
|
||||
{
|
||||
_activeCacheDirty = true;
|
||||
OnActiveModifiersChanged?.Invoke(Active);
|
||||
OnChanged?.Invoke();
|
||||
}
|
||||
if (!changed) return;
|
||||
|
||||
_activeCacheDirty = true;
|
||||
OnActiveModifiersChanged?.Invoke(Active);
|
||||
OnChanged?.Invoke();
|
||||
}
|
||||
|
||||
public List<ModifierSaveEntry> GetSaveData()
|
||||
{
|
||||
var entries = new List<ModifierSaveEntry>();
|
||||
for (int i = 0; i < _instances.Count; i++)
|
||||
foreach (var inst in _instances)
|
||||
{
|
||||
var inst = _instances[i];
|
||||
var entry = new ModifierSaveEntry
|
||||
{
|
||||
modifierId = inst.Definition.Id,
|
||||
@@ -158,9 +157,8 @@ namespace YachtDice.Modifiers.Runtime
|
||||
|
||||
if (entries == null) return;
|
||||
|
||||
for (int i = 0; i < entries.Count; i++)
|
||||
foreach (var entry in entries)
|
||||
{
|
||||
var entry = entries[i];
|
||||
var definition = catalog.FindById(entry.modifierId);
|
||||
|
||||
if (definition == null)
|
||||
|
||||
Reference in New Issue
Block a user