From 2cb32aa540572a16cce4fbd7407a812986b60866 Mon Sep 17 00:00:00 2001 From: Dual-Iron <31146412+Dual-Iron@users.noreply.github.com> Date: Sat, 3 Jul 2021 16:15:07 -0400 Subject: [PATCH 1/3] Let other peoples compile --- .gitignore | 3 +++ HeadsShouldersKneesAndToes.csproj | 3 ++- 2 files changed, 5 insertions(+), 1 deletion(-) 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/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 From 02f70799783f57d753d3d78204d4329ecf831563 Mon Sep 17 00:00:00 2001 From: Dual-Iron <31146412+Dual-Iron@users.noreply.github.com> Date: Sat, 3 Jul 2021 16:19:04 -0400 Subject: [PATCH 2/3] Reduce some lag, throw less, generalize drawing to physical objects instead of creatures --- ChunkLabel.cs | 12 +++--------- SpriteLabel.cs | 14 ++++---------- TaggerMod.cs | 50 +++++++++++++++++++++++++------------------------ TileGridLine.cs | 16 +++++----------- 4 files changed, 38 insertions(+), 54 deletions(-) diff --git a/ChunkLabel.cs b/ChunkLabel.cs index a80bf72..9e86883 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); } @@ -83,6 +78,5 @@ public override void ApplyPalette(RoomCamera.SpriteLeaser sLeaser, RoomCamera rC readonly BodyChunk chunk; readonly FLabel label; - readonly string startRoomName; } } 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); } From c934dd5912ce1e8d3a55e2f9ea826fdb44a99e5d Mon Sep 17 00:00:00 2001 From: Dual-Iron <31146412+Dual-Iron@users.noreply.github.com> Date: Sun, 4 Jul 2021 01:56:21 -0400 Subject: [PATCH 3/3] Scale chunk label background to show radius --- ChunkLabel.cs | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/ChunkLabel.cs b/ChunkLabel.cs index 9e86883..10e5597 100644 --- a/ChunkLabel.cs +++ b/ChunkLabel.cs @@ -40,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); } @@ -52,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; @@ -71,7 +68,7 @@ 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; }