Skip to content

Commit 0359be5

Browse files
author
hamstar0
committed
v1.4.1 -Updated for TML11.5
* Updated for TML11.5 * Added FloatInputElement for float config settings * Added ranges to some config settings
1 parent 5db7f20 commit 0359be5

22 files changed

+73
-62
lines changed

Buffs/ShadowWalkerBuff.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ public void PlayerPreItemCheck( Player player ) {
8282
////////////////
8383

8484
private void Run( Player player ) {
85-
var myplayer = player.GetModPlayer<TheLunaticPlayer>( this.mod );
85+
var myplayer = player.GetModPlayer<TheLunaticPlayer>();
8686
if( myplayer.Noclip == null ) { return; }
8787

8888
player.AddBuff( mod.BuffType("ShadowWalkerBuff"), 4 );
@@ -122,7 +122,7 @@ public void End( Player player, bool safely=true ) {
122122
return;
123123
}
124124

125-
var myplayer = player.GetModPlayer<TheLunaticPlayer>( this.mod );
125+
var myplayer = player.GetModPlayer<TheLunaticPlayer>();
126126
if( myplayer.Noclip != null ) {
127127
myplayer.Noclip.Off();
128128
}

ConfigDefaults.cs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
using System;
1+
using HamstarHelpers.Classes.UI.ModConfig;
2+
using System;
23
using System.ComponentModel;
34
using Terraria.ModLoader.Config;
45

@@ -26,17 +27,24 @@ public class LunaticConfig : ModConfig {
2627
[DefaultValue( true )]
2728
public bool Enabled = true;
2829

30+
////
2931

32+
[Range( 0, 999 )]
3033
[DefaultValue( 9 )]
3134
public int DaysUntil = 9; // Days until The End
3235

36+
[Range( 0, 999 )]
3337
[DefaultValue( 4 )]
3438
public int HalfDaysRecoveredPerMask = 4; // Half days recovered per mask
3539

40+
[Range( 0f, 100f )]
3641
[DefaultValue( 2.5f )]
42+
[CustomModConfigItem( typeof( FloatInputElement ) )]
3743
public float WallOfFleshMultiplier = 2.5f; // Added time for WoF kill
3844

45+
[Range( 0f, 100f )]
3946
[DefaultValue( 1.5f )]
47+
[CustomModConfigItem( typeof( FloatInputElement ) )]
4048
public float HardModeMultiplier = 1.5f; // Added time for hard mode bosses
4149

4250

Items/CustomBossMaskItem.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ class CustomBossMaskItem : ModItem {
1414
public static Texture2D GetMaskTextureOfPlayer( Player player ) {
1515
if( Main.dedServ || Main.netMode == 2 ) { return null; }
1616

17-
int itemType = TheLunaticMod.Instance.ItemType<CustomBossMaskItem>();
17+
int itemType = ModContent.ItemType<CustomBossMaskItem>();
1818
ModItem myitem;
1919
CustomBossMaskItem mymaskitem = null;
2020

Items/UmbralCowlItem.cs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,19 +19,19 @@ class UmbralCowlItem : ModItem {
1919

2020
public static void Give( Player player ) {
2121
var mymod = TheLunaticMod.Instance;
22-
int who = ItemHelpers.CreateItem( player.Center, mymod.ItemType<UmbralCowlItem>(), 1, UmbralCowlItem.Width, UmbralCowlItem.Height );
22+
int who = ItemHelpers.CreateItem( player.Center, ModContent.ItemType<UmbralCowlItem>(), 1, UmbralCowlItem.Width, UmbralCowlItem.Height );
2323
Item item = Main.item[who];
2424
item.noGrabDelay = 15;
2525

26-
var itemInfo = item.GetGlobalItem<UmbralCowlItemInfo>( mymod );
26+
var itemInfo = item.GetGlobalItem<UmbralCowlItemInfo>();
2727
itemInfo.IsAllowed = true;
2828
}
2929

3030
////////////////
3131

3232
public static void CheckEquipState( Player player ) {
3333
var mymod = TheLunaticMod.Instance;
34-
int cowlType = mymod.ItemType<UmbralCowlItem>();
34+
int cowlType = ModContent.ItemType<UmbralCowlItem>();
3535
bool found = false;
3636

3737
for( int i=0; i<player.armor.Length; i++ ) {
@@ -67,7 +67,7 @@ public override void SetDefaults() {
6767
}
6868

6969
public override void ModifyTooltips( List<TooltipLine> tooltips ) {
70-
var itemInfo = item.GetGlobalItem<UmbralCowlItemInfo>();
70+
var itemInfo = this.item.GetGlobalItem<UmbralCowlItemInfo>();
7171
if( itemInfo.IsAllowed ) {
7272
TooltipLine tip = new TooltipLine( this.mod, "how_to", "Enter complete darkness to use" );
7373
TooltipLine tip2 = new TooltipLine( this.mod, "how_to2", "Press Shift to reenter light" );
@@ -87,12 +87,12 @@ public override void ModifyTooltips( List<TooltipLine> tooltips ) {
8787
////////////////
8888

8989
public override void Load( TagCompound tag ) {
90-
var itemInfo = item.GetGlobalItem<UmbralCowlItemInfo>();
90+
var itemInfo = this.item.GetGlobalItem<UmbralCowlItemInfo>();
9191
itemInfo.IsAllowed = tag.GetBool( "is_allowed_use" );
9292
}
9393

9494
public override TagCompound Save() {
95-
var itemInfo = item.GetGlobalItem<UmbralCowlItemInfo>();
95+
var itemInfo = this.item.GetGlobalItem<UmbralCowlItemInfo>();
9696
return new TagCompound { { "is_allowed_use", (bool)itemInfo.IsAllowed } };
9797
}
9898

@@ -102,15 +102,15 @@ public override TagCompound Save() {
102102
public override void UpdateAccessory( Player player, bool hideVisual ) {
103103
if( player.whoAmI != Main.myPlayer ) { return; } // Current player only
104104

105-
var itemInfo = item.GetGlobalItem<UmbralCowlItemInfo>( this.mod );
105+
var itemInfo = this.item.GetGlobalItem<UmbralCowlItemInfo>();
106106
if( !itemInfo.IsAllowed ) { return; } // Allowed to use
107107

108108
if( ShadowWalkerBuff.CanShadowWalk( player ) ) {
109109
if( ShadowWalkerBuff.FindBuffIndex( this.mod, player ) == -1 ) {
110110
ShadowWalkerBuff.AddBuffFor( this.mod, player );
111111
}
112112

113-
var myplayer = player.GetModPlayer<TheLunaticPlayer>( this.mod );
113+
var myplayer = player.GetModPlayer<TheLunaticPlayer>();
114114
if( myplayer.Noclip != null ) {
115115
myplayer.Noclip.UpdateMode( player ); // Redundant?
116116
}

Logic/GameLogic.cs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
using Terraria;
77
using Terraria.Graphics.Effects;
88
using Terraria.Localization;
9+
using Terraria.ModLoader;
910
using TheLunatic.NetProtocol;
1011
using TheLunatic.NPCs;
1112

@@ -47,7 +48,7 @@ public GameLogic() {
4748

4849
public void LoadOnce( bool hasLoonyArrived, bool hasLoonyQuit, bool hasGameEnded, bool hasWon, bool isSafe, int time ) {
4950
var mymod = TheLunaticMod.Instance;
50-
var myworld = mymod.GetModWorld<TheLunaticWorld>();
51+
var myworld = ModContent.GetInstance<TheLunaticWorld>();
5152

5253
if( this.IsLoaded ) {
5354
LogHelpers.Log( "Redundant Game Logic load. " + hasLoonyArrived + "," + hasLoonyQuit + "," + hasGameEnded + "," + hasWon + "," + isSafe + "," + time +
@@ -130,7 +131,7 @@ public void Update() {
130131
}
131132

132133
if( mymod.Config.DebugModeInfo ) {
133-
var modworld = mymod.GetModWorld<TheLunaticWorld>();
134+
var modworld = ModContent.GetInstance<TheLunaticWorld>();
134135
DebugHelpers.Print( "WorldID", "" + modworld.ID, 20 );
135136
DebugHelpers.Print( "IsApocalypse", "" + this.IsApocalypse, 20 );
136137
DebugHelpers.Print( "IsSafe", "" + this.IsSafe, 20 );
@@ -203,7 +204,7 @@ public void Update() {
203204
public void UpdateMyMusic( ref int music ) {
204205
var mymod = TheLunaticMod.Instance;
205206
Player player = Main.player[Main.myPlayer];
206-
var myplayer = player.GetModPlayer<TheLunaticPlayer>( mymod );
207+
var myplayer = player.GetModPlayer<TheLunaticPlayer>();
207208

208209
if( this.IsApocalypse ) {
209210
if( myplayer.IsInDangerZone ) {
@@ -318,7 +319,7 @@ private bool HaveWeApocalypse() {
318319

319320
private bool HaveWeWon() {
320321
var mymod = TheLunaticMod.Instance;
321-
var myworld = mymod.GetModWorld<TheLunaticWorld>();
322+
var myworld = ModContent.GetInstance<TheLunaticWorld>();
322323

323324
return this.HasWon || ( this.HasLoonyArrived
324325
//&& this.IsSafe

Logic/MaskLogic.cs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
using System.Linq;
77
using Terraria;
88
using Terraria.ID;
9+
using Terraria.ModLoader;
910
using TheLunatic.Items;
1011
using TheLunatic.NetProtocol;
1112

@@ -78,7 +79,7 @@ public static int GetMaskTypeOfNpc( int npcType ) {
7879
npc.SetDefaults( npcType );
7980

8081
if( npc.boss ) {
81-
return mymod.ItemType<CustomBossMaskItem>();
82+
return ModContent.ItemType<CustomBossMaskItem>();
8283
}
8384
return -1;
8485
}
@@ -89,7 +90,7 @@ public static string GetMaskDisplayName( Item maskItem ) {
8990
}
9091

9192
var mymod = TheLunaticMod.Instance;
92-
int customType = mymod.ItemType<CustomBossMaskItem>();
93+
int customType = ModContent.ItemType<CustomBossMaskItem>();
9394
if( maskItem.type == customType && maskItem.modItem != null ) {
9495
var myMaskItem = (CustomBossMaskItem)maskItem.modItem;
9596
if( myMaskItem != null ) {
@@ -136,7 +137,7 @@ public void LoadOnce( int[] masks, string[] customMasks ) {
136137
public void RegisterReceiptOfMask( Player givingPlayer, int maskType, int bossNpcType ) {
137138
var mymod = TheLunaticMod.Instance;
138139

139-
if( maskType == mymod.ItemType<CustomBossMaskItem>() && bossNpcType != 0 && bossNpcType != -1 ) { // -1 for legacy support
140+
if( maskType == ModContent.ItemType<CustomBossMaskItem>() && bossNpcType != 0 && bossNpcType != -1 ) { // -1 for legacy support
140141
NPC npc = new NPC();
141142
npc.SetDefaults( bossNpcType );
142143

@@ -151,7 +152,7 @@ public void RegisterReceiptOfMask( Player givingPlayer, int maskType, int bossNp
151152

152153
// Buy time before the end comes
153154
if( this.GivenVanillaMasksByType.Count < (MaskLogic.AvailableMaskCount) ) {
154-
var modworld = mymod.GetModWorld<TheLunaticWorld>();
155+
var modworld = ModContent.GetInstance<TheLunaticWorld>();
155156
int recovered = mymod.Config.HalfDaysRecoveredPerMask;
156157

157158
switch( maskType ) {
@@ -225,7 +226,7 @@ public void GiveAllVanillaMasks() {
225226

226227
public bool IsValidMask( Item mask ) {
227228
var mymod = TheLunaticMod.Instance;
228-
var myworld = mymod.GetModWorld<TheLunaticWorld>();
229+
var myworld = ModContent.GetInstance<TheLunaticWorld>();
229230
if( !myworld.GameLogic.HaveWeHopeToWin() ) { return false; }
230231

231232
if( !mymod.Config.LoonyAcceptsMasksWithoutBossKill ) {
@@ -304,7 +305,7 @@ public void GiveMaskToLoony( Player player, Item maskItem ) {
304305
}
305306

306307
int bossType = -1;
307-
if( maskItem.type == mymod.ItemType<CustomBossMaskItem>() && maskItem.modItem != null ) {
308+
if( maskItem.type == ModContent.ItemType<CustomBossMaskItem>() && maskItem.modItem != null ) {
308309
bossType = ( (CustomBossMaskItem)maskItem.modItem ).BossNpcType;
309310
} else {
310311
var bossOfMask = MaskLogic.VanillaBossOfMask

NPCs/TheLunaticTownNPC.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ public override bool UsesPartyHat() {
109109
}
110110

111111
public override void AI() {
112-
var myworld = this.mod.GetModWorld<TheLunaticWorld>();
112+
var myworld = ModContent.GetInstance<TheLunaticWorld>();
113113
if( myworld.GameLogic == null ) { throw new ModHelpersException( "Game logic not initialized." ); }
114114

115115
TheLunaticTownNPC.AmHere = true;

NPCs/TheLunaticTownNPC_Interact.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@ partial class TheLunaticTownNPC : ModNPC {
1717

1818
public override void SetChatButtons( ref string button1, ref string button2 ) {
1919
var mymod = (TheLunaticMod)this.mod;
20-
var myworld = this.mod.GetModWorld<TheLunaticWorld>();
20+
var myworld = ModContent.GetInstance<TheLunaticWorld>();
2121
if( myworld.GameLogic == null ) { throw new ModHelpersException( "Game logic not initialized." ); }
2222

2323
Player player = Main.player[Main.myPlayer];
24-
var myplayer = player.GetModPlayer<TheLunaticPlayer>( this.mod );
24+
var myplayer = player.GetModPlayer<TheLunaticPlayer>( );
2525

2626
if( !myplayer.IsCheater() && myworld.GameLogic.HaveWeHopeToWin() ) {
2727
this.FirstButtonIsShop = false;
@@ -50,7 +50,7 @@ public override void OnChatButtonClicked( bool firstButton, ref bool shop ) {
5050

5151
private string onGiveMaskButtonClick() {
5252
var mymod = (TheLunaticMod)this.mod;
53-
var myworld = mymod.GetModWorld<TheLunaticWorld>();
53+
var myworld = ModContent.GetInstance<TheLunaticWorld>();
5454
if( myworld.MaskLogic == null ) { throw new ModHelpersException( "Mask logic not initialized." ); }
5555

5656
Player player = Main.player[Main.myPlayer];
@@ -64,7 +64,7 @@ private string onGiveMaskButtonClick() {
6464

6565
Item mask = PlayerItemFinderHelpers.FindFirstOfPossessedItemFor( player, remainingMasks, false );
6666
if( mask == null ) {
67-
mask = PlayerItemFinderHelpers.FindFirstOfPossessedItemFor( player, new HashSet<int> { mymod.ItemType<CustomBossMaskItem>() }, false );
67+
mask = PlayerItemFinderHelpers.FindFirstOfPossessedItemFor( player, new HashSet<int> { ModContent.ItemType<CustomBossMaskItem>() }, false );
6868
isCustom = mask != null;
6969
isGiven = isCustom && myworld.MaskLogic.DoesLoonyHaveThisMask( mask );
7070
}
@@ -200,7 +200,7 @@ public string GiveMaskReply( Item mask ) {
200200
////
201201

202202
public string GetHint() {
203-
var myworld = this.mod.GetModWorld<TheLunaticWorld>();
203+
var myworld = ModContent.GetInstance<TheLunaticWorld>();
204204
if( myworld.MaskLogic == null ) { throw new ModHelpersException( "Mask logic not initialized." ); }
205205
var masks = myworld.MaskLogic.GetRemainingVanillaMasks();
206206
string msg;

NPCs/TheLunaticTownNPC_InteractChat.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ private static void InitializeReplies() {
3333
public override string GetChat() {
3434
try {
3535
var mymod = (TheLunaticMod)this.mod;
36-
var myworld = mymod.GetModWorld<TheLunaticWorld>();
36+
var myworld = ModContent.GetInstance<TheLunaticWorld>();
3737
if( myworld.GameLogic == null ) { throw new ModHelpersException( "Game logic not initialized." ); }
3838

3939
Player player = Main.player[Main.myPlayer];

NPCs/TheLunaticTownNPC_Shop.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ namespace TheLunatic.NPCs {
99
partial class TheLunaticTownNPC : ModNPC {
1010
public override void SetupShop( Chest shop, ref int nextSlot ) {
1111
var mymod = (TheLunaticMod)this.mod;
12-
var myworld = mymod.GetModWorld<TheLunaticWorld>();
12+
var myworld = ModContent.GetInstance<TheLunaticWorld>();
1313
bool strict = mymod.Config.LoonyEnforcesBossSequence;
1414
bool downedMech = NPC.downedMechBoss1 || NPC.downedMechBoss2 || NPC.downedMechBoss3;
1515
bool downedTowers = NPC.downedTowerSolar && NPC.downedTowerVortex && NPC.downedTowerNebula && NPC.downedTowerStardust;

0 commit comments

Comments
 (0)