예제 #1
0
        // While hovering over an item, if inventory is closed and RMB isn't held, show item's durability
        // Code below is mostly copy&pasted from original implementation
        protected override void SetupDurabilityInfo()
        {
            if (!m_DurabilityParent)
            {
                return;
            }

            m_DurabilityParent.SetActive(false);

            if (IsExpanded())
            {
                return;
            }

            Trigger trigger = GetTrigger();

            if (trigger == null || !trigger.IsItem())
            {
                return;
            }

            Item obj = trigger as Item;

            if (obj && obj.IsFood())
            {
                Food food = obj as Food;
                if (!food || !food.CanSpoil())
                {
                    return;
                }

                m_DurabilityParent.SetActive(true);
                m_DurabilityName.text = GreenHellGame.Instance.GetLocalization().Get("HUDTrigger_Decay", true);
                float  num1 = food.m_FInfo.m_SpoilOnlyIfTriggered ? food.m_FirstTriggerTime : food.m_FInfo.m_CreationTime;
                double num2 = food.m_FInfo.m_SpoilTime - ((float)MainLevel.Instance.m_TODSky.Cycle.GameTime - num1);
                float  num3 = (float)(num2 % 1.0);
                float  num4 = (float)num2 - num3;
                float  num5 = Mathf.Floor(num4 / 24f);
                float  num6 = num4 - num5 * 24f;
                float  num7 = num3 * 60f;
                m_Durability.text = num5.ToString("F0") + "d " + num6.ToString("F0") + "h " + num7.ToString("F0") + "m";
            }
            else
            {
                if (!obj.m_Info.IsWeapon() && !obj.m_Info.IsTool() && (!obj.m_Info.IsArmor() || obj.m_Info.m_ID == ItemID.broken_armor))
                {
                    return;
                }

                m_DurabilityParent.SetActive(true);
                m_DurabilityName.text = GreenHellGame.Instance.GetLocalization().Get("HUDTrigger_Durability", true);
                m_Durability.text     = ((obj.m_Info.m_Health / obj.m_Info.m_MaxHealth * 100.0)).ToString("F0") + "%";
            }
        }
예제 #2
0
    private void SetupSpoilInfo()
    {
        if (!this.m_DurabilityParent)
        {
            return;
        }
        this.m_DurabilityParent.SetActive(false);
        if (!Inventory3DManager.Get().gameObject.activeSelf || this.IsExpanded())
        {
            return;
        }
        Trigger trigger = this.GetTrigger();

        if (trigger == null || !trigger.IsItem())
        {
            return;
        }
        Item item = (Item)trigger;

        if (item.m_Info.IsFood())
        {
            Food food = (Food)item;
            if (food.CanSpoil())
            {
                this.m_DurabilityParent.SetActive(true);
                this.m_DurabilityName.text = GreenHellGame.Instance.GetLocalization().Get("HUDTrigger_Decay");
                float num  = (!food.m_FInfo.m_SpoilOnlyIfTriggered) ? food.m_FInfo.m_CreationTime : food.m_FirstTriggerTime;
                float num2 = food.m_FInfo.m_SpoilTime - (MainLevel.Instance.m_TODSky.Cycle.GameTime - num);
                float num3 = num2 % 1f;
                float num4 = num2 - num3;
                float num5 = Mathf.Floor(num4 / 24f);
                num4 -= num5 * 24f;
                num3 *= 60f;
                this.m_Durability.text = string.Concat(new string[]
                {
                    num5.ToString("F0"),
                    "d ",
                    num4.ToString("F0"),
                    "h ",
                    num3.ToString("F0"),
                    "m"
                });
            }
            return;
        }
        if (item.m_Info.IsWeapon() || item.m_Info.IsTool())
        {
            this.m_DurabilityParent.SetActive(true);
            this.m_DurabilityName.text = GreenHellGame.Instance.GetLocalization().Get("HUDTrigger_Durability");
            this.m_Durability.text     = (item.m_Info.m_Health / item.m_Info.m_MaxHealth * 100f).ToString("F0") + "%";
            return;
        }
    }