arena truly is a solid wall now

This commit is contained in:
doze-zoze authored and Cameron Ewell committed 2025-10-31 15:55:04 -04:00
1 parent 1e2af9a28f
commit adf713d724
4 files changed
+106 -13

No files matched your search

+3
View File
@@ -92,6 +92,9 @@ namespace CalamityMod.ILEditing
On_Player.ItemCheck_ReleaseCritter += ReleaseCritterVariant;
On_Player.IsItemSlotUnlockedAndUsable += MasterModeCelestialOnionCheck;
On_Projectile.AI_007_GrapplingHooks += AllowHooksToGrabArenabox;
On_Collision.SolidCollision_Vector2_int_int += ArenaCollision_Vector2_int_int;
On_Collision.SolidCollision_Vector2_int_int_bool += ArenaCollision_Vector2_int_int_bool;
On_Collision.TileCollision += ArenaCollision_TileCollision;
// Mana Burn (Chaos Stone) and Chalice of the Blood God
IL_Player.ApplyLifeAndOrMana += ChaliceBufferHeal;
+77 -6
View File
@@ -677,7 +677,7 @@ namespace CalamityMod.ILEditing
#endregion
#region Chaos Stone Mana Burn changes
private static bool AllowNegativeCheckMana(On_Player.orig_CheckMana_int_bool_bool orig,Player self, int amount, bool pay, bool blockQuickMana) {
private static bool AllowNegativeCheckMana(On_Player.orig_CheckMana_int_bool_bool orig, Player self, int amount, bool pay, bool blockQuickMana) {
if (self.Calamity().ChaosStone)
{
if (pay)
@@ -1095,7 +1095,7 @@ namespace CalamityMod.ILEditing
BlockLavaDrawing_Vanilla(il);
}
}
private void BlockLavaDrawing_Vanilla(ILContext il)
{
//This edit to DrawNormalLiquids makes lavas in normal and white lighting draw with an alpha and with new textures
@@ -1152,7 +1152,7 @@ namespace CalamityMod.ILEditing
{
Assembly lspAsm = ModLoader.GetMod("LiquidSlopesPatch").Code;
Type liquidDrawCache = lspAsm.GetType("LiquidSlopesPatch.Common.RewrittenLiquidRenderer").GetNestedType("LiquidDrawCache");
//This edit to DrawNormalLiquids makes lavas in normal and white lighting draw with an alpha and with new textures
//If the parameter for the waterstyle is more than the max waterstyles then its subtracted by the max water style count and thats the lava style ID
ILCursor cursor = new ILCursor(il);
@@ -1466,7 +1466,7 @@ namespace CalamityMod.ILEditing
LiquidDrawColors_Vanilla(il);
}
}
private static void LiquidDrawColors_Vanilla(ILContext il)
{
ILCursor cursor = new ILCursor(il);
@@ -1494,12 +1494,12 @@ namespace CalamityMod.ILEditing
}
});
}
private static void LiquidDrawColors_LiquidSlopesPatch(ILContext il)
{
Assembly lspAsm = ModLoader.GetMod("LiquidSlopesPatch").Code;
Type liquidDrawCache = lspAsm.GetType("LiquidSlopesPatch.Common.RewrittenLiquidRenderer").GetNestedType("LiquidDrawCache");
ILCursor cursor = new ILCursor(il);
if (!cursor.TryGotoNext(MoveType.Before, c => c.MatchLdarg2(), c => c.MatchLdloc(out _), c => c.MatchLdloc(out _), c => c.MatchCall<Main>("DrawTileInWater")))
{
@@ -2693,5 +2693,76 @@ namespace CalamityMod.ILEditing
orig(self);
}
#endregion
#region Arena Collision for other things
private bool ArenaCollision_Vector2_int_int_bool(On_Collision.orig_SolidCollision_Vector2_int_int_bool orig, Vector2 Position, int Width, int Height, bool acceptTopSurfaces)
{
if (ArenaWallSystem.ActiveBoxes.Count > 0)
{
foreach (var item in ArenaWallSystem.ActiveBoxes)
{
if (item.Vector2PairInWall(Position, new(Width, Height)))
return true;
}
}
return orig(Position, Width, Height, acceptTopSurfaces);
}
private bool ArenaCollision_Vector2_int_int(On_Collision.orig_SolidCollision_Vector2_int_int orig, Vector2 Position, int Width, int Height)
{
if (ArenaWallSystem.ActiveBoxes.Count > 0)
{
foreach (var item in ArenaWallSystem.ActiveBoxes)
{
if (item.Vector2PairInWall(Position, new(Width, Height)))
return true;
}
}
return orig(Position, Width, Height);
}
private Vector2 ArenaCollision_TileCollision(On_Collision.orig_TileCollision orig, Vector2 Position, Vector2 Velocity, int Width, int Height, bool fallThrough, bool fall2, int gravDir)
{
Velocity = orig(Position, Velocity, Width, Height, fallThrough, fall2, gravDir);
if (ArenaWallSystem.ActiveBoxes.Count > 0)
{
foreach (var item in ArenaWallSystem.ActiveBoxes)
{
if (item.InnerEffect(Position,new Vector2(Width,Height)))
Velocity = ArenaCollisionLogic(item, Position, Width, Height, Velocity);
}
}
return Velocity;
}
Vector2 ArenaCollisionLogic(ArenaWallSystem.Box box, Vector2 Position, int Width, int Height, Vector2 Velocity)
{
var originalVelocity = Velocity;
var originalTopLeft = Position;
var originalBottomRight = Position + new Vector2(Height, Width);
Position += originalVelocity;
if (Position.X < box.TopLeft.X)
{
Velocity.X = box.TopLeft.X - originalTopLeft.X;
}
if (Position.X + Width > box.BottomRight.X)
{
Velocity.X = box.BottomRight.X - originalBottomRight.X;
}
if (Position.Y < box.TopLeft.Y)
{
Velocity.Y = box.TopLeft.Y - originalTopLeft.Y;
}
if (Position.Y + Height > box.BottomRight.Y)
{
Velocity.Y = box.BottomRight.Y - originalBottomRight.Y;
}
return Velocity;
}
#endregion
}
}
+5 -4
View File
@@ -645,8 +645,8 @@ namespace CalamityMod.NPCs.SupremeCalamitas
return baseSize;
}
//arena
if (lifeRatio > 0.01f)
//Commented out code is for deleting arena in Acceptance if needed
//if (lifeRatio > 0.01f)
{
if (ArenaWallSystem.ActiveBoxes.Count < 1)
{
@@ -654,7 +654,8 @@ namespace CalamityMod.NPCs.SupremeCalamitas
}
ArenaWallSystem.ActiveBoxes[0].NewDimensions = Vector4.Lerp(ArenaWallSystem.ActiveBoxes[0].boxDimensions, GetArenaSize(), startFourthAttack ? 0.05f : 0.1f);
ArenaWallSystem.ActiveBoxes[0].borderColor = permafrost ? Color.LightBlue : Color.Lerp(Color.Crimson, Color.IndianRed, (MathF.Sin(Main.GlobalTimeWrappedHourly) + 1) * 0.25f);
} else
}
/*else
{
if (ArenaWallSystem.ActiveBoxes.Count > 0)
{
@@ -663,7 +664,7 @@ namespace CalamityMod.NPCs.SupremeCalamitas
if (box.NewDimensions.X >= 2000)
ArenaWallSystem.ActiveBoxes.Remove(box);
}
}
}*/
#endregion
#region Enrage and DR
if (ArenaWallSystem.ActiveBoxes.Count > 0 && !Collision.CheckAABBvAABBCollision(ArenaWallSystem.ActiveBoxes[0].TopLeft, ArenaWallSystem.ActiveBoxes[0].Size, player.position, player.Size))
+21 -3
View File
@@ -58,12 +58,30 @@ namespace CalamityMod.Systems.Mechanic
{
oldData = new Box() { borderColor = borderColor, borderThickness = borderThickness, boxDimensions = boxDimensions, position = position };
}
public bool Contains(Player player)
public bool Contains(Vector2 Position, Vector2 size)
{
return Collision.CheckAABBvAABBCollision(TopLeft - new Vector2(borderThickness * 0.5f), Size + new Vector2(borderThickness), player.TopLeft, player.Size);
return Collision.CheckAABBvAABBCollision(TopLeft - new Vector2(borderThickness * 0.5f), Size + new Vector2(borderThickness), Position, size);
}
public bool ShouldEffectPlayer(Player player) => Collision.CheckAABBvAABBCollision(TopLeft - new Vector2(borderThickness + 300), Size + new Vector2(borderThickness + 300)*2, player.TopLeft, player.Size);
public bool InnerEffect(Vector2 Position, Vector2 size) => Collision.CheckAABBvAABBCollision(TopLeft - new Vector2(borderThickness)*0.5f, Size + new Vector2(borderThickness), Position, size);
public bool PointInWall(Vector2 pos)
{
static bool Vector2PointCollision(Vector2 position, Vector2 size, Vector2 point)
{
return (point.X >= position.X && point.X <= position.X + size.X && point.Y >= position.Y && point.Y <= position.Y + size.Y);
}
return !Vector2PointCollision(TopLeft, Size, pos) && Vector2PointCollision(TopLeft - new Vector2(borderThickness), Size + new Vector2(borderThickness) * 2, pos);
}
public bool Vector2PairInWall(Vector2 pos, Vector2 size)
{
return Collision.CheckAABBvAABBCollision(TopLeft - new Vector2(borderThickness), new Vector2(size.X + borderThickness * 2, borderThickness), pos, size)
|| Collision.CheckAABBvAABBCollision(TopRight + new Vector2(0, -borderThickness), new Vector2(borderThickness, size.Y + borderThickness * 2), pos, size)
|| Collision.CheckAABBvAABBCollision(BottomLeft + new Vector2(-borderThickness, 0), new Vector2(size.X + borderThickness * 2, borderThickness), pos, size)
|| Collision.CheckAABBvAABBCollision(TopLeft - new Vector2(borderThickness), new Vector2(borderThickness, size.Y + borderThickness * 2), pos, size);
}
}
public override void PostDrawTiles() //Later all of this method should be stored in the box instance for more customizability.
{
@@ -160,7 +178,7 @@ namespace CalamityMod.Systems.Mechanic
{
if (box.ShouldEffectPlayer(Player))
{
if (box.Contains(Player))
if (box.Contains(Player.position,Player.Size))
ContainPlayerLogic(box);
}
}