/// <summary>Applies conditional settings to each specific effect as it's generated. Used to apply changes based on location name, tile, etc.</summary> /// <param name="effect">The cauldron effect to modify.</param> /// <param name="locationName">The name of the effect's <see cref="GameLocation"/>. Empty ("") if unavailable.</param> /// <param name="tile">The tile coordinates of the effect.</param> /// <returns>The provided effect with any necessary changes applied.</returns> private static CauldronEffect ApplyConditionalEffectSettings(CauldronEffect effect, string locationName, Vector2 tile) { if (locationName == "Farm") { effect.DrawAboveAlwaysFront = true; //draw above all map layers (avoids issues with Grandpa's Farm layers, etc) } else if (locationName == "Custom_SpriteSpring2") { effect.DrawAboveAlwaysFront = true; } else if (locationName == "Custom_CrimsonBadlands") { effect.TextureName = "Maps\\SandstormEffect"; effect.SourceRect = new Rectangle(0, 0, 200, 200); effect.MinTickRate = 35; effect.MaxTickRate = 70; effect.Flipped = false; effect.AlphaFade = 0.0012f; //effect.TintColor = new Color(240, 248, 255); effect.DrawAboveAlwaysFront = true; effect.Alpha = 0.50f; effect.Motion = new Vector2(3f, -0.05f); effect.Acceleration = new Vector2(0.1f, -0.01f); effect.Scale = 2f; effect.ScaleChange = 0.005f; effect.MinRotation = 1; effect.MaxRotation = 6; effect.MinRotationChange = -5; effect.MaxRotationChange = 6; } return(effect); }
/// <summary>Update the current player's list of effects for their location.</summary> private static void UpdateEffects() { if (Context.IsWorldReady == false) //if a game is NOT currently loaded { return; //do nothing } CauldronEffects.Value = new List <CauldronEffect>(); //clear the existing list Vector2 offset = new Vector2(32, 32); //define the offset within each tile (e.g. 32,32 = effects appear at the center of a tile) string locationName = Game1.player.currentLocation?.Name ?? ""; //get the local player's current location name (use "" if null) WaterfallTiles.TryGetValue(locationName, out List <Vector2> staticTiles); //get static waterfall tiles for this location, if any if (staticTiles == null) //if no static tiles exist { staticTiles = new List <Vector2>(); //use a blank list } foreach (Vector2 tile in staticTiles.Concat(GetConditionalWaterfallTiles(locationName))) //for each waterfall tile in the static list AND conditional list { Vector2 effectPosition = (tile * 64) + offset; //get the position of this tile's effect CauldronEffect effect = new CauldronEffect(effectPosition); //create a new effect effect = ApplyConditionalEffectSettings(effect, locationName, tile); //apply conditional changes CauldronEffects.Value.Add(effect); //add the effect to the list } }