Fixed Timekeeper crash?
This commit is contained in:
parent
847841c181
commit
f188eb2757
@ -1,5 +1,6 @@
|
|||||||
using System;
|
using System;
|
||||||
using Decimation.Lib.Items;
|
using Decimation.Lib.Items;
|
||||||
|
using Decimation.Lib.Util;
|
||||||
using Microsoft.Xna.Framework;
|
using Microsoft.Xna.Framework;
|
||||||
using Terraria;
|
using Terraria;
|
||||||
|
|
||||||
@ -22,8 +23,7 @@ namespace Decimation.Content.Projectiles.Boss.DuneWyrm
|
|||||||
set => projectile.localAI[1] = value;
|
set => projectile.localAI[1] = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Projectile SiblingProjectile =>
|
private Projectile SiblingProjectile => !IsChild && Sibling >= 0 && Sibling < Main.projectile.Length ? Main.projectile[Sibling] : null;
|
||||||
Sibling >= 0 && Sibling < Main.projectile.Length ? Main.projectile[Sibling] : null;
|
|
||||||
|
|
||||||
private int Counter
|
private int Counter
|
||||||
{
|
{
|
||||||
@ -36,6 +36,8 @@ namespace Decimation.Content.Projectiles.Boss.DuneWyrm
|
|||||||
private float Speed { get; set; }
|
private float Speed { get; set; }
|
||||||
private bool Initialization { get; set; } = true;
|
private bool Initialization { get; set; } = true;
|
||||||
|
|
||||||
|
private readonly Vector3 _dustColor = LightingUtils.Rgb255ToRgb1(106, 232, 184);
|
||||||
|
|
||||||
protected override void Init()
|
protected override void Init()
|
||||||
{
|
{
|
||||||
projectile.width = 12;
|
projectile.width = 12;
|
||||||
@ -50,24 +52,21 @@ namespace Decimation.Content.Projectiles.Boss.DuneWyrm
|
|||||||
public override bool PreKill(int timeLeft)
|
public override bool PreKill(int timeLeft)
|
||||||
{
|
{
|
||||||
SiblingProjectile?.Kill();
|
SiblingProjectile?.Kill();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Kill(int timeLeft)
|
public override void Kill(int timeLeft)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < 8; i++)
|
DustUtils.NewDustCircle(8, projectile.position, projectile.width, projectile.height, 229,
|
||||||
{
|
1.5f * projectile.scale, gravity: true);
|
||||||
Dust.NewDust(projectile.position, projectile.width, projectile.height, 135, 0,
|
|
||||||
0, 100, default, 4f * projectile.scale);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void AI()
|
public override void AI()
|
||||||
{
|
{
|
||||||
if (!IsChild)
|
if (!IsChild)
|
||||||
{
|
{
|
||||||
if (Sibling == -1)
|
if (SiblingProjectile == null)
|
||||||
{
|
{
|
||||||
projectile.position.Y -= 8f;
|
projectile.position.Y -= 8f;
|
||||||
|
|
||||||
@ -85,15 +84,19 @@ namespace Decimation.Content.Projectiles.Boss.DuneWyrm
|
|||||||
projectile.velocity = parentVelocity.RotatedBy(Rotation);
|
projectile.velocity = parentVelocity.RotatedBy(Rotation);
|
||||||
|
|
||||||
// Sibling
|
// Sibling
|
||||||
Vector2 siblingVelocity = parentVelocity * new Vector2(1, -1);
|
if (SiblingProjectile != null)
|
||||||
SiblingProjectile.velocity = siblingVelocity.RotatedBy(Rotation);
|
|
||||||
|
|
||||||
if (Initialization)
|
|
||||||
{
|
{
|
||||||
Vector2 offset = new Vector2(projectile.position.X - SiblingProjectile.position.X, -16);
|
Vector2 siblingVelocity = parentVelocity * new Vector2(1, -1);
|
||||||
projectile.velocity += offset.RotatedBy(Rotation);
|
SiblingProjectile.velocity = siblingVelocity.RotatedBy(Rotation);
|
||||||
|
|
||||||
Initialization = false;
|
|
||||||
|
if (Initialization)
|
||||||
|
{
|
||||||
|
Vector2 offset = new Vector2(projectile.position.X - SiblingProjectile.position.X, -16);
|
||||||
|
projectile.velocity += offset.RotatedBy(Rotation);
|
||||||
|
|
||||||
|
Initialization = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Counter++;
|
Counter++;
|
||||||
@ -103,9 +106,10 @@ namespace Decimation.Content.Projectiles.Boss.DuneWyrm
|
|||||||
Sibling = projectile.owner;
|
Sibling = projectile.owner;
|
||||||
}
|
}
|
||||||
|
|
||||||
Lighting.AddLight(projectile.Center, 0f, 0f, 1f);
|
Lighting.AddLight(projectile.Center, _dustColor);
|
||||||
Dust.NewDust(projectile.position, projectile.width, projectile.height, 135, projectile.velocity.X * 0.2f,
|
Dust dust = Dust.NewDustDirect(projectile.position, projectile.width, projectile.height, 229, projectile.velocity.X * 0.2f,
|
||||||
projectile.velocity.Y * 0.2f, 100, default, 2f * projectile.scale);
|
projectile.velocity.Y * 0.2f, 100, default, 1f * projectile.scale);
|
||||||
|
dust.noGravity = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -24,7 +24,6 @@
|
|||||||
item.axe = AxePower / 5; // Axe power is multiplied by 5 for some reason
|
item.axe = AxePower / 5; // Axe power is multiplied by 5 for some reason
|
||||||
item.hammer = HammerPower;
|
item.hammer = HammerPower;
|
||||||
|
|
||||||
item.damage = 1000;
|
|
||||||
if (MeleeDamages > 0) item.noMelee = false;
|
if (MeleeDamages > 0) item.noMelee = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -6,7 +6,7 @@ namespace Decimation.Lib.Util
|
|||||||
{
|
{
|
||||||
public class DustUtils
|
public class DustUtils
|
||||||
{
|
{
|
||||||
public static void NewDustCircle(int amount, Vector2 position, int width, int height, int type, float scale = 1f, float speedX = 1f, float speedY = 1f, bool gravity = false, int alpha = 0, Color color = default)
|
public static void NewDustCircle(int amount, Vector2 position, int width, int height, int type, float scale = 1f, float speedX = 0f, float speedY = 0f, bool gravity = false, int alpha = 0, Color color = default)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < amount; i++)
|
for (int i = 0; i < amount; i++)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -2,11 +2,16 @@ using Microsoft.Xna.Framework;
|
|||||||
|
|
||||||
namespace Decimation.Lib.Util
|
namespace Decimation.Lib.Util
|
||||||
{
|
{
|
||||||
public class LightingUtils
|
public static class LightingUtils
|
||||||
{
|
{
|
||||||
public static Vector3 Rgb255ToRgb1(int r, int g, int b)
|
public static Vector3 Rgb255ToRgb1(int r, int g, int b)
|
||||||
{
|
{
|
||||||
return new Vector3(r / 255f, g / 255f, b / 255f);
|
return new Vector3(r / 255f, g / 255f, b / 255f);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static Color Rgb1ToColor(this Vector3 rgb)
|
||||||
|
{
|
||||||
|
return new Color(rgb.X, rgb.Y, rgb.Z);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Loading…
Reference in New Issue
Block a user