Exemplo n.º 1
0
    private void RPC_CreateKey(BaseEntity.RPCMessage rpc)
    {
        if (!rpc.player.CanInteract() || this.IsLocked() && !this.HasLockPermission(rpc.player))
        {
            return;
        }
        ItemDefinition itemDefinition = ItemManager.FindItemDefinition(this.keyItemType.itemid);

        if (Object.op_Equality((Object)itemDefinition, (Object)null))
        {
            Debug.LogWarning((object)("RPC_CreateKey: Itemdef is missing! " + (object)this.keyItemType));
        }
        else
        {
            ItemBlueprint blueprint = ItemManager.FindBlueprint(itemDefinition);
            if (!rpc.player.inventory.crafting.CanCraft(blueprint, 1))
            {
                return;
            }
            Item.InstanceData instanceData = (Item.InstanceData)Pool.Get <Item.InstanceData>();
            instanceData.dataInt = (__Null)this.keyCode;
            rpc.player.inventory.crafting.CraftItem(blueprint, rpc.player, instanceData, 1, 0, (Item)null);
            if (this.firstKeyCreated)
            {
                return;
            }
            this.LockLock(rpc.player);
            this.SendNetworkUpdate(BasePlayer.NetworkQueue.Update);
            this.firstKeyCreated = true;
        }
    }
Exemplo n.º 2
0
    public bool CraftItem(
        ItemBlueprint bp,
        BasePlayer owner,
        Item.InstanceData instanceData = null,
        int amount             = 1,
        int skinID             = 0,
        Item fromTempBlueprint = null)
    {
        if (!this.CanCraft(bp, amount))
        {
            return(false);
        }
        ++this.taskUID;
        ItemCraftTask task = (ItemCraftTask)Pool.Get <ItemCraftTask>();

        task.blueprint = bp;
        this.CollectIngredients(bp, task, amount, owner);
        task.endTime      = 0.0f;
        task.taskUID      = this.taskUID;
        task.owner        = owner;
        task.instanceData = instanceData;
        if (task.instanceData != null)
        {
            task.instanceData.ShouldPool = (__Null)0;
        }
        task.amount = amount;
        task.skinID = skinID;
        if (fromTempBlueprint != null && task.takenItems != null)
        {
            fromTempBlueprint.RemoveFromContainer();
            task.takenItems.Add(fromTempBlueprint);
            task.conditionScale = 0.5f;
        }
        object obj = Interface.CallHook("OnItemCraft", (object)task, (object)owner, (object)fromTempBlueprint);

        if (obj is bool)
        {
            return((bool)obj);
        }
        this.queue.Enqueue(task);
        if (Object.op_Inequality((Object)task.owner, (Object)null))
        {
            task.owner.Command("note.craft_add", (object)task.taskUID, (object)task.blueprint.targetItem.itemid, (object)amount, (object)task.skinID);
        }
        return(true);
    }
Exemplo n.º 3
0
 public void ReceiveInstanceData(Item.InstanceData data)
 {
     this.genetics = (int)data.dataInt;
 }
Exemplo n.º 4
0
 public virtual void Load(Item load)
 {
     if (Object.op_Equality((Object)this.info, (Object)null) || this.info.itemid != load.itemid)
     {
         this.info = ItemManager.FindItemDefinition((int)load.itemid);
     }
     this.uid            = (uint)load.UID;
     this.name           = (string)load.name;
     this.text           = (string)load.text;
     this.amount         = (int)load.amount;
     this.position       = (int)load.slot;
     this.busyTime       = (float)load.locktime;
     this.removeTime     = (float)load.removetime;
     this.flags          = (Item.Flag)load.flags;
     this.worldEnt.uid   = (uint)load.worldEntity;
     this.heldEntity.uid = (uint)load.heldEntity;
     if (this.instanceData != null)
     {
         this.instanceData.ShouldPool = (__Null)1;
         this.instanceData.ResetToPool();
         this.instanceData = (Item.InstanceData)null;
     }
     this.instanceData = (Item.InstanceData)load.instanceData;
     if (this.instanceData != null)
     {
         this.instanceData.ShouldPool = (__Null)0;
     }
     this.skin = (ulong)load.skinid;
     if (Object.op_Equality((Object)this.info, (Object)null) || this.info.itemid != load.itemid)
     {
         this.info = ItemManager.FindItemDefinition((int)load.itemid);
     }
     if (Object.op_Equality((Object)this.info, (Object)null))
     {
         return;
     }
     this._condition    = 0.0f;
     this._maxCondition = 0.0f;
     if (load.conditionData != null)
     {
         this._condition    = (float)((Item.ConditionData)load.conditionData).condition;
         this._maxCondition = (float)((Item.ConditionData)load.conditionData).maxCondition;
     }
     else if (this.info.condition.enabled)
     {
         this._condition    = this.info.condition.max;
         this._maxCondition = this.info.condition.max;
     }
     if (load.contents != null)
     {
         if (this.contents == null)
         {
             this.contents = new ItemContainer();
             if (this.isServer)
             {
                 this.contents.ServerInitialize(this, (int)((ItemContainer)load.contents).slots);
             }
         }
         this.contents.Load((ItemContainer)load.contents);
     }
     if (!this.isServer)
     {
         return;
     }
     this.removeTime = 0.0f;
     this.OnItemCreated();
 }