Code structure cleanup.
This commit is contained in:
33
Assets/Cryville/Crtr/Skin/EffectManager.cs
Normal file
33
Assets/Cryville/Crtr/Skin/EffectManager.cs
Normal file
@@ -0,0 +1,33 @@
|
||||
using Cryville.Common;
|
||||
using Cryville.Common.Collections.Specialized;
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Cryville.Crtr.Skin {
|
||||
public class EffectManager {
|
||||
readonly IntKeyedDictionary<EffectGroup> _groups
|
||||
= new IntKeyedDictionary<EffectGroup>();
|
||||
public EffectManager(PdtSkin skin) {
|
||||
foreach (var e in skin.effects) {
|
||||
_groups.Add(e.Key.Key, new EffectGroup(e.Value));
|
||||
}
|
||||
}
|
||||
public void Tick(double time) {
|
||||
foreach (var g in _groups) g.Value.Tick(time);
|
||||
}
|
||||
public void Emit(int id, float index) {
|
||||
GetGroup(id).Emit(index);
|
||||
}
|
||||
public void EmitSelf(int id, float index, Transform target) {
|
||||
GetGroup(id).Emit(index, target);
|
||||
}
|
||||
EffectGroup GetGroup(int id) {
|
||||
EffectGroup result;
|
||||
if (_groups.TryGetValue(id, out result)) return result;
|
||||
throw new ArgumentException(string.Format("The effect \"{0}\" is not found", IdentifierManager.Shared.Retrieve(id)));
|
||||
}
|
||||
public void Dispose() {
|
||||
foreach (var g in _groups) g.Value.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user