public static Entity CreateEntity(EntityState es) {
            var entity = new Entity(es.TextureName, es.Id);

            AppendStateToEntity(entity, es);

            return entity;
        }
 public static void AppendStateToEntity(Entity entity, EntityState es) {
     // погрешность в ~ 3 пикселя не правим
     if (Math.Abs(entity.PositionX - es.PositionX) > 4) {
         entity.PositionX = es.PositionX;
     }
     if (Math.Abs(entity.PositionY - es.PositionY) > 4) {
         entity.PositionY = es.PositionY;
     }
     entity.FlipX = es.FlipX;
     entity.Tag = es.Tag;
     entity.Scale = es.Scale;
     entity.Speed = es.Speed;
     entity.AttackDamage = es.AttackDamage;
     entity.Direction = es.Direction;
     entity.Hp = es.Hp;
     entity.ActionState = es.ActionState;
 }
 public static EntityState ParseEntity(Entity entity) {
     var es = new EntityState(entity.Id) {
         PositionX = entity.PositionX,
         PositionY = entity.PositionY,
         FlipX = entity.FlipX,
         Speed = entity.Speed,
         Direction = entity.Direction,
         AttackDamage = entity.AttackDamage,
         ActionState = entity.ActionState,
         Tag = entity.Tag,
         Scale = entity.ScaleX,
         TextureName = entity.Texture.Name.ToString(),
         Hp = new Stat(entity.Hp.Maximum) {
             Current = entity.Hp.Current,
         }
     };
     return es;
 }
        /// <summary>
        ///     Обновляет состояние игрока, полученное от клиента
        ///     Обновляется только его позиция
        /// </summary>
        internal void AppendPlayerState(EntityState es) {
            Entity player = GetPlayer(es.Id);

            if (player != null) {
                player.PositionX = es.PositionX;
                player.PositionY = es.PositionY;
                player.FlipX = es.FlipX;
            }
        }