Exemplo n.º 1
0
    protected void RemoveFromBag()
    {
        Pathea.PackageCmpt pkg = Pathea.PeCreature.Instance.mainPlayer.packageCmpt;

        //some item stack count > 1, seed eg.
        if (itemDragging.itemObj.stackCount > 1)
        {
            pkg.DestroyItem(itemDragging.itemObj, 1);
        }
        else
        {
            pkg.Remove(itemDragging.itemObj);
        }

        if (Pathea.PlayerPackageCmpt.LockStackCount &&
            !ItemAsset.ItemMgr.IsCreationItem(itemDragging.itemObj.protoId))
        {
            Pathea.PlayerPackageCmpt playerPkg = pkg as Pathea.PlayerPackageCmpt;
            if (playerPkg != null)
            {
                playerPkg.package.Add(itemDragging.itemObj.protoId, 1);
            }
        }
    }
Exemplo n.º 2
0
        public bool Use(ItemAsset.ItemObject item)
        {
            CheckMainPlayerUseItem(item.protoId);
            bool destroy = false;

            destroy = ExtractBundle(item.GetCmpt <ItemAsset.Bundle>()) || destroy;
            destroy = ConsumeItem(item.GetCmpt <ItemAsset.Consume>()) || destroy;
            destroy = LearnReplicatorFormula(item.GetCmpt <ItemAsset.ReplicatorFormula>()) || destroy;
            destroy = LearnMetalScan(item.GetCmpt <ItemAsset.MetalScan>()) || destroy;

            bool remove = TakeOnEquipment(item.GetCmpt <ItemAsset.Equip>());

            if (mPkg != null)
            {
                if (destroy)
                {
                    mPkg.DestroyItem(item, 1);
                }
                else if (remove)
                {
                    mPkg.Remove(item);
                }
            }

            bool ret = destroy || remove;

            if (ret)
            {
                eventor.Dispatch(new EventArg()
                {
                    itemObj = item
                }, this);
            }

            return(ret);
        }