internal static bool Prefix(CookingPotItem __instance) { if (__instance.GetCookingState() == CookingPotItem.CookingState.Cooking) { return(true); } float waterAmount = WaterUtils.GetWaterAmount(__instance); if (waterAmount <= 0) { return(true); } bool potable = __instance.GetCookingState() == CookingPotItem.CookingState.Ready; GearItem gearItem = __instance.GetComponent <GearItem>(); WaterSupply waterSupply = gearItem.m_WaterSupply; if (waterSupply == null) { waterSupply = gearItem.gameObject.AddComponent <WaterSupply>(); gearItem.m_WaterSupply = waterSupply; } waterSupply.m_VolumeInLiters = waterAmount; waterSupply.m_WaterQuality = potable ? LiquidQuality.Potable : LiquidQuality.NonPotable; waterSupply.m_TimeToDrinkSeconds = GameManager.GetInventoryComponent().GetPotableWaterSupply().m_WaterSupply.m_TimeToDrinkSeconds; waterSupply.m_DrinkingAudio = GameManager.GetInventoryComponent().GetPotableWaterSupply().m_WaterSupply.m_DrinkingAudio; GameManager.GetPlayerManagerComponent().UseInventoryItem(gearItem); return(false); }
private static void ConfigureCookingPot(ModComponent modComponent) { ModCookingPotComponent modCookingPotComponent = modComponent as ModCookingPotComponent; if (modCookingPotComponent == null) { return; } CookingPotItem cookingPotItem = ModUtils.GetOrCreateComponent <CookingPotItem>(modComponent); cookingPotItem.m_WaterCapacityLiters = modCookingPotComponent.Capacity; cookingPotItem.m_CanCookGrub = modCookingPotComponent.CanCookGrub; cookingPotItem.m_CanCookLiquid = modCookingPotComponent.CanCookLiquid; cookingPotItem.m_CanCookMeat = modCookingPotComponent.CanCookMeat; cookingPotItem.m_CanOnlyWarmUpFood = false; CookingPotItem template = ModUtils.GetItem <CookingPotItem>(modCookingPotComponent.Template, modComponent.name); cookingPotItem.m_BoilingTimeMultiplier = template.m_BoilingTimeMultiplier; cookingPotItem.m_BoilWaterPotMaterialsList = template.m_BoilWaterPotMaterialsList; cookingPotItem.m_BoilWaterReadyMaterialsList = template.m_BoilWaterReadyMaterialsList; cookingPotItem.m_ConditionPercentDamageFromBoilingDry = template.m_ConditionPercentDamageFromBoilingDry; cookingPotItem.m_ConditionPercentDamageFromBurningFood = template.m_ConditionPercentDamageFromBurningFood; cookingPotItem.m_CookedCalorieMultiplier = template.m_CookedCalorieMultiplier; cookingPotItem.m_CookingTimeMultiplier = template.m_CookingTimeMultiplier; cookingPotItem.m_GrubMeshType = template.m_GrubMeshType; cookingPotItem.m_LampOilMultiplier = template.m_LampOilMultiplier; cookingPotItem.m_MeltSnowMaterialsList = template.m_MeltSnowMaterialsList; cookingPotItem.m_NearFireWarmUpCookingTimeMultiplier = template.m_NearFireWarmUpCookingTimeMultiplier; cookingPotItem.m_NearFireWarmUpReadyTimeMultiplier = template.m_NearFireWarmUpReadyTimeMultiplier; cookingPotItem.m_ParticlesItemCooking = template.m_ParticlesItemCooking; cookingPotItem.m_ParticlesItemReady = template.m_ParticlesItemReady; cookingPotItem.m_ParticlesItemRuined = template.m_ParticlesItemRuined; cookingPotItem.m_ParticlesSnowMelting = template.m_ParticlesSnowMelting; cookingPotItem.m_ParticlesWaterBoiling = template.m_ParticlesWaterBoiling; cookingPotItem.m_ParticlesWaterReady = template.m_ParticlesWaterReady; cookingPotItem.m_ParticlesWaterRuined = template.m_ParticlesWaterRuined; cookingPotItem.m_ReadyTimeMultiplier = template.m_ReadyTimeMultiplier; cookingPotItem.m_RuinedFoodMaterialsList = template.m_RuinedFoodMaterialsList; cookingPotItem.m_SnowMesh = modCookingPotComponent.SnowMesh; cookingPotItem.m_WaterMesh = modCookingPotComponent.WaterMesh; GameObject grubMesh = UnityEngine.Object.Instantiate(template.m_GrubMeshFilter.gameObject, cookingPotItem.transform); cookingPotItem.m_GrubMeshFilter = grubMesh.GetComponent <MeshFilter>(); cookingPotItem.m_GrubMeshRenderer = grubMesh.GetComponent <MeshRenderer>(); PlaceableItem placeableItem = ModUtils.GetOrCreateComponent <PlaceableItem>(modComponent); placeableItem.m_Range = template.GetComponent <PlaceableItem>()?.m_Range ?? 3; }
internal static void OnDrink() { float waterAmount = cookingPot.m_LitersWaterBeingBoiled; waterVolumeToDrink = GameManager.GetPlayerManagerComponent().CalculateWaterVolumeToDrink(waterAmount); gearItem = cookingPot.GetComponent <GearItem>(); waterSupply = gearItem.m_WaterSupply; if (waterSupply == null) { waterSupply = gearItem.gameObject.AddComponent <WaterSupply>(); gearItem.m_WaterSupply = waterSupply; } waterSupply.m_VolumeInLiters = waterAmount; bool potable = cookingPot.GetCookingState() == CookingPotItem.CookingState.Ready; waterSupply.m_WaterQuality = potable ? LiquidQuality.Potable : LiquidQuality.NonPotable; waterSupply.m_TimeToDrinkSeconds = GameManager.GetInventoryComponent().GetPotableWaterSupply().m_WaterSupply.m_TimeToDrinkSeconds; waterSupply.m_DrinkingAudio = GameManager.GetInventoryComponent().GetPotableWaterSupply().m_WaterSupply.m_DrinkingAudio; GameManager.GetThirstComponent().AddThirstOverTime(waterVolumeToDrink, waterSupply.m_TimeToDrinkSeconds); InterfaceManager.m_Panel_GenericProgressBar.Launch(Localization.Get("GAMEPLAY_DrinkingProgress"), waterSupply.m_TimeToDrinkSeconds, 0f, 0f, null, waterSupply.m_DrinkingAudio, true, false, new System.Action <bool, bool, float>(OnDrinkComplete)); GameManager.GetPlayerVoiceComponent().BlockNonCriticalVoiceForDuration(waterSupply.m_TimeToDrinkSeconds + 2f); }