예제 #1
0
        public bool Eat(int value)
        {
            int   num  = Terrain.ExtractContents(value);
            Block obj  = BlocksManager.Blocks[num];
            float num2 = obj.GetNutritionalValue(value);
            float sicknessProbability = obj.GetSicknessProbability(value);

            if (num2 > 0f)
            {
                if (m_componentPlayer.ComponentSickness.IsSick && sicknessProbability > 0f)
                {
                    m_componentPlayer.ComponentGui.DisplaySmallMessage(LanguageControl.Get(fName, 1), Color.White, blinking: true, playNotificationSound: true);
                    return(false);
                }
                if (Food >= 0.98f)
                {
                    m_componentPlayer.ComponentGui.DisplaySmallMessage(LanguageControl.Get(fName, 2), Color.White, blinking: true, playNotificationSound: true);
                    return(false);
                }
                m_subsystemAudio.PlayRandomSound("Audio/Creatures/HumanEat", 1f, m_random.Float(-0.2f, 0.2f), m_componentPlayer.ComponentBody.Position, 2f, 0f);
                if (m_componentPlayer.ComponentSickness.IsSick)
                {
                    num2 *= 0.75f;
                }
                Food += num2;
                m_satiation.TryGetValue(num, out float value2);
                value2          += MathUtils.Max(num2, 0.5f);
                m_satiation[num] = value2;
                if (m_componentPlayer.ComponentSickness.IsSick)
                {
                    m_componentPlayer.ComponentSickness.NauseaEffect();
                }
                else if (sicknessProbability >= 0.5f)
                {
                    m_componentPlayer.ComponentGui.DisplaySmallMessage(LanguageControl.Get(fName, 3), Color.White, blinking: true, playNotificationSound: true);
                }
                else if (sicknessProbability > 0f)
                {
                    m_componentPlayer.ComponentGui.DisplaySmallMessage(LanguageControl.Get(fName, 4), Color.White, blinking: true, playNotificationSound: true);
                }
                else if (value2 > 2.5f)
                {
                    m_componentPlayer.ComponentGui.DisplaySmallMessage(LanguageControl.Get(fName, 5), Color.White, blinking: true, playNotificationSound: true);
                }
                else if (value2 > 2f)
                {
                    m_componentPlayer.ComponentGui.DisplaySmallMessage(LanguageControl.Get(fName, 6), Color.White, blinking: true, playNotificationSound: true);
                }
                else if (Food > 0.85f)
                {
                    m_componentPlayer.ComponentGui.DisplaySmallMessage(LanguageControl.Get(fName, 7), Color.White, blinking: true, playNotificationSound: true);
                }
                else
                {
                    m_componentPlayer.ComponentGui.DisplaySmallMessage(LanguageControl.Get(fName, 8), Color.White, blinking: true, playNotificationSound: false);
                }
                if (m_random.Bool(sicknessProbability) || value2 > 3.5f)
                {
                    m_componentPlayer.ComponentSickness.StartSickness();
                }
                m_componentPlayer.PlayerStats.FoodItemsEaten++;
                return(true);
            }
            return(false);
        }