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; }));
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(); }));
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); } }));
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 }); } }));
public static Node InitializeGame() => Node.Inject((AllEntities entities, AllComponents components) => Node.System <Phases.Initialize> .Run(() => entities.Player(components)));