public static BlackholeBG CreateBlackholeWithCustomColors(BinaryPacker.Element effectData) { if (!effectData.Attr("colorsMild").Contains("|") && !effectData.Attr("colorsWild").Contains("|") && !effectData.Attr("bgColorInner").Contains("|") && !effectData.Attr("bgColorOuterMild").Contains("|") && !effectData.Attr("bgColorOuterWild").Contains("|")) { // there is no gradient on any color: we can just instanciate a vanilla blackhole and mess with its properties. // set up colorsMild for the hook above. we can't use DynData to pass this over, since the object does not exist yet! colorsMild = parseColors(effectData.Attr("colorsMild", "6e3199,851f91,3026b0")); for (int i = 0; i < colorsMild.Length; i++) { colorsMild[i] *= 0.8f; } // build the blackhole: the hook will take care of setting colorsMild. BlackholeBG blackhole = new BlackholeBG(); // ... now we've got to set everything else. DynData <BlackholeBG> blackholeData = new DynData <BlackholeBG>(blackhole); blackholeData["colorsWild"] = parseColors(effectData.Attr("colorsWild", "ca4ca7,b14cca,ca4ca7")); blackholeData["bgColorInner"] = Calc.HexToColor(effectData.Attr("bgColorInner", "000000")); blackholeData["bgColorOuterMild"] = Calc.HexToColor(effectData.Attr("bgColorOuterMild", "512a8b")); blackholeData["bgColorOuterWild"] = Calc.HexToColor(effectData.Attr("bgColorOuterWild", "bd2192")); blackhole.Alpha = effectData.AttrFloat("alpha", 1f); return(blackhole); } else { // there are gradients: we need a custom blackhole! // set up colorsMild for the hook above. we can't use DynData to pass this over, since the object does not exist yet! colorsMild = new ColorCycle(effectData.Attr("colorsMild", "6e3199,851f91,3026b0"), 0.8f).GetColors(); // build the blackhole: the hook will take care of setting colorsMild. BlackholeCustomColors blackhole = new BlackholeCustomColors( effectData.Attr("colorsMild", "6e3199,851f91,3026b0"), effectData.Attr("colorsWild", "ca4ca7,b14cca,ca4ca7"), effectData.Attr("bgColorInner", "000000"), effectData.Attr("bgColorOuterMild", "512a8b"), effectData.Attr("bgColorOuterWild", "bd2192")); // ... now we've got to set the initial values of everything else. blackhole.blackholeData["colorsWild"] = blackhole.cycleColorsWild.GetColors(); blackhole.blackholeData["bgColorInner"] = blackhole.cycleBgColorInner.GetColors()[0]; blackhole.blackholeData["bgColorOuterMild"] = blackhole.cycleBgColorOuterMild.GetColors()[0]; blackhole.blackholeData["bgColorOuterWild"] = blackhole.cycleBgColorOuterWild.GetColors()[0]; blackhole.Alpha = effectData.AttrFloat("alpha", 1f); return(blackhole); } }
public static bool AttrIfFloat(this BinaryPacker.Element el, string name, Action <float> value) { if (el.HasAttr(name)) { value(el.AttrFloat(name)); return(true); } return(false); }
public static bool AttrRef(this BinaryPacker.Element el, string name, ref float value) { if (el.HasAttr(name)) { value = el.AttrFloat(name); return(true); } return(false); }
public static BlackholeBG CreateBlackholeWithCustomColors(BinaryPacker.Element effectData) { // set up colorsMild for the hook above. we can't use DynData to pass this over, since the object does not exist yet! colorsMild = parseColors(effectData.Attr("colorsMild", "6e3199,851f91,3026b0")); for (int i = 0; i < colorsMild.Length; i++) { colorsMild[i] *= 0.8f; } // build the blackhole: the hook will take care of setting colorsMild. BlackholeBG blackhole = new BlackholeBG(); // ... now we've got to set everything else. DynData <BlackholeBG> blackholeData = new DynData <BlackholeBG>(blackhole); blackholeData["colorsWild"] = parseColors(effectData.Attr("colorsWild", "ca4ca7,b14cca,ca4ca7")); blackholeData["bgColorInner"] = Calc.HexToColor(effectData.Attr("bgColorInner", "000000")); blackholeData["bgColorOuterMild"] = Calc.HexToColor(effectData.Attr("bgColorOuterMild", "512a8b")); blackholeData["bgColorOuterWild"] = Calc.HexToColor(effectData.Attr("bgColorOuterWild", "bd2192")); blackhole.Alpha = effectData.AttrFloat("alpha", 1f); return(blackhole); }
private Backdrop onLoadBackdrop(MapData map, BinaryPacker.Element child, BinaryPacker.Element above) { if (child.Name.Equals("MaxHelpingHand/HeatWaveNoColorGrade", StringComparison.OrdinalIgnoreCase)) { return(new HeatWaveNoColorGrade(child.AttrBool("controlColorGradeWhenActive"))); } if (child.Name.Equals("MaxHelpingHand/BlackholeCustomColors", StringComparison.OrdinalIgnoreCase)) { return(BlackholeCustomColors.CreateBlackholeWithCustomColors(child)); } if (child.Name.Equals("MaxHelpingHand/CustomPlanets", StringComparison.OrdinalIgnoreCase)) { return(new CustomPlanets(child.AttrInt("count", 32), child.Attr("directory", "MaxHelpingHand/customplanets/bigstars"), child.AttrFloat("animationDelay", 0.1f))); } if (child.Name.Equals("MaxHelpingHand/CustomStars", StringComparison.OrdinalIgnoreCase)) { int?starCount = null; if (int.TryParse(child.Attr("starCount", ""), out int starCountParsed)) { starCount = starCountParsed; } string tint = child.Attr("tint", ""); if (child.AttrBool("disableTinting", false)) { tint = "ffffff"; // approximative backwards compatibility } return(new CustomStars(starCount, string.IsNullOrEmpty(tint) ? (Color?)null : Calc.HexToColor(tint), child.Attr("spriteDirectory", "bgs/02/stars"))); } if (child.Name.Equals("MaxHelpingHand/SnowCustomColors", StringComparison.OrdinalIgnoreCase)) { string[] colorsAsStrings = child.Attr("colors").Split(','); Color[] colors = new Color[colorsAsStrings.Length]; for (int i = 0; i < colors.Length; i++) { colors[i] = Calc.HexToColor(colorsAsStrings[i]); } return(new SnowCustomColors(colors, child.AttrBool("foreground"))); } if (child.Name.Equals("MaxHelpingHand/NorthernLightsCustomColors", StringComparison.OrdinalIgnoreCase)) { string[] colorsAsStrings = child.Attr("colors").Split(','); Color[] colors = new Color[colorsAsStrings.Length]; for (int i = 0; i < colors.Length; i++) { colors[i] = Calc.HexToColor(colorsAsStrings[i]); } NorthernLightsCustomColors.GradientColor1 = child.Attr("gradientColor1", "020825"); NorthernLightsCustomColors.GradientColor2 = child.Attr("gradientColor2", "170c2f"); NorthernLightsCustomColors.Colors = colors; NorthernLightsCustomColors effect = new NorthernLightsCustomColors(colors, child.AttrBool("displayBackground", true)); NorthernLightsCustomColors.GradientColor1 = null; NorthernLightsCustomColors.GradientColor2 = null; NorthernLightsCustomColors.Colors = null; return(effect); } return(null); }