public void InitSleepHud(SleepAndDeathScreen sleepAndDeathScreen, Map.MapData mapData, SlugcatStats charStats) { this.AddPart(new FoodMeter(this, charStats.maxFood, charStats.foodToHibernate)); this.foodMeter.pos = new Vector2(sleepAndDeathScreen.FoodMeterXPos((sleepAndDeathScreen.ID != ProcessManager.ProcessID.SleepScreen) ? 1f : 0f), 0f); this.foodMeter.lastPos = this.foodMeter.pos; if (mapData != null) { this.AddPart(new Map(this, mapData)); } int dayType; if ((this.owner as patch_SleepAndDeathScreen).nextcycleLength < 20000) { dayType = 1; } else if ((this.owner as patch_SleepAndDeathScreen).nextcycleLength < 28000) { dayType = 2; } else { dayType = 3; } this.AddPart(new KarmaMeter(this, this.fContainers[1], new IntVector2(dayType, 12), false)); this.karmaMeter.pos = new Vector2(this.rainWorld.options.ScreenSize.x - 280f, this.rainWorld.options.ScreenSize.y - 70f); this.karmaMeter.lastPos = this.karmaMeter.pos; this.karmaMeter.fade = 1f; if ((this.owner as patch_SleepAndDeathScreen).nextcycleLength2 < 20000) { dayType = 1; } else if ((this.owner as patch_SleepAndDeathScreen).nextcycleLength2 < 28000) { dayType = 2; } else { dayType = 3; } this.AddPart(new KarmaMeter(this, this.fContainers[1], new IntVector2(dayType, 12), false)); this.karmaMeter.pos = new Vector2(this.rainWorld.options.ScreenSize.x - 175f, this.rainWorld.options.ScreenSize.y - 70f); this.karmaMeter.lastPos = this.karmaMeter.pos; this.karmaMeter.fade = 1f; if ((this.owner as patch_SleepAndDeathScreen).nextcycleLength3 < 20000) { dayType = 1; } else if ((this.owner as patch_SleepAndDeathScreen).nextcycleLength3 < 28000) { dayType = 2; } else { dayType = 3; } this.AddPart(new KarmaMeter(this, this.fContainers[1], new IntVector2(dayType, 12), false)); this.karmaMeter.pos = new Vector2(this.rainWorld.options.ScreenSize.x - 70f, this.rainWorld.options.ScreenSize.y - 70f); this.karmaMeter.lastPos = this.karmaMeter.pos; this.karmaMeter.fade = 1f; this.AddPart(new RainMeter(this, this.fContainers[1])); this.rainMeter.pos = new Vector2(this.rainWorld.options.ScreenSize.x - 280f, this.rainWorld.options.ScreenSize.y - 70f); this.rainMeter.lastPos = this.rainMeter.pos; this.rainMeter.fade = 1f; this.AddPart(new RainMeter(this, this.fContainers[1])); this.rainMeter.pos = new Vector2(this.rainWorld.options.ScreenSize.x - 175f, this.rainWorld.options.ScreenSize.y - 70f); this.rainMeter.lastPos = this.rainMeter.pos; this.rainMeter.fade = 1f; this.AddPart(new RainMeter(this, this.fContainers[1])); this.rainMeter.pos = new Vector2(this.rainWorld.options.ScreenSize.x - 70f, this.rainWorld.options.ScreenSize.y - 70f); this.rainMeter.lastPos = this.rainMeter.pos; this.rainMeter.fade = 1f; }
// The original method may crash when called, since it assumes that there are 3+ images in the scene // Replace the method entirely for modded slugcats private static void SleepAndDeathScreen_Update(On.Menu.SleepAndDeathScreen.orig_Update orig, SleepAndDeathScreen self) { if (self.scene.sceneFolder != resourceFolderName) { orig(self); return; } if (self.starvedWarningCounter >= 0) { self.starvedWarningCounter++; } // base.Update(); if (!updateDelegates.TryGetValue(self, out Action baseUpdate)) { MethodInfo m = typeof(KarmaLadderScreen).GetMethod("Update", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance); baseUpdate = (Action)Activator.CreateInstance(typeof(Action), self, m.MethodHandle.GetFunctionPointer()); updateDelegates[self] = baseUpdate; } baseUpdate(); if (self.exitButton != null) { self.exitButton.buttonBehav.greyedOut = self.ButtonsGreyedOut; } if (self.passageButton != null) { self.passageButton.buttonBehav.greyedOut = (self.ButtonsGreyedOut || self.goalMalnourished); self.passageButton.black = Mathf.Max(0f, self.passageButton.black - 0.0125f); } if (self.endGameSceneCounter >= 0) { self.endGameSceneCounter++; if (self.endGameSceneCounter > 140) { self.manager.RequestMainProcessSwitch(ProcessManager.ProcessID.CustomEndGameScreen); } } if (self.RevealMap) { self.fadeOutIllustration = Custom.LerpAndTick(self.fadeOutIllustration, 1f, 0.02f, 0.025f); } else { self.fadeOutIllustration = Custom.LerpAndTick(self.fadeOutIllustration, 0f, 0.02f, 0.025f); } for (int i = 0; i < self.scene.subObjects.Count; i++) { ImageSettings settings = null; if (!(self.scene.subObjects[i] is MenuIllustration illust)) { continue; } if (customRep.TryGet(illust, out SceneImage csi)) { settings = csi.GetTempProperty <ImageSettings>("ShelterSettings"); } illust.setAlpha = Mathf.Lerp(settings?.baseAlpha ?? 1f, settings?.fadeAlpha ?? 1f, self.fadeOutIllustration); } }
private static void InitSleepHudHK(On.HUD.HUD.orig_InitSleepHud orig, HUD.HUD self, SleepAndDeathScreen sleepAndDeathScreen, Map.MapData mapData, SlugcatStats charStats) { if (!(sleepAndDeathScreen is MultiplayerSleepAndDeathScreen)) { Debug.Log("Calling orig ctor Sleeping Screen"); orig(self, sleepAndDeathScreen, mapData, charStats); return; } self.AddPart(new FoodMeter(self, charStats.maxFood, charStats.foodToHibernate)); //if (mapData != null) //{ //this.AddPart(new Map(this, mapData)); //} self.foodMeter.pos = new Vector2(sleepAndDeathScreen.FoodMeterXPos((sleepAndDeathScreen.ID != ProcessManager.ProcessID.SleepScreen) ? 1f : 0f), 0f); self.foodMeter.lastPos = self.foodMeter.pos; RainMeterMultiplayer rainMeter = new RainMeterMultiplayer(self, self.fContainers[1]); rainMeter.pos = new Vector2(self.rainWorld.options.ScreenSize.x - 335f, self.rainWorld.options.ScreenSize.y - 70f); self.AddPart(rainMeter); }
// Parse FADE tag private static void SleepAndDeathScreen_AddBkgIllustration(On.Menu.SleepAndDeathScreen.orig_AddBkgIllustration orig, SleepAndDeathScreen self) { orig(self); for (int i = 0; i < self.scene.subObjects.Count; i++) { if (!(self.scene.subObjects[i] is MenuIllustration illust)) { continue; } if (!customRep.TryGet(illust, out SceneImage csi)) { continue; } ImageSettings settings = new ImageSettings(); settings.baseAlpha = illust.setAlpha ?? illust.alpha; settings.fadeAlpha = settings.baseAlpha; // Fade property // The image's alpha will lerp to this when the map is open settings.fadeAlpha = csi.GetProperty <float?>("FADE") ?? settings.baseAlpha; csi.SetTempProperty("ShelterSettings", settings); } }