diff --git a/Assets/Masks/RingGlow.png b/Assets/Masks/RingGlow.png new file mode 100644 index 000000000..8833cf304 Binary files /dev/null and b/Assets/Masks/RingGlow.png differ diff --git a/Assets/Masks/RingGlowInner.png b/Assets/Masks/RingGlowInner.png new file mode 100644 index 000000000..2e12b35e5 Binary files /dev/null and b/Assets/Masks/RingGlowInner.png differ diff --git a/Assets/Masks/RingGlowInnerTwo.png b/Assets/Masks/RingGlowInnerTwo.png new file mode 100644 index 000000000..a1df4ff04 Binary files /dev/null and b/Assets/Masks/RingGlowInnerTwo.png differ diff --git a/Assets/Misc/AuroraWater.png b/Assets/Misc/AuroraWater.png index 7c26549d8..8d9e38e7b 100644 Binary files a/Assets/Misc/AuroraWater.png and b/Assets/Misc/AuroraWater.png differ diff --git a/Content/Abilities/AbilityHandler.cs b/Content/Abilities/AbilityHandler.cs index d4de3332d..aa4a1dac4 100644 --- a/Content/Abilities/AbilityHandler.cs +++ b/Content/Abilities/AbilityHandler.cs @@ -16,8 +16,6 @@ public class AbilityHandler : ModPlayer, IOrderedLoadable private InfusionItem[] infusions = new InfusionItem[Infusion.InfusionSlots]; public Dictionary unlockedAbilities = new(); - - private float stamina; private float staminaMaxBonus; private int staminaRegenCD; @@ -99,9 +97,9 @@ public float StaminaMaxBonus /// public float Stamina { - get => stamina; + get; // Can't have less than 0 or more than max stamina. - set => stamina = MathHelper.Clamp(value, 0, StaminaMax); + set => field = MathHelper.Clamp(value, 0, StaminaMax); } //for some reason without specifically setting these values to zero with cloneNewInstances => false and contructor, @@ -400,8 +398,7 @@ public override void PreUpdate() // To ensure fusions always have their owner set to a valid Player. for (int i = 0; i < infusions.Length; i++) { - if (infusions[i] != null) - infusions[i].Item.playerIndexTheItemIsReservedFor = Player.whoAmI; + infusions[i]?.Item.playerIndexTheItemIsReservedFor = Player.whoAmI; } } diff --git a/Content/Abilities/Hint/HintAbility.cs b/Content/Abilities/Hint/HintAbility.cs index e2ca75bf0..3c87523f6 100644 --- a/Content/Abilities/Hint/HintAbility.cs +++ b/Content/Abilities/Hint/HintAbility.cs @@ -153,8 +153,7 @@ public override void UpdateActive() int i = Projectile.NewProjectile(Player.GetSource_FromThis(), Main.MouseWorld + Vector2.UnitY * -32, Vector2.Zero, ModContent.ProjectileType(), 0, 0, Main.myPlayer); var proj = Main.projectile[i].ModProjectile as HintText; - if (proj != null) - proj.text = hintToDisplay; + proj?.text = hintToDisplay; } Deactivate(); diff --git a/Content/Abilities/InfusionItem.ModItemMethods.cs b/Content/Abilities/InfusionItem.ModItemMethods.cs index 482490336..cd63f8f49 100644 --- a/Content/Abilities/InfusionItem.ModItemMethods.cs +++ b/Content/Abilities/InfusionItem.ModItemMethods.cs @@ -33,8 +33,7 @@ public void Draw(SpriteBatch spriteBatch, Vector2 position, float opacity, float public override void UpdateInventory(Player player) { - if (ability != null) - ability.User = player.GetHandler(); + ability?.User = player.GetHandler(); } public override void Update(ref float gravity, ref float maxFallSpeed) diff --git a/Content/Alchemy/AlchemyIngredient.cs b/Content/Alchemy/AlchemyIngredient.cs deleted file mode 100644 index e94682959..000000000 --- a/Content/Alchemy/AlchemyIngredient.cs +++ /dev/null @@ -1,134 +0,0 @@ -using Terraria.DataStructures; -using Terraria.ID; - -namespace StarlightRiver.Content.Alchemy -{ - public abstract class AlchemyIngredient - { - /// - /// When instantiated by the cauldron dummy we may need to store exactly the Item being used as an ingredient so we don't lose properties on the ingredient like modifiers etc - /// - public Item storedItem; - - /// - /// Item type ID of the ingredient, use ItemType() to get Mod Item IDs and Terraria.ID.ItemID for vanilla Items - /// - public readonly int ItemType; - - /// - /// if not overriding default visuals this will be used to lerp the overall color towards this value. defaults to a sort of light blue - /// - public Color ingredientColor = new(3, 127, 252); - - protected int timeSinceAdded; - - public AlchemyIngredient() { } - - public abstract int GetItemID(); - - /// - /// for instantiating the actual Item into the ingredient - /// - /// - public void PutIngredient(Item ingredientItem) - { - this.storedItem = ingredientItem; - timeSinceAdded = 0; - } - - /// - /// called at the end of every frame that this is in the cauldron to increment the timer - /// 0 on first frame inserted - /// - public void IncrementTimer() - { - timeSinceAdded++; - } - - /// - /// performs logic and visuals while this is the most recent Item added to the cauldron. return true if visual updates should be skipped for other ingredents currently in cauldron - /// - public virtual bool MostRecentUpdate(AlchemyWrapper wrapper) - { - return false; - } - - /// - /// performs logic and visuals that occur AFTER ALL other ingredient visuals / logic are run while this is the most recent Item added to the cauldron - /// executes even if mostRecentUpdate returns true - /// by default just adds cauldron lighting for the resulting bubble color - /// - /// - public virtual void MostRecentPostUpdate(AlchemyWrapper wrapper) - { - Lighting.AddLight(wrapper.cauldronRect.TopLeft() + new Vector2(wrapper.cauldronRect.Width / 2, 0), wrapper.bubbleColor.ToVector3()); - } - - /// - /// perform logic updates while this is added to the cauldron, executed by both client and server. runs even if mostRecentUpdate returned true. - /// runs after the most recent ingredient executes mostRecentUpdate and executes in order of oldest ingredient to newest. also executes for most recent ingredient. - /// designed for the idea of "dangerous" ingredients that may damage nearby Players or have other tangible effects on the world and Players outside of just visuals - /// - public virtual void Update(AlchemyWrapper wrapper) - { - - } - - /// - /// Perform client-only updates while this is added to the cauldron runs after Update, skipped if mostRecentUpdate returned true. - /// Executes in order of the oldest ingredient to newest immediately after running Update for this ingredient - /// - public virtual void VisualUpdate(AlchemyWrapper wrapper) - { - wrapper.bubbleAnimationTimer += 0.1f; //slightly increase bubbling speed - - if (timeSinceAdded == 0) - { - for (int k = 0; k < 10; k++) - Dust.NewDust(wrapper.cauldronRect.TopLeft() + new Vector2(wrapper.cauldronRect.Width / 4, 0), wrapper.cauldronRect.Width / 2, 0, DustID.Water, 0, -6, 0, default, 1f); - - Terraria.Audio.SoundEngine.PlaySound(SoundID.Splash, wrapper.cauldronRect.Center.ToVector2()); - } - - wrapper.bubbleColor = Color.Lerp(wrapper.bubbleColor, ingredientColor, 0.7f); - - if (timeSinceAdded < 15) - { - wrapper.bubbleAnimationTimer += 2; - //lerp towards a white flash when freshly added - wrapper.bubbleColor = Color.Lerp(Color.White, wrapper.bubbleColor, timeSinceAdded / 15f); - } - } - - /// - /// spawns this Item into the world randomized in the cauldron's rectangle subtracting the consumedCount from the stack or doing nothing if 0 after subtracting - /// - /// - /// - public virtual void Dump(Rectangle cauldronRect) - { - if (storedItem.stack > 0) - { - //TODO: rework this to handle exact clone dropping like keeping modifiers, maybe look into calling newItem to get an open Main.item index and then replace it with the clone and net send it - Item.NewItem(new EntitySource_WorldEvent(), cauldronRect, storedItem.type, storedItem.stack); - } - - storedItem = null; - } - - /// - /// PRECONDITION: Item type matches this ingredient's Item type - /// Attempts to add the Item stack to the ingredient stack - /// return false if this is an ingredient that should not stack and instead create another AlchemyIngredient instance - /// by default adds the stack counts together, resets timeSinceAdded to 0 and returns true - /// - /// - /// - public virtual bool AddToStack(Item Item) - { - timeSinceAdded = 0; - storedItem.stack += Item.stack; - return true; - } - } -} \ No newline at end of file diff --git a/Content/Alchemy/AlchemyModifier.cs b/Content/Alchemy/AlchemyModifier.cs deleted file mode 100644 index c033f9717..000000000 --- a/Content/Alchemy/AlchemyModifier.cs +++ /dev/null @@ -1,6 +0,0 @@ -namespace StarlightRiver.Content.Alchemy -{ - class AlchemyModifier - { - } -} \ No newline at end of file diff --git a/Content/Alchemy/AlchemyRecipe.cs b/Content/Alchemy/AlchemyRecipe.cs deleted file mode 100644 index 60c058e93..000000000 --- a/Content/Alchemy/AlchemyRecipe.cs +++ /dev/null @@ -1,171 +0,0 @@ -using System; -using System.Collections.Generic; -using Terraria.DataStructures; - -namespace StarlightRiver.Content.Alchemy -{ - /// - /// base alchemy class, can be directly created if no unique visuals / logic is needed for the recipe - /// otherwise override and use provided hooks for more advanced logic and visuals - /// - public class AlchemyRecipe - { - - protected Dictionary requiredIngredientsMap = new(); - protected List requiredModifiers = new(); - - protected List outputItemList = new(); - - /// - /// adds this recipe to the recipe cache now that it is done - /// make sure to call this after adding all the modifiers / ingredients - /// - public void AddRecipe() - { - AlchemyRecipeSystem.recipeList.Add(this); - } - - public void AddOutputById(int outputItemId, int outputCount = 1) - { - var newOutput = new Item(); - newOutput.SetDefaults(outputItemId); - newOutput.stack = outputCount; - outputItemList.Add(newOutput); - } - - /// - /// creats an output by a clone of provided Item for potential exact matching - /// - /// - public void AddOutputByItem(Item Item) - { - outputItemList.Add(Item.Clone()); - } - - public void AddIngredientById(int requiredIngredientId, int inputCount = 1) - { - var newIngredient = new Item(); - newIngredient.SetDefaults(requiredIngredientId); - newIngredient.stack = inputCount; - requiredIngredientsMap.Add(requiredIngredientId, newIngredient); - } - - /// - /// creates an ingredient by a clone of provided Item for potential exact matching - /// - /// - public void AddIngredientByItem(Item Item) - { - requiredIngredientsMap.Add(Item.type, Item.Clone()); - } - - public void AddRequiredModifier(int requiredModifierTileId) - { - requiredModifiers.Add(requiredModifierTileId); - } - - /// - /// Runs when this recipe is the only possible remaining recipe from the current set of ingredients and has enough of each ingredient to be valid. - /// return true to block any individual ingredient code from running. - /// executes on client and server. - /// by default does no logic and returns false. - /// - /// - public virtual bool UpdateReady(AlchemyWrapper wrapper) - { - return false; - } - - /// - /// runs when this recipe is the only possible remaining recipe but the current set of ingredients is NOT valid for atleast one craft. - /// return true to block any individual ingredient code from running. - /// executes on client and server. - /// by default does not logic and returns false. - /// - /// - public virtual bool UpdateAlmostReady(AlchemyWrapper wrapper) - { - //TODO: maybe default to some kind of way to indicate to the Player they are on the right track but missing quantity / certain Items - return false; - } - - /// - /// Runs when Player has initiated crafting this recipe with all ingredients added. return true to skip individual ingredient code from running. - /// responsible for spawning in Items and visuals. - /// executes on client and server. return true to stop individual ingredient code from running. - /// by default consumes ingredients and spawns output instantly - /// - /// - public virtual bool UpdateCrafting(AlchemyWrapper wrapper, List currentingredients, CauldronDummyAbstract cauldronDummy) - { - foreach (Item eachOutputItem in outputItemList) - { - Item.NewItem(new EntitySource_WorldEvent(), wrapper.cauldronRect, eachOutputItem.type, eachOutputItem.stack * wrapper.currentBatchSize); - } - - foreach (AlchemyIngredient eachIngredient in currentingredients) - { - requiredIngredientsMap.TryGetValue(eachIngredient.storedItem.type, out Item requiredItem); - - eachIngredient.storedItem.stack -= requiredItem.stack * wrapper.currentBatchSize; - } - - cauldronDummy.DumpIngredients(); - - return false; - } - - /// - /// returns true if an Item is part of this recipe, false otherwise. - /// by default only checks Item Id, override for stricter checking (like weapon modifier, ensuring minimum amount at insertion time, fields on the Item, etc). - /// ignores minimum amounts by default under the assumption that Player can add the rest at a later step - /// - /// - public virtual bool CheckItem(Item Item) - { - return requiredIngredientsMap.ContainsKey(Item.type); - } - - /// - /// returns a number for the amount of times this ingredient can be batched in the recipe 0 if invalid/insufficient. - /// Used for ensuring the ingredient is valid and in proper stack size right before initializing the craft. - /// By default only checks id and stack. override if needs stricter checking (like weapon modifier, maximums, split Item stacks etc.). - /// - /// - /// - public virtual int CheckIngredientBatch(AlchemyIngredient ingredient) - { - if (requiredIngredientsMap.ContainsKey(ingredient.storedItem.type)) - { - requiredIngredientsMap.TryGetValue(ingredient.storedItem.type, out Item requiredItem); - - return ingredient.storedItem.stack / requiredItem.stack; - } - - return 0; - } - - /// - /// Returns number of times this recipe can craft if all the conditions are correct for the this recipe, otherwise 0 - /// - /// - /// - /// - public virtual int GetCraftBatchSize(List currentIngredients, List currentModifiers) - { - //if they don't match in count its not possible for it to be complete so we short circuit and avoid needing to iterate through lists multiple times - if (currentIngredients.Count != requiredIngredientsMap.Count) - return 0; - if (currentModifiers.Count != requiredModifiers.Count) - return 0; - - int batchSize = int.MaxValue; - foreach (AlchemyIngredient eachCurrentIngredient in currentIngredients) - { - batchSize = Math.Min(batchSize, CheckIngredientBatch(eachCurrentIngredient)); - } - - return batchSize; - } - } -} \ No newline at end of file diff --git a/Content/Alchemy/AlchemyRecipeSystem.cs b/Content/Alchemy/AlchemyRecipeSystem.cs deleted file mode 100644 index c18ef72b1..000000000 --- a/Content/Alchemy/AlchemyRecipeSystem.cs +++ /dev/null @@ -1,79 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; - -namespace StarlightRiver.Content.Alchemy -{ - public static class AlchemyRecipeSystem - { - //static class to handle recipe loading / unloading as well as helper functions for codex integration and determining result of a list of ingredients - - public static List recipeList; - - /// - /// cache Types of all the alchemy ingredients in use, indexed by ItemId, - /// done this way since we want to instantiate new instances b/c there can be multiple cauldrons and we don't want to use reflection every time an ingredient needs to be created - /// - public static Dictionary allIngredientMap; - - public static void Load() - { - allIngredientMap = new Dictionary(); - recipeList = new List(); - //reflection to discover and cache AlchemyIngredient override types - Mod Mod = StarlightRiver.Instance; - foreach (Type type in Mod.Code.GetTypes().Where(t => !t.IsAbstract && t.IsSubclassOf(typeof(AlchemyIngredient)) && t != typeof(GenericAlchemyIngredient))) - { - var tempIngredient = (AlchemyIngredient)Activator.CreateInstance(type); - allIngredientMap.Add(tempIngredient.GetItemID(), type); - } - } - - public static void Unload() - { - if (allIngredientMap != null) - { - allIngredientMap.Clear(); - allIngredientMap = null; - } - - if (recipeList != null) - { - recipeList.Clear(); - recipeList = null; - } - } - - public static List GetRemainingPossiblities(Item addedItem, List previousPossibilities) - { - var remainingPossibilities = new List(); - foreach (AlchemyRecipe eachRecipe in previousPossibilities) - { - if (eachRecipe.CheckItem(addedItem)) - remainingPossibilities.Add(eachRecipe); - } - - return remainingPossibilities; - } - - /// - /// Creates an instance of AlchemyIngredient based on provided Item and puts the Item itself into the ingredient object - /// - /// - /// - public static AlchemyIngredient InstantiateIngredient(Item Item) - { - bool inMap = allIngredientMap.TryGetValue(Item.type, out Type ingredientClassType); - - AlchemyIngredient instantiatedIngredient; - - if (inMap) - instantiatedIngredient = (AlchemyIngredient)Activator.CreateInstance(ingredientClassType); - else - instantiatedIngredient = new GenericAlchemyIngredient(Item.type); - - instantiatedIngredient.PutIngredient(Item); - return instantiatedIngredient; - } - } -} \ No newline at end of file diff --git a/Content/Alchemy/AlchemyWrapper.cs b/Content/Alchemy/AlchemyWrapper.cs deleted file mode 100644 index b0760d8b6..000000000 --- a/Content/Alchemy/AlchemyWrapper.cs +++ /dev/null @@ -1,28 +0,0 @@ -namespace StarlightRiver.Content.Alchemy -{ - public class AlchemyWrapper - { - //used to pass around to all the alchemy components to maintain context about bubble color, position, modifiers etc - //add variables to this for more data - //cauldron should be resetting any relevant fields every frame otherwise keeps context between frames - - public Rectangle cauldronRect; - - public Color bubbleColor; - public Color bloomColor; - - /// - /// opacity of the bubbling fluid in the cauldron 1f is fully opaque, 0f is fully transparent - /// - public float bubbleOpacity = 1f; - - public float bubbleAnimationTimer; //float for % multipliers potentially - - public int bubbleAnimationFrame; - - public int timeSinceCraftStarted; - public int timeSinceCraftReady; - - public int currentBatchSize = 0; //when this has a value greater than 0, the recipe is ready - } -} \ No newline at end of file diff --git a/Content/Alchemy/Cauldron.cs b/Content/Alchemy/Cauldron.cs deleted file mode 100644 index bccfd8d97..000000000 --- a/Content/Alchemy/Cauldron.cs +++ /dev/null @@ -1,70 +0,0 @@ -using StarlightRiver.Content.Dusts; -using StarlightRiver.Core.Systems.DummyTileSystem; -using Terraria.ID; -using static Terraria.ModLoader.ModContent; - -namespace StarlightRiver.Content.Alchemy -{ - public class CauldronItem : ModItem - { - public override string Texture => AssetDirectory.Alchemy + Name; - - public override void SetStaticDefaults() - { - Tooltip.SetDefault("Places an Alchemic Cauldron"); - } - - public override void SetDefaults() - { - Item.width = 26; - Item.height = 22; - Item.maxStack = 99; - Item.useTurn = true; - Item.autoReuse = true; - Item.useAnimation = 15; - Item.useTime = 15; - Item.useStyle = ItemUseStyleID.Swing; - Item.consumable = true; - Item.value = 500; - Item.createTile = ModContent.TileType(); - } - } - - internal class CauldronTile : DummyTile - { - public override int DummyType => DummySystem.DummyType(); - - public override string Texture => AssetDirectory.Alchemy + Name; - - public override void SafeNearbyEffects(int i, int j, bool closer) - { - } - - public override void SetStaticDefaults() - { - this.QuickSetFurniture(3, 2, DustType(), SoundID.Tink, true, new Color(50, 50, 50), false, false, "Alchemic Cauldron"); - } - - public override bool RightClick(int i, int j) - { - int x = i - Main.tile[i, j].TileFrameX / 16 % 3; - int y = j - Main.tile[i, j].TileFrameY / 16 % 2; - if (DummyExists(x, y, DummyType)) - { - var cauldronDummy = (CauldronDummyAbstract)Dummy(x, y); - - if (Main.LocalPlayer.HeldItem.type == ModContent.ItemType()) - cauldronDummy.AttemptStartCraft(); - else - cauldronDummy.DumpIngredients(); - } - - return false; - } - } - - public class CauldronDummy : CauldronDummyAbstract - { - public CauldronDummy() : base(TileType(), 48, 32) { } - } -} \ No newline at end of file diff --git a/Content/Alchemy/CauldronDummyAbstract.cs b/Content/Alchemy/CauldronDummyAbstract.cs deleted file mode 100644 index 347a65f12..000000000 --- a/Content/Alchemy/CauldronDummyAbstract.cs +++ /dev/null @@ -1,238 +0,0 @@ -using StarlightRiver.Core.Systems.DummyTileSystem; -using System.Collections.Generic; -using static Terraria.ModLoader.ModContent; - -namespace StarlightRiver.Content.Alchemy -{ - public abstract class CauldronDummyAbstract : Dummy - { - //This serves as the core logic driver of the alchemy system - //any inputs and outputs will be routed through here - //and this will execute the calls to any ingredient logic and visuals - //Abstract so this can be overridden by more specific cauldrons if later there are multiple cauldrons with similar logic but different visuals - - protected List currentIngredients = new(); - protected List currentModifiers = new(); - - List possibleRecipes = AlchemyRecipeSystem.recipeList; - - AlchemyRecipe currentRecipe = null; - - AlchemyIngredient mostRecentIngredient = null; - readonly AlchemyWrapper wrapper = new(); - - protected bool isCrafting = false; //true when the ingredients are finalized and recipe is doing visuals/crafting - - public const int bubbleAnimationFrameTime = 8; - public const int bubbleAnimationFrames = 10; - public const int bubbleYOffset = 10; //bubble animation is centered in their frames so we need an offset to find bottom - - public int inputCooldown = 0; //if this is greater than 0, the cauldron will not take inputs until it reaches 0 again - - protected CauldronDummyAbstract(int validType, int width, int height) : base(validType, width, height) - { - } - - public override void Update() - { - if (!isCrafting && inputCooldown <= 0) - { - foreach (Item eachWorldItem in Main.item) - { - if (eachWorldItem.active && Hitbox.Contains(eachWorldItem.Center.ToPoint())) - { - if (AttemptAddItem(eachWorldItem.Clone())) - { - //todo: mp logic - eachWorldItem.active = false; - eachWorldItem.TurnToAir(); - } - } - } - } - - wrapper.bubbleColor = new Color(127, 127, 127); - wrapper.cauldronRect = Hitbox; - - bool skipIngredientLogic = false; - if (currentRecipe != null) - { - if (isCrafting) - { - skipIngredientLogic = currentRecipe.UpdateCrafting(wrapper, currentIngredients, this); - } - else if (wrapper.currentBatchSize > 0) - { - skipIngredientLogic = currentRecipe.UpdateReady(wrapper); - } - else - { - skipIngredientLogic = currentRecipe.UpdateAlmostReady(wrapper); - } - } - - if (mostRecentIngredient != null && !skipIngredientLogic) - { - bool ignoreRegularVisuals = mostRecentIngredient.MostRecentUpdate(wrapper); - - foreach (AlchemyIngredient ingredient in currentIngredients) - { - ingredient.Update(wrapper); - if (!ignoreRegularVisuals) - ingredient.VisualUpdate(wrapper); - ingredient.IncrementTimer(); - } - - mostRecentIngredient.MostRecentPostUpdate(wrapper); - } - - IncrementWrapperTimers(); - - if (inputCooldown > 0) - inputCooldown--; - } - - protected virtual void IncrementWrapperTimers() - { - wrapper.bubbleAnimationTimer++; - wrapper.timeSinceCraftStarted++; - wrapper.timeSinceCraftReady++; - - if (wrapper.bubbleAnimationTimer >= bubbleAnimationFrameTime) - { - wrapper.bubbleAnimationTimer = 0; - wrapper.bubbleAnimationFrame++; - wrapper.bubbleAnimationFrame %= bubbleAnimationFrames; - } - } - - public override void PostDraw(Color lightColor) - { - if (mostRecentIngredient != null && wrapper.bubbleOpacity > 0f) - { - Texture2D bubbleSheet = Request(AssetDirectory.Alchemy + "BubbleSheet").Value; - Texture2D bubbleGlow = Request(AssetDirectory.Alchemy + "BubbleSheetGlow").Value; - int frameHeight = bubbleSheet.Height / bubbleAnimationFrames; - - if (wrapper.bubbleOpacity > 1f) - wrapper.bubbleOpacity = 1f; - - wrapper.bubbleColor.A = (byte)(wrapper.bubbleColor.A * wrapper.bubbleOpacity); - SpriteBatch spriteBatch = Main.spriteBatch; - spriteBatch.Draw(bubbleSheet, position - Main.screenPosition - new Vector2(0, frameHeight - bubbleYOffset), new Rectangle(0, frameHeight * wrapper.bubbleAnimationFrame, bubbleSheet.Width, frameHeight), wrapper.bubbleColor); - - spriteBatch.End(); - spriteBatch.Begin(default, BlendState.Additive, SamplerState.PointClamp, default, Main.Rasterizer, default, Main.GameViewMatrix.TransformationMatrix); - - spriteBatch.Draw(bubbleGlow, position - Main.screenPosition - new Vector2(0, frameHeight - bubbleYOffset), new Rectangle(0, frameHeight * wrapper.bubbleAnimationFrame, bubbleSheet.Width, frameHeight), wrapper.bubbleColor * wrapper.bubbleOpacity); - - spriteBatch.End(); - spriteBatch.Begin(default, default, SamplerState.PointClamp, default, Main.Rasterizer, default, Main.GameViewMatrix.TransformationMatrix); - } - } - - /// - /// empties out cauldron and dumps Items into the world and resets any data like possible recipes - /// - public void DumpIngredients() - { - possibleRecipes = AlchemyRecipeSystem.recipeList; - mostRecentIngredient = null; - currentRecipe = null; - isCrafting = false; - wrapper.currentBatchSize = 0; - - foreach (AlchemyIngredient ingredient in currentIngredients) - { - ingredient.Dump(wrapper.cauldronRect); - } - - currentIngredients.Clear(); - inputCooldown = 120; - } - - public void ConsumeAndDumpIngredients() - { - - } - - /// - /// attempts to insert a specific Item into the cauldron. if cannot be added returns false and performs no additional logic. - /// if can be added will create and add ingredient to the current ingredients, and update possibleRecipes, returning true - /// - /// - /// - public bool AttemptAddItem(Item Item) - { - List newPossibilities = AlchemyRecipeSystem.GetRemainingPossiblities(Item, possibleRecipes); - if (newPossibilities != null && newPossibilities.Count >= 1) - { - //first attempts to stack into an existing ingredient stack - bool hasStack = false; - for (int i = 0; i < currentIngredients.Count; i++) - { - AlchemyIngredient eachIngredient = currentIngredients[i]; - if (eachIngredient.GetItemID() == Item.type) - { - if (eachIngredient.AddToStack(Item)) - { - mostRecentIngredient = eachIngredient; - - //move to end of list - currentIngredients.RemoveAt(i); - currentIngredients.Add(eachIngredient); - - hasStack = true; - break; - } - else - { - //if an ingredient stack is found but not stackable we can skip and return false - return false; - } - } - } - - if (!hasStack) - { - AlchemyIngredient newIngredient = AlchemyRecipeSystem.InstantiateIngredient(Item); - - mostRecentIngredient = newIngredient; - - currentIngredients.Add(newIngredient); - } - - possibleRecipes = newPossibilities; - - //TODO: mp logic here ? - //if it reaches here, means that Items were successfully added to the cauldron, so we check for full validation on the recipes to see if theres only 1 and its ready - if (possibleRecipes.Count == 1) - { - currentRecipe = possibleRecipes[0]; - wrapper.currentBatchSize = currentRecipe.GetCraftBatchSize(currentIngredients, currentModifiers); - } - else - { - currentRecipe = null; - wrapper.currentBatchSize = 0; - } - - return true; - } - - return false; - } - - public bool AttemptStartCraft() - { - if (currentRecipe != null && wrapper.currentBatchSize > 0 && !isCrafting) - { - wrapper.timeSinceCraftStarted = 0; - isCrafting = true; - return true; - } - - return false; - } - } -} \ No newline at end of file diff --git a/Content/Alchemy/GenericAlchemyIngredient.cs b/Content/Alchemy/GenericAlchemyIngredient.cs deleted file mode 100644 index 6c4c00808..000000000 --- a/Content/Alchemy/GenericAlchemyIngredient.cs +++ /dev/null @@ -1,21 +0,0 @@ -namespace StarlightRiver.Content.Alchemy -{ - public class GenericAlchemyIngredient : AlchemyIngredient - { - //this class is for instantiating generic ingredients that do not have any custom logic / visuals assigned to them - //defaults to using this for new ingredients if chosen Item Id is not in the AlchemyRecipeSystem cache - //ideally every alchemy ingredient will have its own awesome visuals eventually but this is a nice stopgap - - private readonly int ItemId; - - public GenericAlchemyIngredient(int ItemId) - { - ingredientColor = new Color(Main.rand.Next(255), Main.rand.Next(255), Main.rand.Next(255)); //just randomize it if its not a defined ingredient - this.ItemId = ItemId; - } - public override int GetItemID() - { - return ItemId; - } - } -} \ No newline at end of file diff --git a/Content/Alchemy/Ingredients/DirtIngredient.cs b/Content/Alchemy/Ingredients/DirtIngredient.cs deleted file mode 100644 index 4e21287e2..000000000 --- a/Content/Alchemy/Ingredients/DirtIngredient.cs +++ /dev/null @@ -1,34 +0,0 @@ -using StarlightRiver.Content.Dusts; -using Terraria.ID; - -namespace StarlightRiver.Content.Alchemy.Ingredients -{ - internal class DirtIngredient : AlchemyIngredient - { - //TODO: this is being treated as though it is the tarnished ring that does not exist yet, replace with tarnished ring - public DirtIngredient() - { - ingredientColor = Color.DarkRed; - } - - public override int GetItemID() - { - return ItemID.DirtBlock; - } - - public override void VisualUpdate(AlchemyWrapper wrapper) - { - base.VisualUpdate(wrapper); - - if (Main.rand.NextBool(20)) - { - Dust.NewDust(wrapper.cauldronRect.TopLeft() - new Vector2(0, 20), wrapper.cauldronRect.Width, 0, ModContent.DustType(), 0, -2, 120, Color.Black, 0.5f); - } - } - - public override bool AddToStack(Item Item) - { - return false; //unstackable equipment - } - } -} \ No newline at end of file diff --git a/Content/Alchemy/Ingredients/DullBladeIngredient.cs b/Content/Alchemy/Ingredients/DullBladeIngredient.cs deleted file mode 100644 index 6187fa93d..000000000 --- a/Content/Alchemy/Ingredients/DullBladeIngredient.cs +++ /dev/null @@ -1,31 +0,0 @@ -using StarlightRiver.Content.Dusts; -using StarlightRiver.Content.Items.Misc; - -namespace StarlightRiver.Content.Alchemy.Ingredients -{ - internal class DullBladeIngredient : AlchemyIngredient - { - public DullBladeIngredient() - { - ingredientColor = new Color(200, 200, 205); - } - - public override int GetItemID() - { - return ModContent.ItemType(); - } - - public override void VisualUpdate(AlchemyWrapper wrapper) - { - base.VisualUpdate(wrapper); - - if (Main.rand.NextBool(20)) - Dust.NewDust(wrapper.cauldronRect.TopLeft() + new Vector2(0, 20), wrapper.cauldronRect.Width, 0, ModContent.DustType(), 0, -2, 0, new Color(200, 200, 205) * 0.8f, 0.75f); - } - - public override bool AddToStack(Item Item) - { - return false; //unstackable equipment - } - } -} \ No newline at end of file diff --git a/Content/Alchemy/Ingredients/LivingFireIngredient.cs b/Content/Alchemy/Ingredients/LivingFireIngredient.cs deleted file mode 100644 index e40d78d4f..000000000 --- a/Content/Alchemy/Ingredients/LivingFireIngredient.cs +++ /dev/null @@ -1,19 +0,0 @@ -using Terraria.ID; - -namespace StarlightRiver.Content.Alchemy.Ingredients -{ - class LivingFireIngredient : AlchemyIngredient - { - - //TODO: this is a placeholder for Blood replace with that once added - public LivingFireIngredient() - { - ingredientColor = Color.Red; - } - - public override int GetItemID() - { - return ItemID.LivingFireBlock; - } - } -} \ No newline at end of file diff --git a/Content/Alchemy/Ingredients/VitricOreIngredient.cs b/Content/Alchemy/Ingredients/VitricOreIngredient.cs deleted file mode 100644 index cc3beec5c..000000000 --- a/Content/Alchemy/Ingredients/VitricOreIngredient.cs +++ /dev/null @@ -1,38 +0,0 @@ -using StarlightRiver.Content.Dusts; - -namespace StarlightRiver.Content.Alchemy.Ingredients -{ - class VitricOreIngredient : AlchemyIngredient - { - public VitricOreIngredient() - { - ingredientColor = Color.Aquamarine; - } - - public override int GetItemID() - { - return ModContent.ItemType(); - } - - public override void VisualUpdate(AlchemyWrapper wrapper) - { - base.VisualUpdate(wrapper); - if (timeSinceAdded == 0) - { - for (int i = 0; i < 3; i++) - { - Dust.NewDust(wrapper.cauldronRect.TopLeft() - new Vector2(0, 25), wrapper.cauldronRect.Width, 25, ModContent.DustType(), 0, 0); - Dust.NewDust(wrapper.cauldronRect.TopLeft() - new Vector2(0, 25), wrapper.cauldronRect.Width, 25, ModContent.DustType(), 0, 0); - } - } - - if (Main.rand.NextBool(50)) - { - if (Main.rand.NextBool()) - Dust.NewDust(wrapper.cauldronRect.TopLeft() - new Vector2(0, 25), wrapper.cauldronRect.Width, 25, ModContent.DustType(), 0, 0); - else - Dust.NewDust(wrapper.cauldronRect.TopLeft() - new Vector2(0, 25), wrapper.cauldronRect.Width, 25, ModContent.DustType(), 0, 0); - } - } - } -} \ No newline at end of file diff --git a/Content/Alchemy/MixingStick.cs b/Content/Alchemy/MixingStick.cs deleted file mode 100644 index 8fc3954c8..000000000 --- a/Content/Alchemy/MixingStick.cs +++ /dev/null @@ -1,35 +0,0 @@ -using StarlightRiver.Core.Systems; -using Terraria.ID; - -namespace StarlightRiver.Content.Alchemy -{ - [SLRDebug] - public class MixingStick : ModItem - { - public override string Texture => AssetDirectory.Alchemy + Name; - - public override bool AltFunctionUse(Player Player) - { - return true; - } - - public override void SetStaticDefaults() - { - Tooltip.SetDefault("Mixing Stick\nUse this to finalize alchemy recipes to craft them."); - } - - public override void SetDefaults() - { - Item.width = 26; - Item.height = 22; - Item.maxStack = 99; - Item.useTurn = true; - Item.autoReuse = true; - Item.useAnimation = 15; - Item.useTime = 15; - Item.useStyle = ItemUseStyleID.Shoot; - Item.consumable = true; - Item.value = 500; - } - } -} \ No newline at end of file diff --git a/Content/Alchemy/Recipes/BloodCrystalRecipe.cs b/Content/Alchemy/Recipes/BloodCrystalRecipe.cs deleted file mode 100644 index a68a4af1e..000000000 --- a/Content/Alchemy/Recipes/BloodCrystalRecipe.cs +++ /dev/null @@ -1,116 +0,0 @@ -using StarlightRiver.Content.Dusts; -using StarlightRiver.Content.Items.Misc; -using StarlightRiver.Content.Items.Vitric; -using System.Collections.Generic; -using Terraria.DataStructures; -using Terraria.ID; - -namespace StarlightRiver.Content.Alchemy.Recipes -{ - public class BloodCrystalRecipe : AlchemyRecipe, IPostLoadable - { - public void PostLoad() - { - //todo: update with real components blood crystal, tarnished ring, blood when they are implemented - - AddIngredientById(ItemID.DirtBlock); //placeholder for "tarnished ring" - AddIngredientById(ItemID.LivingFireBlock); //placeholder for "blood" - AddIngredientById(ModContent.ItemType(), 16); - - AddOutputById(ModContent.ItemType()); //placeholder for "blood crystal" - - AddRecipe(); - } - - public void PostLoadUnload() - { - } - - public override bool UpdateCrafting(AlchemyWrapper wrapper, List currentingredients, CauldronDummyAbstract cauldronDummy) - { - if (wrapper.timeSinceCraftStarted < 60) - { - for (int i = 0; i < wrapper.timeSinceCraftStarted / 3; i++) - { - Dust.NewDust(wrapper.cauldronRect.TopLeft() + new Vector2(5, -30), wrapper.cauldronRect.Width - 10, 30, ModContent.DustType(), 0, -10, Scale: 0.3f); - } - } - - wrapper.bubbleColor = Color.Red; - - if (Main.rand.NextBool(10)) - { - if (Main.rand.NextBool()) - Dust.NewDust(wrapper.cauldronRect.TopLeft() - new Vector2(0, wrapper.timeSinceCraftStarted / 2), wrapper.cauldronRect.Width, 20, ModContent.DustType(), 0, 0, newColor: Color.Red); - else - Dust.NewDust(wrapper.cauldronRect.TopLeft() - new Vector2(0, wrapper.timeSinceCraftStarted / 2), wrapper.cauldronRect.Width, 20, ModContent.DustType(), 0, 0, newColor: Color.Red); - } - - if (wrapper.timeSinceCraftStarted > 60) - { - wrapper.bubbleOpacity = 1f - (wrapper.timeSinceCraftStarted - 60) * 0.025f; - } - - if (wrapper.timeSinceCraftStarted >= 200) - { - foreach (Item eachOutputItem in outputItemList) - { - Item.NewItem(new EntitySource_WorldEvent(), wrapper.cauldronRect.Center() - new Vector2(0, 100), Vector2.Zero, eachOutputItem.type, Stack: eachOutputItem.stack, prefixGiven: eachOutputItem.prefix); - } - - foreach (AlchemyIngredient eachIngredient in currentingredients) - { - requiredIngredientsMap.TryGetValue(eachIngredient.storedItem.type, out Item requiredItem); - - eachIngredient.storedItem.stack -= requiredItem.stack * wrapper.currentBatchSize; - } - - cauldronDummy.DumpIngredients(); - } - - return true; - } - } - public class BloodCrystalRecipeDust : ModDust - { - public override string Texture => AssetDirectory.Dust + "NeedlerDust"; - - public override void OnSpawn(Dust dust) - { - dust.noGravity = true; - dust.scale *= Main.rand.NextFloat(0.8f, 2f); - dust.frame = new Rectangle(0, 0, 34, 36); - } - - public override Color? GetAlpha(Dust dust, Color lightColor) - { - var gray = new Color(25, 25, 25); - return gray * ((255 - dust.alpha) / 255f); - } - - public override bool Update(Dust dust) - { - if (dust.velocity.Length() > 3) - dust.velocity *= 0.85f; - else - dust.velocity *= 0.92f; - - if (dust.alpha > 130) - { - dust.scale *= 0.92f; - dust.alpha += 8; - } - else - { - dust.alpha += 1; - } - - dust.position += dust.velocity; - - if (dust.alpha >= 255) - dust.active = false; - - return false; - } - } -} \ No newline at end of file diff --git a/Content/Alchemy/Recipes/TaintedGreataxeRecipe.cs b/Content/Alchemy/Recipes/TaintedGreataxeRecipe.cs deleted file mode 100644 index b9c9cd54a..000000000 --- a/Content/Alchemy/Recipes/TaintedGreataxeRecipe.cs +++ /dev/null @@ -1,70 +0,0 @@ -using StarlightRiver.Content.Dusts; -using StarlightRiver.Content.Items.Haunted; -using StarlightRiver.Content.Items.Misc; -using System.Collections.Generic; -using Terraria.Audio; -using Terraria.DataStructures; -using Terraria.ID; - -namespace StarlightRiver.Content.Alchemy.Recipes -{ - public class TaintedGreataxeRecipe : AlchemyRecipe, IPostLoadable - { - public void PostLoad() - { - AddIngredientById(ModContent.ItemType()); - AddIngredientById(ItemID.LivingFireBlock); //placeholder for "blood" - AddOutputById(ModContent.ItemType()); - AddRecipe(); - } - - public void PostLoadUnload() - { - } - - public override bool UpdateCrafting(AlchemyWrapper wrapper, List currentingredients, CauldronDummyAbstract cauldronDummy) - { - if (wrapper.timeSinceCraftStarted < 180) - { - if (wrapper.timeSinceCraftStarted % 3 == 0) - { - Dust.NewDust(wrapper.cauldronRect.TopLeft() + new Vector2(5, 20), wrapper.cauldronRect.Width - 10, 30, ModContent.DustType(), 0, -5, newColor: new Color(200, 200, 205) * 0.8f); - if (Main.rand.NextBool(3)) - Dust.NewDust(wrapper.cauldronRect.TopLeft() - new Vector2(0, 20), wrapper.cauldronRect.Width - 10, 30, ModContent.DustType(), 0, -3.5f, newColor: new Color(200, 200, 205), Scale: 0.35f); - - if (Main.rand.NextBool(3)) - Dust.NewDust(wrapper.cauldronRect.TopLeft() - new Vector2(0, 20), wrapper.cauldronRect.Width - 10, 30, ModContent.DustType(), 0, -3.5f, newColor: new Color(85, 220, 55), Scale: 0.35f); - } - } - - wrapper.bubbleColor = new Color(200, 200, 205); - - if (wrapper.timeSinceCraftStarted >= 200) - { - foreach (Item eachOutputItem in outputItemList) - { - Item.NewItem(new EntitySource_WorldEvent(), wrapper.cauldronRect.Center(), Vector2.Zero, eachOutputItem.type, Stack: eachOutputItem.stack, prefixGiven: eachOutputItem.prefix); - } - - foreach (AlchemyIngredient eachIngredient in currentingredients) - { - requiredIngredientsMap.TryGetValue(eachIngredient.storedItem.type, out Item requiredItem); - - eachIngredient.storedItem.stack -= requiredItem.stack * wrapper.currentBatchSize; - } - - for (int i = 0; i < 13; i++) - { - Dust.NewDust(wrapper.cauldronRect.TopLeft() + new Vector2(0, 5), wrapper.cauldronRect.Width - 10, 30, ModContent.DustType(), 0, -3.5f, newColor: new Color(200, 200, 205), Scale: 0.4f); - - Dust.NewDust(wrapper.cauldronRect.TopLeft() + new Vector2(0, 5), wrapper.cauldronRect.Width - 10, 30, ModContent.DustType(), 0, -3f, newColor: new Color(200, 200, 205), Scale: 0.45f); - } - - SoundEngine.PlaySound(SoundID.Splash, wrapper.cauldronRect.Center()); - cauldronDummy.DumpIngredients(); - } - - return true; - } - } -} \ No newline at end of file diff --git a/Content/Bosses/SquidBoss/Misc.AuroraWaterMetaballs.cs b/Content/Bosses/SquidBoss/Misc.AuroraWaterMetaballs.cs index 438e6cbdb..2c5fc40fb 100644 --- a/Content/Bosses/SquidBoss/Misc.AuroraWaterMetaballs.cs +++ b/Content/Bosses/SquidBoss/Misc.AuroraWaterMetaballs.cs @@ -12,19 +12,13 @@ internal class AuroraWaterMetaballs : MetaballActor { public override bool Active => Main.LocalPlayer.InModBiome(ModContent.GetInstance()); - public override Color OutlineColor => new(255, 254, 255); + public override Color OutlineColor => new(255, 0, 0); public override void DrawShapes(SpriteBatch spriteBatch) { Texture2D tex = Assets.Items.Misc.MagmaGunProj.Value; - for (int k = 0; k < Main.maxNPCs; k++) - { - NPC NPC = Main.npc[k]; - - if (NPC.active && NPC.ModNPC is ArenaActor) - (NPC.ModNPC as ArenaActor).DrawWater(Main.spriteBatch); - } + ArenaActor.latestActor?.DrawWater(Main.spriteBatch); Effect borderNoise = ShaderLoader.GetShader("BorderNoise").Value; @@ -41,7 +35,7 @@ public override void DrawShapes(SpriteBatch spriteBatch) if (dust.active && (dust.type == ModContent.DustType() || dust.type == ModContent.DustType())) { borderNoise.Parameters["offset"].SetValue((float)Main.time / 1000f + dust.rotation); - spriteBatch.Draw(tex, (dust.position - Main.screenPosition) / 2, null, new Color(0.4f, 1, 1), 0f, Vector2.One * 256f, dust.scale * 0.05f, SpriteEffects.None, 0); + spriteBatch.Draw(tex, (dust.position - Main.screenPosition) / 2, null, new Color(0, 255, 0), 0f, Vector2.One * 256f, dust.scale * 0.05f, SpriteEffects.None, 0); } } @@ -50,7 +44,7 @@ public override void DrawShapes(SpriteBatch spriteBatch) Texture2D tex2 = Assets.Bosses.SquidBoss.AuroraWaterSplash.Value; var frame = new Rectangle(0, (int)(6 - proj.timeLeft / 40f * 6) * 106, 72, 106); - spriteBatch.Draw(tex2, (proj.Center - Main.screenPosition) / 2f, frame, new Color(0.4f, 1, 1), 0, new Vector2(36, 53), 0.5f, 0, 0); + spriteBatch.Draw(tex2, (proj.Center - Main.screenPosition) / 2f, frame, new Color(0, 255, 0), 0, new Vector2(36, 53), 0.5f, 0, 0); } spriteBatch.End(); @@ -87,21 +81,29 @@ public override bool PostDraw(SpriteBatch spriteBatch, Texture2D target) if (effect != null) { + Main.spriteBatch.End(); + Main.graphics.GraphicsDevice.SetRenderTarget(Main.screenTargetSwap); + effect.Parameters["uTime"].SetValue((float)Main.timeForVisualEffects * 0.02f); - effect.Parameters["power"].SetValue(0.01f); effect.Parameters["offset"].SetValue(new Vector2(Main.screenPosition.X / Main.screenWidth * -0.5f, Main.screenPosition.Y / Main.screenHeight * -0.5f)); effect.Parameters["sampleTexture"].SetValue(AuroraWaterSystem.auroraBackTarget.RenderTarget); effect.Parameters["uImageSize1"].SetValue(new Vector2(Main.screenWidth, Main.screenHeight)); - effect.Parameters["speed"].SetValue(50f); effect.Parameters["lightTexture"].SetValue(LightingBuffer.screenLightingTarget.RenderTarget); + effect.Parameters["gameTexture"].SetValue(Main.screenTarget); + effect.Parameters["transform"].SetValue(Matrix.Invert(Main.GameViewMatrix.TransformationMatrix)); - Main.spriteBatch.End(); - Main.spriteBatch.Begin(default, default, SamplerState.PointClamp, default, Main.Rasterizer, effect, Main.GameViewMatrix.TransformationMatrix); + var inv = Matrix.Invert(Main.GameViewMatrix.TransformationMatrix); + + Main.spriteBatch.Begin(default, default, SamplerState.PointClamp, default, RasterizerState.CullNone, effect, Matrix.Identity); - Main.spriteBatch.Draw(target, Vector2.Zero, null, Color.Red * 0.4f, 0, Vector2.Zero, 2, 0, 0); + Main.spriteBatch.Draw(target, Vector2.Zero, null, Color.White, 0, Vector2.Zero, 2, 0, 0); Main.spriteBatch.End(); - Main.spriteBatch.Begin(default, default, SamplerState.PointClamp, default, Main.Rasterizer, default, Main.GameViewMatrix.TransformationMatrix); + + Main.graphics.GraphicsDevice.SetRenderTarget(Main.screenTarget); + + Main.spriteBatch.Begin(default, default, SamplerState.PointClamp, default, RasterizerState.CullNone, default, Matrix.Identity); + Main.spriteBatch.Draw(Main.screenTargetSwap, Vector2.Zero, null, Color.White, 0, Vector2.Zero, 1, 0, 0); } return false; diff --git a/Content/Bosses/SquidBoss/NPCs.ArenaActor.cs b/Content/Bosses/SquidBoss/NPCs.ArenaActor.cs index 17e427350..306a69317 100644 --- a/Content/Bosses/SquidBoss/NPCs.ArenaActor.cs +++ b/Content/Bosses/SquidBoss/NPCs.ArenaActor.cs @@ -27,6 +27,8 @@ class ArenaActor : ModNPC private static VertexPositionColorTexture[] verticies; private static VertexBuffer buffer; + public static ArenaActor latestActor; + public ref float WaterLevel => ref NPC.ai[0]; public ref float VisualTimerA => ref NPC.ai[1]; public ref float VisualTimerB => ref NPC.ai[2]; @@ -106,6 +108,8 @@ private void DoParticleUpdates() public override void AI() { + latestActor = this; + VisualTimerA += 0.04f; //used as timers for visuals VisualTimerB += 0.01f; @@ -316,7 +320,7 @@ public void DrawWater(SpriteBatch spriteBatch) Vector2 pos = NPC.Center + new Vector2(-840, 30 * 16) + new Vector2(0, -tex.Height) - Main.screenPosition; var source = new Rectangle(0, tex.Height - (int)WaterLevel + 5 * 16, tex.Width, (int)WaterLevel - 5 * 16); - spriteBatch.Draw(tex, (pos + source.TopLeft()) * 0.5f, source, new Color(0.4f, 1, 1), 0, default, 0.5f, 0, 0); + spriteBatch.Draw(tex, (pos + source.TopLeft()) * 0.5f, source, new Color(0, 255, 0), 0, default, 0.5f, 0, 0); DrawWaterfalls(spriteBatch); } diff --git a/Content/Bosses/SquidBoss/NPCs.IcePlatform.cs b/Content/Bosses/SquidBoss/NPCs.IcePlatform.cs index 60ef2c05e..eb8889796 100644 --- a/Content/Bosses/SquidBoss/NPCs.IcePlatform.cs +++ b/Content/Bosses/SquidBoss/NPCs.IcePlatform.cs @@ -47,7 +47,7 @@ public override void SafeAI() if (Main.npc.Any(n => n.active && n.type == ModContent.NPCType())) { - var actor = Main.npc.FirstOrDefault(n => n.active && n.type == ModContent.NPCType()).ModNPC as ArenaActor; + ArenaActor actor = ArenaActor.latestActor; if (NPC.position.Y >= HomeYPosition) { diff --git a/Content/Bosses/SquidBoss/NPCs.SquidBoss.Attacks.cs b/Content/Bosses/SquidBoss/NPCs.SquidBoss.Attacks.cs index 1d6700030..9e9317e63 100644 --- a/Content/Bosses/SquidBoss/NPCs.SquidBoss.Attacks.cs +++ b/Content/Bosses/SquidBoss/NPCs.SquidBoss.Attacks.cs @@ -1052,7 +1052,7 @@ private void TentacleSpike2() { RandomizeTarget(); - tentacles[k].Center = new Vector2(Main.npc.FirstOrDefault(n => n.active && n.ModNPC is ArenaActor).Center.X + (k % 2 == 0 ? -500 : 500), NPC.Center.Y + Main.rand.Next(-200, 200)); + tentacles[k].Center = new Vector2(ArenaActor.latestActor.NPC.Center.X + (k % 2 == 0 ? -500 : 500), NPC.Center.Y + Main.rand.Next(-200, 200)); tentacle.basePoint = tentacles[k].Center; tentacle.movementTarget = Main.player[NPC.target].Center; diff --git a/Content/Bosses/SquidBoss/NPCs.SquidBoss.cs b/Content/Bosses/SquidBoss/NPCs.SquidBoss.cs index 972c28c5a..158e6ee08 100644 --- a/Content/Bosses/SquidBoss/NPCs.SquidBoss.cs +++ b/Content/Bosses/SquidBoss/NPCs.SquidBoss.cs @@ -202,7 +202,7 @@ public override void ModifyNPCLoot(NPCLoot npcLoot) npcLoot.Add(ItemDropRule.MasterModeCommonDrop(Mod.Find("AuroracleRelicItem").Type)); } - public override void BossLoot(ref string name, ref int potionType) + public override void BossLoot(ref int potionType) { for (int k = 0; k < Main.maxPlayers; k++) { @@ -483,7 +483,7 @@ public override void AI() Animate(12, 0, 8); if (arenaActor is null || !arenaActor.active) - arenaActor = Main.npc.FirstOrDefault(n => n.active && n.ModNPC is ArenaActor); + arenaActor = ArenaActor.latestActor.NPC; if (Phase > (int)AIStates.SpawnAnimation) FindEssentialNPCs(); @@ -840,7 +840,7 @@ public override void AI() GlobalTimer++; if (GlobalTimer % 6 == 0) - Main.npc.FirstOrDefault(n => n.active && n.ModNPC is ArenaActor).ai[0]++; //rising water + ArenaActor.latestActor.WaterLevel++; //rising water AttackTimer++; diff --git a/Content/Bosses/VitricBoss/NPCs.VitricBoss.Attacks.cs b/Content/Bosses/VitricBoss/NPCs.VitricBoss.Attacks.cs index 2f5e6f7d4..3dfc91a89 100644 --- a/Content/Bosses/VitricBoss/NPCs.VitricBoss.Attacks.cs +++ b/Content/Bosses/VitricBoss/NPCs.VitricBoss.Attacks.cs @@ -108,8 +108,7 @@ private void MakeCrystalVulnerable() { NPC crystal = crystals.FirstOrDefault(n => n.ai[0] == 2); - if (crystal != null) - crystal.ai[0] = 0; + crystal?.ai[0] = 0; } if (AttackTimer > 180 && AttackTimer % 25 == 0 && Main.netMode != NetmodeID.MultiplayerClient) diff --git a/Content/Bosses/VitricBoss/NPCs.VitricBoss.cs b/Content/Bosses/VitricBoss/NPCs.VitricBoss.cs index daefc2e52..2790e846a 100644 --- a/Content/Bosses/VitricBoss/NPCs.VitricBoss.cs +++ b/Content/Bosses/VitricBoss/NPCs.VitricBoss.cs @@ -360,7 +360,7 @@ public override void ModifyNPCLoot(NPCLoot npcLoot) npcLoot.Add(ItemDropRule.MasterModeCommonDrop(Mod.Find("CeirosRelicItem").Type)); } - public override void BossLoot(ref string name, ref int potionType) + public override void BossLoot(ref int potionType) { BossRushDataStore.DefeatBoss(BossrushUnlockFlag.Ceiros); StarlightWorld.Flag(WorldFlags.VitricBossDowned); diff --git a/Content/CustomHooks/Mechanics.PassiveLight.cs b/Content/CustomHooks/Mechanics.PassiveLight.cs index 06546fe3e..3fc1955aa 100644 --- a/Content/CustomHooks/Mechanics.PassiveLight.cs +++ b/Content/CustomHooks/Mechanics.PassiveLight.cs @@ -1,4 +1,5 @@ using StarlightRiver.Content.Biomes; +using StarlightRiver.Content.Bosses.SquidBoss; using StarlightRiver.Content.Events; using System.Collections.Generic; using Terraria.ID; @@ -93,6 +94,15 @@ public override void PostUpdateEverything() squidDomeRect.Y += 35; squidDomeRect.Height = 76; } + + if (ArenaActor.latestActor?.WaterLevel > 1100) + { + squidDomeRect.Height = (int)(76 - (ArenaActor.latestActor.WaterLevel - 1100) / 16); + } + else + { + squidDomeRect.Height = 76; + } } } } \ No newline at end of file diff --git a/Content/CustomHooks/Visuals.DrawUnderCathedralWater.cs b/Content/CustomHooks/Visuals.DrawUnderCathedralWater.cs index 88618e862..df34649ad 100644 --- a/Content/CustomHooks/Visuals.DrawUnderCathedralWater.cs +++ b/Content/CustomHooks/Visuals.DrawUnderCathedralWater.cs @@ -43,12 +43,12 @@ public static void DrawWater() Main.spriteBatch.End(); Main.spriteBatch.Begin(default, default, SamplerState.PointClamp, default, Main.Rasterizer, default, Main.GameViewMatrix.TransformationMatrix); - NPC NPC = Main.npc.FirstOrDefault(n => n.active && n.ModNPC is ArenaActor); + NPC npc = ArenaActor.latestActor?.NPC; - if (NPC != null && NPC.active) + if (npc != null && npc.active) { if (ReflectionTarget.canUseTarget || !ModContent.GetInstance().ReflectionConfig.ReflectionsOn) - (NPC.ModNPC as ArenaActor).DrawBigWindow(Main.spriteBatch); + (npc.ModNPC as ArenaActor).DrawBigWindow(Main.spriteBatch); int boss = -1; var drawCache = new List(); diff --git a/Content/Items/Forest/Armors.SlimePrinceMinion.cs b/Content/Items/Forest/Armors.SlimePrinceMinion.cs index fa19beec3..04e5d17b6 100644 --- a/Content/Items/Forest/Armors.SlimePrinceMinion.cs +++ b/Content/Items/Forest/Armors.SlimePrinceMinion.cs @@ -194,8 +194,7 @@ public void FuseAnimation() { var helm = Owner.armor[0].ModItem as SlimePrinceHead; - if (helm != null) - helm.targetVel = new Vector2(0, -10); + helm?.targetVel = new Vector2(0, -10); State = 3; Timer = 0; diff --git a/Content/Items/Gravedigger/Weapons.RadculasRapier.cs b/Content/Items/Gravedigger/Weapons.RadculasRapier.cs index 5a27f3610..144eafcc3 100644 --- a/Content/Items/Gravedigger/Weapons.RadculasRapier.cs +++ b/Content/Items/Gravedigger/Weapons.RadculasRapier.cs @@ -424,8 +424,7 @@ public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) RadculasRapierBleed buff = InstancedBuffNPC.GetInstance(target); - if (buff != null) - buff.lastHitPos = Owner.Center; + buff?.lastHitPos = Owner.Center; Vector2 pos = Owner.Center - (Owner.Center - target.Center); diff --git a/Content/Items/Haunted/Weapons.SpiritSeal.cs b/Content/Items/Haunted/Weapons.SpiritSeal.cs index 5a34e5cea..2b70c6d60 100644 --- a/Content/Items/Haunted/Weapons.SpiritSeal.cs +++ b/Content/Items/Haunted/Weapons.SpiritSeal.cs @@ -141,8 +141,8 @@ private void DrawPainShare(NPC npc, SpriteBatch spriteBatch, Vector2 screenPos, { if (Inflicted(npc)) { - var tex = Assets.Items.Haunted.SpiritSealBuff.Value; - var glow = Assets.Masks.GlowAlpha.Value; + Texture2D tex = Assets.Items.Haunted.SpiritSealBuff.Value; + Texture2D glow = Assets.Masks.GlowAlpha.Value; spriteBatch.Draw(tex, npc.Center - Main.screenPosition, null, new Color(0.4f, 0.5f, 0.25f) * 0.8f, 0, tex.Size() / 2f, 2f + (float)Math.Sin(Main.GameUpdateCount * 0.1f) * 0.5f, 0, 0); spriteBatch.Draw(glow, npc.Center - Main.screenPosition, null, new Color(0.3f, 0.5f, 0.2f, 0.0f) * 0.8f, 0, glow.Size() / 2f, 0.5f + (float)Math.Sin(Main.GameUpdateCount * 0.1f) * 0.1f, 0, 0); diff --git a/Content/Items/Magnet/Weapons.Thunderbus.cs b/Content/Items/Magnet/Weapons.Thunderbus.cs index 8b4f436bc..8d5c07fba 100644 --- a/Content/Items/Magnet/Weapons.Thunderbus.cs +++ b/Content/Items/Magnet/Weapons.Thunderbus.cs @@ -209,9 +209,6 @@ internal class ThunderbussShot : ModProjectile, IDrawPrimitive private List cache; private Trail trail; - private readonly float dist1; - private readonly float dist2; - readonly List nodes = new(); public ref float TargetID => ref Projectile.ai[0]; diff --git a/Content/Items/MechBoss/ViewFinder.cs b/Content/Items/MechBoss/ViewFinder.cs index 7ec92e626..0cb1f40b3 100644 --- a/Content/Items/MechBoss/ViewFinder.cs +++ b/Content/Items/MechBoss/ViewFinder.cs @@ -202,7 +202,7 @@ public override void PostAI() public override bool PreDraw(ref Color lightColor) { - var spike = Assets.Misc.SpikeTell.Value; + Texture2D spike = Assets.Misc.SpikeTell.Value; var spikeFrame = new Rectangle(spike.Width / 2, 0, spike.Width / 2, spike.Height); float opacity = 1f; diff --git a/Content/Items/Permafrost/Accessories.SquidFins.cs b/Content/Items/Permafrost/Accessories.SquidFins.cs index c456dfa9e..223856350 100644 --- a/Content/Items/Permafrost/Accessories.SquidFins.cs +++ b/Content/Items/Permafrost/Accessories.SquidFins.cs @@ -28,7 +28,7 @@ public override void SafeUpdateEquip(Player player) { bool canSwim = player.grapCount <= 0 && player.wet && !player.mount.Active; player.GetModPlayer().ShouldSwim = canSwim; - player.GetModPlayer().SwimSpeed = 1.33f + player.moveSpeed * 1.33f; + player.GetModPlayer().SwimSpeed += 3f + player.moveSpeed * 1.33f; } private void DrawSquidFins(ref PlayerDrawSet drawInfo) diff --git a/Content/NPCs/Actors/StarlightWaterActor.cs b/Content/NPCs/Actors/StarlightWaterActor.cs index a64d9c03a..893f2b668 100644 --- a/Content/NPCs/Actors/StarlightWaterActor.cs +++ b/Content/NPCs/Actors/StarlightWaterActor.cs @@ -48,8 +48,7 @@ public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestia public void ResetConversion() { - if (targetItem != null) - targetItem.GetGlobalItem().starlightWaterActor = null; + targetItem?.GetGlobalItem().starlightWaterActor = null; targetItem = null; targetItemTransformType = 0; diff --git a/Content/NPCs/Moonstone/DreambeastSystems.cs b/Content/NPCs/Moonstone/DreambeastSystems.cs index 5ab6a1f05..c9c41426c 100644 --- a/Content/NPCs/Moonstone/DreambeastSystems.cs +++ b/Content/NPCs/Moonstone/DreambeastSystems.cs @@ -186,8 +186,7 @@ public override void PostUpdateBuffs() { SoundEngine.TryGetActiveSound((SlotId)insaneChargeSound, out ActiveSound sound); - if (sound != null) - sound.Volume = 0; + sound?.Volume = 0; insaneChargeSound = null; } diff --git a/Content/NPCs/Permafrost/WaterCube.cs b/Content/NPCs/Permafrost/WaterCube.cs index f279c183e..7ad75056e 100644 --- a/Content/NPCs/Permafrost/WaterCube.cs +++ b/Content/NPCs/Permafrost/WaterCube.cs @@ -28,6 +28,8 @@ public override void AI() { AuroraWaterSystem.visCounter = 30; NPC.velocity.X = 1; + + Lighting.AddLight(NPC.Center, new Vector3(0.4f, 0.8f, 1f)); } public override bool CanHitPlayer(Player target, ref int cooldownSlot) @@ -49,7 +51,7 @@ public void DrawToTarget(SpriteBatch spriteBatch) Vector2 pos = (NPC.position - Main.screenPosition) / 2f; var target = new Rectangle((int)pos.X, (int)pos.Y, NPC.width / 2, NPC.height / 2); - spriteBatch.Draw(tex, target, Color.Red); + spriteBatch.Draw(tex, target, Color.Lime); } } } \ No newline at end of file diff --git a/Content/Noise/FastNoise.NoiseCellular.cs b/Content/Noise/FastNoise.NoiseCellular.cs index 857b8c6fd..ecfdbfb73 100644 --- a/Content/Noise/FastNoise.NoiseCellular.cs +++ b/Content/Noise/FastNoise.NoiseCellular.cs @@ -66,10 +66,10 @@ public void GradientPerturbFractal(ref DECIMAL x, ref DECIMAL y) SingleGradientPerturb(seed, amp, Frequency, ref x, ref y); - for (int i = 1; i < octaves; i++) + for (int i = 1; i < FractalOctaves; i++) { freq *= FractalLacunarity; - amp *= gain; + amp *= FractalGain; SingleGradientPerturb(++seed, amp, freq, ref x, ref y); } } @@ -81,10 +81,10 @@ public void GradientPerturbFractal(ref DECIMAL x, ref DECIMAL y, ref DECIMAL z) SingleGradientPerturb(seed, amp, Frequency, ref x, ref y, ref z); - for (int i = 1; i < octaves; i++) + for (int i = 1; i < FractalOctaves; i++) { freq *= FractalLacunarity; - amp *= gain; + amp *= FractalGain; SingleGradientPerturb(++seed, amp, freq, ref x, ref y, ref z); } } diff --git a/Content/Noise/FastNoise.NoiseCubic.cs b/Content/Noise/FastNoise.NoiseCubic.cs index ce7ded098..069086488 100644 --- a/Content/Noise/FastNoise.NoiseCubic.cs +++ b/Content/Noise/FastNoise.NoiseCubic.cs @@ -132,12 +132,12 @@ private DECIMAL SingleCubicFractalFBM(DECIMAL x, DECIMAL y) DECIMAL amp = 1; int i = 0; - while (++i < octaves) + while (++i < FractalOctaves) { x *= FractalLacunarity; y *= FractalLacunarity; - amp *= gain; + amp *= FractalGain; sum += SingleCubic(++seed, x, y) * amp; } @@ -150,13 +150,13 @@ private DECIMAL SingleCubicFractalFBM(DECIMAL x, DECIMAL y, DECIMAL z) DECIMAL amp = 1; int i = 0; - while (++i < octaves) + while (++i < FractalOctaves) { x *= FractalLacunarity; y *= FractalLacunarity; z *= FractalLacunarity; - amp *= gain; + amp *= FractalGain; sum += SingleCubic(++seed, x, y, z) * amp; } @@ -169,12 +169,12 @@ private DECIMAL SingleCubicFractalBillow(DECIMAL x, DECIMAL y) DECIMAL amp = 1; int i = 0; - while (++i < octaves) + while (++i < FractalOctaves) { x *= FractalLacunarity; y *= FractalLacunarity; - amp *= gain; + amp *= FractalGain; sum += (Math.Abs(SingleCubic(++seed, x, y)) * 2 - 1) * amp; } @@ -187,13 +187,13 @@ private DECIMAL SingleCubicFractalBillow(DECIMAL x, DECIMAL y, DECIMAL z) DECIMAL amp = 1; int i = 0; - while (++i < octaves) + while (++i < FractalOctaves) { x *= FractalLacunarity; y *= FractalLacunarity; z *= FractalLacunarity; - amp *= gain; + amp *= FractalGain; sum += (Math.Abs(SingleCubic(++seed, x, y, z)) * 2 - 1) * amp; } @@ -206,12 +206,12 @@ private DECIMAL SingleCubicFractalRigidMulti(DECIMAL x, DECIMAL y) DECIMAL amp = 1; int i = 0; - while (++i < octaves) + while (++i < FractalOctaves) { x *= FractalLacunarity; y *= FractalLacunarity; - amp *= gain; + amp *= FractalGain; sum -= (1 - Math.Abs(SingleCubic(++seed, x, y))) * amp; } @@ -224,13 +224,13 @@ private DECIMAL SingleCubicFractalRigidMulti(DECIMAL x, DECIMAL y, DECIMAL z) DECIMAL amp = 1; int i = 0; - while (++i < octaves) + while (++i < FractalOctaves) { x *= FractalLacunarity; y *= FractalLacunarity; z *= FractalLacunarity; - amp *= gain; + amp *= FractalGain; sum -= (1 - Math.Abs(SingleCubic(++seed, x, y, z))) * amp; } diff --git a/Content/Noise/FastNoise.NoisePerlin.cs b/Content/Noise/FastNoise.NoisePerlin.cs index a5c28e198..5cd0d7156 100644 --- a/Content/Noise/FastNoise.NoisePerlin.cs +++ b/Content/Noise/FastNoise.NoisePerlin.cs @@ -134,12 +134,12 @@ private DECIMAL SinglePerlinFractalFBM(DECIMAL x, DECIMAL y) DECIMAL sum = SinglePerlin(seed, x, y); DECIMAL amp = 1; - for (int i = 1; i < octaves; i++) + for (int i = 1; i < FractalOctaves; i++) { x *= FractalLacunarity; y *= FractalLacunarity; - amp *= gain; + amp *= FractalGain; sum += SinglePerlin(++seed, x, y) * amp; } @@ -151,13 +151,13 @@ private DECIMAL SinglePerlinFractalFBM(DECIMAL x, DECIMAL y, DECIMAL z) DECIMAL sum = SinglePerlin(seed, x, y, z); DECIMAL amp = 1; - for (int i = 1; i < octaves; i++) + for (int i = 1; i < FractalOctaves; i++) { x *= FractalLacunarity; y *= FractalLacunarity; z *= FractalLacunarity; - amp *= gain; + amp *= FractalGain; sum += SinglePerlin(++seed, x, y, z) * amp; } @@ -169,12 +169,12 @@ private DECIMAL SinglePerlinFractalBillow(DECIMAL x, DECIMAL y) DECIMAL sum = Math.Abs(SinglePerlin(seed, x, y)) * 2 - 1; DECIMAL amp = 1; - for (int i = 1; i < octaves; i++) + for (int i = 1; i < FractalOctaves; i++) { x *= FractalLacunarity; y *= FractalLacunarity; - amp *= gain; + amp *= FractalGain; sum += (Math.Abs(SinglePerlin(++seed, x, y)) * 2 - 1) * amp; } @@ -186,13 +186,13 @@ private DECIMAL SinglePerlinFractalBillow(DECIMAL x, DECIMAL y, DECIMAL z) DECIMAL sum = Math.Abs(SinglePerlin(seed, x, y, z)) * 2 - 1; DECIMAL amp = 1; - for (int i = 1; i < octaves; i++) + for (int i = 1; i < FractalOctaves; i++) { x *= FractalLacunarity; y *= FractalLacunarity; z *= FractalLacunarity; - amp *= gain; + amp *= FractalGain; sum += (Math.Abs(SinglePerlin(++seed, x, y, z)) * 2 - 1) * amp; } @@ -204,12 +204,12 @@ private DECIMAL SinglePerlinFractalRigidMulti(DECIMAL x, DECIMAL y) DECIMAL sum = 1 - Math.Abs(SinglePerlin(seed, x, y)); DECIMAL amp = 1; - for (int i = 1; i < octaves; i++) + for (int i = 1; i < FractalOctaves; i++) { x *= FractalLacunarity; y *= FractalLacunarity; - amp *= gain; + amp *= FractalGain; sum -= (1 - Math.Abs(SinglePerlin(++seed, x, y))) * amp; } @@ -221,13 +221,13 @@ private DECIMAL SinglePerlinFractalRigidMulti(DECIMAL x, DECIMAL y, DECIMAL z) DECIMAL sum = 1 - Math.Abs(SinglePerlin(seed, x, y, z)); DECIMAL amp = 1; - for (int i = 1; i < octaves; i++) + for (int i = 1; i < FractalOctaves; i++) { x *= FractalLacunarity; y *= FractalLacunarity; z *= FractalLacunarity; - amp *= gain; + amp *= FractalGain; sum -= (1 - Math.Abs(SinglePerlin(++seed, x, y, z))) * amp; } diff --git a/Content/Noise/FastNoise.NoiseSimplex.cs b/Content/Noise/FastNoise.NoiseSimplex.cs index 54ef8f6a4..b8f0dbda7 100644 --- a/Content/Noise/FastNoise.NoiseSimplex.cs +++ b/Content/Noise/FastNoise.NoiseSimplex.cs @@ -397,12 +397,12 @@ private DECIMAL SingleSimplexFractalBillow(DECIMAL x, DECIMAL y) DECIMAL sum = Math.Abs(SingleSimplex(seed, x, y)) * 2 - 1; DECIMAL amp = 1; - for (int i = 1; i < octaves; i++) + for (int i = 1; i < FractalOctaves; i++) { x *= FractalLacunarity; y *= FractalLacunarity; - amp *= gain; + amp *= FractalGain; sum += (Math.Abs(SingleSimplex(++seed, x, y)) * 2 - 1) * amp; } @@ -414,13 +414,13 @@ private DECIMAL SingleSimplexFractalBillow(DECIMAL x, DECIMAL y, DECIMAL z) DECIMAL sum = Math.Abs(SingleSimplex(seed, x, y, z)) * 2 - 1; DECIMAL amp = 1; - for (int i = 1; i < octaves; i++) + for (int i = 1; i < FractalOctaves; i++) { x *= FractalLacunarity; y *= FractalLacunarity; z *= FractalLacunarity; - amp *= gain; + amp *= FractalGain; sum += (Math.Abs(SingleSimplex(++seed, x, y, z)) * 2 - 1) * amp; } @@ -432,12 +432,12 @@ private DECIMAL SingleSimplexFractalFBM(DECIMAL x, DECIMAL y) DECIMAL sum = SingleSimplex(seed, x, y); DECIMAL amp = 1; - for (int i = 1; i < octaves; i++) + for (int i = 1; i < FractalOctaves; i++) { x *= FractalLacunarity; y *= FractalLacunarity; - amp *= gain; + amp *= FractalGain; sum += SingleSimplex(++seed, x, y) * amp; } @@ -449,13 +449,13 @@ private DECIMAL SingleSimplexFractalFBM(DECIMAL x, DECIMAL y, DECIMAL z) DECIMAL sum = SingleSimplex(seed, x, y, z); DECIMAL amp = 1; - for (int i = 1; i < octaves; i++) + for (int i = 1; i < FractalOctaves; i++) { x *= FractalLacunarity; y *= FractalLacunarity; z *= FractalLacunarity; - amp *= gain; + amp *= FractalGain; sum += SingleSimplex(++seed, x, y, z) * amp; } @@ -467,12 +467,12 @@ private DECIMAL SingleSimplexFractalRigidMulti(DECIMAL x, DECIMAL y) DECIMAL sum = 1 - Math.Abs(SingleSimplex(seed, x, y)); DECIMAL amp = 1; - for (int i = 1; i < octaves; i++) + for (int i = 1; i < FractalOctaves; i++) { x *= FractalLacunarity; y *= FractalLacunarity; - amp *= gain; + amp *= FractalGain; sum -= (1 - Math.Abs(SingleSimplex(++seed, x, y))) * amp; } @@ -484,13 +484,13 @@ private DECIMAL SingleSimplexFractalRigidMulti(DECIMAL x, DECIMAL y, DECIMAL z) DECIMAL sum = 1 - Math.Abs(SingleSimplex(seed, x, y, z)); DECIMAL amp = 1; - for (int i = 1; i < octaves; i++) + for (int i = 1; i < FractalOctaves; i++) { x *= FractalLacunarity; y *= FractalLacunarity; z *= FractalLacunarity; - amp *= gain; + amp *= FractalGain; sum -= (1 - Math.Abs(SingleSimplex(++seed, x, y, z))) * amp; } diff --git a/Content/Noise/FastNoise.NoiseValue.cs b/Content/Noise/FastNoise.NoiseValue.cs index e7e0cf709..161a50823 100644 --- a/Content/Noise/FastNoise.NoiseValue.cs +++ b/Content/Noise/FastNoise.NoiseValue.cs @@ -122,11 +122,11 @@ private DECIMAL SingleValueFractalBillow(DECIMAL x, DECIMAL y) DECIMAL sum = Math.Abs(SingleValue(seed, x, y)) * 2 - 1; DECIMAL amp = 1; - for (int i = 1; i < octaves; i++) + for (int i = 1; i < FractalOctaves; i++) { x *= FractalLacunarity; y *= FractalLacunarity; - amp *= gain; + amp *= FractalGain; sum += (Math.Abs(SingleValue(++seed, x, y)) * 2 - 1) * amp; } @@ -138,13 +138,13 @@ private DECIMAL SingleValueFractalBillow(DECIMAL x, DECIMAL y, DECIMAL z) DECIMAL sum = Math.Abs(SingleValue(seed, x, y, z)) * 2 - 1; DECIMAL amp = 1; - for (int i = 1; i < octaves; i++) + for (int i = 1; i < FractalOctaves; i++) { x *= FractalLacunarity; y *= FractalLacunarity; z *= FractalLacunarity; - amp *= gain; + amp *= FractalGain; sum += (Math.Abs(SingleValue(++seed, x, y, z)) * 2 - 1) * amp; } @@ -156,12 +156,12 @@ private DECIMAL SingleValueFractalFBM(DECIMAL x, DECIMAL y) DECIMAL sum = SingleValue(seed, x, y); DECIMAL amp = 1; - for (int i = 1; i < octaves; i++) + for (int i = 1; i < FractalOctaves; i++) { x *= FractalLacunarity; y *= FractalLacunarity; - amp *= gain; + amp *= FractalGain; sum += SingleValue(++seed, x, y) * amp; } @@ -173,13 +173,13 @@ private DECIMAL SingleValueFractalFBM(DECIMAL x, DECIMAL y, DECIMAL z) DECIMAL sum = SingleValue(seed, x, y, z); DECIMAL amp = 1; - for (int i = 1; i < octaves; i++) + for (int i = 1; i < FractalOctaves; i++) { x *= FractalLacunarity; y *= FractalLacunarity; z *= FractalLacunarity; - amp *= gain; + amp *= FractalGain; sum += SingleValue(++seed, x, y, z) * amp; } @@ -191,12 +191,12 @@ private DECIMAL SingleValueFractalRigidMulti(DECIMAL x, DECIMAL y) DECIMAL sum = 1 - Math.Abs(SingleValue(seed, x, y)); DECIMAL amp = 1; - for (int i = 1; i < octaves; i++) + for (int i = 1; i < FractalOctaves; i++) { x *= FractalLacunarity; y *= FractalLacunarity; - amp *= gain; + amp *= FractalGain; sum -= (1 - Math.Abs(SingleValue(++seed, x, y))) * amp; } @@ -208,13 +208,13 @@ private DECIMAL SingleValueFractalRigidMulti(DECIMAL x, DECIMAL y, DECIMAL z) DECIMAL sum = 1 - Math.Abs(SingleValue(seed, x, y, z)); DECIMAL amp = 1; - for (int i = 1; i < octaves; i++) + for (int i = 1; i < FractalOctaves; i++) { x *= FractalLacunarity; y *= FractalLacunarity; z *= FractalLacunarity; - amp *= gain; + amp *= FractalGain; sum -= (1 - Math.Abs(SingleValue(++seed, x, y, z))) * amp; } diff --git a/Content/Noise/FastNoise.cs b/Content/Noise/FastNoise.cs index 43abc8bd5..f4a4fcb13 100644 --- a/Content/Noise/FastNoise.cs +++ b/Content/Noise/FastNoise.cs @@ -10,9 +10,6 @@ public partial class FastNoise { private const short Inline = (short)MethodImplOptions.AggressiveInlining; private const int CellularMaxIndex = 3; - - private int octaves = 3; - private DECIMAL gain = (DECIMAL)0.5; private DECIMAL fractalBounding; public int Seed { get; set; } @@ -24,24 +21,24 @@ public partial class FastNoise public int FractalOctaves { - get => octaves; + get; set { - octaves = value; + field = value; CalculateFractalBounding(); } - } + } = 3; public DECIMAL FractalGain { - get => gain; + get; set { - gain = value; + field = value; CalculateFractalBounding(); } - } + } = (DECIMAL)0.5; public FastNoise(int seed = 0) { @@ -150,13 +147,13 @@ public DECIMAL GetNoise(DECIMAL x, DECIMAL y, DECIMAL z) private void CalculateFractalBounding() { - DECIMAL amp = gain; + DECIMAL amp = FractalGain; DECIMAL ampFractal = 1; - for (int i = 1; i < octaves; i++) + for (int i = 1; i < FractalOctaves; i++) { ampFractal += amp; - amp *= gain; + amp *= FractalGain; } fractalBounding = 1 / ampFractal; diff --git a/Content/Tiles/Starlight/DreamingOnyx.cs b/Content/Tiles/Starlight/DreamingOnyx.cs index f7a142f4c..4f7974f32 100644 --- a/Content/Tiles/Starlight/DreamingOnyx.cs +++ b/Content/Tiles/Starlight/DreamingOnyx.cs @@ -46,7 +46,7 @@ public override void PostDraw(int i, int j, SpriteBatch spriteBatch) { Tile tile = Main.tile[i, j]; - var tex = Assets.Tiles.Starlight.DreamingOnyxGlow.Value; + Texture2D tex = Assets.Tiles.Starlight.DreamingOnyxGlow.Value; var frame = new Rectangle(tile.TileFrameX, tile.TileFrameY, 16, 16); Vector2 target = new Vector2(i, j) * 16 + Vector2.One * Main.offScreenRange - Main.screenPosition + Vector2.One * 8; var color = new Color(255, 255, 255, 0); diff --git a/Content/Tiles/Starlight/GlowingOracleGlass.cs b/Content/Tiles/Starlight/GlowingOracleGlass.cs index 9a5b0e7b4..8762428c3 100644 --- a/Content/Tiles/Starlight/GlowingOracleGlass.cs +++ b/Content/Tiles/Starlight/GlowingOracleGlass.cs @@ -42,7 +42,7 @@ public override void PostDraw(int i, int j, SpriteBatch spriteBatch) { Tile tile = Main.tile[i, j]; - var tex = Assets.Tiles.Starlight.OracleGlassGlow.Value; + Texture2D tex = Assets.Tiles.Starlight.OracleGlassGlow.Value; var frame = new Rectangle(tile.TileFrameX, tile.TileFrameY, 16, 16); Vector2 target = new Vector2(i, j) * 16 + Vector2.One * Main.offScreenRange - Main.screenPosition + Vector2.One * 8; var color = new Color(255, 255, 255, 0); diff --git a/Content/Tiles/Starlight/ObservatoryDoodad.cs b/Content/Tiles/Starlight/ObservatoryDoodad.cs index 3f0ac2eaa..d28ca43a4 100644 --- a/Content/Tiles/Starlight/ObservatoryDoodad.cs +++ b/Content/Tiles/Starlight/ObservatoryDoodad.cs @@ -35,7 +35,7 @@ public override void Update() public override void DrawBehindTiles() { - var tex = Assets.Tiles.Starlight.ObervatoryDoodadBack.Value; + Texture2D tex = Assets.Tiles.Starlight.ObervatoryDoodadBack.Value; LightingBufferRenderer.DrawWithLighting(tex, Center + Vector2.UnitY * height / 2f - Main.screenPosition, null, Color.White, 0, new Vector2(tex.Width / 2f, tex.Height), 1); } } diff --git a/Content/Tiles/Vitric/Temple/GearPuzzle/GearTile.cs b/Content/Tiles/Vitric/Temple/GearPuzzle/GearTile.cs index 477d5ae2c..9eebd9e73 100644 --- a/Content/Tiles/Vitric/Temple/GearPuzzle/GearTile.cs +++ b/Content/Tiles/Vitric/Temple/GearPuzzle/GearTile.cs @@ -307,11 +307,8 @@ protected bool Engaged return false; } - set - { - if (GearEntity != null) - GearEntity.engaged = value; - } + + set => GearEntity?.engaged = value; } protected float RotationVelocity @@ -323,11 +320,8 @@ protected float RotationVelocity return 0; } - set - { - if (GearEntity != null) - GearEntity.rotationVelocity = value; - } + + set => GearEntity?.rotationVelocity = value; } protected float RotationOffset @@ -339,11 +333,8 @@ protected float RotationOffset return 0; } - set - { - if (GearEntity != null) - GearEntity.rotationOffset = value; - } + + set => GearEntity?.rotationOffset = value; } protected GearTileEntity GearEntity @@ -361,12 +352,7 @@ protected GearTileEntity GearEntity public int GearSize { - get => GearEntity?.size ?? 0; - set - { - if (GearEntity != null) - GearEntity.size = value % 4; - } + get => GearEntity?.size ?? 0; set => GearEntity?.size = value % 4; } public float Rotation diff --git a/Content/Tiles/Vitric/Temple/SoundPuzzle/SoundPuzzleHandler.cs b/Content/Tiles/Vitric/Temple/SoundPuzzle/SoundPuzzleHandler.cs index ca2300149..9564c4963 100644 --- a/Content/Tiles/Vitric/Temple/SoundPuzzle/SoundPuzzleHandler.cs +++ b/Content/Tiles/Vitric/Temple/SoundPuzzle/SoundPuzzleHandler.cs @@ -70,11 +70,11 @@ public override void PreUpdateEntities() public override void PostDrawTiles() { - var one = Assets.Tiles.Vitric.OldCeirosOrnament0.Value; - var two = Assets.Tiles.Vitric.OldCeirosOrnament3.Value; - var three = Assets.Tiles.Vitric.OldCeirosOrnament1.Value; - var four = Assets.Tiles.Vitric.OldCeirosOrnament2.Value; - var blank = Assets.Bosses.VitricBoss.VitricBossCrystal.Value; + Texture2D one = Assets.Tiles.Vitric.OldCeirosOrnament0.Value; + Texture2D two = Assets.Tiles.Vitric.OldCeirosOrnament3.Value; + Texture2D three = Assets.Tiles.Vitric.OldCeirosOrnament1.Value; + Texture2D four = Assets.Tiles.Vitric.OldCeirosOrnament2.Value; + Texture2D blank = Assets.Bosses.VitricBoss.VitricBossCrystal.Value; Vector2 pos = StarlightWorld.VitricBossArena.BottomLeft() * 16 + new Vector2(-762, 1424) - Main.screenPosition; diff --git a/Content/WorldGeneration/GenerateVitric.cs b/Content/WorldGeneration/GenerateVitric.cs index 31b507ff9..c2783e61d 100644 --- a/Content/WorldGeneration/GenerateVitric.cs +++ b/Content/WorldGeneration/GenerateVitric.cs @@ -1,7 +1,6 @@ using StarlightRiver.Content.CustomHooks; using StarlightRiver.Content.Tiles.Vitric; using StarlightRiver.Content.Tiles.Vitric.Temple.GearPuzzle; -using StarlightRiver.Helpers; using StarlightRiver.Noise; using System; using System.Collections.Generic; @@ -37,8 +36,7 @@ public partial class StarlightWorld : ModSystem /// public static void VitricGen(GenerationProgress progress, GameConfiguration configuration) { - if (progress != null) - progress.Message = "Digging the Vitric Desert"; + progress?.Message = "Digging the Vitric Desert"; int vitricHeight = 140; ValidGround = new int[] { instance.Find("VitricSand").Type, instance.Find("VitricSoftSand").Type }; @@ -73,7 +71,7 @@ public static void VitricGen(GenerationProgress progress, GameConfiguration conf PlaceTile(vitricBiome.X + vitricBiome.Width / 2 + 41, y, StarlightRiver.Instance.Find("VitricBossBarrier").Type, false, false); } - VitricIslandLocations = new List(); //List for island positions + VitricIslandLocations = []; //List for island positions int fail = 0; for (int i = 0; i < vitricBiome.Width / 40 - 1; ++i) @@ -194,12 +192,11 @@ public static void VitricGen(GenerationProgress progress, GameConfiguration conf } } - if (progress != null) - progress.Message = "Melting Glass"; + progress?.Message = "Melting Glass"; GenConsistentMiniIslands(); GenSandstonePillars(); - RuinedPillarPositions = new List(); + RuinedPillarPositions = []; GenRuins(); GenForge(); GenDecoration(); diff --git a/Core/ParticleSystem.cs b/Core/ParticleSystem.cs index dac6b0d36..14dbfc60f 100644 --- a/Core/ParticleSystem.cs +++ b/Core/ParticleSystem.cs @@ -293,8 +293,7 @@ public void SetTexture(Texture2D texture) { this.texture = texture; - if (effect != null) - effect.Texture = texture; + effect?.Texture = texture; } } diff --git a/Core/PrimitiveDrawing.cs b/Core/PrimitiveDrawing.cs index 061e91685..4daa16b92 100644 --- a/Core/PrimitiveDrawing.cs +++ b/Core/PrimitiveDrawing.cs @@ -95,7 +95,7 @@ public class Trail : IDisposable /// public Vector2[] Positions { - get => positions; + get; set { if (value.Length != maxPointCount) @@ -103,12 +103,10 @@ public Vector2[] Positions throw new ArgumentException("Array of positions was a different length than the expected result!"); } - positions = value; + field = value; } } - private Vector2[] positions; - /// /// Used in order to calculate the normal from the frontmost position, because there isn't a point after it in the original list. /// diff --git a/Core/Systems/ArmatureSystem/Arm.cs b/Core/Systems/ArmatureSystem/Arm.cs index 80b47a532..ea41abe8d 100644 --- a/Core/Systems/ArmatureSystem/Arm.cs +++ b/Core/Systems/ArmatureSystem/Arm.cs @@ -109,7 +109,7 @@ public void IKToPoint(Vector2 target) Vector2 toTarget = target - currentSegment.start; float targetRotation = toTarget.ToRotation(); - if (targetRotation != targetRotation) // == NaN + if (float.IsNaN(targetRotation)) targetRotation = 0; segments[i].rotation = targetRotation; diff --git a/Core/Systems/AuroraWaterSystem/AuroraWaterSystem.cs b/Core/Systems/AuroraWaterSystem/AuroraWaterSystem.cs index 98ce5d897..6213ecb7f 100644 --- a/Core/Systems/AuroraWaterSystem/AuroraWaterSystem.cs +++ b/Core/Systems/AuroraWaterSystem/AuroraWaterSystem.cs @@ -2,11 +2,15 @@ using StarlightRiver.Content.Dusts; using StarlightRiver.Content.NPCs.Permafrost; using StarlightRiver.Core.Loaders; +using StarlightRiver.Core.Systems.LightingSystem; using StarlightRiver.Core.Systems.MetaballSystem; using StarlightRiver.Core.Systems.ScreenTargetSystem; using System; +using System.Collections.Generic; using System.Linq; +using Terraria.ID; using Terraria.ModLoader.IO; +using Terraria.WorldBuilding; namespace StarlightRiver.Core.Systems.AuroraWaterSystem @@ -34,6 +38,21 @@ public int AuroraWaterFrameY } } + class AuroraRipple + { + public Vector2 pos; + public float scale; + public float speed; + public float prog; + + public AuroraRipple(Vector2 pos, float scale, float speed) + { + this.pos = pos; + this.scale = scale; + this.speed = speed; + } + } + class AuroraWaterSystem : ModSystem { public static int visCounter = 0; @@ -44,6 +63,8 @@ class AuroraWaterSystem : ModSystem public static bool failedLoad = false; + public static List ripplePoints = new(); + public float Priority => 1; public override void Load() @@ -115,6 +136,7 @@ private static void DrawAuroraTarget(SpriteBatch sb) private static void DrawAuroraBackTarget(SpriteBatch sb) { Asset asset = Assets.Misc.AuroraWaterMap; + Asset asset2 = Assets.Noise.SwirlyNoiseLooping; if (asset.IsLoaded) { @@ -124,6 +146,9 @@ private static void DrawAuroraBackTarget(SpriteBatch sb) Main.graphics.GraphicsDevice.Clear(Color.Transparent); Texture2D tex = asset.Value; + Texture2D tex2 = asset2.Value; + Texture2D tex3 = Assets.Masks.Glow.Value; + Texture2D rippleTex = Assets.Masks.RingGlowInnerTwo.Value; Vector2 layer1Pivot = Main.GameUpdateCount * new Vector2(-0.55f, 0.3f); Vector2 layer2Pivot = Main.GameUpdateCount * new Vector2(0.75f, -0.4f); @@ -134,7 +159,7 @@ private static void DrawAuroraBackTarget(SpriteBatch sb) (int)(Main.screenPosition.Y + layer1Pivot.Y) % tex.Height, Main.screenWidth, Main.screenHeight), - Color.White * 0.7f); + Color.Red * 0.7f); sb.Draw(tex, Vector2.Zero, new Rectangle( @@ -142,13 +167,74 @@ private static void DrawAuroraBackTarget(SpriteBatch sb) (int)(Main.screenPosition.Y + layer2Pivot.Y) % tex.Height, Main.screenWidth, Main.screenHeight), - Color.White); + Color.Red); + + sb.Draw(tex2, + Vector2.Zero, + new Rectangle( + (int)(Main.screenPosition.X + layer1Pivot.X) % tex2.Width, + (int)(Main.screenPosition.Y + layer1Pivot.Y) % tex2.Height, + Main.screenWidth, + Main.screenHeight), + Color.Green * 0.7f); + sb.Draw(tex2, + Vector2.Zero, + new Rectangle( + (int)(Main.screenPosition.X + layer2Pivot.X) % tex2.Width, + (int)(Main.screenPosition.Y + layer2Pivot.Y) % tex2.Height, + Main.screenWidth, + Main.screenHeight), + Color.Green); + + sb.Draw(tex3, + Main.LocalPlayer.Center - Main.screenPosition, + null, + Color.Blue, 0, tex3.Size() / 2f, 3f, 0, 0); + + foreach (AuroraRipple ripple in ripplePoints) + { + Color col = Color.Lime * (1f - ripple.prog) * ripple.scale; + Color col2 = Color.Red * (1f - ripple.prog) * ripple.scale; + sb.Draw(rippleTex, ripple.pos - Main.screenPosition, null, col, 0, rippleTex.Size() / 2f, ripple.scale * ripple.prog, 0, 0); + sb.Draw(rippleTex, ripple.pos - Main.screenPosition, null, col2, 0, rippleTex.Size() / 2f, ripple.scale * ripple.prog, 0, 0); + } sb.End(); sb.Begin(); } } + public override void PostUpdateNPCs() + { + Rectangle rectangle = WorldUtils.ClampToWorld(new Rectangle((int)Main.screenPosition.X / 16, (int)Main.screenPosition.Y / 16, Main.screenWidth / 16, Main.screenHeight / 16)); + for (int k = rectangle.Left; k < rectangle.Right; k++) + { + for (int l = rectangle.Top; l < rectangle.Bottom; l++) + { + Tile tile = Main.tile[k, l]; + if (tile.Get().HasAuroraWater) + { + AuroraWaterSystem.visCounter = 30; + + if (l % 2 == 0 && k % 2 == 0 && !tile.IsSquareSolidTile()) + Lighting.AddLight(new Vector2(k, l) * 16, new Vector3(0.4f, 0.8f, 1f)); + } + } + } + + for (int k = 0; k < ripplePoints.Count; k++) + { + ripplePoints[k].prog += ripplePoints[k].speed; + } + + ripplePoints.RemoveAll(n => n.prog >= 1f); + } + + public static void AddRipple(Vector2 pos, float scale, float speed) + { + ripplePoints.Add(new(pos, scale, speed)); + } + private void DrawAuroraWater(On_Main.orig_DrawInfernoRings orig, Main self) { orig(self); @@ -286,20 +372,11 @@ public override unsafe void LoadWorldData(TagCompound tag) } } - class AuroraWaterGlobalTile : GlobalTile - { - public override void NearbyEffects(int i, int j, int type, bool closer) - { - if (Main.tile[i, j].Get().HasAuroraWater) - AuroraWaterSystem.visCounter = 30; - } - } - class AuroraWaterTileMetaballs : MetaballActor { public override bool Active => AuroraWaterSystem.Visible && !Main.LocalPlayer.InModBiome(ModContent.GetInstance()); - public override Color OutlineColor => new(255, 0, 255); + public override Color OutlineColor => new(255, 0, 0); public override void DrawShapes(SpriteBatch spriteBatch) { @@ -319,7 +396,7 @@ public override void DrawShapes(SpriteBatch spriteBatch) foreach (Dust dust in Main.dust) { if (dust.active && dust.type == ModContent.DustType()) - spriteBatch.Draw(tex, (dust.position - Main.screenPosition) / 2, null, Color.Red, 0f, Vector2.One * 256f, dust.scale * 0.05f, SpriteEffects.None, 0); + spriteBatch.Draw(tex, (dust.position - Main.screenPosition) / 2, null, Color.Lime, 0f, Vector2.One * 256f, dust.scale * 0.05f, SpriteEffects.None, 0); } spriteBatch.End(); @@ -336,27 +413,39 @@ public static void DrawSpecial() return; } - Effect shader = ShaderLoader.GetShader("AuroraWaterShader").Value; + Effect effect = ShaderLoader.GetShader("AuroraWaterShader").Value; - if (shader is null) + if (effect is null) { MetaballSystem.MetaballSystem.actorsSem.Release(); return; } - shader.Parameters["time"].SetValue(StarlightWorld.visualTimer); - shader.Parameters["screenSize"].SetValue(new Vector2(Main.screenWidth, Main.screenHeight)); - shader.Parameters["offset"].SetValue(new Vector2(Main.screenPosition.X % Main.screenWidth / Main.screenWidth, Main.screenPosition.Y % Main.screenHeight / Main.screenHeight)); - shader.Parameters["sampleTexture2"].SetValue(AuroraWaterSystem.auroraBackTarget.RenderTarget); - Main.spriteBatch.End(); - Main.spriteBatch.Begin(default, BlendState.Additive, Main.DefaultSamplerState, default, Main.Rasterizer, shader, Main.GameViewMatrix.TransformationMatrix); + Main.graphics.GraphicsDevice.SetRenderTarget(Main.screenTargetSwap); + + effect.Parameters["uTime"].SetValue((float)Main.timeForVisualEffects * 0.02f); + effect.Parameters["offset"].SetValue(new Vector2(Main.screenPosition.X / Main.screenWidth * -0.5f, Main.screenPosition.Y / Main.screenHeight * -0.5f)); + effect.Parameters["sampleTexture"].SetValue(AuroraWaterSystem.auroraBackTarget.RenderTarget); + effect.Parameters["uImageSize1"].SetValue(new Vector2(Main.screenWidth, Main.screenHeight)); + //effect.Parameters["lightTexture"].SetValue(LightingBuffer.screenLightingTarget.RenderTarget); + effect.Parameters["gameTexture"].SetValue(Main.screenTarget); + effect.Parameters["transform"].SetValue(Matrix.Invert(Main.GameViewMatrix.TransformationMatrix)); + effect.Parameters["offset"].SetValue(new Vector2(Main.screenPosition.X % Main.screenWidth / Main.screenWidth, Main.screenPosition.Y % Main.screenHeight / Main.screenHeight)); + + var inv = Matrix.Invert(Main.GameViewMatrix.TransformationMatrix); + + Main.spriteBatch.Begin(default, default, SamplerState.PointClamp, default, RasterizerState.CullNone, effect, Matrix.Identity); Texture2D target = MetaballSystem.MetaballSystem.actors.FirstOrDefault(n => n is AuroraWaterTileMetaballs).Target.RenderTarget; Main.spriteBatch.Draw(target, Vector2.Zero, null, Color.White, 0, Vector2.Zero, 2, 0, 0); Main.spriteBatch.End(); - Main.spriteBatch.Begin(0, BlendState.AlphaBlend, Main.DefaultSamplerState, DepthStencilState.None, Main.Rasterizer, null, Main.GameViewMatrix.TransformationMatrix); + + Main.graphics.GraphicsDevice.SetRenderTarget(Main.screenTarget); + + Main.spriteBatch.Begin(default, default, SamplerState.PointClamp, default, RasterizerState.CullNone, default, Matrix.Identity); + Main.spriteBatch.Draw(Main.screenTargetSwap, Vector2.Zero, null, Color.White, 0, Vector2.Zero, 1, 0, 0); MetaballSystem.MetaballSystem.actorsSem.Release(); } diff --git a/Core/Systems/AuroraWaterSystem/SwimPlayer.cs b/Core/Systems/AuroraWaterSystem/SwimPlayer.cs index 5d086a27f..5ce50dc95 100644 --- a/Core/Systems/AuroraWaterSystem/SwimPlayer.cs +++ b/Core/Systems/AuroraWaterSystem/SwimPlayer.cs @@ -11,7 +11,12 @@ class SwimPlayer : ModPlayer float targetRotation = 0; float realRotation = 0; float armRotation; + int emergeTime = 0; + float emergeRotatio = 0; + + int emergeBoostTime = 0; + Vector2 emergeBoostSpeed = default; public bool wasSwimming; @@ -51,6 +56,8 @@ class SwimPlayer : ModPlayer { if (!wasSwimming) { + AuroraWaterSystem.AddRipple(Player.Center, 1.5f, 0.03f); + SoundHelper.PlayPitched("Magic/WaterWoosh", 0.8f, 0, Player.Center); for (int k = 0; k < 20; k++) @@ -62,7 +69,6 @@ class SwimPlayer : ModPlayer } ShouldSwim = true; - SwimSpeed *= 0.7f; } } } @@ -71,11 +77,40 @@ public override void PreUpdate() { CheckAuroraSwimming(); + if (emergeBoostTime > 0) + { + // Special effects for when we re-enter out of an exit boost + if (ShouldSwim) + { + emergeBoostTime = 0; + Player.velocity = Vector2.Normalize(Player.velocity) * 0.5f; + + SoundHelper.PlayPitched("Magic/WaterWoosh", 1f, -0.3f, Player.Center); + + for (int k = 0; k < 20; k++) + { + Dust.NewDustPerfect(Player.Center, DustType(), -Vector2.Normalize(Player.velocity).RotatedByRandom(0.5f) * Main.rand.NextFloat(15), 0, new Color(200, 220, 255) * 0.4f, Main.rand.NextFloat(0.2f, 0.8f)); + } + } + else + { + // Makes the exit boost "flat" + emergeBoostTime--; + Player.velocity = emergeBoostSpeed * (0.1f + emergeBoostTime / 20f); + + for (int k = 0; k < 5; k++) + { + Dust.NewDustPerfect(Player.Center + Main.rand.NextVector2Circular(16, 16), DustType(), -Vector2.Normalize(Player.velocity).RotatedByRandom(0.5f) * Main.rand.NextFloat(5), 0, new Color(100, Main.rand.Next(150, 255), 255, 0), Main.rand.NextFloat(0.1f, 0.2f)); + } + } + } + if (emergeTime == 18) //reset jumps { Player.RefreshExtraJumps(); Player.rocketTime = Player.rocketTimeMax; Player.wingTime = Player.wingTimeMax; + emergeRotatio = realRotation; SoundHelper.PlayPitched("Magic/WaterWoosh", 0.8f, 0, Player.Center); @@ -84,6 +119,21 @@ public override void PreUpdate() Dust.NewDustPerfect(Player.Center, DustType(), Main.rand.NextVector2Circular(2, 2), 0, new Color(200, 220, 255) * 0.4f, Main.rand.NextFloat(0.2f, 0.8f)); } + if (boostCD > 20 && Player.velocity.Length() > 0) + { + SoundHelper.PlayPitched("SquidBoss/LightSplash", 1f, 0.2f, Player.Center); + + for (int k = 0; k < 20; k++) + { + Dust.NewDustPerfect(Player.Center, DustType(), Vector2.Normalize(Player.velocity).RotatedByRandom(0.5f) * Main.rand.NextFloat(15), 0, new Color(200, 220, 255) * 0.4f, Main.rand.NextFloat(0.2f, 0.8f)); + } + + emergeBoostTime = 20; + emergeBoostSpeed = Vector2.Normalize(Player.velocity) * 20; + + boostCD = 0; + } + wasSwimming = false; } @@ -91,7 +141,7 @@ public override void PreUpdate() { if (boostCD > 0) { - boostCD = 0; + //boostCD = 0; Player.UpdateRotation(0); } @@ -101,10 +151,6 @@ public override void PreUpdate() targetRotation = ShouldSwim ? Player.velocity.ToRotation() : 1.57f + 3.14f; - // Forces the rotation target to be upright if the player is emerging - if (emergeTime < 19) - targetRotation = -MathHelper.PiOver2; - realRotation %= 6.28f; //handles the rotation, ensures the Player wont randomly snap to rotation when entering/leaving swimming if (Math.Abs(targetRotation - realRotation) % 6.28f > 0.21f) @@ -124,6 +170,10 @@ static float Mod(float a, float b) realRotation = targetRotation; } + // Forces the rotation target to be upright if the player is emerging + if (emergeTime < 18) + realRotation = -MathHelper.PiOver2 + (emergeRotatio + MathHelper.PiOver2) * (emergeTime - 1) / 19f; + Player.fullRotationOrigin = Player.Size / 2; //so the Player rotates around their center... why is this not the default? Player.fullRotation = realRotation + MathHelper.PiOver2; @@ -154,53 +204,67 @@ static float Mod(float a, float b) Player.legFrame = new Rectangle(0, 56 * (int)(5 + Main.GameUpdateCount / 7 % 3), 40, 56); - float speed = 0.2f * SwimSpeed; + float speed = 0.02f * SwimSpeed; + Vector2 dir = Vector2.Zero; if (Player.controlRight) - Player.velocity.X += speed; //there should probably be a better way of doing this? + dir.X += 1; if (Player.controlLeft) - Player.velocity.X -= speed; + dir.X -= 1; if (Player.controlDown) - Player.velocity.Y += speed; + dir.Y += 1; if (Player.controlUp) - Player.velocity.Y -= speed; + dir.Y -= 1; + + if (dir.Length() > 0) + Player.velocity += Vector2.Normalize(dir) * speed; Player.gravity = 0; - Player.velocity *= 0.95f; + + float slow = Player.velocity.Length() > SwimSpeed ? 0.5f : 0.95f; + Player.velocity *= slow; + + if (Main.GameUpdateCount % 10 == 0) + AuroraWaterSystem.AddRipple(Player.Center, 0.5f + Player.velocity.Length() * 0.05f, 0.02f); if (Player.controlJump && boostCD <= 0) { - SoundHelper.PlayPitched("SquidBoss/MagicSplash", 1f, -0.5f, Player.Center); - SoundHelper.PlayPitched("SquidBoss/MagicSplash", 1f, 0f, Player.Center); + SoundHelper.PlayPitched("SquidBoss/LightSplash", Main.rand.NextFloat(0.5f, 0.8f), Main.rand.NextFloat(-0.9f, -0.6f), Player.Center); + SoundHelper.PlayPitched("Magic/WaterWoosh", Main.rand.NextFloat(0.3f, 0.6f), Main.rand.NextFloat(-0.5f, -0.2f), Player.Center); + AuroraWaterSystem.AddRipple(Player.Center, 1.5f, 0.03f); boostCD = 60; } - if (boostCD > 40) + if (boostCD > 20) { - float timer = (boostCD - 40) / 20f; - float angle = timer * 6.28f; - Vector2 vel = -Player.velocity * 0f; + float timer = (boostCD - 20) / 40f; + float angle = timer * 6.28f * 2f; + Vector2 vel = Vector2.One.RotatedByRandom(6.28f) * Main.rand.NextFloat(0.15f); Player.UpdateRotation(angle); for (int k = 0; k < 2; k++) { float prog = k / 2f; var off = new Vector2((float)Math.Cos(angle + 1 / 20f * 6.28f * prog) * 18, (float)Math.Sin(angle + 1 / 20f * 6.28f * prog) * 4); + Color color = new Color(timer, 1 - timer, 0.5f + 0.5f * MathF.Sin(timer * 3.14f), 0) * MathF.Sin(timer * 3.14f) * 0.3f; - var l = Dust.NewDustPerfect(Player.Center + Player.velocity * prog + off.RotatedBy(Player.fullRotation), DustType(), vel, 0, new Color(1 - timer, timer, 1), Main.rand.NextFloat(0.4f, 0.7f)); - var r = Dust.NewDustPerfect(Player.Center + Player.velocity * prog - off.RotatedBy(Player.fullRotation), DustType(), vel, 0, new Color(1 - timer, timer, 1), Main.rand.NextFloat(0.4f, 0.7f)); + var l = Dust.NewDustPerfect(Player.Center + Player.velocity * prog + off.RotatedBy(Player.fullRotation), DustType(), vel, 0, color, Main.rand.NextFloat(0.1f, 0.23f)); + var r = Dust.NewDustPerfect(Player.Center + Player.velocity * prog - off.RotatedBy(Player.fullRotation), DustType(), vel, 0, color, Main.rand.NextFloat(0.1f, 0.23f)); l.noGravity = true; r.noGravity = true; } + } + if (boostCD > 40) + { if (Player.velocity == Vector2.Zero) Player.velocity = new Vector2(0, -0.01f); - Player.velocity += Vector2.Normalize(Player.velocity) * 0.8f * SwimSpeed; + Player.velocity += Vector2.Normalize(Player.velocity) * 0.08f * SwimSpeed; Player.AddBuff(Terraria.ID.BuffID.Cursed, 1, true); } else @@ -231,7 +295,7 @@ public override void PostUpdate() public override void ResetEffects() { ShouldSwim = false; - SwimSpeed = 1f; + SwimSpeed = 10f; } } } \ No newline at end of file diff --git a/Core/Systems/CameraSystem/ZoomHandler.cs b/Core/Systems/CameraSystem/ZoomHandler.cs index 98faf612a..152b271d8 100644 --- a/Core/Systems/CameraSystem/ZoomHandler.cs +++ b/Core/Systems/CameraSystem/ZoomHandler.cs @@ -15,19 +15,17 @@ public class ZoomHandler : ModSystem private static float flatZoomTarget = 0; private static float flatZoom = 0; - private static float extraZoomTarget = 1; - public static float ExtraZoomTarget { - get => extraZoomTarget; + get; private set { oldZoom = zoomOverride; zoomTimer = 0; - extraZoomTarget = value; + field = value; } - } + } = 1; public static float ClampedExtraZoomTarget => System.Math.Min(1, ExtraZoomTarget); @@ -83,12 +81,12 @@ public static void TickZoom() public static void UpdateZoom() { - zoomOverride = Vector2.SmoothStep(new Vector2(oldZoom, 0), new Vector2(extraZoomTarget, 0), zoomTimer / (float)maxTimer).X; + zoomOverride = Vector2.SmoothStep(new Vector2(oldZoom, 0), new Vector2(ExtraZoomTarget, 0), zoomTimer / (float)maxTimer).X; if (zoomOverride == Main.GameZoomTarget) oldZoom = Main.GameZoomTarget; - if (zoomTimer == maxTimer && extraZoomTarget == Main.GameZoomTarget) + if (zoomTimer == maxTimer && ExtraZoomTarget == Main.GameZoomTarget) maxTimer = 0; if (maxTimer == 0) diff --git a/Core/Systems/DummyTileSystem/Dummy.cs b/Core/Systems/DummyTileSystem/Dummy.cs index 9954227d2..9bd3f45e9 100644 --- a/Core/Systems/DummyTileSystem/Dummy.cs +++ b/Core/Systems/DummyTileSystem/Dummy.cs @@ -307,8 +307,7 @@ protected override void Receive() { Dummy dummy = DummyTile.GetDummy((int)(x / 16), (int)(y / 16), type); - if (dummy != null) - dummy.active = false; + dummy?.active = false; } } } \ No newline at end of file diff --git a/Effects/Source/AuroraWaterShader.fx b/Effects/Source/AuroraWaterShader.fx index 8b2cc98a1..aca3f0e1c 100644 --- a/Effects/Source/AuroraWaterShader.fx +++ b/Effects/Source/AuroraWaterShader.fx @@ -1,8 +1,10 @@ #include "Common.fxh" -float time; -float2 screenSize; -float2 offset; +sampler uImage0 : register(s0); +float uTime; +float2 uImageSize0; +float2 uImageSize1; +float4x4 transform; texture sampleTexture; sampler2D samplerTex = sampler_state { texture = ; magfilter = LINEAR; minfilter = LINEAR; mipfilter = LINEAR; AddressU = wrap; AddressV = wrap; }; @@ -10,24 +12,63 @@ sampler2D samplerTex = sampler_state { texture = ; magfilter = LI texture sampleTexture2; sampler2D samplerTex2 = sampler_state { texture = ; magfilter = LINEAR; minfilter = LINEAR; mipfilter = LINEAR; AddressU = wrap; AddressV = wrap; }; -float4 PixelShaderFunction(float4 screenSpace : TEXCOORD0) : COLOR0 -{ - float2 st = screenSpace.xy; - float2 off = float2(sin(time + st.y * 200.0 + offset.y * 100.0), sin(time + st.x * 200.0 + offset.x * 100.0)) / screenSize; +texture gameTexture; +sampler2D gameTex = sampler_state { texture = ; magfilter = LINEAR; minfilter = LINEAR; mipfilter = LINEAR; AddressU = clamp; AddressV = clamp; }; - float map = tex2D(samplerTex2, st * 2 + off).r; - float4 color = tex2D(samplerTex, st + off); +float2 offset; - float progress = (st.x + st.y) * 10.0; +float4 GetRainbow(float2 coords) +{ + float progress = (coords.x + coords.y) * 10.0; - float r = 40.0 * (1.0 + sin(time + progress * 0.2)); - float g = 46.0 * (1.0 + sin(HALF_PI + time + progress)); + float r = 40.0 * (1.0 + sin(uTime + progress * 0.2)); + float g = 46.0 * (1.0 + sin(HALF_PI + uTime + progress)); float b = 72.0; + + return float4(r, g, b, 0.0) * 0.005; +} - float3 colorB = float3(r, g, b); - float3 color2 = colorB * 0.015 * map * (color.r + color.b * 4.0); +float4 PixelShaderFunction(float4 screenSpace : TEXCOORD0) : COLOR0 +{ + float2 coords = screenSpace.xy; + float2 off = float2(sin(uTime + coords.y * 200.0 + offset.y * 100.0), sin(uTime + coords.x * 200.0 + offset.x * 100.0)) / uImageSize1; + + float2 originalCoords = coords; + + coords += off; + + float2 pixel = coords * uImageSize1 * 2.0; + coords = mul(float4(pixel, 0.0, 1.0), transform).xy / (uImageSize1 * 2.0); + + float2 pixCoord = coords - coords % (1.0 / uImageSize1) + float2(1.0 / uImageSize1); + + float4 mapSample = tex2D(samplerTex, coords * 2.0); + float swirl = sin((mapSample.g + uTime * 0.3) * 6.28); + + float4 light = GetRainbow(coords); + + float2 underCoord = coords * 2.0 + (swirl) * 0.005 * tex2D(uImage0, coords).a; + float2 pixUnderCoord = underCoord - underCoord % (2.0 / uImageSize1); + + float4 distortLight = GetRainbow(pixUnderCoord); + float shapeMask = tex2D(uImage0, coords).a; + + float lum = ((light.r + light.g + light.b) / 3.0); + + float caustics = tex2D(samplerTex, pixUnderCoord).r; + caustics = max(0.0, caustics - 0.1); + float speculars = tex2D(uImage0, pixCoord).g * 0.4 * (caustics + pow(caustics, 3.0) * 1.2 * lum); + speculars += tex2D(uImage0, coords).r * (0.5 + light * 0.5); + + float bright = pow(speculars, 6.0) * 200.0 * pow(lum, 2.0); + float4 color = distortLight * (pow(speculars, 2.0) * 3.0 + bright); + color.a = shapeMask; + + float2 originalUnderCoord = originalCoords * 2.0 + (swirl) * 0.005 * tex2D(uImage0, coords).a * (1.0 - mapSample.b); + float4 underColor = tex2D(gameTex, originalUnderCoord); + underColor += shapeMask * distortLight * distortLight * (1.0 - abs(swirl)); - return float4(color2, color.a) * 0.5; + return underColor + color; } technique Technique1 diff --git a/Effects/Source/Waves.fx b/Effects/Source/Waves.fx index 78d83a2bd..803b54cc6 100644 --- a/Effects/Source/Waves.fx +++ b/Effects/Source/Waves.fx @@ -1,20 +1,8 @@ sampler uImage0 : register(s0); -sampler uImage1 : register(s1); -sampler uImage2 : register(s2); -float3 uColor; -float3 uSecondaryColor; -float uOpacity; -float uSaturation; -float uRotation; float uTime; -float4 uSourceRect; -float2 uWorldPosition; -float uDirection; -float3 uLightSource; float2 uImageSize0; float2 uImageSize1; -float power; -float speed; +float4x4 transform; texture sampleTexture; sampler2D samplerTex = sampler_state { texture = ; magfilter = LINEAR; minfilter = LINEAR; mipfilter = LINEAR; AddressU = wrap; AddressV = wrap; }; @@ -22,22 +10,53 @@ sampler2D samplerTex = sampler_state { texture = ; magfilter = LI texture lightTexture; sampler2D lightTex = sampler_state { texture = ; magfilter = LINEAR; minfilter = LINEAR; mipfilter = LINEAR; AddressU = wrap; AddressV = wrap; }; +texture gameTexture; +sampler2D gameTex = sampler_state { texture = ; magfilter = LINEAR; minfilter = LINEAR; mipfilter = LINEAR; AddressU = clamp; AddressV = clamp; }; + float2 offset; float4 PixelShaderFunction(float2 coords : TEXCOORD0) : COLOR0 -{ - float4 color = tex2D(uImage0, coords).a * tex2D(uImage0, coords).r * tex2D(lightTex, coords * 2.0); - float map = tex2D(samplerTex, coords * 2).r; - float map2 = map * map * map; - float bright = min((color.r + color.g + color.b) * 2.5, 0.005); +{ + float2 originalCoords = coords; + + float2 pixel = coords * uImageSize1 * 2.0; + coords = mul(float4(pixel, 0.0, 1.0), transform).xy / (uImageSize1 * 2.0); + + float2 pixCoord = coords - coords % (1.0 / uImageSize1) + float2(1.0 / uImageSize1); + + float4 mapSample = tex2D(samplerTex, coords * 2.0); + float swirl = sin((mapSample.g + uTime * 0.3) * 6.28); + + float4 light = tex2D(lightTex, coords * 2.0); + + float2 underCoord = coords * 2.0 + (swirl) * 0.005 * tex2D(uImage0, coords).a; + float2 pixUnderCoord = underCoord - underCoord % (2.0 / uImageSize1); + + float4 distortLight = tex2D(lightTex, pixUnderCoord); + float shapeMask = tex2D(uImage0, coords).a; + + float lum = ((light.r + light.g + light.b) / 3.0); + + float caustics = tex2D(samplerTex, pixUnderCoord).r; + caustics = max(0.0, caustics - 0.1); + float speculars = tex2D(uImage0, pixCoord).g * 0.4 * (caustics + pow(caustics, 3.0) * 1.2 * lum); + speculars += tex2D(uImage0, coords).r * (0.5 + light * 0.5); + + float bright = pow(speculars, 6.0) * 200.0 * pow(lum, 2.0); + float4 color = distortLight * (pow(speculars, 2.0) * 3.0 + bright); + color.a = shapeMask; + + float2 originalUnderCoord = originalCoords * 2.0 + (swirl) * 0.005 * tex2D(uImage0, coords).a; + float4 underColor = tex2D(gameTex, originalUnderCoord); + underColor += shapeMask * distortLight * distortLight * (1.0 - abs(swirl)); - return float4(color.xyz * map * 3.0, color.a * map); + return underColor + color; } technique Technique1 { pass Pass1 { - PixelShader = compile ps_2_0 PixelShaderFunction(); + PixelShader = compile ps_3_0 PixelShaderFunction(); } } \ No newline at end of file diff --git a/Helpers/DustHelper.cs b/Helpers/DustHelper.cs index 7f9d1419f..d4b7e204d 100644 --- a/Helpers/DustHelper.cs +++ b/Helpers/DustHelper.cs @@ -44,8 +44,7 @@ public static void SpawnImagePattern(Vector2 position, int dustType, float size, var d = Dust.NewDustPerfect(position, dustType, new Vector2((float)dustX, (float)dustY).RotatedBy(rotation), Alpha, (Color)color, dustSize); - if (d != null) - d.noGravity = noGravity; + d?.noGravity = noGravity; } } } @@ -92,8 +91,7 @@ public static void SpawnStillImagePattern(Vector2 position, int dustType, float var d = Dust.NewDustPerfect(position + new Vector2(dustX, dustY), dustType, Vector2.UnitX.RotatedByRandom(6.28f) * randomVel, Alpha, (Color)color, dustSize); - if (d != null) - d.noGravity = noGravity; + d?.noGravity = noGravity; } } } diff --git a/StarlightRiver.csproj b/StarlightRiver.csproj index 462b61e36..31120a097 100644 --- a/StarlightRiver.csproj +++ b/StarlightRiver.csproj @@ -4,7 +4,7 @@ StarlightRiver net8.0 - latest + preview true AnyCPU;x64;x86 @@ -28,7 +28,6 @@ -