World.GameActors.GameObjects.Avatar.PerformPickup C# (CSharp) Method

PerformPickup() private method

private PerformPickup ( IAtlas atlas, ITilesetTable tilesetTable ) : bool
atlas IAtlas
tilesetTable ITilesetTable
return bool
        private bool PerformPickup(IAtlas atlas, ITilesetTable tilesetTable)
        {
            // check tile in front of
            List<GameActorPosition> targets = GetInteractableTilesInFrontOf(atlas);
            // if no tile, check objects
            if (targets.Count == 0)
            {
                targets = GetInteractableObjectsInFrontOf(atlas);
            }
            if (targets.Count == 0) return false;

            foreach (GameActorPosition target in targets)
            {
                IPickableGameActor interactableTarget = target.Actor as IPickableGameActor;
                if (interactableTarget == null) continue;
                GameAction pickUpAction = new PickUp(this);
                interactableTarget.PickUp(atlas, pickUpAction, target.Position, tilesetTable);

                RemoveSpeed(target);
                return true;
            }
            return false;
        }