コード例 #1
0
        private Item GetBlueprint(ItemDefinition learnableItem, int amount = 1)
        {
            Item item = ItemManager.Create(ResearchTable.GetBlueprintTemplate(), amount);

            item.blueprintTarget = learnableItem.itemid;

            return(item);
        }
コード例 #2
0
    public void ResearchAttemptFinished()
    {
        Item targetItem = this.GetTargetItem();
        Item scrapItem  = this.GetScrapItem();

        if (targetItem != null && scrapItem != null)
        {
            int    num = this.ScrapForResearch(targetItem);
            object obj = Interface.CallHook("OnItemResearched", this, num);
            if (obj is int)
            {
                num = (int)obj;
            }
            if (scrapItem.amount >= num)
            {
                if (scrapItem.amount > num)
                {
                    scrapItem.UseItem(num);
                }
                else
                {
                    this.inventory.Remove(scrapItem);
                    scrapItem.RemoveFromContainer();
                    scrapItem.Remove(0f);
                }
                this.inventory.Remove(targetItem);
                targetItem.Remove(0f);
                Item item = ItemManager.Create(ResearchTable.GetBlueprintTemplate(), 1, (ulong)0);
                item.blueprintTarget = targetItem.info.itemid;
                if (!item.MoveToContainer(this.inventory, 0, true))
                {
                    item.Drop(this.GetDropPosition(), this.GetDropVelocity(), new Quaternion());
                }
                if (this.researchSuccessEffect.isValid)
                {
                    Effect.server.Run(this.researchSuccessEffect.resourcePath, this, 0, Vector3.zero, Vector3.zero, null, false);
                }
            }
        }
        base.SendNetworkUpdateImmediate(false);
        if (this.user != null)
        {
            this.user.inventory.loot.SendImmediate();
        }
        this.EndResearch();
    }
コード例 #3
0
    public void ResearchAttemptFinished()
    {
        Item targetItem = this.GetTargetItem();
        Item scrapItem  = this.GetScrapItem();

        if (targetItem != null && scrapItem != null)
        {
            int    amountToConsume = this.ScrapForResearch(targetItem);
            object obj1            = Interface.CallHook("OnItemResearched", (object)this, (object)amountToConsume);
            if (obj1 is int)
            {
                amountToConsume = (int)obj1;
            }
            if (scrapItem.amount >= amountToConsume)
            {
                if (scrapItem.amount <= amountToConsume)
                {
                    this.inventory.Remove(scrapItem);
                    scrapItem.RemoveFromContainer();
                    scrapItem.Remove(0.0f);
                }
                else
                {
                    scrapItem.UseItem(amountToConsume);
                }
                this.inventory.Remove(targetItem);
                targetItem.Remove(0.0f);
                Item obj2 = ItemManager.Create(ResearchTable.GetBlueprintTemplate(), 1, 0UL);
                obj2.blueprintTarget = targetItem.info.itemid;
                if (!obj2.MoveToContainer(this.inventory, 0, true))
                {
                    obj2.Drop(this.GetDropPosition(), this.GetDropVelocity(), (Quaternion)null);
                }
                if (this.researchSuccessEffect.isValid)
                {
                    Effect.server.Run(this.researchSuccessEffect.resourcePath, (BaseEntity)this, 0U, Vector3.get_zero(), Vector3.get_zero(), (Connection)null, false);
                }
            }
        }
        this.SendNetworkUpdateImmediate(false);
        if (Object.op_Inequality((Object)this.user, (Object)null))
        {
            this.user.inventory.loot.SendImmediate();
        }
        this.EndResearch();
    }