diff --git a/.gitignore b/.gitignore
index 4ce6fdd..9ff0733 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,3 +1,6 @@
+# Ignore user paths
+user.targets
+
## Ignore Visual Studio temporary files, build results, and
## files generated by popular Visual Studio add-ons.
##
diff --git a/ChunkLabel.cs b/ChunkLabel.cs
index a80bf72..10e5597 100644
--- a/ChunkLabel.cs
+++ b/ChunkLabel.cs
@@ -5,10 +5,9 @@ namespace HeadsShouldersKneesAndToes
{
class ChunkLabel : CosmeticSprite
{
- public ChunkLabel(BodyChunk chunk, int index, Room room)
+ public ChunkLabel(BodyChunk chunk, int index)
{
this.chunk = chunk;
- startRoomName = room.abstractRoom.name;
// set label text properties
label = new FLabel("DisplayFont", index.ToString())
@@ -22,14 +21,10 @@ public ChunkLabel(BodyChunk chunk, int index, Room room)
public override void Update(bool eu)
{
- try
+ if (chunk.owner?.room?.abstractRoom?.name != TaggerMod.CurrentRoomName || chunk.owner.slatedForDeletetion)
{
- if (chunk.owner.room.abstractRoom.name != startRoomName)
- {
- Destroy();
- }
+ Destroy();
}
- catch (NullReferenceException) { }
base.Update(eu);
}
@@ -45,11 +40,7 @@ public override void InitiateSprites(RoomCamera.SpriteLeaser sLeaser, RoomCamera
{
// set label background properties (sans color)
sLeaser.sprites = new FSprite[1];
- sLeaser.sprites[0] = new FSprite("pixel", true)
- {
- scaleX = 8f,
- scaleY = 8f
- };
+ sLeaser.sprites[0] = new FSprite("pixel", true);
AddToContainer(sLeaser, rCam, null);
}
@@ -57,6 +48,7 @@ public override void DrawSprites(RoomCamera.SpriteLeaser sLeaser, RoomCamera rCa
{
Vector2 pos = Vector2.Lerp(chunk.lastPos, chunk.pos, timeStacker) - camPos;
sLeaser.sprites[0].SetPosition(pos);
+ sLeaser.sprites[0].scaleX = sLeaser.sprites[0].scaleY = chunk.rad * 2;
label.SetPosition(pos);
sLeaser.sprites[0].isVisible = TaggerMod.ChunkTagsVisible;
label.isVisible = TaggerMod.ChunkTagsVisible;
@@ -76,13 +68,12 @@ public override void AddToContainer(RoomCamera.SpriteLeaser sLeaser, RoomCamera
public override void ApplyPalette(RoomCamera.SpriteLeaser sLeaser, RoomCamera rCam, RoomPalette palette)
{
// set colour of label background
- Color color = Color.black;
+ Color color = palette.skyColor * 0.9f;
color.a = 0.7f;
sLeaser.sprites[0].color = color;
}
readonly BodyChunk chunk;
readonly FLabel label;
- readonly string startRoomName;
}
}
diff --git a/HeadsShouldersKneesAndToes.csproj b/HeadsShouldersKneesAndToes.csproj
index cff3136..ce8f27f 100644
--- a/HeadsShouldersKneesAndToes.csproj
+++ b/HeadsShouldersKneesAndToes.csproj
@@ -62,6 +62,7 @@
- copy /Y $(TargetPath) "D:\Games\Steam\steamapps\common\Rain World\Mods"
+ copy /Y $(TargetPath) "D:\Games\Steam\steamapps\common\Rain World\Mods"
+
\ No newline at end of file
diff --git a/SpriteLabel.cs b/SpriteLabel.cs
index 8756c34..305dd03 100644
--- a/SpriteLabel.cs
+++ b/SpriteLabel.cs
@@ -5,11 +5,10 @@ namespace HeadsShouldersKneesAndToes
{
class SpriteLabel : CosmeticSprite
{
- public SpriteLabel(FSprite sprite, Creature owner, int index, Room room)
+ public SpriteLabel(FSprite sprite, UpdatableAndDeletable owner, int index)
{
this.sprite = sprite;
this.owner = owner;
- startRoomName = room.abstractRoom.name;
// set label text properties
label = new FLabel("DisplayFont", index.ToString())
@@ -23,14 +22,10 @@ public SpriteLabel(FSprite sprite, Creature owner, int index, Room room)
public override void Update(bool eu)
{
- try
+ if (owner.room?.abstractRoom?.name != TaggerMod.CurrentRoomName || owner.slatedForDeletetion)
{
- if (owner.room.abstractRoom.name != startRoomName)
- {
- Destroy();
- }
+ Destroy();
}
- catch (NullReferenceException) { }
base.Update(eu);
}
@@ -85,8 +80,7 @@ public override void ApplyPalette(RoomCamera.SpriteLeaser sLeaser, RoomCamera rC
}
readonly FSprite sprite;
- readonly Creature owner;
+ readonly UpdatableAndDeletable owner;
readonly FLabel label;
- readonly string startRoomName;
}
}
diff --git a/TaggerMod.cs b/TaggerMod.cs
index cc87cdb..7bb213b 100644
--- a/TaggerMod.cs
+++ b/TaggerMod.cs
@@ -7,16 +7,15 @@ namespace HeadsShouldersKneesAndToes
[BepInPlugin("casheww.chunk_tagger", "Tagger", "1.1")]
class TaggerMod : BaseUnityPlugin
{
-
- void OnEnable()
+ public void OnEnable()
{
- On.GraphicsModule.InitiateSprites += GraphicsModule_InitiateSprites;
+ On.RoomCamera.SpriteLeaser.ctor += SpriteLeaser_ctor;
ChunkTagsVisible = false;
SpriteTagsVisible = false;
TileGridVisible = false;
}
- void Update()
+ public void Update()
{
if (Input.GetKeyDown(KeyCode.Equals))
{
@@ -32,44 +31,47 @@ void Update()
}
}
- void GraphicsModule_InitiateSprites(On.GraphicsModule.orig_InitiateSprites orig,
- GraphicsModule self, RoomCamera.SpriteLeaser sLeaser, RoomCamera rCam)
+ private void SpriteLeaser_ctor(On.RoomCamera.SpriteLeaser.orig_ctor orig, RoomCamera.SpriteLeaser self, IDrawable obj, RoomCamera rCam)
{
- orig(self, sLeaser, rCam);
+ orig(self, obj, rCam);
- if (self.owner is Creature)
+ if (!(obj is ChunkLabel || obj is SpriteLabel || obj is TileGridLine))
{
- for (int i = 0; i < self.owner.bodyChunks.Length; i++)
- {
- ChunkLabel chunkLabel = new ChunkLabel(self.owner.bodyChunks[i], i, rCam.room);
- rCam.room.AddObject(chunkLabel);
- }
+ var physobjs = obj as PhysicalObject ?? (obj is GraphicsModule g ? g.owner : null);
- for (int i = 0; i < sLeaser.sprites.Length; i++)
+ if (physobjs != null)
{
- SpriteLabel spriteLabel = new SpriteLabel(sLeaser.sprites[i],
- self.owner as Creature, i, rCam.room);
- rCam.room.AddObject(spriteLabel);
+ for (int i = 0; i < physobjs.bodyChunks.Length; i++)
+ {
+ ChunkLabel chunkLabel = new ChunkLabel(physobjs.bodyChunks[i], i);
+ rCam.room.AddObject(chunkLabel);
+ }
+ for (int i = 0; i < self.sprites.Length; i++)
+ {
+ SpriteLabel spriteLabel = new SpriteLabel(self.sprites[i], physobjs, i);
+ rCam.room.AddObject(spriteLabel);
+ }
}
- if (rCam.room.abstractRoom.name != CurrentTiledRoomName)
+ if (rCam.room.abstractRoom.name != CurrentRoomName)
{
- for (int x = 0; x < rCam.room.Width; x++)
+ for (int x = 0; x < rCam.room.TileWidth; x++)
{
- TileGridLine tileMarker = new TileGridLine(rCam.room, TileGridLine.Orientation.Vertical, x);
+ TileGridLine tileMarker = new TileGridLine(TileGridLine.Orientation.Vertical, x);
rCam.room.AddObject(tileMarker);
}
- for (int y = 0; y < rCam.room.Height; y++)
+ for (int y = 0; y < rCam.room.TileHeight; y++)
{
- TileGridLine tileMarker = new TileGridLine(rCam.room, TileGridLine.Orientation.Horizontal, y);
+ TileGridLine tileMarker = new TileGridLine(TileGridLine.Orientation.Horizontal, y);
rCam.room.AddObject(tileMarker);
}
- CurrentTiledRoomName = rCam.room.abstractRoom.name;
}
}
+
+ CurrentRoomName = rCam.room.abstractRoom.name;
}
- public static string CurrentTiledRoomName { get; private set; }
+ public static string CurrentRoomName { get; private set; }
public static bool ChunkTagsVisible { get; private set; }
public static bool SpriteTagsVisible { get; private set; }
diff --git a/TileGridLine.cs b/TileGridLine.cs
index 2995b76..9a8aeed 100644
--- a/TileGridLine.cs
+++ b/TileGridLine.cs
@@ -5,27 +5,21 @@ namespace HeadsShouldersKneesAndToes
{
class TileGridLine : CosmeticSprite
{
- public TileGridLine(Room room, Orientation o, int n)
+ public TileGridLine(Orientation o, int n)
{
- startRoomName = room.abstractRoom.name;
this.o = o;
this.n = n;
}
readonly Orientation o;
readonly int n;
- readonly string startRoomName;
public override void Update(bool eu)
{
- try
+ if (room.abstractRoom?.name != TaggerMod.CurrentRoomName)
{
- if (room.abstractRoom.name != startRoomName)
- {
- Destroy();
- }
+ Destroy();
}
- catch (NullReferenceException) { }
base.Update(eu);
}
@@ -57,11 +51,11 @@ public override void DrawSprites(RoomCamera.SpriteLeaser sLeaser, RoomCamera rCa
sLeaser.sprites[0].isVisible = TaggerMod.TileGridVisible;
if (o == Orientation.Vertical)
{
- sLeaser.sprites[0].SetPosition(rCam.room.MiddleOfTile(n, rCam.room.Height / 2) - camPos - new Vector2(10, 0));
+ sLeaser.sprites[0].SetPosition(rCam.room.MiddleOfTile(n, rCam.room.TileHeight / 2) - camPos - new Vector2(10, 0));
}
else
{
- sLeaser.sprites[0].SetPosition(rCam.room.MiddleOfTile(rCam.room.Width / 2, n) - camPos - new Vector2(0, 10));
+ sLeaser.sprites[0].SetPosition(rCam.room.MiddleOfTile(rCam.room.TileWidth / 2, n) - camPos - new Vector2(0, 10));
}
base.DrawSprites(sLeaser, rCam, timeStacker, camPos);
}