Ejemplo n.º 1
0
 public static Node UpdateForwardMotion() =>
 Node.Inject((Resource <Resources.Time> .Read time) =>
             Node.System <Phases.Run> .RunEach((ref ForwardMotion motion, ref Rotation rotation, ref Velocity velocity) =>
 {
     var x       = Math.Cos(rotation.Angle);
     var y       = Math.Sin(rotation.Angle);
     velocity.X += x * motion.Speed * time.Value.Delta;
     velocity.Y += y * motion.Speed * time.Value.Delta;
 }));
Ejemplo n.º 2
0
 public static Node UpdateGame() =>
 Node.Inject((Components <Components.Controller> .Read controllers, Emitter <Messages.DoQuit> doQuit) =>
             Node.System <Phases.Run> .Run(() =>
 {
     if (controllers.Has())
     {
         return;
     }
     doQuit.Emit();
 }));
Ejemplo n.º 3
0
 public static Node UpdateDeath() =>
 Node.Inject((AllEntities entities, Emitter <Messages.OnKill> onKill) =>
             Node.System <Phases.Run> .RunEach((Entity entity, ref Health health) =>
 {
     if (health.Current <= 0)
     {
         onKill.Emit(new Messages.OnKill {
             Entity = entity
         });
         entities.Destroy(entity);
     }
 }));
Ejemplo n.º 4
0
 public static Node UpdateLifetime() =>
 Node.Inject((Resource <Resources.Time> time, Emitter <Messages.OnKill> onKill) =>
             Node.System <Phases.Run> .RunEach((Entity entity, ref Lifetime lifetime) =>
 {
     lifetime.Current += time.Value.Delta;
     if (lifetime.Current >= lifetime.Duration)
     {
         // BUG: destroy entity?
         onKill.Emit(new Messages.OnKill {
             Entity = entity
         });
     }
 }));
Ejemplo n.º 5
0
 public static Node InitializeGame() =>
 Node.Inject((AllEntities entities, AllComponents components) =>
             Node.System <Phases.Initialize> .Run(() => entities.Player(components)));