Start of Exoblade rework (Hi Iban!)

This commit is contained in:
Dominic committed 2022-07-11 23:26:36 -05:00
1 parent 3eacd380dd
commit a2e660a0b6
7 files changed
+423 -173

No files matched your search

+4 -1
View File
@@ -1,4 +1,4 @@
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework;
using System.Collections.Generic;
namespace CalamityMod.DataStructures
@@ -34,6 +34,9 @@ namespace CalamityMod.DataStructures
points = nextPoints;
}
if (points.Length <= 1)
return Vector2.Zero;
return Vector2.Lerp(points[0], points[1], T);
}
}
+3
View File
@@ -36,6 +36,7 @@ namespace CalamityMod.Effects
public static Effect LocalLinearTransformationShader;
public static Effect BasicPrimitiveShader;
public static Effect ArtemisLaserShader;
public static Effect ExobladeSlashShader;
public static Effect BaseFusableParticleEdgeShader;
public static Effect AdditiveFusableParticleEdgeShader;
@@ -75,6 +76,7 @@ namespace CalamityMod.Effects
LocalLinearTransformationShader = CalamityMod.Instance.Assets.Request<Effect>("Effects/LocalLinearTransformationShader", AssetRequestMode.ImmediateLoad).Value;
BasicPrimitiveShader = CalamityMod.Instance.Assets.Request<Effect>("Effects/BasicPrimitiveShader", AssetRequestMode.ImmediateLoad).Value;
ArtemisLaserShader = CalamityMod.Instance.Assets.Request<Effect>("Effects/ArtemisLaserShader", AssetRequestMode.ImmediateLoad).Value;
ExobladeSlashShader = CalamityMod.Instance.Assets.Request<Effect>("Effects/ExobladeSlashShader", AssetRequestMode.ImmediateLoad).Value;
BaseFusableParticleEdgeShader = CalamityMod.Instance.Assets.Request<Effect>("Effects/ParticleFusion/BaseFusableParticleEdgeShader", AssetRequestMode.ImmediateLoad).Value;
AdditiveFusableParticleEdgeShader = CalamityMod.Instance.Assets.Request<Effect>("Effects/ParticleFusion/AdditiveFusableParticleEdgeShader", AssetRequestMode.ImmediateLoad).Value;
@@ -111,6 +113,7 @@ namespace CalamityMod.Effects
GameShaders.Misc["CalamityMod:LinearTransformation"] = new MiscShaderData(new Ref<Effect>(LocalLinearTransformationShader), "TransformationPass");
GameShaders.Misc["CalamityMod:PrimitiveDrawer"] = new MiscShaderData(new Ref<Effect>(BasicPrimitiveShader), "TrailPass");
GameShaders.Misc["CalamityMod:ArtemisLaser"] = new MiscShaderData(new Ref<Effect>(ArtemisLaserShader), "TrailPass");
GameShaders.Misc["CalamityMod:ExobladeSlash"] = new MiscShaderData(new Ref<Effect>(ExobladeSlashShader), "TrailPass");
GameShaders.Misc["CalamityMod:BaseFusableParticleEdge"] = new MiscShaderData(new Ref<Effect>(BaseFusableParticleEdgeShader), "ParticlePass");
GameShaders.Misc["CalamityMod:AdditiveFusableParticleEdge"] = new MiscShaderData(new Ref<Effect>(AdditiveFusableParticleEdgeShader), "ParticlePass");
+94
View File
@@ -0,0 +1,94 @@
sampler uImage0 : register(s0);
sampler uImage1 : register(s1);
sampler uImage2 : register(s2);
float3 uColor;
float3 uSecondaryColor;
float3 fireColor;
float uOpacity;
float uSaturation;
float uRotation;
float uTime;
float4 uSourceRect;
float2 uWorldPosition;
float uDirection;
float3 uLightSource;
float2 uImageSize0;
float2 uImageSize1;
float2 uImageSize2;
matrix uWorldViewProjection;
float4 uShaderSpecificData;
bool flipped;
struct VertexShaderInput
{
float4 Position : POSITION0;
float4 Color : COLOR0;
float2 TextureCoordinates : TEXCOORD0;
};
struct VertexShaderOutput
{
float4 Position : SV_POSITION;
float4 Color : COLOR0;
float2 TextureCoordinates : TEXCOORD0;
};
VertexShaderOutput VertexShaderFunction(in VertexShaderInput input)
{
VertexShaderOutput output = (VertexShaderOutput)0;
float4 pos = mul(input.Position, uWorldViewProjection);
output.Position = pos;
output.Color = input.Color;
output.TextureCoordinates = input.TextureCoordinates;
return output;
}
float InverseLerp(float from, float to, float x)
{
return saturate((x - from) / (to - from));
}
float4 PixelShaderFunction(VertexShaderOutput input) : COLOR0
{
float4 color = input.Color;
float2 coords = input.TextureCoordinates;
float timeDirection = -1;
if (flipped)
{
timeDirection = 1;
coords.y = 1 - coords.y;
}
float2 noiseCoords = coords * float2(0.5, 3) - float2(uTime * timeDirection * 0.45, 0);
noiseCoords.x = sin(noiseCoords.x * 5.4) * 0.5 + 0.5;
float noise = tex2D(uImage1, noiseCoords).r;
float noise2 = pow(tex2D(uImage1, noiseCoords * 2.2).r, 1.6);
float noise3 = pow(tex2D(uImage1, noiseCoords * 1.1).r, 1.3);
float opacity = noise * pow(saturate((1 - coords.x) - noise * coords.x * 0.45), 0.8);
// Fade to the second primary color.
color = lerp(color, float4(uColor, 1), noise2);
// Create dark colors.
float darkColorWeight = saturate(coords.y * 1.8 + coords.x * 0.45 + noise * 0.1);
color = lerp(color, float4(uSecondaryColor, 1), darkColorWeight);
// Create a fire streak.
float fireColorWeight = InverseLerp(0.3, 0, coords.y) * pow(1 - coords.x, 2);
color = lerp(color, float4(fireColor, 1), fireColorWeight);
float4 noiseColor = color * opacity * (noise3 * 2.4 + 2.4);
noiseColor.a = lerp(noiseColor.a, 0, 1 - fireColorWeight);
return noiseColor;
}
technique Technique1
{
pass TrailPass
{
VertexShader = compile vs_2_0 VertexShaderFunction();
PixelShader = compile ps_2_0 PixelShaderFunction();
}
}
Binary file not shown.
+10 -81
View File
@@ -12,6 +12,8 @@ namespace CalamityMod.Items.Weapons.Melee
[LegacyName("DraedonsExoblade")]
public class Exoblade : ModItem
{
public bool RMBchannel = false;
public override void SetStaticDefaults()
{
DisplayName.SetDefault("Exoblade");
@@ -26,102 +28,29 @@ namespace CalamityMod.Items.Weapons.Melee
public override void SetDefaults()
{
Item.width = 80;
Item.height = 114;
Item.damage = 900;
Item.useAnimation = 14;
Item.useStyle = ItemUseStyleID.Swing;
Item.useTime = 14;
Item.useTime = 35;
Item.useAnimation = 35;
Item.useTurn = true;
Item.DamageType = DamageClass.Melee;
Item.knockBack = 9f;
Item.UseSound = SoundID.Item1;
Item.autoReuse = true;
Item.height = 114;
Item.noUseGraphic = true;
Item.channel = true;
Item.value = CalamityGlobalItem.Rarity15BuyPrice;
Item.rare = ItemRarityID.Red;
Item.shoot = ModContent.ProjectileType<Exobeam>();
Item.shootSpeed = 19f;
Item.Calamity().customRarity = CalamityRarity.Violet;
}
public override void MeleeEffects(Player player, Rectangle hitbox)
{
if (Main.rand.NextBool(4))
Dust.NewDust(new Vector2(hitbox.X, hitbox.Y), hitbox.Width, hitbox.Height, 107, 0f, 0f, 100, new Color(0, 255, 255));
}
public override bool AltFunctionUse(Player player) => true;
public override void OnHitNPC(Player player, NPC target, int damage, float knockback, bool crit)
{
var source = player.GetSource_ItemUse(Item);
if (crit)
damage /= 2;
public override bool? CanHitNPC(Player player, NPC target) => false;
if (target.life <= (target.lifeMax * 0.05f))
Projectile.NewProjectile(source, target.Center, Vector2.Zero, ModContent.ProjectileType<Exoboom>(), damage, knockback, Main.myPlayer);
target.ExoDebuffs();
SoundEngine.PlaySound(SoundID.Item88, player.Center);
float xPos = player.position.X + 800 * Main.rand.NextBool(2).ToDirectionInt();
float yPos = player.position.Y + Main.rand.Next(-800, 801);
Vector2 startPos = new Vector2(xPos, yPos);
Vector2 velocity = target.position - startPos;
float dir = 10 / startPos.X;
velocity.X *= dir * 150;
velocity.Y *= dir * 150;
velocity.X = MathHelper.Clamp(velocity.X, -15f, 15f);
velocity.Y = MathHelper.Clamp(velocity.Y, -15f, 15f);
if (player.ownedProjectileCounts[ModContent.ProjectileType<Exocomet>()] < 8)
{
for (int comet = 0; comet < 2; comet++)
{
float ai1 = Main.rand.NextFloat() + 0.5f;
Projectile.NewProjectile(source, startPos, velocity, ModContent.ProjectileType<Exocomet>(), damage, knockback, player.whoAmI, 0f, ai1);
}
}
if (!target.canGhostHeal || player.moonLeech)
return;
int healAmount = Main.rand.Next(3) + 5;
player.statLife += healAmount;
player.HealEffect(healAmount);
}
public override void OnHitPvp(Player player, Player target, int damage, bool crit)
{
var source = player.GetSource_ItemUse(Item);
if (crit)
damage /= 2;
if (target.statLife <= (target.statLifeMax2 * 0.05f))
Projectile.NewProjectile(source, target.Center.X, target.Center.Y, 0f, 0f, ModContent.ProjectileType<Exoboom>(), damage, Item.knockBack, Main.myPlayer);
target.ExoDebuffs();
SoundEngine.PlaySound(SoundID.Item88, player.Center);
float xPos = player.position.X + 800 * Main.rand.NextBool(2).ToDirectionInt();
float yPos = player.position.Y + Main.rand.Next(-800, 801);
Vector2 startPos = new Vector2(xPos, yPos);
Vector2 velocity = target.position - startPos;
float dir = 10 / startPos.X;
velocity.X *= dir * 150;
velocity.Y *= dir * 150;
velocity.X = MathHelper.Clamp(velocity.X, -15f, 15f);
velocity.Y = MathHelper.Clamp(velocity.Y, -15f, 15f);
if (player.ownedProjectileCounts[ModContent.ProjectileType<Exocomet>()] < 8)
{
for (int comet = 0; comet < 2; comet++)
{
float ai1 = Main.rand.NextFloat() + 0.5f;
Projectile.NewProjectile(source, startPos, velocity, ModContent.ProjectileType<Exocomet>(), damage, Item.knockBack, player.whoAmI, 0f, ai1);
}
}
if (player.moonLeech)
return;
int healAmount = Main.rand.Next(3) + 5;
player.statLife += healAmount;
player.HealEffect(healAmount);
}
public override bool CanHitPvp(Player player, Player target) => false;
public override void AddRecipes()
{
+8 -91
View File
@@ -39,99 +39,16 @@ namespace CalamityMod.Projectiles.Melee
SoundEngine.PlaySound(SoundID.Item60, Projectile.position);
Projectile.localAI[1] += 1f;
}
counter++;
if (counter == 12)
// Aim very, very quickly at targets.
NPC potentialTarget = Projectile.Center.ClosestNPCAt(1600f, false);
if (potentialTarget != null)
{
counter = 0;
for (int l = 0; l < 12; l++)
{
Vector2 vector3 = Vector2.UnitX * (float)-(float)Projectile.width / 2f;
vector3 += -Vector2.UnitY.RotatedBy((double)((float)l * 3.14159274f / 6f), default) * new Vector2(8f, 16f);
vector3 = vector3.RotatedBy((double)(Projectile.rotation - 1.57079637f), default);
int num9 = Dust.NewDust(Projectile.Center, 0, 0, 107, 0f, 0f, 160, new Color(0, 255, 255), 1f);
Main.dust[num9].scale = 1.1f;
Main.dust[num9].noGravity = true;
Main.dust[num9].position = Projectile.Center + vector3;
Main.dust[num9].velocity = Projectile.velocity * 0.1f;
Main.dust[num9].velocity = Vector2.Normalize(Projectile.Center - Projectile.velocity * 3f - Main.dust[num9].position) * 1.25f;
}
Vector2 idealVelocity = Projectile.SafeDirectionTo(potentialTarget.Center) * (Projectile.velocity.Length() + 2f);
Projectile.velocity = Vector2.Lerp(Projectile.velocity, idealVelocity, 0.1f);
}
Projectile.alpha -= 40;
if (Projectile.alpha < 0)
{
Projectile.alpha = 0;
}
if (Projectile.ai[0] == 0f)
{
Projectile.localAI[0] += 1f;
if (Projectile.localAI[0] >= 90f)
{
Projectile.localAI[0] = 0f;
Projectile.ai[0] = 1f;
Projectile.netUpdate = true;
}
}
else if (Projectile.ai[0] == 1f)
{
Projectile.localAI[0] += 1f;
if (Projectile.localAI[0] >= 60f)
{
Projectile.localAI[0] = 0f;
Projectile.ai[0] = 2f;
Projectile.ai[1] = (float)Player.FindClosest(Projectile.position, Projectile.width, Projectile.height);
Projectile.netUpdate = true;
}
}
else if (Projectile.ai[0] == 2f)
{
Vector2 vector70 = Main.player[(int)Projectile.ai[1]].Center - Projectile.Center;
if (vector70.Length() < 30f)
{
Projectile.Kill();
return;
}
vector70.Normalize();
vector70 *= 14f;
vector70 = Vector2.Lerp(Projectile.velocity, vector70, 0.6f);
if (vector70.Y < 24f)
{
vector70.Y = 24f;
}
float num804 = 0.4f;
if (Projectile.velocity.X < vector70.X)
{
Projectile.velocity.X = Projectile.velocity.X + num804;
if (Projectile.velocity.X < 0f && vector70.X > 0f)
{
Projectile.velocity.X = Projectile.velocity.X + num804;
}
}
else if (Projectile.velocity.X > vector70.X)
{
Projectile.velocity.X = Projectile.velocity.X - num804;
if (Projectile.velocity.X > 0f && vector70.X < 0f)
{
Projectile.velocity.X = Projectile.velocity.X - num804;
}
}
if (Projectile.velocity.Y < vector70.Y)
{
Projectile.velocity.Y = Projectile.velocity.Y + num804;
if (Projectile.velocity.Y < 0f && vector70.Y > 0f)
{
Projectile.velocity.Y = Projectile.velocity.Y + num804;
}
}
else if (Projectile.velocity.Y > vector70.Y)
{
Projectile.velocity.Y = Projectile.velocity.Y - num804;
if (Projectile.velocity.Y > 0f && vector70.Y < 0f)
{
Projectile.velocity.Y = Projectile.velocity.Y - num804;
}
}
}
Projectile.rotation = (float)Math.Atan2((double)Projectile.velocity.Y, (double)Projectile.velocity.X) + 0.785f;
Projectile.rotation = Projectile.velocity.ToRotation() + MathHelper.PiOver4;
}
public override void OnHitNPC(NPC target, int damage, float knockback, bool crit)
+304
View File
@@ -0,0 +1,304 @@
using CalamityMod.Items.Weapons.Melee;
using CalamityMod.Projectiles.BaseProjectiles;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using System;
using System.IO;
using Terraria;
using Terraria.Graphics.Shaders;
using Terraria.ID;
using Terraria.ModLoader;
using Terraria.Audio;
using System.Collections.Generic;
using CalamityMod.DataStructures;
using System.Linq;
namespace CalamityMod.Projectiles.Melee
{
public class ExobladeProj : BaseIdleHoldoutProjectile
{
public enum SwingState
{
Default,
Swinging,
BonkDash
}
public int Direction = 1;
public PrimitiveTrail SlashDrawer = null;
public SwingState CurrentState;
public ref float ChargeTime => ref Projectile.ai[0];
public ref float GeneralTime => ref Projectile.ai[1];
public ref float VerticalStretchFactor => ref Projectile.localAI[0];
public ref float SwingDirection => ref Projectile.localAI[1];
public ref bool RMBChannel => ref (Owner.HeldItem.ModItem as Exoblade).RMBchannel;
public bool LMBUse => Owner.altFunctionUse != 2 && !RMBChannel && Owner.itemAnimation > 0 && Main.mouseLeft;
public const float StartingSwingRotation = -0.72f;
public const float EndingSwingRotation = StartingSwingRotation + MathHelper.TwoPi - 0.33f;
public override string Texture => "CalamityMod/Items/Weapons/Melee/Exoblade";
public override int AssociatedItemID => ModContent.ItemType<Exoblade>();
public override int IntendedProjectileType => ModContent.ProjectileType<ExobladeProj>();
public override void SetStaticDefaults()
{
DisplayName.SetDefault("Exoblade");
ProjectileID.Sets.TrailingMode[Projectile.type] = 2;
ProjectileID.Sets.TrailCacheLength[Projectile.type] = 120;
}
public override void SetDefaults()
{
Projectile.width = Projectile.height = 98;
Projectile.friendly = true;
Projectile.DamageType = DamageClass.Melee;
Projectile.tileCollide = false;
Projectile.penetrate = -1;
Projectile.timeLeft = 90000;
Projectile.usesLocalNPCImmunity = true;
Projectile.localNPCHitCooldown = 10;
Projectile.MaxUpdates = 3;
Projectile.noEnchantments = true;
}
public override void SendExtraAI(BinaryWriter writer)
{
writer.Write(Direction);
writer.Write((int)CurrentState);
}
public override void ReceiveExtraAI(BinaryReader reader)
{
Direction = reader.ReadInt32();
CurrentState = (SwingState)reader.ReadInt32();
}
public override void SafeAI()
{
// Handle right click behaviors.
if (Main.myPlayer == Projectile.owner)
Owner.Calamity().rightClickListener = true;
if (!Owner.Calamity().mouseRight)
RMBChannel = false;
else
RMBChannel = true;
// Initialize the animation max time if necessary.
if (Owner.itemAnimationMax == 0)
Owner.itemAnimationMax = (int)(Owner.ActiveItem().useAnimation * Owner.GetAttackSpeed<MeleeDamageClass>());
// Decide the current phase state of the blade.
DecideCurrentState();
Projectile.scale = 0f;
Projectile.Opacity = 0f;
switch (CurrentState)
{
case SwingState.Swinging:
DoBehavior_Swinging();
break;
default:
Direction = Owner.direction;
Projectile.oldRot = new float[Projectile.oldRot.Length];
break;
}
// Glue the sword to its owner.
Projectile.Center = Owner.RotatedRelativePoint(Owner.Center, true) - Projectile.velocity;
Owner.heldProj = Projectile.whoAmI;
// Decide the arm rotation for the owner.
float armRotation = Projectile.rotation + MathHelper.Pi;
if (Direction == -1)
armRotation += MathHelper.PiOver2;
if (CurrentState == SwingState.Default)
armRotation = 0f;
Owner.SetCompositeArmFront(Math.Abs(armRotation) > 0.01f, Player.CompositeArmStretchAmount.Full, Owner.compositeFrontArm.rotation.AngleLerp(armRotation, 0.2f));
GeneralTime++;
}
public void DoBehavior_Swinging()
{
// Decide the swing direction.
if (Owner.itemAnimation == Owner.itemAnimationMax)
{
if (SwingDirection == 0f)
SwingDirection = Main.rand.NextBool().ToDirectionInt();
SwingDirection *= -1f;
}
float exactSwingCompletion = 1f - Owner.itemAnimation / (float)Owner.itemAnimationMax;
float directionalSwingCompletion = exactSwingCompletion;
if (SwingDirection == -1f)
directionalSwingCompletion = 1f - directionalSwingCompletion;
directionalSwingCompletion = MathHelper.Clamp(directionalSwingCompletion, 0f, 1f);
// TODO -- Make this better.
// Hi Iban! Good luck :)
float swingCompletion;
if (directionalSwingCompletion < 0.3f)
swingCompletion = Utils.Remap(directionalSwingCompletion, 0f, 0.3f, 0.12f, 0f);
else if (directionalSwingCompletion < 0.54f)
swingCompletion = (float)Math.Pow(Utils.GetLerpValue(0.3f, 0.54f, directionalSwingCompletion, true), 0.75);
else
swingCompletion = 1f;
// Clear the rotation cache after enough time has passed.
if (directionalSwingCompletion >= 0.74f)
Projectile.oldRot = new float[Projectile.oldRot.Length];
// Decide the swing direction.
Projectile.rotation = MathHelper.Lerp(StartingSwingRotation, EndingSwingRotation, swingCompletion) * Direction - MathHelper.PiOver4;
VerticalStretchFactor = Utils.Remap(swingCompletion, 0f, 0.5f, 0f, 0.4f);
// Decide the scale of the sword.
Projectile.scale = 1f;
if (!LMBUse)
Projectile.scale = Utils.GetLerpValue(0f, 0.2f, exactSwingCompletion, true) * Utils.GetLerpValue(1f, 0.8f, exactSwingCompletion, true);
// Create a bunch of homing beams.
int beamShootRate = (Projectile.MaxUpdates * 3);
if (Main.myPlayer == Projectile.owner && Projectile.timeLeft % beamShootRate == 0 && directionalSwingCompletion < 0.33f)
{
int boltDamage = Projectile.damage / 2;
Vector2 boltVelocity = (Projectile.rotation + MathHelper.PiOver4).ToRotationVector2();
boltVelocity = Vector2.Lerp(boltVelocity, Projectile.SafeDirectionTo(Main.MouseWorld), 0.6f).SafeNormalize(Vector2.UnitY) * 9f;
Projectile.NewProjectile(Projectile.GetSource_FromAI(), Projectile.Center + boltVelocity * 5f, boltVelocity, ModContent.ProjectileType<Exobeam>(), boltDamage, Projectile.knockBack / 3f, Projectile.owner);
}
Projectile.Opacity = Projectile.scale;
}
public void DecideCurrentState()
{
// Reset the state of the weapon if the player stops using it. This cannot reset a dash.
if (Owner.itemAnimation <= 0 && CurrentState != SwingState.BonkDash)
{
Owner.itemAnimation = 0;
CurrentState = SwingState.Default;
}
// Switch to the swing state as necessary. This cannot happen while channeling or dashing.
if (CurrentState == 0f && !RMBChannel && Owner.itemAnimation > 0)
CurrentState = SwingState.Swinging;
// Switch to the dash charge state. This can only be done while in the default state.
if (CurrentState == 0f && Owner.itemAnimation > 0)
{
Owner.fallStart = (int)(Owner.position.Y / 16f);
if (CurrentState != SwingState.BonkDash)
{
SoundEngine.PlaySound(SoundID.DD2_BookStaffCast, Owner.Center);
CurrentState = SwingState.BonkDash;
Projectile.netUpdate = true;
}
}
}
public float SlashWidthFunction(float completionRatio) => Projectile.scale * 43.5f;
public Color SlashColorFunction(float completionRatio) => Color.Lime * Utils.GetLerpValue(1f, 0.6f, completionRatio, true) * Projectile.Opacity;
public IEnumerable<Vector2> GenerateSlashPoints()
{
List<Vector2> result = new();
for (int i = 0; i < Owner.itemAnimationMax; i++)
{
if (Projectile.oldRot[i] == 0f)
continue;
if (i >= 1 && Projectile.oldRot[i] == Projectile.oldRot[i - 1])
continue;
float oldRotation = Projectile.oldRot[i] - MathHelper.PiOver4 + (SwingDirection == -1 ? -0.18f : 0.04f);
if (Direction == -1)
oldRotation += MathHelper.PiOver2 - 0.2f;
result.Add(oldRotation.ToRotationVector2() * (SlashWidthFunction(0f) + 10f));
}
if (result.Count < 4 || result.First() == result.Last())
result.Clear();
return result;
}
public override bool PreDraw(ref Color lightColor)
{
if (Projectile.Opacity <= 0f)
return false;
// Initialize the trail drawer.
SlashDrawer ??= new(SlashWidthFunction, SlashColorFunction, null, GameShaders.Misc["CalamityMod:ExobladeSlash"]);
// Draw the zany slash effect.
Main.spriteBatch.EnterShaderRegion();
GameShaders.Misc["CalamityMod:ExobladeSlash"].SetShaderTexture(ModContent.Request<Texture2D>("CalamityMod/ExtraTextures/VoronoiShapes"));
GameShaders.Misc["CalamityMod:ExobladeSlash"].UseColor(new Color(105, 240, 220));
GameShaders.Misc["CalamityMod:ExobladeSlash"].UseSecondaryColor(new Color(57, 46, 115));
GameShaders.Misc["CalamityMod:ExobladeSlash"].Shader.Parameters["fireColor"].SetValue(new Color(242, 112, 72).ToVector3());
// What the heck? XOR? In MY exoblade code?????
GameShaders.Misc["CalamityMod:ExobladeSlash"].Shader.Parameters["flipped"].SetValue((SwingDirection == 1) ^ (Direction == -1));
GameShaders.Misc["CalamityMod:ExobladeSlash"].Apply();
if (CurrentState == SwingState.Swinging)
SlashDrawer.Draw(GenerateSlashPoints(), Projectile.Center - Main.screenPosition, 94);
Main.spriteBatch.EnterShaderRegion();
var texture = ModContent.Request<Texture2D>(Texture).Value;
CalamityUtils.CalculatePerspectiveMatricies(out Matrix viewMatrix, out Matrix projectionMatrix);
GameShaders.Misc["CalamityMod:LinearTransformation"].UseColor(Main.hslToRgb(0.95f, 0.85f, 0.5f));
GameShaders.Misc["CalamityMod:LinearTransformation"].UseOpacity(0f);
GameShaders.Misc["CalamityMod:LinearTransformation"].Shader.Parameters["uWorldViewProjection"].SetValue(viewMatrix * projectionMatrix);
GameShaders.Misc["CalamityMod:LinearTransformation"].Shader.Parameters["localMatrix"].SetValue(new Matrix()
{
M11 = 1f,
M12 = 0f,
M21 = 0f,
M22 = 1f + VerticalStretchFactor * 0.4f,
});
GameShaders.Misc["CalamityMod:LinearTransformation"].Apply();
float rotation = Projectile.rotation;
Vector2 origin = Projectile.Size * new Vector2(0.5f, 1f);
Vector2 drawPosition = Projectile.Center + Projectile.rotation.ToRotationVector2() * Projectile.scale * 32f - Main.screenPosition;
if (Direction == -1)
rotation += MathHelper.Pi;
Main.EntitySpriteDraw(texture, drawPosition, null, Projectile.GetAlpha(Color.White), rotation, origin, Projectile.scale, Direction == -1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None, 0);
Main.spriteBatch.ExitShaderRegion();
return false;
}
public override void OnHitNPC(NPC target, int damage, float knockback, bool crit)
{
ItemLoader.OnHitNPC(Owner.ActiveItem(), Owner, target, damage, knockback, crit);
NPCLoader.OnHitByItem(target, Owner, Owner.ActiveItem(), damage, knockback, crit);
PlayerLoader.OnHitNPC(Owner, Owner.ActiveItem(), target, damage, knockback, crit);
}
public override bool? CanDamage() => CurrentState != SwingState.Default;
public override void Kill(int timeLeft) => Owner.fullRotation = 0f;
}
}