Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class ProcessingModule : ProcessingBase, ITick
- {
- Group<ComponentViewModule, ComponentState> groupBrains;
- [GroupBy(Tag.StateActive)]
- Group<ComponentViewModule> groupActive;
- [GroupBy(Tag.StateInactive)]
- Group<ComponentViewModule> groupInactive;
- public ProcessingModule()
- {
- groupBrains.Add += entity =>
- {
- var cViewModule = entity.ComponentViewModel();
- foreach (var a in cViewModule.core)
- {
- a(entity);
- }
- };
- groupActive.Add += entity =>
- {
- var cViewModule = entity.ComponentViewModel();
- foreach (var a in cViewModule.active)
- {
- a(entity);
- }
- };
- groupInactive.Add += entity =>
- {
- var cViewModule = entity.ComponentViewModel();
- foreach (var a in cViewModule.inactive)
- {
- a(entity);
- }
- };
- }
- public void Tick()
- {
- var delta = Time.delta;
- foreach (var entity in groupBrains)
- {
- var cViewModule = entity.ComponentViewModel();
- foreach (var a in cViewModule.coreUpdate)
- {
- var cState = entity.ComponentState();
- a(entity, delta);
- if (cState.current != cState.previous)
- {
- if (cState.previous != -1)
- entity.Remove(cState.previous);
- entity.Add(cState.current);
- cState.previous = cState.current;
- }
- }
- }
- foreach (var entity in groupActive)
- {
- var cViewModule = entity.ComponentViewModel();
- foreach (var a in cViewModule.activeUpdate)
- {
- a(entity, delta);
- }
- }
- foreach (var entity in groupInactive)
- {
- var cViewModule = entity.ComponentViewModel();
- foreach (var a in cViewModule.inactiveUpdate)
- {
- a(entity, delta);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement