Exemplo n.º 1
0
        public static void Postfix(FoodItem __instance)
        {
            AlcoholComponent alcoholComponent = ModUtils.GetComponent <AlcoholComponent>(__instance);

            if (alcoholComponent != null)
            {
                alcoholComponent.AmountRemaining = __instance.m_CaloriesRemaining / __instance.m_CaloriesTotal * alcoholComponent.AmountTotal;
            }
        }
Exemplo n.º 2
0
        public static void Postfix(GearItem __instance, float normalizedValue)
        {
            AlcoholComponent alcoholComponent = ModUtils.GetComponent <AlcoholComponent>(__instance);

            if (alcoholComponent != null)
            {
                alcoholComponent.Apply(normalizedValue);
            }
        }
Exemplo n.º 3
0
        private static void ConfigureFood(ModComponent modComponent)
        {
            ModFoodComponent modFoodComponent = modComponent as ModFoodComponent;

            if (modFoodComponent == null)
            {
                return;
            }

            FoodItem foodItem = ModUtils.GetOrCreateComponent <FoodItem>(modFoodComponent);

            foodItem.m_CaloriesTotal     = modFoodComponent.Calories;
            foodItem.m_CaloriesRemaining = modFoodComponent.Calories;
            foodItem.m_ReduceThirst      = modFoodComponent.ThirstEffect;

            foodItem.m_ChanceFoodPoisoning             = Mathf.Clamp01(modFoodComponent.FoodPoisoning / 100f);
            foodItem.m_ChanceFoodPoisoningLowCondition = Mathf.Clamp01(modFoodComponent.FoodPoisoningLowCondition / 100f);
            foodItem.m_DailyHPDecayInside  = GetDecayPerStep(modFoodComponent.DaysToDecayIndoors, modFoodComponent.MaxHP);
            foodItem.m_DailyHPDecayOutside = GetDecayPerStep(modFoodComponent.DaysToDecayOutdoors, modFoodComponent.MaxHP);

            foodItem.m_TimeToEatSeconds   = Mathf.Clamp(1, modFoodComponent.EatingTime, 10);
            foodItem.m_EatingAudio        = modFoodComponent.EatingAudio;
            foodItem.m_OpenAndEatingAudio = modFoodComponent.EatingPackagedAudio;
            foodItem.m_Packaged           = !string.IsNullOrEmpty(foodItem.m_OpenAndEatingAudio);

            foodItem.m_IsDrink   = modFoodComponent.Drink;
            foodItem.m_IsFish    = modFoodComponent.Fish;
            foodItem.m_IsMeat    = modFoodComponent.Meat;
            foodItem.m_IsRawMeat = modFoodComponent.Raw;
            foodItem.m_IsNatural = modFoodComponent.Natural;
            foodItem.m_ParasiteRiskPercentIncrease = ModUtils.NotNull(modFoodComponent.ParasiteRiskIncrements);

            foodItem.m_PercentHeatLossPerMinuteIndoors  = 1;
            foodItem.m_PercentHeatLossPerMinuteOutdoors = 2;

            if (modFoodComponent.Opening)
            {
                foodItem.m_GearRequiredToOpen  = true;
                foodItem.m_OpenedWithCanOpener = modFoodComponent.OpeningWithCanOpener;
                foodItem.m_OpenedWithHatchet   = modFoodComponent.OpeningWithHatchet;
                foodItem.m_OpenedWithKnife     = modFoodComponent.OpeningWithKnife;

                if (modFoodComponent.OpeningWithSmashing)
                {
                    SmashableItem smashableItem = ModUtils.GetOrCreateComponent <SmashableItem>(modFoodComponent);
                    smashableItem.m_MinPercentLoss = 10;
                    smashableItem.m_MaxPercentLoss = 30;
                    smashableItem.m_TimeToSmash    = 6;
                    smashableItem.m_SmashAudio     = "Play_EatingSmashCan";
                }

                if (modFoodComponent.Canned)
                {
                    foodItem.m_GearPrefabHarvestAfterFinishEatingNormal = Resources.Load <GameObject>("GEAR_RecycledCan");
                }
            }

            if (modFoodComponent.AffectRest)
            {
                FatigueBuff fatigueBuff = ModUtils.GetOrCreateComponent <FatigueBuff>(modFoodComponent);
                fatigueBuff.m_InitialPercentDecrease = modFoodComponent.InstantRestChange;
                fatigueBuff.m_RateOfIncreaseScale    = modFoodComponent.RestFactor;
                fatigueBuff.m_DurationHours          = modFoodComponent.RestFactorMinutes / 60f;
            }

            if (modFoodComponent.AffectCold)
            {
                FreezingBuff freezingBuff = ModUtils.GetOrCreateComponent <FreezingBuff>(modFoodComponent);
                freezingBuff.m_InitialPercentDecrease = modFoodComponent.InstantColdChange;
                freezingBuff.m_RateOfIncreaseScale    = modFoodComponent.ColdFactor;
                freezingBuff.m_DurationHours          = modFoodComponent.ColdFactorMinutes / 60f;
            }

            if (modFoodComponent.AffectCondition)
            {
                ConditionRestBuff conditionRestBuff = ModUtils.GetOrCreateComponent <ConditionRestBuff>(modFoodComponent);
                conditionRestBuff.m_ConditionRestBonus   = modFoodComponent.ConditionRestBonus;
                conditionRestBuff.m_NumHoursRestAffected = modFoodComponent.ConditionRestMinutes / 60f;
            }

            if (modFoodComponent.ContainsAlcohol)
            {
                AlcoholComponent alcohol = ModUtils.GetOrCreateComponent <AlcoholComponent>(modFoodComponent);
                alcohol.AmountTotal     = modFoodComponent.WeightKG * modFoodComponent.AlcoholPercentage * 0.01f;
                alcohol.AmountRemaining = alcohol.AmountTotal;
                alcohol.UptakeSeconds   = modFoodComponent.AlcoholUptakeMinutes * 60;
            }

            HoverIconsToShow hoverIconsToShow = ModUtils.GetOrCreateComponent <HoverIconsToShow>(modFoodComponent);

            hoverIconsToShow.m_HoverIcons = new HoverIconsToShow.HoverIcons[] { HoverIconsToShow.HoverIcons.Food };
        }