示例#1
0
        public void Execute(List <Entity> entities)
        {
            var hero             = entities.SingleEntity();
            var pullDirection    = hero.inputPullItem.Direction;
            var pushablePosition = hero.position.Value - pullDirection;
            var pushableItem     = _pool.PushableItemAt(pushablePosition, pullDirection);

            if (pushableItem != null)
            {
                var newHeroPosition            = hero.position.Value + pullDirection;
                var playerHasOpenSpaceToMoveTo = _pool.OpenTileAt(newHeroPosition);
                if (playerHasOpenSpaceToMoveTo)
                {
                    pushableItem.ReplaceKnocked(pullDirection, false, 0);
                    hero.ReplacePosition(newHeroPosition);
                    hero.ReplaceRotation(LocalDirections.ToRotation(-pullDirection));
                    hero.IsPulling(true);
                }
            }
        }