Skip to content

Commit ab5701e

Browse files
author
Kirtle
committed
BuildInPeace now fully disables NPCs execept for Town NPCs
Made the Utilities namespace a single static class. Made the mod release ready
1 parent 36e4b89 commit ab5701e

14 files changed

+41
-33
lines changed

Buffs/BuildInPeaceBuff.cs

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1-
using System;
1+
using Terraria.ID;
2+
using System;
23
using Terraria;
34
using Terraria.ModLoader;
5+
using BuilderEssentials.Utilities;
46
using static BuilderEssentials.BuilderPlayer;
57

68
namespace BuilderEssentials.Buffs
@@ -16,7 +18,6 @@ public override void SetDefaults()
1618
Main.buffNoTimeDisplay[Type] = true;
1719
canBeCleared = false;
1820
}
19-
2021
public override void Update(Player player, ref int buffIndex)
2122
{
2223
BuilderPlayer modPlayer = player.GetModPlayer<BuilderPlayer>();
@@ -34,19 +35,13 @@ public override void Update(Player player, ref int buffIndex)
3435
Main.invasionSize = 0;
3536
Main.time = 27000; //mid day
3637
Main.fastForwardTime = false;
37-
}
38-
}
3938

40-
public class PeacefulNPCs : GlobalNPC
41-
{
42-
public override void EditSpawnRate(Player player, ref int spawnRate, ref int maxSpawns)
43-
{
44-
if (player.HasBuff(mod.BuffType("BuildInPeaceBuff")))
45-
spawnRate = 0;
46-
else
47-
base.EditSpawnRate(player, ref spawnRate, ref maxSpawns);
39+
foreach (var npc in Main.npc)
40+
{
41+
//Don't want to remove town NPC's
42+
if (!Tools.IsTownNpc(npc))
43+
npc.active = false;
44+
}
4845
}
4946
}
50-
51-
5247
}

Buffs/BuildInPeaceBuff.png

-453 Bytes
Loading

BuilderPlayer.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ public override void ResetEffects()
100100
public override void ProcessTriggers(TriggersSet triggersSet)
101101
{
102102
if (BuilderEssentials.ToggleBuildingMode.JustPressed)
103-
BuildingMode.BuildingModeAccessoriesToggle();
103+
Tools.BuildingModeAccessoriesToggle();
104104
}
105105

106106
public override TagCompound Save()
@@ -168,8 +168,8 @@ public override void OnEnterWorld(Player player)
168168
BasePanel.buildingModeButton.SetImage(BuilderEssentials.BuildingModeOff);
169169

170170
//Loads (or populates) all lists on enter world
171-
BuildingMode.BuildingModeAccessoriesToggle();
172-
BuildingMode.BuildingModeAccessoriesToggle();
171+
Tools.BuildingModeAccessoriesToggle();
172+
Tools.BuildingModeAccessoriesToggle();
173173
}
174174
}
175175
}

Items/Accessories/BuildInPeace.png

682 Bytes
Loading

Items/Accessories/CreativeWrench.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public override void UpdateAccessory(Player player, bool hideVisual)
4747
Player.tileRangeY = 55;
4848

4949
//Right click timer
50-
if (Main.mouseRight && UIUtilities.IsUIAvailable()
50+
if (Main.mouseRight && Tools.IsUIAvailable()
5151
&& (!player.mouseInterface || CreativeWheelRework.CreativeWheelReworkPanel.IsMouseHovering)
5252
&& !BasePanel.paintingUIOpen && player.inventory[player.selectedItem].IsAir)
5353
{
@@ -61,15 +61,15 @@ public override void UpdateAccessory(Player player, bool hideVisual)
6161
//ItemPicker
6262
if (Main.mouseMiddle && modPlayer.creativeWheelSelectedIndex.Contains((int)CreativeWheelItem.ItemPicker)
6363
&& !player.mouseInterface && !Main.playerInventory)
64-
ItemPicker.PickItem(ref oldPosX, ref oldPosY);
64+
Tools.PickItem(ref oldPosX, ref oldPosY);
6565

6666
//AutoHammer
6767
if (Main.mouseLeft && modPlayer.creativeWheelSelectedIndex.Contains((int)CreativeWheelItem.AutoHammer)
6868
&& player.inventory[player.selectedItem].IsAir && CreativeWheelRework.CreativeWheelReworkPanel != null && !player.mouseInterface
6969
&& !Main.playerInventory)
7070
{
7171
if (!CreativeWheelRework.CreativeWheelReworkPanel.IsMouseHovering)
72-
AutoHammer.ChangeSlope(ref oldPosX, ref oldPosY, ref previousClickedTile);
72+
Tools.ChangeSlope(ref oldPosX, ref oldPosY, ref previousClickedTile);
7373
}
7474
else if (Main.mouseLeft && modPlayer.creativeWheelSelectedIndex.Contains((int)CreativeWheelItem.AutoHammer)
7575
&& !player.inventory[player.selectedItem].IsAir && !player.mouseInterface && !Main.playerInventory)
@@ -135,7 +135,7 @@ public override bool CanPlace(int i, int j, int type)
135135
NetMessage.SendTileSquare(-1, Player.tileTargetX, Player.tileTargetY, 1);
136136

137137
if (modPlayer.mirrorWandEffects)
138-
UIUtilities.MirrorWandPlacement(Player.tileTargetX, Player.tileTargetY, selectedItem, -1);
138+
Tools.MirrorWandPlacement(Player.tileTargetX, Player.tileTargetY, selectedItem, -1);
139139

140140
return base.CanPlace(i, j, type);
141141
}
@@ -182,7 +182,7 @@ public override void PlaceInWorld(int i, int j, Item item)
182182
}
183183

184184
if (modPlayer.mirrorWandEffects)
185-
UIUtilities.MirrorWandPlacement(i, j, item, -1);
185+
Tools.MirrorWandPlacement(i, j, item, -1);
186186

187187
if (modPlayer.creativeWheelSelectedIndex.Contains((int)CreativeWheelItem.InfinitePlacement) ||
188188
modPlayer.creativeWheelSelectedIndex.Contains((int)CreativeWheelItem.InfinityUpgrade))
@@ -204,7 +204,7 @@ public override void PlaceInWorld(int i, int j, int type, Item item)
204204
item.consumable = true;
205205

206206
if (modPlayer.mirrorWandEffects)
207-
UIUtilities.MirrorWandPlacement(i, j, item, type);
207+
Tools.MirrorWandPlacement(i, j, item, type);
208208
}
209209
}
210210
}

Items/SuperPaintingTool.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ public override void UpdateInventory(Player player)
5757
BasePanel.paintingUIOpen = false;
5858
}
5959

60-
if (Main.mouseRight && UIUtilities.IsUIAvailable()
60+
if (Main.mouseRight && Tools.IsUIAvailable()
6161
&& (!player.mouseInterface || (BasePanel.paintingUIOpen && BasePanel.paintingPanel.IsMouseHovering))
6262
&& player.inventory[player.selectedItem].IsTheSameAs(item)
6363
&& !BasePanel.creativeWheelUIOpen)

UI/BasePanel.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
using Microsoft.Xna.Framework.Graphics;
55
using Microsoft.Xna.Framework;
66
using BuilderEssentials.Utilities;
7-
using static BuilderEssentials.BuilderPlayer;
87
using System.Collections.Generic;
98

109
namespace BuilderEssentials.UI
@@ -137,7 +136,7 @@ public override void Update(GameTime gameTime)
137136
public void ChangeAccessories_OnClick(UIMouseEvent evt, UIElement listeningElement)
138137
{
139138
if (isBuildingModeButtonVisible)
140-
BuildingMode.BuildingModeAccessoriesToggle();
139+
Tools.BuildingModeAccessoriesToggle();
141140
}
142141
}
143142
}

Utilities/AutoHammer.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
namespace BuilderEssentials.Utilities
55
{
66

7-
public static class AutoHammer
7+
public static partial class Tools
88
{
99
public static void ChangeSlope(ref int oldPosX, ref int oldPosY, ref Tile previousClickedTile)
1010
{

Utilities/BuildingMode.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
namespace BuilderEssentials.Utilities
1010
{
11-
public static class BuildingMode
11+
public static partial class Tools
1212
{
1313
public static void BuildingModeAccessoriesToggle()
1414
{

Utilities/FurnitureFinder.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
namespace BuilderEssentials.Utilities
55
{
6-
public static class FurnitureFinder
6+
public static partial class Tools
77
{
88
public static void FindFurniture(Tile tile, ref Item item)
99
{

Utilities/ItemPicker.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
namespace BuilderEssentials.Utilities
55
{
66

7-
public class ItemPicker
7+
public static partial class Tools
88
{
99
public static void PickItem(ref int oldPosX, ref int oldPosY)
1010
{
@@ -48,7 +48,7 @@ public static void PickItem(ref int oldPosX, ref int oldPosY)
4848
{
4949
//Furniture Check
5050
//If it is a furniture and has a different frame, item will be changed to the correct frame item
51-
FurnitureFinder.FindFurniture(tile, ref item);
51+
FindFurniture(tile, ref item);
5252

5353
bool isItemInInventory = false;
5454
for (int i = 0; i < 50; i++)

Utilities/UIUtilities.cs renamed to Utilities/MiscUtilities.cs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
namespace BuilderEssentials.Utilities
88
{
9-
public static class UIUtilities
9+
public static partial class Tools
1010
{
1111
public static bool IsUIAvailable()
1212
{
@@ -126,5 +126,18 @@ bool IsWithinRange(float number, float value1, float value2)
126126
}
127127
}
128128
}
129+
130+
public static bool IsTownNpc(NPC npc)
131+
{
132+
return (npc.type == NPCID.Guide || npc.type == NPCID.Merchant || npc.type == NPCID.Nurse ||
133+
npc.type == NPCID.Demolitionist || npc.type == NPCID.DyeTrader || npc.type == NPCID.Angler ||
134+
npc.type == NPCID.Dryad || npc.type == NPCID.Painter || npc.type == NPCID.ArmsDealer ||
135+
npc.type == NPCID.DD2Bartender || npc.type == NPCID.Stylist || npc.type == NPCID.GoblinTinkerer ||
136+
npc.type == NPCID.WitchDoctor || npc.type == NPCID.Clothier || npc.type == NPCID.Mechanic ||
137+
npc.type == NPCID.PartyGirl || npc.type == NPCID.Wizard || npc.type == NPCID.TaxCollector ||
138+
npc.type == NPCID.Truffle || npc.type == NPCID.Pirate || npc.type == NPCID.Steampunker ||
139+
npc.type == NPCID.Cyborg || npc.type == NPCID.SantaClaus || npc.type == NPCID.TravellingMerchant ||
140+
npc.type == NPCID.OldMan || npc.type == NPCID.SkeletonMerchant);
141+
}
129142
}
130143
}

build.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
displayName = Builder Essentials
22
author = Kirtle
3-
version = 0.1.11.3
3+
version = 0.1.12
44
buildIgnore = *.csproj, *.user, obj\*, bin\*, .vs\*
55
homepage = https://discord.gg/wQYMbQq

description.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ Happy Building!
1717

1818
Latest Changelog:
1919
- Introduced the Mirror Wand
20+
- Introduced the BuildInPeace accessory and buff
2021
- Fixed a few more bugs and edge cases
2122

2223
Dev Team

0 commit comments

Comments
 (0)