コード例 #1
0
    public void OnArmorInsert(ArmorSlot slot, Item item)
    {
        ((Armor)item).m_Limb = slot.m_Limb;
        item.ItemsManagerUnregister();
        item.transform.SetParent(slot.transform);
        Physics.IgnoreCollision(this.m_Player.m_Collider, item.GetComponent <Collider>());
        Renderer[] componentsDeepChild = General.GetComponentsDeepChild <Renderer>(item.gameObject);
        for (int i = 0; i < componentsDeepChild.Length; i++)
        {
            componentsDeepChild[i].enabled = false;
        }
        ArmorInfo armorInfo = (ArmorInfo)item.m_Info;
        ArmorData armorData = this.m_LimbMap[(int)slot.m_Limb];

        armorData.m_MeshMap[(int)armorInfo.m_ArmorType].SetActive(true);
        armorData.m_Mesh          = armorData.m_MeshMap[(int)armorInfo.m_ArmorType];
        armorData.m_AttachedArmor = item;
        armorData.m_AttachedArmorOrigCollCenter        = armorData.m_AttachedArmor.m_BoxCollider.center;
        armorData.m_AttachedArmorOrigCollSize          = armorData.m_AttachedArmor.m_BoxCollider.size;
        armorData.m_AttachedArmor.m_BoxCollider.center = armorData.m_AttachedArmorCollCenter;
        armorData.m_AttachedArmor.m_BoxCollider.size   = armorData.m_AttachedArmorCollSize;
        armorData.m_ArmorType  = armorInfo.m_ArmorType;
        armorData.m_Absorption = armorInfo.m_Absorption;
        armorData.m_Health     = armorInfo.m_Health;
        HUDBodyInspection.Get().m_ArmorEnabled = true;
        this.SetMeshesVisible(HUDBodyInspection.Get().m_ArmorEnabled);
        BodyInspectionController.Get().OnArmorAttached(slot.m_Limb);
    }
コード例 #2
0
 public override bool CanInsertItem(Item item)
 {
     if (this.m_Injury == null)
     {
         return(false);
     }
     if (this.m_Injury.m_ParentInjury != null)
     {
         return(false);
     }
     if (PlayerArmorModule.Get().IsArmorActive(EnumTools.ConvertInjuryPlaceToLimb(this.m_InjuryPlace)) && HUDBodyInspection.Get().m_ArmorEnabled)
     {
         return(false);
     }
     if (this.m_Injury.m_State == InjuryState.Infected)
     {
         return(!(this.m_Injury.m_Bandage != null) && this.m_Injury.m_Slot.m_Maggots == null && (item.m_Info.m_ID == ItemID.Maggots || item.m_Info.m_ID == ItemID.Honey_Dressing));
     }
     if (this.m_Injury.m_Type == InjuryType.SmallWoundAbrassion || this.m_Injury.m_Type == InjuryType.SmallWoundScratch || this.m_Injury.m_Type == InjuryType.WormHole)
     {
         if (this.m_Injury.m_Type == InjuryType.WormHole && this.m_Injury.m_State == InjuryState.WormInside && (item.m_Info.m_ID == ItemID.Fish_Bone || item.m_Info.m_ID == ItemID.Bone_Needle))
         {
             return(true);
         }
         if (this.m_Injury.m_Bandage != null)
         {
             return(false);
         }
         if (item.m_Info.m_Type == ItemType.Dressing)
         {
             return(true);
         }
     }
     else if (this.m_Injury.m_Type == InjuryType.Worm || (this.m_Injury.m_Type == InjuryType.WormHole && this.m_Injury.m_State == InjuryState.WormInside))
     {
         if (item.m_Info.m_ID == ItemID.Fish_Bone || item.m_Info.m_ID == ItemID.Bone_Needle)
         {
             return(true);
         }
     }
     else if (this.m_Injury.m_Type == InjuryType.VenomBite || this.m_Injury.m_Type == InjuryType.SnakeBite)
     {
         if (item.m_Info.m_ID == ItemID.Tabaco_Dressing || item.m_Info.m_ID == ItemID.lily_dressing)
         {
             return(true);
         }
     }
     else if ((this.m_Injury.m_Type == InjuryType.Laceration || this.m_Injury.m_Type == InjuryType.LacerationCat) && (this.m_Injury.m_State == InjuryState.Bleeding || this.m_Injury.m_State == InjuryState.Open))
     {
         if (item.m_Info.m_ID == ItemID.Ants)
         {
             return(true);
         }
         if (item.m_Info.m_ID == ItemID.ash_dressing || item.m_Info.m_ID == ItemID.Goliath_dressing || item.m_Info.m_ID == ItemID.Honey_Dressing || item.m_Info.m_ID == ItemID.Leaf_Bandage)
         {
             return(true);
         }
     }
     if (this.m_Injury.m_Type == InjuryType.Rash)
     {
         if (this.m_Injury.m_Bandage != null)
         {
             return(false);
         }
         if (item.m_Info.m_ID == ItemID.lily_dressing || item.m_Info.m_ID == ItemID.Honey_Dressing)
         {
             return(true);
         }
     }
     return(false);
 }
コード例 #3
0
ファイル: HUDItem.cs プロジェクト: Blightbuster/Green-Hell
    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);
    }
コード例 #4
0
    private void UpdateWoundSlots(SlotData data)
    {
        if (!Inventory3DManager.Get().isActiveAndEnabled || !BodyInspectionController.Get().IsActive())
        {
            data.obj.gameObject.SetActive(false);
            return;
        }
        if (GreenHellGame.IsPCControllerActive() && (Inventory3DManager.Get().m_CarriedItem == null || !data.slot.CanInsertItem(Inventory3DManager.Get().m_CarriedItem)))
        {
            data.obj.gameObject.SetActive(false);
            return;
        }
        BIWoundSlot biwoundSlot = (BIWoundSlot)data.slot;

        if (biwoundSlot == null || biwoundSlot.m_Injury == null)
        {
            data.obj.gameObject.SetActive(false);
            return;
        }
        if (biwoundSlot.m_Injury.m_Type == InjuryType.Leech)
        {
            data.obj.gameObject.SetActive(false);
            return;
        }
        if (!data.obj.gameObject.activeSelf)
        {
            data.obj.gameObject.SetActive(true);
        }
        Vector3 screenPoint = data.slot.GetScreenPoint();

        if (screenPoint.z <= 0f)
        {
            data.icon.enabled = false;
            return;
        }
        data.icon.rectTransform.position = screenPoint;
        if (biwoundSlot.GetInjury() != null && BodyInspectionController.Get() != null && BodyInspectionController.Get().enabled&& EnumTools.ConvertInjuryPlaceToLimb(biwoundSlot.GetInjury().m_Place) == HUDBodyInspection.Get().GetSelectedLimb() && biwoundSlot.GetInjury().m_Bandage == null && biwoundSlot.m_Maggots == null && biwoundSlot.GetInjury().m_ParentInjury == null)
        {
            data.icon.enabled       = true;
            this.m_SelectedSlotData = data;
            return;
        }
        data.icon.enabled = false;
    }
コード例 #5
0
ファイル: HUDItem.cs プロジェクト: Blightbuster/Green-Hell
    public bool Activate(Item item)
    {
        if (this.m_Active)
        {
            return(false);
        }
        if (!item || !item.CanExecuteActions())
        {
            return(false);
        }
        this.ResetItems();
        this.m_Item = item;
        this.ClearSlots();
        if (GreenHellGame.IsPadControllerActive() && Inventory3DManager.Get().IsActive() && Inventory3DManager.Get().CanSetCarriedItem(true))
        {
            this.AddSlot(HUDItem.Action.Pick);
            this.AddSlot(HUDItem.Action.PickStack);
        }
        if (this.m_Item.m_Info.IsArmor() && ((Armor)this.m_Item).m_Limb != Limb.None)
        {
            this.AddSlot(HUDItem.Action.TakeOffArmor);
            this.Activate();
            return(true);
        }
        bool flag = Player.Get().m_SwimController.IsActive();

        if (this.m_Item.m_Info.m_Craftable && !this.m_Item.m_OnCraftingTable && Player.Get().CanStartCrafting())
        {
            this.AddSlot(HUDItem.Action.Craft);
        }
        if (this.m_Item.IsStorage())
        {
            this.AddSlot(HUDItem.Action.Use);
        }
        else if (item.IsAcre())
        {
            this.AddSlot(HUDItem.Action.Plow);
        }
        else if (this.m_Item.m_Info.IsHeavyObject() && !this.m_Item.m_Info.m_CanBeAddedToInventory)
        {
            if (!MakeFireController.Get().IsActive())
            {
                this.AddSlot(HUDItem.Action.PickUp);
            }
        }
        else if (this.m_Item.m_Info.m_CanEquip)
        {
            if (this.m_Item.IsFireTool())
            {
                if (!InventoryBackpack.Get().Contains(this.m_Item))
                {
                    this.AddSlot(HUDItem.Action.Take);
                }
                if (!MakeFireController.Get().IsActive() && !Player.Get().IsInWater())
                {
                    this.AddSlot(HUDItem.Action.Use);
                }
            }
            else if (this.m_Item.m_InInventory || this.m_Item.m_InStorage)
            {
                if (item != InventoryBackpack.Get().m_EquippedItem)
                {
                    this.AddSlot(HUDItem.Action.Equip);
                }
            }
            else if (InventoryBackpack.Get().FindFreeSlot(this.m_Item))
            {
                this.AddSlot(HUDItem.Action.Take);
            }
            else
            {
                this.AddSlot(HUDItem.Action.Swap);
            }
        }
        else if (this.m_Item.m_Info.m_CanBeAddedToInventory && !InventoryBackpack.Get().Contains(this.m_Item))
        {
            this.AddSlot(HUDItem.Action.Take);
        }
        if (MakeFireController.Get().IsActive() && MakeFireController.Get().CanUseItemAsKindling(item))
        {
            this.AddSlot(HUDItem.Action.Use);
        }
        if (this.m_Item.m_Info.m_Eatable && !flag)
        {
            this.AddSlot(HUDItem.Action.Eat);
        }
        if (this.m_Item.m_Info.CanDrink() && !flag)
        {
            this.AddSlot(HUDItem.Action.Drink);
        }
        if (this.m_Item.m_Info.IsLiquidContainer() && ((LiquidContainerInfo)this.m_Item.m_Info).CanSpill())
        {
            this.AddSlot(HUDItem.Action.Spill);
        }
        if (this.m_Item.m_Info.m_Harvestable && !flag && (!this.m_Item.RequiresToolToHarvest() || Player.Get().HasBlade()))
        {
            this.AddSlot(HUDItem.Action.Harvest);
        }
        if (this.m_Item.m_Info.IsArmor() && BodyInspectionController.Get().IsActive())
        {
            Limb selectedLimb = HUDBodyInspection.Get().GetSelectedLimb();
            if (PlayerArmorModule.Get().IsArmorActive(selectedLimb))
            {
                this.AddSlot(HUDItem.Action.SwapArmor);
            }
            else
            {
                this.AddSlot(HUDItem.Action.EquipArmor);
            }
        }
        if (HUDItemSlot.Get().m_SelectedSlotData != null && HUDItemSlot.Get().m_SelectedSlotData.slot.CanInsertItem(this.m_Item))
        {
            this.AddSlot(HUDItem.Action.Insert);
        }
        if (GreenHellGame.IsPadControllerActive() && (item.m_InInventory || item.m_InStorage))
        {
            this.AddSlot(HUDItem.Action.Drop);
        }
        if (this.m_Item.m_Info.IsStand())
        {
            Stand stand = (Stand)this.m_Item;
            if (stand.GetNumitems() > 0)
            {
                this.AddSlot(HUDItem.Action.Take);
            }
            if (stand.GetNumitems() >= 3)
            {
                this.AddSlot(HUDItem.Action.Take3);
            }
            if (stand.GetNumitems() >= 2)
            {
                this.AddSlot(HUDItem.Action.TakeAll);
            }
        }
        else if (!item.m_Info.m_CantDestroy && !item.m_AttachedToSpear && item.m_Info.m_ID != ItemID.Chellange_Battery && item.m_Info.m_ID != ItemID.Chellange_WalkieTalkie && !item.IsStorage() && !item.IsAcre())
        {
            this.AddSlot(HUDItem.Action.Destroy);
            if ((item.m_InventorySlot && item.m_InventorySlot.m_Items.Count > 0) || (item.m_CurrentSlot && item.m_CurrentSlot.IsStack()))
            {
                this.AddSlot(HUDItem.Action.DestroyStack);
            }
        }
        this.Activate();
        return(true);
    }