public override MSystemJob GetJob(MEntity entity) { ComMovement _comMovement = entity.Get <ComMovement>(C.Movement); ComPosition _comPosition = entity.Get <ComPosition>(C.Position); return(new MSystemJob <ComMovement, ComPosition>(_comMovement, _comPosition, UpdatePosition)); }
public static void UpdatePosition(ComMovement move, ComPosition comPosition, float deltaTime) { var m = move.MoveDirection * move.MoveSpeed * deltaTime; //arrive if (move.HasTarget) { var d = move.MoveTarget - comPosition.Position; if (d.sqrMagnitude <= m.sqrMagnitude) { move.IsArrived = true; m = d; } } comPosition.Position += m; }