Advertisement
Guest User

Untitled

a guest
Jul 22nd, 2019
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.66 KB | None | 0 0
  1. public class MoveSystem : ISystem, IUpdatable
  2. {
  3.  
  4.     void ISystem.Update(GameState State) {
  5.  
  6.         State.Components.FilterBy<Moving>().ForEach((i)=> {
  7.            
  8.             i.Entity.Components.FindAll(c => c is Velocity).ForEach((velc) =>
  9.             {
  10.                 var speed = (i as Moving).Speed * TimeService.DeltaTime;
  11.                 var vec = (velc as Velocity).Vector;
  12.                 TransformService.AddPosition(i.Entity, vec.X * speed, vec.Y * speed, vec.Z * speed);
  13.                 var animation = i.Entity.Components.Find(c => c is AnimationState) as AnimationState;
  14.                 if (animation != null && animation.Name<AnimationState.EName.Run)
  15.                 {
  16.                     animation.SetState(AnimationState.EName.Run);
  17.                 }
  18.             });
  19.         });
  20.     }
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement