Beispiel #1
0
    public void Craft()
    {
        if (this.m_Result == ItemID.None)
        {
            DebugUtils.Assert("ERROR - Missing result ItemID! Can't craft item!", true, DebugUtils.AssertType.Info);
            return;
        }
        Item item = this.CreateItem(this.m_Result);

        ItemsManager.Get().OnCrafted(this.m_Result);
        this.m_Result = ItemID.None;
        InventoryBackpack.InsertResult insertResult = InventoryBackpack.Get().InsertItem(item, null, null, true, false, true, true, true);
        if (insertResult != InventoryBackpack.InsertResult.Ok)
        {
            this.AddItem(item, true);
        }
        else
        {
            item.OnTake();
        }
        InventoryBackpack.Get().SetupPocket(item.m_Info.m_BackpackPocket);
        Inventory3DManager.Get().SetNewCraftedItem(item);
        this.CheckResult();
        HUDCrafting.Get().Setup();
    }
Beispiel #2
0
 public void AddItem(Item item, bool setup_pos)
 {
     item.m_OnCraftingTable = true;
     item.StaticPhxRequestAdd();
     this.m_Items.Add(item);
     item.UpdateScale(false);
     item.UpdatePhx();
     if (setup_pos)
     {
         item.gameObject.transform.rotation = Quaternion.identity;
         Vector3 position = this.m_Table.transform.position + item.transform.up * item.m_BoxCollider.size.y * item.transform.localScale.y * 0.5f;
         item.gameObject.transform.position = position;
         Matrix4x4 identity = Matrix4x4.identity;
         Vector3   vector   = -this.m_TableCollider.transform.forward;
         identity.SetColumn(1, vector);
         Vector3 v = Vector3.Cross(this.m_TableCollider.transform.up, vector);
         identity.SetColumn(0, v);
         identity.SetColumn(2, Vector3.Cross(identity.GetColumn(1), identity.GetColumn(0)));
         identity.SetColumn(0, Vector3.Cross(identity.GetColumn(1), identity.GetColumn(2)));
         Quaternion rotation = CJTools.Math.QuaternionFromMatrix(identity);
         item.gameObject.transform.rotation = rotation;
         if (item.m_Info.m_InventoryRotated)
         {
             item.transform.RotateAround(item.m_BoxCollider.bounds.center, item.transform.up, 90f);
         }
     }
     this.CheckResult();
     HUDCrafting.Get().Setup();
 }
Beispiel #3
0
 public void RemoveItem(Item item)
 {
     item.m_OnCraftingTable = false;
     item.StaticPhxRequestRemove();
     this.m_Items.Remove(item);
     this.CheckResult();
     HUDCrafting.Get().Setup();
 }
Beispiel #4
0
 public void RemoveItem(Item item, bool crafting_started = false)
 {
     item.m_Info.m_UsedForCrafting = crafting_started;
     item.StaticPhxRequestRemove();
     item.m_OnCraftingTable = false;
     this.m_Items.Remove(item);
     item.UpdatePhx();
     item.UpdateLayer();
     item.UpdateScale(false);
     this.CheckResult();
     HUDCrafting.Get().Setup();
     InventoryBackpack.Get().CalculateCurrentWeight();
 }
Beispiel #5
0
    public void Craft(List <Item> items)
    {
        if (this.m_Result == ItemID.None)
        {
            DebugUtils.Assert("ERROR - Missing result ItemID! Can't craft item!", true, DebugUtils.AssertType.Info);
            return;
        }
        Item item = this.CreateItem(this.m_Result);
        Dictionary <int, int> dictionary = new Dictionary <int, int>(item.m_Info.m_ComponentsToReturn);

        foreach (Item item2 in items)
        {
            int infoID = (int)item2.GetInfoID();
            if (dictionary.ContainsKey(infoID))
            {
                InventoryBackpack.Get().InsertItem(item2, null, null, true, true, true, true, true);
                Dictionary <int, int> dictionary2 = dictionary;
                int key   = infoID;
                int value = dictionary2[key] - 1;
                dictionary2[key] = value;
                if (dictionary[infoID] == 0)
                {
                    dictionary.Remove(infoID);
                }
            }
            else
            {
                UnityEngine.Object.Destroy(item2.gameObject);
            }
        }
        ItemsManager.Get().OnCrafted(this.m_Result);
        this.m_Result = ItemID.None;
        if (InventoryBackpack.Get().InsertItem(item, null, null, true, false, true, true, true) != InsertResult.Ok)
        {
            this.Activate();
            this.AddItem(item, true);
        }
        else
        {
            item.OnTake();
        }
        InventoryBackpack.Get().SetupPocket(item.m_Info.m_BackpackPocket);
        Inventory3DManager.Get().SetNewCraftedItem(item);
        this.CheckResult();
        HUDCrafting.Get().Setup();
    }