public static AltSidesHelperMode GetModeMetaForAltSide(AreaData data) { if (data == null) { return(null); } AltSidesHelperMeta parentHelperMeta = GetMetaForAreaData(AreaData.Get(GetMetaForAreaData(AreaData.Get(data.SID))?.AltSideData?.For)); if (parentHelperMeta != null) { foreach (var mode in parentHelperMeta.Sides) { if (mode.Map.Equals(data.SID)) { return(mode); } } } // check for a-side overrides too AltSidesHelperMeta helperMeta = GetMetaForAreaData(data); if (helperMeta != null) { foreach (var mode in helperMeta.Sides) { if (mode.OverrideVanillaSideData) { return(mode); } } } return(null); }
public static AltSidesHelperMode GetModeMetaForAltSide(AreaData data) { if (data == null) { return(null); } AltSidesHelperMeta parentHelperMeta = GetMetaForAreaData(AreaData.Get(GetMetaForAreaData(AreaData.Get(data.SID))?.AltSideData?.For)); if (parentHelperMeta != null) { foreach (var mode in parentHelperMeta.Sides) { if (mode.Map.Equals(data.SID)) { return(mode); } } } return(null); }
private void SetPoemColour(On.Celeste.Poem.orig_ctor orig, Poem self, string text, int heartIndex, float heartAlpha) { orig(self, text, heartIndex, heartAlpha); // customize heart gem icon string animId = null; // our sprite ID will be "AltSidesHelper_<heart sprite path keyified>" // log duplicate entries for a map var sid = (Engine.Scene as Level).Session.Area.SID; Color?color = null; AltSidesHelperMeta parentHelperMeta = GetMetaForAreaData(AreaData.Get(GetMetaForAreaData(AreaData.Get(sid))?.AltSideData?.For)); if (parentHelperMeta != null) { foreach (var mode in parentHelperMeta.Sides) { if (mode.Map.Equals(sid)) { animId = mode.ChapterPanelHeartIcon.DialogKeyify(); if (!mode.PoemDisplayColor.Equals("")) { color = Calc.HexToColor(mode.PoemDisplayColor); } } } } if (animId != null) { if (HeartSpriteBank.Has(animId)) { HeartSpriteBank.CreateOn(self.Heart, animId); self.Heart.Play("spin"); self.Heart.CenterOrigin(); } } if (color != null) { new DynData <Poem>(self)["Color"] = color; } }
private static void CustomizeCrystalHeart(OuiChapterPanel panel) { // customize heart gem icon string animId = null; // our sprite ID will be "AltSidesHelper_<heart sprite path keyified>" // log duplicate entries for a map AltSidesHelperMeta parentHelperMeta = GetMetaForAreaData(AreaData.Get(GetMetaForAreaData(AreaData.Get(panel.Area))?.AltSideData?.For)); if (parentHelperMeta != null) { foreach (var mode in parentHelperMeta.Sides) { if (mode.Map.Equals(panel.Area.SID)) { animId = mode.ChapterPanelHeartIcon.DialogKeyify(); } } } if (animId != null) { if (HeartSpriteBank.Has(animId)) { Sprite heartSprite = HeartSpriteBank.Create(animId); var selfdata = new DynData <OuiChapterPanel>(panel); var oldheart = selfdata.Get <HeartGemDisplay>("heart"); bool prevVisible = oldheart.Sprites[0].Visible; oldheart.Sprites[0] = heartSprite; heartSprite.CenterOrigin(); heartSprite.Play("spin"); heartSprite.Visible = prevVisible; selfdata["AsHeartDirty"] = true; } } }
private static void AddExtraModes(OuiChapterPanel self) { // check map meta for extra sides or side overrides //AltSidesHelperMeta meta = new DynData<AreaData>(self.Data).Get<AltSidesHelperMeta>("AltSidesHelperMeta"); AltSidesHelperMeta meta = GetMetaForAreaData(self.Data); //AltSidesMetadata[self.Data]; if (meta?.Sides != null) { Logger.Log("AltSidesHelper", $"Customising panel UI for \"{self.Data.SID}\"."); bool[] unlockedSides = new bool[meta.Sides.Count()]; int siblings = ((IList)modesField.GetValue(self)).Count; int oldModes = siblings; bool bsidesunlocked = !self.Data.Interlude_Safe && self.Data.HasMode(AreaMode.BSide) && (self.DisplayedStats.Cassette || ((SaveData.Instance.DebugMode || SaveData.Instance.CheatMode) && self.DisplayedStats.Cassette == self.RealStats.Cassette)); bool csidesunlocked = !self.Data.Interlude_Safe && self.Data.HasMode(AreaMode.CSide) && SaveData.Instance.UnlockedModes >= 3 && Celeste.Celeste.PlayMode != Celeste.Celeste.PlayModes.Event; // find the new total number of unlocked modes int unlockedModeCount = 0; // if this map has a C-Side, this is whether they have C-sides unlocked. else, if this map has a B-Sides, its whether they have a cassette. else, true. bool prevUnlocked = self.Data.HasMode(AreaMode.CSide) ? csidesunlocked : self.Data.HasMode(AreaMode.BSide) ? bsidesunlocked : true; // if this map has a C-Side, this is whether they've beaten it; else, if this map has a B-Side, its whether they've completed it; else, its whether they've completed the level. bool prevCompleted = self.Data.HasMode(AreaMode.CSide) ? SaveData.Instance.GetAreaStatsFor(self.Data.ToKey()).Modes[(int)AreaMode.CSide].Completed : self.Data.HasMode(AreaMode.BSide) ? SaveData.Instance.GetAreaStatsFor(self.Data.ToKey()).Modes[(int)AreaMode.BSide].Completed : SaveData.Instance.GetAreaStatsFor(self.Data.ToKey()).Modes[(int)AreaMode.Normal].Completed; for (int i1 = 0; i1 < meta.Sides.Length; i1++) { AltSidesHelperMode mode = meta.Sides[i1]; if (!mode.OverrideVanillaSideData) { if ((mode.UnlockMode.Equals("consecutive") && prevCompleted) || (mode.UnlockMode.Equals("with_previous") && prevUnlocked) || (mode.UnlockMode.Equals("triggered") && AltSidesSaveData.UnlockedAltSideIDs.Contains(mode.Map)) || (mode.UnlockMode.Equals("c_sides_unlocked") && csidesunlocked) || mode.UnlockMode.Equals("always") || SaveData.Instance.DebugMode || SaveData.Instance.CheatMode) { unlockedModeCount++; siblings++; prevUnlocked = true; prevCompleted = SaveData.Instance.GetAreaStatsFor(AreaData.Get(mode.Map).ToKey()).Modes[(int)AreaMode.Normal].Completed; unlockedSides[i1] = true; } else { prevUnlocked = prevCompleted = false; unlockedSides[i1] = false; } } else { unlockedSides[i1] = true; } } // adjust the original options to fit, and attach the map path & mode to the original options int origMode = 0; foreach (var vmode in (IList)modesField.GetValue(self)) { DynamicData data = new DynamicData(vmode); if (siblings > 5) { data.Set("Siblings", siblings); data.Set("Large", false); } data.Set("AreaKey", self.Data.ToKey((AreaMode)origMode)); origMode++; } // apply mode settings int newSides = 0; for (int i = 0; i < meta.Sides.Length /*&& newSides < unlockedModes*/; i++) { AltSidesHelperMode mode = meta.Sides[i]; // only add if its unlocked if (unlockedSides[i]) { if (!mode.OverrideVanillaSideData) { object newOptn; ((IList)modesField.GetValue(self)).Add( newOptn = DynamicData.New(t_OuiChapterPanelOption)(new { Label = Dialog.Clean(mode.Label), Icon = GFX.Gui[mode.Icon], ID = "AltSidesHelperMode_" + i.ToString(), Siblings = siblings > 5 ? siblings : 0 }) ); DynamicData data = new DynamicData(newOptn); AreaData map = null; foreach (var area in AreaData.Areas) { if (area.SID.Equals(mode.Map)) { map = area; } } data.Set("AreaKey", map.ToKey()); newSides++; Logger.Log("AltSidesHelper", $"Added new side for \"{self.Data.SID}\"."); } else { // find the a-side and modify it DynamicData data = new DynamicData(((IList)modesField.GetValue(self))[0]); data.Set("Label", Dialog.Clean(mode.Label)); data.Set("Icon", GFX.Gui[mode.Icon]); Logger.Log("AltSidesHelper", $"Modifying A-Side data for \"{self.Data.SID}\"."); } } } } int count = ((IList)modesField.GetValue(self)).Count; for (int i = 0; i < count; i++) { //DynamicData data = new DynamicData(((IList)modesField.GetValue(self))[i]); //data.Invoke("SlideTowards", count, i); } }