Exemple #1
0
 public override void OnExecute(TriggerAction.TYPE action)
 {
     base.OnExecute(action);
     if (action == TriggerAction.TYPE.Use)
     {
         Storage3D.Get().Activate(this);
     }
 }
Exemple #2
0
    public InsertResult InsertItem(Item item, ItemSlot slot, InventoryCellsGroup group, bool notify_if_cant, bool drop_if_cant)
    {
        if (this.m_Items.Contains(item))
        {
            return(InsertResult.CantInsert);
        }
        bool isStatic = item.gameObject.isStatic;

        item.gameObject.isStatic = false;
        item.transform.parent    = null;
        InsertResult insertResult = InsertResult.None;

        if (Storage3D.Get().GetGrid(this.m_Type).InsertItem(item, slot, group, true, true, this))
        {
            insertResult = InsertResult.Ok;
        }
        else
        {
            insertResult = InsertResult.NoSpace;
        }
        if (insertResult == InsertResult.Ok)
        {
            this.m_Items.Add(item);
            if (!item.m_CurrentSlot)
            {
                item.transform.parent = Storage3D.Get().transform;
            }
            item.OnAddToStorage(this);
            item.gameObject.SetActive(Inventory3DManager.Get().gameObject.activeSelf&& item.m_Info.m_BackpackPocket == Inventory3DManager.Get().m_ActivePocket);
            using (List <Item> .Enumerator enumerator = this.m_Items.GetEnumerator())
            {
                while (enumerator.MoveNext())
                {
                    Item item2 = enumerator.Current;
                    item2.UpdatePhx();
                    item2.UpdateScale(false);
                    item.UpdateLayer();
                }
                return(insertResult);
            }
        }
        item.gameObject.isStatic = isStatic;
        if (notify_if_cant)
        {
            ((HUDMessages)HUDManager.Get().GetHUD(typeof(HUDMessages))).AddMessage(GreenHellGame.Instance.GetLocalization().Get("HUD_NoSpaceInStorage", true), new Color?(Color.red), HUDMessageIcon.None, "", null);
            HUDManager.Get().PlaySound("Sounds/HUD/GH_Inventory_Full");
        }
        if (drop_if_cant)
        {
            Inventory3DManager.Get().DropItem(item);
        }
        return(insertResult);
    }
Exemple #3
0
    public void Setup()
    {
        this.m_MatchingGroups.Clear();
        Item carriedItem = Inventory3DManager.Get().m_CarriedItem;

        if (!carriedItem)
        {
            return;
        }
        if (this.m_Pocked == BackpackPocket.Storage && !Storage3D.Get().CanInsertItem(Inventory3DManager.Get().m_CarriedItem))
        {
            return;
        }
        int num  = 0;
        int num2 = 0;

        this.CalcRequiredCells(carriedItem, ref num, ref num2);
        InventoryCell[,] cells = this.m_Cells;
        int upperBound  = cells.GetUpperBound(0);
        int upperBound2 = cells.GetUpperBound(1);

        for (int i = cells.GetLowerBound(0); i <= upperBound; i++)
        {
            for (int j = cells.GetLowerBound(1); j <= upperBound2; j++)
            {
                InventoryCell inventoryCell = cells[i, j];
                if (inventoryCell.m_IndexX + num <= (int)this.m_GridSize.x && inventoryCell.m_IndexY + num2 <= (int)this.m_GridSize.y)
                {
                    InventoryCellsGroup inventoryCellsGroup = new InventoryCellsGroup(this.m_Pocked);
                    for (int k = inventoryCell.m_IndexX; k < inventoryCell.m_IndexX + num; k++)
                    {
                        for (int l = inventoryCell.m_IndexY; l < inventoryCell.m_IndexY + num2; l++)
                        {
                            inventoryCellsGroup.m_Cells.Add(this.m_Cells[k, l]);
                        }
                    }
                    if (inventoryCellsGroup.m_Cells.Count != 0)
                    {
                        inventoryCellsGroup.Setup();
                        this.m_MatchingGroups.Add(inventoryCellsGroup);
                    }
                }
            }
        }
    }
 public override void RemoveItem(Item item, bool from_destroy = false)
 {
     if (LoadingScreen.Get().m_State == LoadingScreenState.ReturnToMainMenu)
     {
         return;
     }
     if (!this.m_Items.Contains(item))
     {
         if (item == this.m_ItemParent)
         {
             this.ReorganizeStack(from_destroy);
         }
         return;
     }
     this.OnRemoveItem();
     item.m_CurrentSlot = null;
     if (!item.m_InStorage)
     {
         item.StaticPhxRequestRemove();
     }
     if (!from_destroy && !item.m_IsBeingDestroyed)
     {
         if (item.m_InStorage)
         {
             item.transform.parent = Storage3D.Get().transform;
         }
         else if (item.m_InInventory)
         {
             item.transform.parent = InventoryBackpack.Get().transform;
         }
         else
         {
             item.transform.parent = null;
         }
     }
     this.m_Items.Remove(item);
     this.SetupStack();
     if (item.m_InventorySlot)
     {
         item.m_InventorySlot.m_ActivityUpdate = true;
     }
 }
Exemple #5
0
 public void Activate()
 {
     if (base.gameObject.activeSelf)
     {
         return;
     }
     if (this.m_AvailableItems.Count == 0)
     {
         this.InitializeAvailableItems();
     }
     this.EnableTable();
     Player.Get().StartController(PlayerControllerType.Crafting);
     base.gameObject.SetActive(true);
     if (!Inventory3DManager.Get().gameObject.activeSelf)
     {
         Inventory3DManager.Get().Activate();
     }
     if (Storage3D.Get().IsActive())
     {
         Storage3D.Get().Deactivate();
     }
 }
Exemple #6
0
 protected override bool ShouldShow()
 {
     return(!Player.Get().IsDead() && !Player.Get().m_DreamActive&& !CutscenesManager.Get().IsCutscenePlaying() && !SleepController.Get().IsActive() && !HUDWheel.Get().enabled&& !Storage3D.Get().IsActive() && !BodyInspectionController.Get().IsBandagingInProgress() && (Inventory3DManager.Get().gameObject.activeSelf || NotepadController.Get().IsActive() || MapController.Get().IsActive() || BodyInspectionController.Get().IsActive()));
 }
Exemple #7
0
 void Awake()
 {
     World = new Storage3D <Component> (GetPosition, cellSize, gridWidth, gridWidth, gridWidth);
 }
Exemple #8
0
    public void OnSetSelectedGroup(InventoryCellsGroup group)
    {
        InventoryCell[,] cells = this.m_Cells;
        int upperBound  = cells.GetUpperBound(0);
        int upperBound2 = cells.GetUpperBound(1);

        for (int i = cells.GetLowerBound(0); i <= upperBound; i++)
        {
            for (int j = cells.GetLowerBound(1); j <= upperBound2; j++)
            {
                cells[i, j].m_Renderer.enabled = false;
            }
        }
        if (group == null)
        {
            return;
        }
        for (int k = 0; k < (int)this.m_GridSize.y; k++)
        {
            for (int l = 0; l < (int)this.m_GridSize.x; l++)
            {
                this.m_Cells[l, k].m_Renderer.material.color = Color.white;
            }
        }
        if (group.IsFree())
        {
            for (int m = 0; m < group.m_Cells.Count; m++)
            {
                group.m_Cells[m].m_Renderer.enabled        = true;
                group.m_Cells[m].m_Renderer.material.color = InventoryBackpack.Get().m_FreeColor;
            }
            return;
        }
        for (int n = 0; n < group.m_Cells.Count; n++)
        {
            group.m_Cells[n].m_Renderer.enabled        = true;
            group.m_Cells[n].m_Renderer.material.color = InventoryBackpack.Get().m_OccupiedColor;
            if (group.m_Cells[n].m_Items.Count > 0)
            {
                for (int num = 0; num < group.m_Cells[n].m_Items.Count; num++)
                {
                    InventoryCellsGroup inventoryCellsGroup = group.m_Cells[n].m_Items[num].m_Info.m_InventoryCellsGroup;
                    if (this.m_Pocked != BackpackPocket.Storage || !group.m_Cells[n].m_Items[num].m_Storage || !(group.m_Cells[n].m_Items[num].m_Storage != Storage3D.Get().m_Storage))
                    {
                        for (int num2 = 0; num2 < inventoryCellsGroup.m_Cells.Count; num2++)
                        {
                            inventoryCellsGroup.m_Cells[num2].m_Renderer.enabled        = true;
                            inventoryCellsGroup.m_Cells[num2].m_Renderer.material.color = InventoryBackpack.Get().m_OccupiedColor;
                        }
                    }
                }
            }
        }
    }
Exemple #9
0
 void Awake() {
     World = new Storage3D<MonoBehaviour> (GetPosition, cellSize, gridWidth, gridWidth, gridWidth);
 }
Exemple #10
0
    private bool ExecuteAction(HUDItem.Action action, Item item)
    {
        if (action != HUDItem.Action.Close && this.m_ItemReplacer != null)
        {
            item = this.m_ItemReplacer.ReplaceItem();
            this.m_ItemReplacer = null;
        }
        switch (action)
        {
        case HUDItem.Action.Close:
            this.SetActive(false);
            break;

        case HUDItem.Action.Take:
            if (item)
            {
                item.Take();
            }
            else if (this.m_PlantFruit)
            {
                this.m_PlantFruit.Take();
            }
            break;

        case HUDItem.Action.PickUp:
            item.PickUp(true);
            break;

        case HUDItem.Action.Eat:
            if (item)
            {
                item.Eat();
            }
            else if (this.m_PlantFruit)
            {
                this.m_PlantFruit.Eat();
            }
            break;

        case HUDItem.Action.Drink:
            if (item)
            {
                item.Drink();
            }
            else if (this.m_LiquidSource)
            {
                this.m_LiquidSource.Drink();
            }
            break;

        case HUDItem.Action.Harvest:
            Player.Get().HideWeapon();
            HarvestingSmallAnimalController.Get().SetItem(item);
            Player.Get().StartController(PlayerControllerType.HarvestingSmallAnimal);
            break;

        case HUDItem.Action.Craft:
            if (Player.Get().CanStartCrafting())
            {
                if (WalkieTalkieController.Get().IsActive())
                {
                    WalkieTalkieController.Get().Stop();
                }
                if (Player.Get().GetCurrentItem(Hand.Left) == item)
                {
                    Player.Get().SetWantedItem(Hand.Left, null, true);
                }
                else if (Player.Get().GetCurrentItem(Hand.Right) == item)
                {
                    Player.Get().SetWantedItem(Hand.Right, null, true);
                }
                else if (!item.m_CurrentSlot && item.m_InventorySlot && item.m_InventorySlot.m_Items.Count > 0)
                {
                    item.m_InventorySlot.RemoveItem(item, false);
                }
                else if (item.m_CurrentSlot && item.m_CurrentSlot.m_InventoryStackSlot)
                {
                    item.m_CurrentSlot.RemoveItem(item, false);
                }
                else if (item.m_CurrentSlot && item.m_CurrentSlot.m_WeaponRackParent)
                {
                    item.m_CurrentSlot.RemoveItem(item, false);
                }
                if (InventoryBackpack.Get().m_EquippedItem == item)
                {
                    InventoryBackpack.Get().m_EquippedItem = null;
                }
                InventoryBackpack.Get().RemoveItem(item, false);
                Storage3D.Get().RemoveItem(item, false);
                CraftingManager.Get().Activate();
                CraftingManager.Get().AddItem(item, true);
            }
            break;

        case HUDItem.Action.Fill:
            this.m_LiquidSource.TakeLiquid();
            break;

        case HUDItem.Action.Equip:
            Player.Get().Equip(item.m_CurrentSlot);
            break;

        case HUDItem.Action.Drop:
            if (CraftingManager.Get().gameObject.activeSelf&& CraftingManager.Get().ContainsItem(item))
            {
                CraftingManager.Get().RemoveItem(item, false);
            }
            if (!item.m_CurrentSlot && item.m_InventorySlot && item.m_InventorySlot.m_Items.Count > 0)
            {
                item.m_InventorySlot.RemoveItem(item, false);
            }
            else if (item.m_CurrentSlot && item.m_CurrentSlot.m_InventoryStackSlot)
            {
                item.m_CurrentSlot.RemoveItem(item, false);
            }
            if (InventoryBackpack.Get().m_EquippedItem == item)
            {
                InventoryBackpack.Get().m_EquippedItem = null;
            }
            InventoryBackpack.Get().RemoveItem(item, false);
            Inventory3DManager.Get().DropItem(item);
            break;

        case HUDItem.Action.Swap:
            item.Swap();
            break;

        case HUDItem.Action.Use:
            if (this.m_Item.IsStorage())
            {
                Storage3D.Get().Activate((Storage)this.m_Item);
            }
            else if (MakeFireController.Get().IsActive())
            {
                InventoryBackpack.Get().RemoveItem(this.m_Item, false);
                MakeFireController.Get().InsertItemToKindlingSlot(this.m_Item);
            }
            else
            {
                Item currentItem = Player.Get().GetCurrentItem();
                if (currentItem)
                {
                    InventoryBackpack.Get().InsertItem(currentItem, InventoryBackpack.Get().m_EquippedItemSlot, null, true, true, true, true, false);
                    Player.Get().SetWantedItem(currentItem.m_Info.IsBow() ? Hand.Left : Hand.Right, null, true);
                    if (Player.Get().m_ControllerToStart != PlayerControllerType.Unknown)
                    {
                        Player.Get().StartControllerInternal();
                    }
                }
                Player.Get().SetWantedItem(this.m_Item, true);
            }
            break;

        case HUDItem.Action.Spill:
            ((LiquidContainer)this.m_Item).Spill(-1f);
            break;

        case HUDItem.Action.Destroy:
            if (GreenHellGame.IsPadControllerActive() && !this.m_DestroyButton.confirm.gameObject.activeSelf)
            {
                this.m_DestroyButton.confirm.gameObject.SetActive(true);
                this.m_DestroyButton.confirm_sel.gameObject.SetActive(true);
                return(false);
            }
            if (!this.m_DestroyButton.confirm_sel.gameObject.activeSelf)
            {
                return(true);
            }
            if (CraftingManager.Get().gameObject.activeSelf&& CraftingManager.Get().ContainsItem(item))
            {
                CraftingManager.Get().RemoveItem(item, false);
            }
            if (!item.m_CurrentSlot && item.m_InventorySlot && item.m_InventorySlot.m_Items.Count > 0)
            {
                item.m_InventorySlot.RemoveItem(item, false);
            }
            else if (item.m_CurrentSlot && item.m_CurrentSlot.m_InventoryStackSlot)
            {
                item.m_CurrentSlot.RemoveItem(item, false);
            }
            if (InventoryBackpack.Get().m_EquippedItem == item)
            {
                InventoryBackpack.Get().m_EquippedItem = null;
            }
            InventoryBackpack.Get().RemoveItem(item, false);
            UnityEngine.Object.Destroy(item.gameObject);
            break;

        case HUDItem.Action.Take3:
            if (item)
            {
                item.Take3();
            }
            break;

        case HUDItem.Action.TakeAll:
            if (item)
            {
                item.TakeAll();
            }
            break;

        case HUDItem.Action.TakeClay:
            if (this.m_LiquidSource)
            {
                this.m_LiquidSource.TakeClay();
            }
            break;

        case HUDItem.Action.CleanUp:
            PlayerArmorModule.Get().SetMeshesVisible(true);
            BodyInspectionController.Get().OnArmorMeshesEnabled();
            Player.Get().m_Animator.SetBool(Player.Get().m_CleanUpHash, false);
            break;

        case HUDItem.Action.DestroyStack:
            if (GreenHellGame.IsPadControllerActive() && !this.m_DestroyStackButton.confirm.gameObject.activeSelf)
            {
                this.m_DestroyStackButton.confirm.gameObject.SetActive(true);
                this.m_DestroyStackButton.confirm_sel.gameObject.SetActive(true);
                return(false);
            }
            if (!this.m_DestroyStackButton.confirm_sel.gameObject.activeSelf)
            {
                return(true);
            }
            if (!item.m_CurrentSlot && item.m_InventorySlot && item.m_InventorySlot.m_Items.Count > 0)
            {
                UnityEngine.Object.Destroy(item.gameObject);
            }
            else if (item.m_CurrentSlot && item.m_CurrentSlot.m_InventoryStackSlot)
            {
                UnityEngine.Object.Destroy(item.m_CurrentSlot.m_ItemParent.gameObject);
            }
            else if (item.m_CurrentSlot && item.m_CurrentSlot.m_BackpackSlot && item.m_CurrentSlot.IsStack())
            {
                for (int i = 0; i < ((ItemSlotStack)item.m_CurrentSlot).m_Items.Count; i++)
                {
                    UnityEngine.Object.Destroy(((ItemSlotStack)item.m_CurrentSlot).m_Items[i].gameObject);
                }
            }
            break;

        case HUDItem.Action.SwapArmor:
        {
            Limb      selectedLimb  = HUDBodyInspection.Get().GetSelectedLimb();
            ArmorData armorData     = PlayerArmorModule.Get().GetArmorData(selectedLimb);
            Item      attachedArmor = armorData.m_AttachedArmor;
            ItemSlot  currentSlot   = attachedArmor.m_CurrentSlot;
            if (currentSlot != null)
            {
                currentSlot.RemoveItem();
            }
            PlayerArmorModule.Get().ArmorCarryStarted(attachedArmor);
            InventoryCellsGroup inventoryCellsGroup = this.m_Item.m_Info.m_InventoryCellsGroup;
            InventoryBackpack.Get().RemoveItem(this.m_Item, false);
            if (attachedArmor.m_Info.m_InventoryRotated != this.m_Item.m_Info.m_InventoryRotated)
            {
                Inventory3DManager.Get().RotateItem(attachedArmor, false);
            }
            InventoryBackpack.Get().InsertItem(attachedArmor, null, inventoryCellsGroup, true, true, true, true, true);
            armorData.m_Slot.InsertItem(this.m_Item);
            break;
        }

        case HUDItem.Action.EquipArmor:
            InventoryBackpack.Get().RemoveItem(this.m_Item, false);
            PlayerArmorModule.Get().GetArmorData(HUDBodyInspection.Get().GetSelectedLimb()).m_Slot.InsertItem(this.m_Item);
            break;

        case HUDItem.Action.Insert:
            if (HUDItemSlot.Get().m_SelectedSlotData == null)
            {
                return(false);
            }
            if (!HUDItemSlot.Get().m_SelectedSlotData.slot.CanInsertItem(this.m_Item))
            {
                ((HUDMessages)HUDManager.Get().GetHUD(typeof(HUDMessages))).AddMessage(GreenHellGame.Instance.GetLocalization().Get("HUD_CannotInsertItem", true), new Color?(Color.red), HUDMessageIcon.None, "", null);
                return(true);
            }
            if (this.m_Item.m_Storage)
            {
                this.m_Item.m_Storage.RemoveItem(this.m_Item, false);
            }
            InventoryBackpack.Get().RemoveItem(this.m_Item, false);
            HUDItemSlot.Get().m_SelectedSlotData.slot.InsertItem(this.m_Item);
            break;

        case HUDItem.Action.Pick:
            Inventory3DManager.Get().StartCarryItem(this.m_Item, false);
            break;

        case HUDItem.Action.TakeOffArmor:
        {
            Item attachedArmor2 = PlayerArmorModule.Get().GetArmorData(HUDBodyInspection.Get().GetSelectedLimb()).m_AttachedArmor;
            if (attachedArmor2)
            {
                PlayerArmorModule.Get().ArmorCarryStarted(attachedArmor2);
                InventoryBackpack.Get().InsertItem(attachedArmor2, null, null, true, true, true, true, true);
            }
            break;
        }

        case HUDItem.Action.Plow:
        {
            Acre acre = (this.m_Item && this.m_Item.IsAcre()) ? ((Acre)this.m_Item) : null;
            if (!acre)
            {
                return(true);
            }
            acre.Plow();
            break;
        }

        case HUDItem.Action.PickStack:
            Inventory3DManager.Get().StartCarryItem(this.m_Item, true);
            break;
        }
        return(true);
    }