Exemplo n.º 1
0
 /// <summary>
 /// Entry point for wrapping interaction of wrappable objects/items.
 /// Will evaluate if the wrap can happen, giving a message to the performer in case it can not
 /// and doing the wrap if successful.
 /// </summary>
 /// <param name="performer"></param>
 /// <param name="paper"></param>
 public void TryWrap(GameObject performer, WrappingPaper paper)
 {
     if (CanBeWrapped(performer, paper))
     {
         Wrap(performer, paper);
     }
 }
Exemplo n.º 2
0
        private void FinishWrapping(WrappingPaper paper)
        {
            GameObject result;

            switch (paper.WrapType)
            {
            case WrapType.Normal:
                result = normalPackagePrefab;
                break;

            case WrapType.Festive:
                result = festivePackagePrefab;
                break;

            default:
                Logger.LogError($"Tried to wrap {gameObject} with unknown type of paper", Category.Cargo);
                result = normalPackagePrefab;
                break;
            }

            result = Spawn.ServerPrefab(result, gameObject.AssumedWorldPosServer()).GameObject;
            var wrap = result.GetComponent <WrappedObject>();

            wrap.SetContent(gameObject);

            wrap.SetContainerTypeSprite(spriteType);
            Inventory.ServerConsume(paper.ItemSlot, neededPaperAmount);
        }
        protected override bool CanBeWrapped(GameObject performer, WrappingPaper paper)
        {
            if (paper.PaperAmount >= neededPaperAmount)
            {
                return(true);
            }

            Chat.AddExamineMsg(
                performer,
                $"It seems like I don't have enough {paper.gameObject.ExpensiveName()} to wrap {gameObject.ExpensiveName()}");

            return(false);
        }
        protected override void Wrap(GameObject performer, WrappingPaper paper)
        {
            var cfg = new StandardProgressActionConfig(
                StandardProgressActionType.Restrain);

            Chat.AddActionMsgToChat(
                performer,
                string.Format(actionTextOriginator, gameObject.ExpensiveName(), paper.gameObject.ExpensiveName()),
                string.Format(actionTextOthers, performer.ExpensiveName(), gameObject.ExpensiveName(), paper.gameObject.ExpensiveName()));

            StandardProgressAction.Create(
                cfg,
                () => FinishWrapping(paper)
                ).ServerStartProgress(ActionTarget.Object(performer.RegisterTile()), wrapTime, performer);
        }
        private void FinishWrapping(WrappingPaper paper)
        {
            GameObject result = null;

            switch (paper.WrapType)
            {
            case WrapType.Normal:
                result = normalPackagePrefab;
                break;

            case WrapType.Festive:
                result = festivePackagePrefab;
                break;

            default:
                Logger.LogError($"Tried to wrap {gameObject} with unknown type of paper", Category.Interaction);
                result = normalPackagePrefab;
                break;
            }

            result = Spawn.ServerPrefab(result, gameObject.AssumedWorldPosServer()).GameObject;
            var wrap = result.GetComponent <WrappedObject>();

            wrap.SetContent(gameObject);
            ContainerTypeSprite spriteType;

            switch (registerCloset.closetType)
            {
            case ClosetType.LOCKER:
                spriteType = ContainerTypeSprite.Locker;
                break;

            case ClosetType.CRATE:
                spriteType = ContainerTypeSprite.Crate;
                break;

            default:
                Logger.LogWarning($"{gameObject} is not a locker nor crate but it an attempt to wrap mas done." +
                                  "We set the crate sprite and go on.");
                spriteType = ContainerTypeSprite.Crate;
                break;
            }

            wrap.SetContainerTypeSprite(spriteType);
            Inventory.ServerConsume(paper.ItemSlot, neededPaperAmount);
        }
Exemplo n.º 6
0
        private void FinishWrapping(WrappingPaper paper)
        {
            GameObject result = null;

            switch (paper.WrapType)
            {
            case WrapType.Normal:
                result = normalPackagePrefab;
                break;

            case WrapType.Festive:
                result = festivePackagePrefab;
                break;

            default:
                Logger.LogError($"Tried to wrap {gameObject} with unknown type of paper", Category.Cargo);
                result = normalPackagePrefab;
                break;
            }

            result = Spawn.ServerPrefab(result, gameObject.AssumedWorldPosServer()).GameObject;
            var wrap    = result.GetComponent <WrappedItem>();
            var package = GetPackageType();

            wrap.SetSprite(package);
            wrap.SetSize(itemAttributesV2.Size);

            if (pickupable != null && pickupable.ItemSlot != null)
            {
                Inventory.ServerAdd(
                    wrap.gameObject,
                    pickupable.ItemSlot,
                    ReplacementStrategy.DropOther);
            }

            wrap.SetContent(gameObject);
            Inventory.ServerConsume(paper.ItemSlot, GetPaperAmount());
        }
Exemplo n.º 7
0
 protected abstract void Wrap(GameObject performer, WrappingPaper paper);
Exemplo n.º 8
0
 protected abstract bool CanBeWrapped(GameObject performer, WrappingPaper paper);