Fusable Particle System
Also start of Gruesome Eminence
This commit is contained in:
1 parent
91be4f0a32
commit
e33ae06ef6
15 files changed
+430
-6
No files matched your search
+20
-2
@@ -62,6 +62,7 @@ using Terraria.ID;
|
||||
using Terraria.ModLoader;
|
||||
using Terraria.ModLoader.Config;
|
||||
using Terraria.UI;
|
||||
using CalamityMod.Particles;
|
||||
|
||||
namespace CalamityMod
|
||||
{
|
||||
@@ -274,6 +275,8 @@ namespace CalamityMod
|
||||
SkyManager.Instance["CalamityMod:StormWeaverFlash"] = new StormWeaverFlashSky();
|
||||
|
||||
CalamityShaders.LoadShaders();
|
||||
BaseFusableParticleSet.LoadParticleRenderTargets();
|
||||
Main.OnPreDraw += _ => BaseFusableParticleSet.PrepareFusableParticleTargets();
|
||||
|
||||
RipperUI.Load();
|
||||
AstralArcanumUI.Load(this);
|
||||
@@ -350,6 +353,8 @@ namespace CalamityMod
|
||||
|
||||
TileFraming.Unload();
|
||||
|
||||
Main.OnPreDraw -= _ => BaseFusableParticleSet.PrepareFusableParticleTargets();
|
||||
|
||||
RipperUI.Unload();
|
||||
AstralArcanumUI.Unload();
|
||||
|
||||
@@ -399,8 +404,21 @@ namespace CalamityMod
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Vanilla Enemy DR
|
||||
private void SetupVanillaDR()
|
||||
#region MidUpdateProjectileItem
|
||||
public override void MidUpdateProjectileItem()
|
||||
{
|
||||
// Update all fusable particles.
|
||||
// This are really only visual and as such don't really need any complex netcode.
|
||||
foreach (BaseFusableParticleSet.FusableParticleRenderCollection particleSet in BaseFusableParticleSet.ParticleSets)
|
||||
{
|
||||
foreach (BaseFusableParticleSet.FusableParticle particle in particleSet.ParticleSet.Particles)
|
||||
particleSet.ParticleSet.UpdateBehavior(particle);
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Vanilla Enemy DR
|
||||
private void SetupVanillaDR()
|
||||
{
|
||||
DRValues = new SortedDictionary<int, float> {
|
||||
{ NPCID.AngryBonesBig, 0.2f },
|
||||
|
||||
@@ -22,10 +22,14 @@ namespace CalamityMod.Effects
|
||||
public static Effect ImpFlameTrailShader;
|
||||
public static Effect SCalShieldShader;
|
||||
|
||||
public static Effect BaseFusableParticleBGShader;
|
||||
public static Effect BaseFusableParticleEdgeShader;
|
||||
|
||||
public static void LoadShaders()
|
||||
{
|
||||
if (Main.dedServ)
|
||||
return;
|
||||
|
||||
AstralFogShader = CalamityMod.Instance.GetEffect("Effects/CustomShader");
|
||||
LightShader = CalamityMod.Instance.GetEffect("Effects/LightBurstShader");
|
||||
TentacleShader = CalamityMod.Instance.GetEffect("Effects/TentacleShader");
|
||||
@@ -40,6 +44,9 @@ namespace CalamityMod.Effects
|
||||
ImpFlameTrailShader = CalamityMod.Instance.GetEffect("Effects/ImpFlameTrail");
|
||||
SCalShieldShader = CalamityMod.Instance.GetEffect("Effects/SupremeShieldShader");
|
||||
|
||||
BaseFusableParticleBGShader = CalamityMod.Instance.GetEffect("Effects/ParticleFusion/BaseFusableParticleBGShader");
|
||||
BaseFusableParticleEdgeShader = CalamityMod.Instance.GetEffect("Effects/ParticleFusion/BaseFusableParticleEdgeShader");
|
||||
|
||||
Filters.Scene["CalamityMod:Astral"] = new Filter(new AstralScreenShaderData(new Ref<Effect>(AstralFogShader), "AstralPass").UseColor(0.18f, 0.08f, 0.24f), EffectPriority.VeryHigh);
|
||||
|
||||
Filters.Scene["CalamityMod:LightBurst"] = new Filter(new ScreenShaderData(new Ref<Effect>(LightShader), "BurstPass"), EffectPriority.VeryHigh);
|
||||
@@ -56,6 +63,9 @@ namespace CalamityMod.Effects
|
||||
GameShaders.Misc["CalamityMod:PrismaticStreak"] = new MiscShaderData(new Ref<Effect>(PrismCrystalShader), "TrailPass");
|
||||
GameShaders.Misc["CalamityMod:ImpFlameTrail"] = new MiscShaderData(new Ref<Effect>(ImpFlameTrailShader), "TrailPass");
|
||||
GameShaders.Misc["CalamityMod:SupremeShield"] = new MiscShaderData(new Ref<Effect>(SCalShieldShader), "ShieldPass");
|
||||
|
||||
GameShaders.Misc["CalamityMod:BaseFusableParticleBG"] = new MiscShaderData(new Ref<Effect>(BaseFusableParticleBGShader), "ParticlePass");
|
||||
GameShaders.Misc["CalamityMod:BaseFusableParticleEdge"] = new MiscShaderData(new Ref<Effect>(BaseFusableParticleEdgeShader), "ParticlePass");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
sampler uImage0 : register(s0);
|
||||
sampler uImage1 : register(s1);
|
||||
float3 uColor;
|
||||
float3 uSecondaryColor;
|
||||
float uOpacity;
|
||||
float uSaturation;
|
||||
float uRotation;
|
||||
float uTime;
|
||||
float4 uSourceRect;
|
||||
float2 uWorldPosition;
|
||||
float uDirection;
|
||||
float3 uLightSource;
|
||||
float2 uImageSize0;
|
||||
float2 uImageSize1;
|
||||
|
||||
static float xAdditiveMax = 0.035;
|
||||
float4 PixelShaderFunction(float4 sampleColor : TEXCOORD, float2 coords : TEXCOORD0) : COLOR0
|
||||
{
|
||||
float4 color = tex2D(uImage0, coords);
|
||||
float sineTime = sin(uTime); // Saved so that I don't have the compute this multiple times. Shaders have a limited number of mathematical instructions you can use - 64.
|
||||
float frameY = (coords.y * uImageSize0.y - uSourceRect.y) / uSourceRect.w; // Gets a 0-1 representation of the y position on a given frame, with 0 being the top, and 1 being the bottom.
|
||||
|
||||
float2 modifiedCoords = coords;
|
||||
modifiedCoords.x += cos(uTime + frameY) * 0.5 + 0.5; // Cause the effect to sway around a bit with time.
|
||||
|
||||
float4 noiseColor = tex2D(uImage1, frac(modifiedCoords));
|
||||
|
||||
float xMultiplier = cos(coords.x * 2.3 + uTime * 1.15) + 0.5;
|
||||
float yMultiplier = (sin(frameY * 2 + uTime * 1.4) + 1) * 0.5;
|
||||
|
||||
color.rgb *= lerp(uColor, uSecondaryColor, saturate(xMultiplier * yMultiplier * 1.6));
|
||||
if (noiseColor.r > 0.55 + sineTime * 0.025)
|
||||
{
|
||||
color.rgb *= 1.6; // Sometimes give light "patches" depending on the swaying noise image.
|
||||
}
|
||||
color.rgb *= 1.6 + (sineTime * 0.5 + 1.5) * ((frameY + coords.x) - 1) * 2; // Brighten the shader over time.
|
||||
return color;
|
||||
}
|
||||
technique Technique1
|
||||
{
|
||||
pass ParticlePass
|
||||
{
|
||||
PixelShader = compile ps_2_0 PixelShaderFunction();
|
||||
}
|
||||
}
|
||||
Binary file not shown.
@@ -0,0 +1,48 @@
|
||||
sampler uImage0 : register(s0);
|
||||
sampler uImage1 : register(s1);
|
||||
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 edgeBorderSize;
|
||||
float2 screenArea;
|
||||
float2 renderTargetArea;
|
||||
float3 borderColor;
|
||||
|
||||
float4 PixelShaderFunction(float4 sampleColor : TEXCOORD, float2 coords : TEXCOORD0) : COLOR0
|
||||
{
|
||||
float4 color = tex2D(uImage0, coords);
|
||||
float4 backgroundColor = tex2D(uImage1, frac(coords * 35 + uWorldPosition));
|
||||
float positionNoiseInterpolant = sin(2.71828182846 * uWorldPosition.x / 25) + sin(1.57079632679 * uWorldPosition.x / 25);
|
||||
positionNoiseInterpolant = positionNoiseInterpolant * 0.5 + 0.5;
|
||||
float edgeBorderSizeAdjusted = edgeBorderSize * lerp(0.64, 1.27, positionNoiseInterpolant);
|
||||
|
||||
// Equivalent to edgeBorderSize pixels in both the X and Y direction.
|
||||
float2 edgeOffset = float2(edgeBorderSizeAdjusted, edgeBorderSizeAdjusted) / renderTargetArea;
|
||||
|
||||
// Check if the cardinal directions are not intersecting with any other parts of the render target.
|
||||
// If one of them isn't, that means that a border should be rendered.
|
||||
float4 aboveColor = tex2D(uImage0, coords + float2(0, edgeOffset.y));
|
||||
float4 belowColor = tex2D(uImage0, coords - float2(0, edgeOffset.y));
|
||||
float4 leftColor = tex2D(uImage0, coords + float2(edgeOffset.x, 0));
|
||||
float4 rightColor = tex2D(uImage0, coords - float2(edgeOffset.x, 0));
|
||||
if (aboveColor.r < 0.5 || belowColor.r < 0.5 || leftColor.r < 0.5 || rightColor.r < 0.5)
|
||||
return color;
|
||||
|
||||
return backgroundColor;
|
||||
}
|
||||
technique Technique1
|
||||
{
|
||||
pass ParticlePass
|
||||
{
|
||||
PixelShader = compile ps_2_0 PixelShaderFunction();
|
||||
}
|
||||
}
|
||||
Binary file not shown.
Binary file not shown.
|
After Width: | Height: | Size: 30 KiB |
+20
-4
@@ -2,6 +2,7 @@ using CalamityMod.Buffs.DamageOverTime;
|
||||
using CalamityMod.CalPlayer;
|
||||
using CalamityMod.Events;
|
||||
using CalamityMod.NPCs;
|
||||
using CalamityMod.Particles;
|
||||
using CalamityMod.Projectiles;
|
||||
using CalamityMod.Tiles.DraedonStructures;
|
||||
using CalamityMod.World;
|
||||
@@ -124,6 +125,7 @@ namespace CalamityMod.ILEditing
|
||||
IL.Terraria.Player.QuickMana += ApplyManaBurnIfNeeded;
|
||||
IL.Terraria.Player.ItemCheck += ApplyManaBurnIfNeeded;
|
||||
IL.Terraria.Player.AddBuff += AllowBuffTimeStackingForManaBurn;
|
||||
IL.Terraria.Main.DoDraw += DrawFusableParticles;
|
||||
|
||||
// Damage and health balance
|
||||
IL.Terraria.Main.DamageVar += AdjustDamageVariance;
|
||||
@@ -153,10 +155,10 @@ namespace CalamityMod.ILEditing
|
||||
IL.Terraria.NPC.NPCLoot += FixSplittingWormBannerDrops;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Unloads all IL Editing changes in the mod.
|
||||
/// </summary>
|
||||
internal static void Unload()
|
||||
/// <summary>
|
||||
/// Unloads all IL Editing changes in the mod.
|
||||
/// </summary>
|
||||
internal static void Unload()
|
||||
{
|
||||
VanillaSpawnTownNPCs = null;
|
||||
labDoorOpen = labDoorClosed = aLabDoorOpen = aLabDoorClosed = -1;
|
||||
@@ -176,6 +178,7 @@ namespace CalamityMod.ILEditing
|
||||
IL.Terraria.Player.QuickMana -= ApplyManaBurnIfNeeded;
|
||||
IL.Terraria.Player.ItemCheck -= ApplyManaBurnIfNeeded;
|
||||
IL.Terraria.Player.AddBuff -= AllowBuffTimeStackingForManaBurn;
|
||||
IL.Terraria.Main.DoDraw -= DrawFusableParticles;
|
||||
|
||||
// Damage and health balance
|
||||
IL.Terraria.Main.DamageVar -= AdjustDamageVariance;
|
||||
@@ -559,6 +562,19 @@ namespace CalamityMod.ILEditing
|
||||
Main.spriteBatch.Draw(crosshairTexture, baseDrawPosition, null, cursorColor, 0f, crosshairTexture.Size() * 0.5f, Main.cursorScale, SpriteEffects.None, 0f);
|
||||
}
|
||||
#endregion
|
||||
|
||||
private static void DrawFusableParticles(ILContext il)
|
||||
{
|
||||
ILCursor cursor = new ILCursor(il);
|
||||
if (!cursor.TryGotoNext(c => c.MatchCallOrCallvirt<Main>("SortDrawCacheWorms")))
|
||||
{
|
||||
LogFailure("Fusable Particle Rendering", "Could not locate the reference method to attach to.");
|
||||
return;
|
||||
}
|
||||
|
||||
cursor.EmitDelegate<Action>(() => BaseFusableParticleSet.RenderAllFusableParticles());
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Damage and health balance
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
using CalamityMod.Projectiles.Magic;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using Terraria;
|
||||
using Terraria.ModLoader;
|
||||
using Terraria.ID;
|
||||
|
||||
namespace CalamityMod.Items.Weapons.Magic
|
||||
{
|
||||
public class GruesomeEminence : ModItem
|
||||
{
|
||||
public override void SetStaticDefaults()
|
||||
{
|
||||
DisplayName.SetDefault("Gruesome Eminence");
|
||||
Tooltip.SetDefault("Summons spirits near the cursor\n" +
|
||||
"At first, the spirits will fly wildly. This can hurt enemies and players\n" +
|
||||
"However, over time they will begin to accumulate to create a single, controllable monstrosity");
|
||||
}
|
||||
|
||||
public override void SetDefaults()
|
||||
{
|
||||
item.damage = 666;
|
||||
item.magic = true;
|
||||
item.noUseGraphic = true;
|
||||
item.channel = true;
|
||||
item.mana = 8;
|
||||
item.width = 32;
|
||||
item.height = 36;
|
||||
item.useTime = 27;
|
||||
item.useAnimation = 27;
|
||||
item.useStyle = ItemUseStyleID.HoldingOut;
|
||||
item.noMelee = true;
|
||||
item.knockBack = 5f;
|
||||
item.shootSpeed = 9f;
|
||||
item.shoot = ModContent.ProjectileType<GruesomeEminenceHoldout>();
|
||||
|
||||
item.value = CalamityGlobalItem.Rarity15BuyPrice;
|
||||
item.Calamity().customRarity = CalamityRarity.Violet;
|
||||
}
|
||||
|
||||
// This weapon uses a holdout projectile.
|
||||
public override bool CanUseItem(Player player) => player.ownedProjectileCounts[item.shoot] <= 0;
|
||||
|
||||
public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack)
|
||||
{
|
||||
Projectile.NewProjectile(position.X, position.Y, speedX, speedY, item.shoot, damage, knockBack, player.whoAmI);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 780 B |
@@ -0,0 +1,139 @@
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Terraria;
|
||||
using Terraria.ID;
|
||||
using Terraria.ModLoader;
|
||||
|
||||
namespace CalamityMod.Particles
|
||||
{
|
||||
public abstract class BaseFusableParticleSet
|
||||
{
|
||||
public class FusableParticleRenderCollection
|
||||
{
|
||||
public BaseFusableParticleSet ParticleSet;
|
||||
public RenderTarget2D RenderTarget;
|
||||
public FusableParticleRenderCollection(BaseFusableParticleSet set, RenderTarget2D renderTarget)
|
||||
{
|
||||
ParticleSet = set;
|
||||
RenderTarget = renderTarget;
|
||||
}
|
||||
}
|
||||
|
||||
public class FusableParticle
|
||||
{
|
||||
public Vector2 Center;
|
||||
public float Size;
|
||||
public Vector2 TopLeft => Center + new Vector2(-1f, -1f) * Size * 0.5f;
|
||||
public Vector2 TopRight => Center + new Vector2(1f, -1f) * Size * 0.5f;
|
||||
public Vector2 BottomLeft => Center + new Vector2(-1f, 1f) * Size * 0.5f;
|
||||
public Vector2 BottomRight => Center + new Vector2(1f, 1f) * Size * 0.5f;
|
||||
|
||||
public FusableParticle(Vector2 center, float size)
|
||||
{
|
||||
Center = center;
|
||||
Size = size;
|
||||
}
|
||||
}
|
||||
|
||||
internal static readonly List<FusableParticleRenderCollection> ParticleSets = new List<FusableParticleRenderCollection>();
|
||||
|
||||
public FusableParticleRenderCollection RenderCollection => GetParticleSetByType(GetType());
|
||||
|
||||
public List<FusableParticle> Particles = new List<FusableParticle>();
|
||||
|
||||
public RenderTarget2D GetRenderTarget => RenderCollection.RenderTarget;
|
||||
|
||||
public abstract Effect BackgroundShader { get; }
|
||||
public abstract Effect EdgeShader { get; }
|
||||
public abstract FusableParticle SpawnParticle(Vector2 center);
|
||||
public abstract void UpdateBehavior(FusableParticle particle);
|
||||
public abstract void DrawParticles();
|
||||
|
||||
internal static void LoadParticleRenderTargets()
|
||||
{
|
||||
// Look through every type in the mod, and check if it's derived from BaseFusableParticleSet.
|
||||
// If it is, create a default instance of said particle, save it, and create a RenderTarget2D for it to use.
|
||||
foreach (Type type in typeof(CalamityMod).Assembly.GetTypes())
|
||||
{
|
||||
// Don't load abstract classes; they cannot have instances.
|
||||
if (type.IsAbstract)
|
||||
continue;
|
||||
|
||||
if (type.IsSubclassOf(typeof(BaseFusableParticleSet)))
|
||||
{
|
||||
BaseFusableParticleSet instance = Activator.CreateInstance(type) as BaseFusableParticleSet;
|
||||
RenderTarget2D renderTarget = null;
|
||||
if (Main.netMode != NetmodeID.Server)
|
||||
{
|
||||
renderTarget = new RenderTarget2D(Main.instance.GraphicsDevice, Main.screenWidth, Main.screenHeight, false, default, default, 0, RenderTargetUsage.PreserveContents);
|
||||
}
|
||||
|
||||
FusableParticleRenderCollection particleRenderCollection = new FusableParticleRenderCollection(instance, renderTarget);
|
||||
ParticleSets.Add(particleRenderCollection);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
internal virtual void DrawSet()
|
||||
{
|
||||
// Don't bother doing anything if this method is called serverside.
|
||||
if (Main.netMode == NetmodeID.Server)
|
||||
return;
|
||||
|
||||
// Go to the specialized render target for this particle set and clear the entire thing to use a base of transparent pixels.
|
||||
Main.instance.GraphicsDevice.SetRenderTarget(GetRenderTarget);
|
||||
Main.instance.GraphicsDevice.Clear(Color.Transparent);
|
||||
|
||||
// Draw the particles.
|
||||
Main.spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.Additive, Main.DefaultSamplerState, DepthStencilState.None, Main.instance.Rasterizer, null, Main.GameViewMatrix.ZoomMatrix);
|
||||
DrawParticles();
|
||||
Main.spriteBatch.End();
|
||||
|
||||
// Return to using the previous render targets after done drawing everything to this target.
|
||||
Main.instance.GraphicsDevice.SetRenderTarget(null);
|
||||
}
|
||||
|
||||
internal static void PrepareFusableParticleTargets()
|
||||
{
|
||||
// Don't attempt to draw anything serverside.
|
||||
if (Main.netMode == NetmodeID.Server)
|
||||
return;
|
||||
|
||||
// Draw all fusable particles.
|
||||
foreach (FusableParticleRenderCollection particleSet in ParticleSets)
|
||||
particleSet.ParticleSet.DrawSet();
|
||||
}
|
||||
|
||||
internal static void RenderAllFusableParticles()
|
||||
{
|
||||
foreach (FusableParticleRenderCollection particleRenderSet in ParticleSets)
|
||||
{
|
||||
Main.spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, Main.DefaultSamplerState, DepthStencilState.None, Main.instance.Rasterizer, null, Main.GameViewMatrix.ZoomMatrix);
|
||||
|
||||
BaseFusableParticleSet particleSet = particleRenderSet.ParticleSet;
|
||||
|
||||
// Draw the current target with the specified shader.
|
||||
particleSet.EdgeShader.Parameters["edgeBorderSize"].SetValue(2f);
|
||||
particleSet.EdgeShader.Parameters["screenArea"].SetValue(new Vector2(Main.screenWidth, Main.screenHeight));
|
||||
particleSet.EdgeShader.Parameters["renderTargetArea"].SetValue(new Vector2(particleSet.GetRenderTarget.Width, particleSet.GetRenderTarget.Height));
|
||||
particleSet.EdgeShader.Parameters["borderColor"].SetValue(Color.Transparent.ToVector3());
|
||||
|
||||
Texture2D backgroundTexture = ModContent.GetTexture("CalamityMod/ExtraTextures/EternityStreak");
|
||||
Main.graphics.GraphicsDevice.Textures[1] = backgroundTexture;
|
||||
particleSet.EdgeShader.Parameters["uImageSize1"].SetValue(backgroundTexture.Size());
|
||||
particleSet.EdgeShader.CurrentTechnique.Passes[0].Apply();
|
||||
Main.spriteBatch.Draw(particleSet.GetRenderTarget, Vector2.Zero, Color.White);
|
||||
|
||||
Main.spriteBatch.End();
|
||||
}
|
||||
}
|
||||
|
||||
public static FusableParticleRenderCollection GetParticleSetByType(Type type)
|
||||
{
|
||||
return ParticleSets.First(s => s.ParticleSet.GetType() == type);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
using CalamityMod.Effects;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using System.Linq;
|
||||
using Terraria;
|
||||
using Terraria.ModLoader;
|
||||
|
||||
namespace CalamityMod.Particles
|
||||
{
|
||||
public class GhostlyFusableParticleSet : BaseFusableParticleSet
|
||||
{
|
||||
public static GhostlyFusableParticleSet Instance => GetParticleSetByType(typeof(GhostlyFusableParticleSet)).ParticleSet as GhostlyFusableParticleSet;
|
||||
public override Effect BackgroundShader { get; }
|
||||
public override Effect EdgeShader => CalamityShaders.BaseFusableParticleEdgeShader;
|
||||
public override FusableParticle SpawnParticle(Vector2 center)
|
||||
{
|
||||
Particles.Add(new FusableParticle(center, Main.rand.NextFloat(64f, 85f)));
|
||||
return Particles.Last();
|
||||
}
|
||||
|
||||
public override void UpdateBehavior(FusableParticle particle)
|
||||
{
|
||||
particle.Size = MathHelper.Clamp(particle.Size - 0.7f, 0f, 100f);
|
||||
}
|
||||
|
||||
public override void DrawParticles()
|
||||
{
|
||||
// Clear away any particles that shouldn't exist anymore.
|
||||
Particles.RemoveAll(p => p.Size <= 1f);
|
||||
|
||||
foreach (FusableParticle particle in Particles)
|
||||
{
|
||||
Texture2D fusableParticleBase = ModContent.GetTexture("CalamityMod/ExtraTextures/FusableParticleBase");
|
||||
Vector2 drawPosition = particle.Center - Main.screenPosition;
|
||||
Vector2 origin = fusableParticleBase.Size() * 0.5f;
|
||||
Vector2 scale = Vector2.One * particle.Size / fusableParticleBase.Size();
|
||||
Main.spriteBatch.Draw(fusableParticleBase, drawPosition, null, Color.White, 0f, origin, scale, SpriteEffects.None, 0f);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
using CalamityMod.Particles;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using System;
|
||||
using Terraria;
|
||||
using Terraria.ID;
|
||||
using Terraria.ModLoader;
|
||||
|
||||
namespace CalamityMod.Projectiles.Magic
|
||||
{
|
||||
public class GruesomeEminenceHoldout : ModProjectile
|
||||
{
|
||||
public Player Owner => Main.player[projectile.owner];
|
||||
public override void SetStaticDefaults()
|
||||
{
|
||||
DisplayName.SetDefault("Gruesome Eminence");
|
||||
Main.projFrames[projectile.type] = 4;
|
||||
}
|
||||
|
||||
public override void SetDefaults()
|
||||
{
|
||||
projectile.width = 26;
|
||||
projectile.height = 32;
|
||||
projectile.friendly = true;
|
||||
projectile.penetrate = -1;
|
||||
projectile.tileCollide = false;
|
||||
projectile.magic = true;
|
||||
projectile.ignoreWater = true;
|
||||
}
|
||||
|
||||
public override void AI()
|
||||
{
|
||||
Lighting.AddLight(projectile.Center, 0.65f, 0f, 0.1f);
|
||||
|
||||
StickToOwner();
|
||||
GhostlyFusableParticleSet.Instance.SpawnParticle(Main.MouseWorld + Main.rand.NextVector2Circular(6f, 6f));
|
||||
|
||||
if (!Owner.channel)
|
||||
projectile.Kill();
|
||||
}
|
||||
|
||||
public void StickToOwner()
|
||||
{
|
||||
projectile.position = Owner.RotatedRelativePoint(Owner.MountedCenter, true) - projectile.Size / 2f;
|
||||
projectile.rotation = 0f;
|
||||
projectile.spriteDirection = projectile.direction;
|
||||
projectile.timeLeft = 2;
|
||||
Owner.ChangeDir(projectile.direction);
|
||||
Owner.heldProj = projectile.whoAmI;
|
||||
Owner.itemTime = 2;
|
||||
Owner.itemAnimation = 2;
|
||||
Owner.itemRotation = 0f;
|
||||
}
|
||||
}
|
||||
}
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 317 B |
@@ -1,4 +1,5 @@
|
||||
using CalamityMod.Items.Accessories;
|
||||
using CalamityMod.Items.Weapons.Magic;
|
||||
using CalamityMod.Items.Weapons.Summon;
|
||||
using CalamityMod.NPCs.Other;
|
||||
using CalamityMod.Projectiles.Melee;
|
||||
@@ -307,6 +308,7 @@ namespace CalamityMod.UI.CalamitasEnchants
|
||||
{
|
||||
[ModContent.ItemType<TheCommunity>()] = ModContent.ItemType<ShatteredCommunity>(),
|
||||
[ModContent.ItemType<BlightedEyeStaff>()] = ModContent.ItemType<ExhumedVigilance>(),
|
||||
[ModContent.ItemType<GhastlyVisage>()] = ModContent.ItemType<GruesomeEminence>(),
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user