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); }
internal static void Postfix(CookingPotItem __instance) { if (!__instance.AttachedFireIsBurning() && WaterUtils.IsCookingItem(__instance)) { __instance.PickUpCookedItem(); } }
private void UpdateBottles() { foreach (LiquidItem eachLiquidItem in this.liquidItems) { WaterUtils.UpdateWaterBottle(eachLiquidItem.GetComponent <GearItem>()); } }
internal static bool Prefix(Panel_ActionsRadial __instance, ref List <GearItem> __result) { __result = new List <GearItem>(); for (int index = 0; index < GameManager.GetInventoryComponent().m_Items.Count; ++index) { GearItem component = GameManager.GetInventoryComponent().m_Items[index]; if (component.m_FoodItem != null && component.m_FoodItem.m_IsDrink) { if (component.m_IsInSatchel) { __result.Insert(0, component); } else { __result.Add(component); } } if (WaterUtils.ContainsWater(component)) { if (component.m_IsInSatchel) { __result.Insert(0, component); } else { __result.Add(component); } } } return(false); }
internal static void Prefix(ref GearItem gi, float volumeAvailable, ref bool __result) { //Added for replacing transpiler patch: //ref to gi //float volumeAvailable //this if clause if (UpdateInspectGearTracker.isExecuting && volumeAvailable > 0f) { gi = GameManager.GetPlayerManagerComponent().m_Gear; } if (!WaterUtils.IsWaterItem(gi)) { return; } LiquidItem liquidItem = gi.m_LiquidItem; WaterSupply waterSupply = liquidItem.GetComponent <WaterSupply>(); if (waterSupply == null) { waterSupply = liquidItem.gameObject.AddComponent <WaterSupply>(); gi.m_WaterSupply = waterSupply; } waterSupply.m_VolumeInLiters = liquidItem.m_LiquidLiters; waterSupply.m_WaterQuality = liquidItem.m_LiquidQuality; waterSupply.m_TimeToDrinkSeconds = liquidItem.m_TimeToDrinkSeconds; waterSupply.m_DrinkingAudio = liquidItem.m_DrinkingAudio; }
internal static void Postfix(GearItem __instance) { LiquidItem liquidItem = __instance.m_LiquidItem; if (liquidItem && liquidItem.m_LiquidType == GearLiquidTypeEnum.Water) { WaterUtils.UpdateWaterBottle(__instance); } }
internal static void Postfix(CookingPotItem __instance) { TrackExitPlaceMesh.isExecuting = false; // This is used to instantly pick up food from pot/ cans, when using right-click (It is bugged otherwise). // It is not allowed for meat -> !__instance.IsDummyPot(). if (!__instance.AttachedFireIsBurning() && WaterUtils.IsCookingItem(__instance) && !__instance.IsDummyPot()) { __instance.PickUpCookedItem(); } }
internal static void Postfix(CookingPotItem __instance) { if (__instance.AttachedFireIsBurning()) { return; } if (__instance.m_ParticlesSnowMelting.activeInHierarchy && WaterUtils.IsCooledDown(__instance)) { Utils.SetActive(__instance.m_ParticlesSnowMelting, false); } }
internal static void Postfix(CookingPotItem __instance) { //Implementation.Log("CookingPotItem -- UpdateMeltingSnow"); if (__instance.AttachedFireIsBurning()) { return; } else if (__instance.m_LitersSnowBeingMelted > 0) { if (__instance.m_ParticlesSnowMelting.activeInHierarchy && WaterUtils.IsCooledDown(__instance)) { Utils.SetActive(__instance.m_ParticlesSnowMelting, false); } } }
internal static void Postfix(GearItem placedGearNew) { if (placedGearNew == null || placedGearNew.m_CookingPotItem == null || !placedGearNew.m_CookingPotItem.AttachedFireIsBurning()) { return; } CookingPotItem cookingPotItem = placedGearNew.m_CookingPotItem; OverrideCookingState overrideCookingState = ModUtils.GetComponent <OverrideCookingState>(cookingPotItem); if (overrideCookingState?.ForceReady ?? false) { WaterUtils.SetElapsedCookingTimeForWater(cookingPotItem, WaterUtils.GetWaterAmount(cookingPotItem)); } }
internal static bool Prefix(GearItem gi, ref bool __result) { if (gi.m_DisableFavoriting) { return(false); } if (WaterUtils.ContainsWater(gi)) { __result = true; return(false); } return(true); }
internal static bool Prefix(GearItem gi, ref Texture2D __result) { LiquidItem liquidItem = gi.m_LiquidItem; if (!liquidItem || liquidItem.m_LiquidType != GearLiquidTypeEnum.Water) { return(true); } string textureName = gi.name.Replace("GEAR_", "ico_GearItem__") + WaterUtils.GetWaterSuffix(liquidItem); __result = Utils.GetInventoryGridIconTexture(textureName); return(__result == null); }
internal static void UpdateCapacityInfo(Panel_PickWater panel) { WaterSource waterSource = GetWaterSource(panel); if (!waterSource) { Debug.LogError("UpdateCapacityInfo: Could not find WaterSource"); return; } labelCapacityInfo.text = GetWaterInfo(LiquidQuality.Potable) + " " + GetWaterInfo(LiquidQuality.NonPotable) + " " + Localization.Get("GAMEPLAY_Empty") + ": " + WaterUtils.FormatWaterAmount(0) + "/" + WaterUtils.FormatWaterAmount(Water.GetRemainingCapacityEmpty()); labelNoCapacityWarning.gameObject.SetActive(Water.GetRemainingCapacityEmpty() == 0 && Water.GetRemainingCapacity(waterSource.GetQuality()) == 0); }
internal static void Prepare(Panel_FeedFire panel) { labelCookingWarning = NGUITools.AddChild <UILabel>(panel.m_TabWater); labelCookingWarning.depth = 2000; labelCookingWarning.color = new Color(0.640f, 0.202f, 0.231f); labelCookingWarning.bitmapFont = panel.m_Label_Water.bitmapFont; labelCookingWarning.fontSize = 14; labelCookingWarning.alignment = NGUIText.Alignment.Center; labelCookingWarning.pivot = UIWidget.Pivot.Center; labelCookingWarning.width = 400; labelCookingWarning.height = 20; labelCookingWarning.capsLock = true; labelCookingWarning.transform.position = new Vector3(0, -0.858f, 0); UISprite[] sprites = Resources.FindObjectsOfTypeAll <UISprite>(); foreach (UISprite eachSprite in sprites) { if (eachSprite.width == 320 && eachSprite.height == 60 && NGUITools.IsChild(panel.transform, eachSprite.transform) && eachSprite.transform.localPosition.x == -160 && eachSprite.transform.localPosition.y == -30) { eachSprite.pivot = UIWidget.Pivot.Top; eachSprite.height = (int)(eachSprite.height + Mathf.Abs(offset.y)); } } UITexture texturePotable = WaterUtils.GetUITexure("gearIcon_Potable"); if (texturePotable != null) { UITexture textureEmpty = Object.Instantiate(texturePotable, texturePotable.transform.parent); textureEmpty.transform.localPosition = texturePotable.transform.localPosition + offset; textureEmpty.mainTexture = (Texture)Resources.Load("InventoryGridIcons/ico_GearItem__WaterSupplyNone"); } UILabel labelPotable = WaterUtils.GetUILabel("LabelPotable"); if (labelPotable != null) { UILabel labelEmpty = Object.Instantiate(labelPotable, labelPotable.transform.parent); labelEmpty.transform.localPosition = labelPotable.transform.localPosition + offset; labelEmpty.GetComponent <UILocalize>().key = "GAMEPLAY_Empty"; } labelEmptyCapacity = Object.Instantiate(panel.m_Label_PotableSupply, panel.m_Label_PotableSupply.transform.parent); labelEmptyCapacity.transform.localPosition = panel.m_Label_PotableSupply.transform.localPosition + offset; }
internal static void Postfix(CookingPotItem __instance) { if (__instance.AttachedFireIsBurning()) { return; } if ((__instance.m_ParticlesWaterBoiling.activeInHierarchy || __instance.m_ParticlesWaterReady.activeInHierarchy) && WaterUtils.IsCooledDown(__instance)) { Utils.SetActive(__instance.m_ParticlesWaterReady, false); Utils.SetActive(__instance.m_ParticlesWaterBoiling, false); if (__instance.GetCookingState() == CookingPotItem.CookingState.Ready) { ModUtils.GetOrCreateComponent <OverrideCookingState>(__instance).ForceReady = true; WaterUtils.SetElapsedCookingTimeForWater(__instance, WaterUtils.GetWaterAmount(__instance)); } } }
internal static void Postfix(PlayerManager __instance, float progress) { //WaterSupply waterSupply = AccessTools.Field(__instance.GetType(), "m_WaterSourceToDrinkFrom").GetValue(__instance) as WaterSupply; WaterSupply waterSupply = __instance.m_WaterSourceToDrinkFrom; if (waterSupply == null) { return; } GearItem gearItem = waterSupply.GetComponent <GearItem>(); if (gearItem.m_LiquidItem != null) { gearItem.m_LiquidItem.m_LiquidLiters = waterSupply.m_VolumeInLiters; Object.Destroy(waterSupply); gearItem.m_WaterSupply = null; } if (gearItem.m_CookingPotItem != null) { if (!WaterUtils.IsCooledDown(gearItem.m_CookingPotItem)) { //GameManager.GetPlayerManagerComponent().ApplyFreezingBuff(20 * progress, 0.5f, 1 * progress); GameManager.GetPlayerManagerComponent().ApplyFreezingBuff(20 * progress, 0.5f, 1 * progress, 24f); PlayerDamageEvent.SpawnAfflictionEvent("GAMEPLAY_WarmingUp", "GAMEPLAY_BuffHeader", "ico_injury_warmingUp", InterfaceManager.m_Panel_ActionsRadial.m_FirstAidBuffColor); } WaterUtils.SetWaterAmount(gearItem.m_CookingPotItem, waterSupply.m_VolumeInLiters); Object.Destroy(waterSupply); } if (waterSupply is WaterSourceSupply) { WaterSourceSupply waterSourceSupply = waterSupply as WaterSourceSupply; waterSourceSupply.UpdateWaterSource(); } Water.AdjustWaterSupplyToWater(); }
internal static void Prefix(GearItem gi, ref bool __result) { if (!WaterUtils.IsWaterItem(gi)) { return; } LiquidItem liquidItem = gi.m_LiquidItem; WaterSupply waterSupply = liquidItem.GetComponent <WaterSupply>(); if (waterSupply == null) { waterSupply = liquidItem.gameObject.AddComponent <WaterSupply>(); gi.m_WaterSupply = waterSupply; } waterSupply.m_VolumeInLiters = liquidItem.m_LiquidLiters; waterSupply.m_WaterQuality = liquidItem.m_LiquidQuality; waterSupply.m_TimeToDrinkSeconds = liquidItem.m_TimeToDrinkSeconds; waterSupply.m_DrinkingAudio = liquidItem.m_DrinkingAudio; }
internal static void Postfix(PlayerManager __instance, float progress) { WaterSupply waterSupply = AccessTools.Field(__instance.GetType(), "m_WaterSourceToDrinkFrom").GetValue(__instance) as WaterSupply; if (waterSupply == null) { return; } GearItem gearItem = waterSupply.GetComponent <GearItem>(); if (gearItem.m_LiquidItem != null) { gearItem.m_LiquidItem.m_LiquidLiters = waterSupply.m_VolumeInLiters; Object.Destroy(waterSupply); gearItem.m_WaterSupply = null; } if (gearItem.m_CookingPotItem != null) { if (!WaterUtils.IsCooledDown(gearItem.m_CookingPotItem)) { GameManager.GetPlayerManagerComponent().ApplyFreezingBuff(20 * progress, 0.5f, 1 * progress, 1); InterfaceManager.m_Panel_HUD.ShowBuffNotification("GAMEPLAY_WarmingUp", "GAMEPLAY_BuffHeader", InterfaceManager.m_Panel_HUD.m_BuffSpriteFreezingBuff); } WaterUtils.SetWaterAmount(gearItem.m_CookingPotItem, waterSupply.m_VolumeInLiters); Object.Destroy(waterSupply); } if (waterSupply is WaterSourceSupply waterSourceSupply) { waterSourceSupply.UpdateWaterSource(); } Water.AdjustWaterSupplyToWater(); }
private static string GetWaterInfo(LiquidQuality quality) { return(Localization.Get("GAMEPLAY_Water" + quality.ToString()) + ": " + WaterUtils.FormatWaterAmount(Water.GetActual(quality)) + "/" + WaterUtils.FormatWaterAmount(Water.GetCapacity(quality))); }
internal static void Prefix(CookingPotItem __instance, ref CookingPotItem.CookingState cookingState) // circumvent the transformation to "ruined" after a long time period. { if (cookingState == CookingPotItem.CookingState.Cooking && !__instance.AttachedFireIsBurning() && WaterUtils.GetWaterAmount(__instance) > 0) { cookingState = __instance.GetCookingState(); } }
internal static void Prefix(CookingPotItem __instance, ref CookingPotItem.CookingState cookingState) { if (cookingState == CookingPotItem.CookingState.Cooking && !__instance.AttachedFireIsBurning() && WaterUtils.GetWaterAmount(__instance) > 0) { cookingState = __instance.GetCookingState(); } }