Advertisement
Guest User

Untitled

a guest
Feb 20th, 2019
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.71 KB | None | 0 0
  1. public class ProcessingModule : ProcessingBase, ITick
  2.     {
  3.         Group<ComponentViewModule, ComponentState> groupBrains;
  4.  
  5.         [GroupBy(Tag.StateActive)]
  6.         Group<ComponentViewModule> groupActive;
  7.  
  8.         [GroupBy(Tag.StateInactive)]
  9.         Group<ComponentViewModule> groupInactive;
  10.  
  11.         public ProcessingModule()
  12.         {
  13.             groupBrains.Add += entity =>
  14.             {
  15.                 var cViewModule = entity.ComponentViewModel();
  16.                 foreach (var a in cViewModule.core)
  17.                 {
  18.                     a(entity);
  19.                 }
  20.             };
  21.  
  22.             groupActive.Add += entity =>
  23.             {
  24.                 var cViewModule = entity.ComponentViewModel();
  25.                 foreach (var a in cViewModule.active)
  26.                 {
  27.                     a(entity);
  28.                 }
  29.             };
  30.  
  31.             groupInactive.Add += entity =>
  32.             {
  33.                 var cViewModule = entity.ComponentViewModel();
  34.                 foreach (var a in cViewModule.inactive)
  35.                 {
  36.                     a(entity);
  37.                 }
  38.             };
  39.         }
  40.  
  41.         public void Tick()
  42.         {
  43.             var delta = Time.delta;
  44.  
  45.             foreach (var entity in groupBrains)
  46.             {
  47.                 var cViewModule = entity.ComponentViewModel();
  48.                 foreach (var a in cViewModule.coreUpdate)
  49.                 {
  50.                     var cState = entity.ComponentState();
  51.                     a(entity, delta);
  52.                    
  53.                     if (cState.current != cState.previous)
  54.                     {
  55.                         if (cState.previous != -1)
  56.                             entity.Remove(cState.previous);
  57.  
  58.                         entity.Add(cState.current);
  59.  
  60.                         cState.previous = cState.current;
  61.                     }
  62.                    
  63.                 }
  64.             }
  65.  
  66.             foreach (var entity in groupActive)
  67.             {
  68.                 var cViewModule = entity.ComponentViewModel();
  69.                 foreach (var a in cViewModule.activeUpdate)
  70.                 {
  71.                     a(entity, delta);
  72.                 }
  73.             }
  74.  
  75.             foreach (var entity in groupInactive)
  76.             {
  77.                 var cViewModule = entity.ComponentViewModel();
  78.                 foreach (var a in cViewModule.inactiveUpdate)
  79.                 {
  80.                     a(entity, delta);
  81.                 }
  82.             }
  83.  
  84.         }
  85.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement