BossTypeDict and EncryptedSchematicIDRelationshipDict

This commit is contained in:
Flowaria authored and Cameron Ewell committed 2024-11-13 16:18:35 -05:00
1 parent b603117a57
commit 0e094e8234
6 files changed
+206 -144

No files matched your search

-105
View File
@@ -2,37 +2,6 @@
using System.Collections.Generic;
using CalamityMod.BiomeManagers;
using CalamityMod.Enums;
using CalamityMod.Items.DraedonMisc;
using CalamityMod.NPCs.AquaticScourge;
using CalamityMod.NPCs.AstrumAureus;
using CalamityMod.NPCs.AstrumDeus;
using CalamityMod.NPCs.BrimstoneElemental;
using CalamityMod.NPCs.Bumblebirb;
using CalamityMod.NPCs.CalClone;
using CalamityMod.NPCs.CeaselessVoid;
using CalamityMod.NPCs.Crabulon;
using CalamityMod.NPCs.Cryogen;
using CalamityMod.NPCs.DesertScourge;
using CalamityMod.NPCs.DevourerofGods;
using CalamityMod.NPCs.ExoMechs.Apollo;
using CalamityMod.NPCs.ExoMechs.Ares;
using CalamityMod.NPCs.ExoMechs.Artemis;
using CalamityMod.NPCs.ExoMechs.Thanatos;
using CalamityMod.NPCs.HiveMind;
using CalamityMod.NPCs.Leviathan;
using CalamityMod.NPCs.OldDuke;
using CalamityMod.NPCs.Perforator;
using CalamityMod.NPCs.PlaguebringerGoliath;
using CalamityMod.NPCs.Polterghast;
using CalamityMod.NPCs.ProfanedGuardians;
using CalamityMod.NPCs.Providence;
using CalamityMod.NPCs.Ravager;
using CalamityMod.NPCs.Signus;
using CalamityMod.NPCs.SlimeGod;
using CalamityMod.NPCs.StormWeaver;
using CalamityMod.NPCs.SupremeCalamitas;
using CalamityMod.NPCs.Yharon;
using Terraria.ID;
using Terraria.ModLoader;
using static Terraria.ModLoader.ModContent;
@@ -40,10 +9,6 @@ namespace CalamityMod
{
public sealed class CalamityLists : ModSystem
{
public static SortedDictionary<int, int> bossTypes;
public static Dictionary<int, int> EncryptedSchematicIDRelationship;
/// <summary>
/// Each Sunken Sea subbiome has a correspoding spawn condition boolean value and a biome type.
/// </summary>
@@ -51,71 +16,6 @@ namespace CalamityMod
public override void OnModLoad()
{
bossTypes = new SortedDictionary<int, int>()
{
{ NPCID.KingSlime, 1 },
{ NPCType<DesertScourgeHead>(), 2 },
{ NPCID.EyeofCthulhu, 3 },
{ NPCType<Crabulon>(), 4 },
{ NPCID.EaterofWorldsHead, 5 },
{ NPCID.EaterofWorldsBody, 5 },
{ NPCID.EaterofWorldsTail, 5 },
{ NPCID.BrainofCthulhu, 6 },
{ NPCType<HiveMind>(), 7 },
{ NPCType<PerforatorHive>(), 8 },
{ NPCID.QueenBee, 9 },
{ NPCID.SkeletronHead, 10 },
{ NPCType<SlimeGodCore>(), 11 },
{ NPCType<SplitEbonianPaladin>(), 11 },
{ NPCType<SplitCrimulanPaladin>(), 11 },
{ NPCID.WallofFlesh, 12 },
{ NPCType<Cryogen>(), 13 },
{ NPCID.Retinazer, 14 },
{ NPCID.Spazmatism, 14 },
{ NPCType<AquaticScourgeHead>(), 15 },
{ NPCID.TheDestroyer, 16 },
{ NPCType<BrimstoneElemental>(), 17 },
{ NPCID.SkeletronPrime, 18 },
{ NPCType<CalamitasClone>(), 19 },
{ NPCID.Plantera, 20 },
{ NPCType<Leviathan>(), 21 },
{ NPCType<Anahita>(), 21 },
{ NPCType<AstrumAureus>(), 22 },
{ NPCID.Golem, 23 },
{ NPCType<PlaguebringerGoliath>(), 24 },
{ NPCID.DukeFishron, 25 },
{ NPCType<RavagerBody>(), 26 },
{ NPCID.CultistBoss, 27 },
{ NPCType<AstrumDeusHead>(), 28 },
{ NPCID.MoonLordCore, 29 },
{ NPCType<ProfanedGuardianCommander>(), 30 },
{ NPCType<Bumblefuck>(), 31 },
{ NPCType<Providence>(), 32 },
{ NPCType<CeaselessVoid>(), 33 },
{ NPCType<StormWeaverHead>(), 34 },
{ NPCType<Signus>(), 35 },
{ NPCType<Polterghast>(), 36 },
{ NPCType<OldDuke>(), 37 },
{ NPCType<DevourerofGodsHead>(), 38 },
{ NPCType<Yharon>(), 39 },
{ NPCType<SupremeCalamitas>(), 40 },
{ NPCType<AresBody>(), 41 },
{ NPCType<ThanatosHead>(), 41 },
{ NPCType<Artemis>(), 41 },
{ NPCType<Apollo>(), 41 },
{ NPCID.QueenSlimeBoss, 42 },
{ NPCID.HallowBoss, 43 },
{ NPCID.Deerclops, 44 }
};
EncryptedSchematicIDRelationship = new Dictionary<int, int>()
{
[1] = ItemType<EncryptedSchematicPlanetoid>(),
[2] = ItemType<EncryptedSchematicJungle>(),
[3] = ItemType<EncryptedSchematicHell>(),
[4] = ItemType<EncryptedSchematicIce>(),
};
SunkenSeaBiomeCorrespondentValues = new()
{
{ SunkenSeaBiomeFlags.UndergroundDesert, (spawnInfo => spawnInfo.Player.ZoneDesert, -1 /* None needed. */) },
@@ -129,11 +29,6 @@ namespace CalamityMod
public override void Unload()
{
bossTypes?.Clear();
bossTypes = null;
EncryptedSchematicIDRelationship = null;
SunkenSeaBiomeCorrespondentValues = null;
}
}
+1 -1
View File
@@ -8637,7 +8637,7 @@ namespace CalamityMod.NPCs
{
if (!GetDownedBossVariable(npc.type))
{
CalamityLists.bossTypes.TryGetValue(npc.type, out int newBossTypeJustDowned);
BossTypeDict.TryGet(npc.type, out int newBossTypeJustDowned);
for (int i = 0; i < Main.maxPlayers; i++)
{
@@ -0,0 +1,52 @@
using System.Collections.Generic;
using System.Linq;
using CalamityMod.Items.DraedonMisc;
using Terraria.ModLoader;
using static Terraria.ModLoader.ModContent;
namespace CalamityMod.Systems.Collections
{
public sealed class EncryptedSchematicIDRelationshipDict : ModSystem
{
public static IDictionary<int, int> Dict { get; private set; }
public override void OnModLoad()
{
var dict = new Dictionary<int, int>()
{
[1] = ItemType<EncryptedSchematicPlanetoid>(),
[2] = ItemType<EncryptedSchematicJungle>(),
[3] = ItemType<EncryptedSchematicHell>(),
[4] = ItemType<EncryptedSchematicIce>(),
};
Dict = dict;
}
public override void Unload()
{
Dict?.Clear();
Dict = null;
}
public static bool TryGet(int schematicID, out int schematicItemType)
{
return Dict.TryGetValue(schematicID, out schematicItemType);
}
public static bool TryGetKey(int schematicItemType, out int schematicID)
{
try
{
var pair = Dict.First(pair => pair.Value == schematicItemType);
schematicID = pair.Key;
return true;
}
catch
{
schematicID = 0;
return false;
}
}
}
}
+112
View File
@@ -0,0 +1,112 @@
using System.Collections.Generic;
using CalamityMod.NPCs.AquaticScourge;
using CalamityMod.NPCs.AstrumAureus;
using CalamityMod.NPCs.AstrumDeus;
using CalamityMod.NPCs.BrimstoneElemental;
using CalamityMod.NPCs.Bumblebirb;
using CalamityMod.NPCs.CalClone;
using CalamityMod.NPCs.CeaselessVoid;
using CalamityMod.NPCs.Crabulon;
using CalamityMod.NPCs.Cryogen;
using CalamityMod.NPCs.DesertScourge;
using CalamityMod.NPCs.DevourerofGods;
using CalamityMod.NPCs.ExoMechs.Apollo;
using CalamityMod.NPCs.ExoMechs.Ares;
using CalamityMod.NPCs.ExoMechs.Artemis;
using CalamityMod.NPCs.ExoMechs.Thanatos;
using CalamityMod.NPCs.HiveMind;
using CalamityMod.NPCs.Leviathan;
using CalamityMod.NPCs.OldDuke;
using CalamityMod.NPCs.Perforator;
using CalamityMod.NPCs.PlaguebringerGoliath;
using CalamityMod.NPCs.Polterghast;
using CalamityMod.NPCs.ProfanedGuardians;
using CalamityMod.NPCs.Providence;
using CalamityMod.NPCs.Ravager;
using CalamityMod.NPCs.Signus;
using CalamityMod.NPCs.SlimeGod;
using CalamityMod.NPCs.StormWeaver;
using CalamityMod.NPCs.SupremeCalamitas;
using CalamityMod.NPCs.Yharon;
using Terraria.ID;
using Terraria.ModLoader;
using static Terraria.ModLoader.ModContent;
namespace CalamityMod.Systems.Collections
{
public sealed class BossTypeDict : ModSystem
{
public static IDictionary<int, int> Dict { get; private set; }
public override void OnModLoad()
{
Dict = new SortedDictionary<int, int>()
{
{ NPCID.KingSlime, 1 },
{ NPCType<DesertScourgeHead>(), 2 },
{ NPCID.EyeofCthulhu, 3 },
{ NPCType<Crabulon>(), 4 },
{ NPCID.EaterofWorldsHead, 5 },
{ NPCID.EaterofWorldsBody, 5 },
{ NPCID.EaterofWorldsTail, 5 },
{ NPCID.BrainofCthulhu, 6 },
{ NPCType<HiveMind>(), 7 },
{ NPCType<PerforatorHive>(), 8 },
{ NPCID.QueenBee, 9 },
{ NPCID.SkeletronHead, 10 },
{ NPCType<SlimeGodCore>(), 11 },
{ NPCType<SplitEbonianPaladin>(), 11 },
{ NPCType<SplitCrimulanPaladin>(), 11 },
{ NPCID.WallofFlesh, 12 },
{ NPCType<Cryogen>(), 13 },
{ NPCID.Retinazer, 14 },
{ NPCID.Spazmatism, 14 },
{ NPCType<AquaticScourgeHead>(), 15 },
{ NPCID.TheDestroyer, 16 },
{ NPCType<BrimstoneElemental>(), 17 },
{ NPCID.SkeletronPrime, 18 },
{ NPCType<CalamitasClone>(), 19 },
{ NPCID.Plantera, 20 },
{ NPCType<Leviathan>(), 21 },
{ NPCType<Anahita>(), 21 },
{ NPCType<AstrumAureus>(), 22 },
{ NPCID.Golem, 23 },
{ NPCType<PlaguebringerGoliath>(), 24 },
{ NPCID.DukeFishron, 25 },
{ NPCType<RavagerBody>(), 26 },
{ NPCID.CultistBoss, 27 },
{ NPCType<AstrumDeusHead>(), 28 },
{ NPCID.MoonLordCore, 29 },
{ NPCType<ProfanedGuardianCommander>(), 30 },
{ NPCType<Bumblefuck>(), 31 },
{ NPCType<Providence>(), 32 },
{ NPCType<CeaselessVoid>(), 33 },
{ NPCType<StormWeaverHead>(), 34 },
{ NPCType<Signus>(), 35 },
{ NPCType<Polterghast>(), 36 },
{ NPCType<OldDuke>(), 37 },
{ NPCType<DevourerofGodsHead>(), 38 },
{ NPCType<Yharon>(), 39 },
{ NPCType<SupremeCalamitas>(), 40 },
{ NPCType<AresBody>(), 41 },
{ NPCType<ThanatosHead>(), 41 },
{ NPCType<Artemis>(), 41 },
{ NPCType<Apollo>(), 41 },
{ NPCID.QueenSlimeBoss, 42 },
{ NPCID.HallowBoss, 43 },
{ NPCID.Deerclops, 44 }
};
}
public override void Unload()
{
Dict?.Clear();
Dict = null;
}
public static bool TryGet(int npcType, out int type)
{
return Dict.TryGetValue(npcType, out type);
}
}
}
+24 -28
View File
@@ -3,6 +3,7 @@ using CalamityMod.CustomRecipes;
using CalamityMod.Items.DraedonMisc;
using CalamityMod.Items.Materials;
using CalamityMod.Packets;
using CalamityMod.Systems.Collections;
using CalamityMod.Tiles.DraedonSummoner;
using Microsoft.Xna.Framework;
using Terraria;
@@ -39,17 +40,16 @@ namespace CalamityMod.TileEntities
get
{
// You can't decrypt nothing.
if (HeldSchematicID == 0 || !CalamityLists.EncryptedSchematicIDRelationship.ContainsKey(HeldSchematicID))
if (HeldSchematicID == 0 || !EncryptedSchematicIDRelationshipDict.TryGet(HeldSchematicID, out var schematicItemType))
return 0;
int schematicType = CalamityLists.EncryptedSchematicIDRelationship[HeldSchematicID];
if (schematicType == ModContent.ItemType<EncryptedSchematicPlanetoid>())
if (schematicItemType == ModContent.ItemType<EncryptedSchematicPlanetoid>())
return 500;
if (schematicType == ModContent.ItemType<EncryptedSchematicJungle>())
if (schematicItemType == ModContent.ItemType<EncryptedSchematicJungle>())
return 950;
if (schematicType == ModContent.ItemType<EncryptedSchematicHell>())
if (schematicItemType == ModContent.ItemType<EncryptedSchematicHell>())
return 1750;
if (schematicType == ModContent.ItemType<EncryptedSchematicIce>())
if (schematicItemType == ModContent.ItemType<EncryptedSchematicIce>())
return 5000;
return 0;
@@ -72,17 +72,16 @@ namespace CalamityMod.TileEntities
get
{
// You can't decrypt nothing.
if (HeldSchematicID == 0 || !CalamityLists.EncryptedSchematicIDRelationship.ContainsKey(HeldSchematicID))
if (HeldSchematicID == 0 || !EncryptedSchematicIDRelationshipDict.TryGet(HeldSchematicID, out var schematicItemType))
return false;
int schematicType = CalamityLists.EncryptedSchematicIDRelationship[HeldSchematicID];
if (schematicType == ModContent.ItemType<EncryptedSchematicPlanetoid>())
if (schematicItemType == ModContent.ItemType<EncryptedSchematicPlanetoid>())
return ContainsDecryptionComputer;
if (schematicType == ModContent.ItemType<EncryptedSchematicJungle>())
if (schematicItemType == ModContent.ItemType<EncryptedSchematicJungle>())
return ContainsDecryptionComputer && ContainsSensorArray;
if (schematicType == ModContent.ItemType<EncryptedSchematicHell>())
if (schematicItemType == ModContent.ItemType<EncryptedSchematicHell>())
return ContainsDecryptionComputer && ContainsSensorArray && ContainsAdvancedDisplay;
if (schematicType == ModContent.ItemType<EncryptedSchematicIce>())
if (schematicItemType == ModContent.ItemType<EncryptedSchematicIce>())
return ContainsDecryptionComputer && ContainsSensorArray && ContainsAdvancedDisplay && ContainsVoltageRegulationSystem;
return false;
@@ -94,15 +93,14 @@ namespace CalamityMod.TileEntities
get
{
// You can't decrypt nothing.
if (HeldSchematicID == 0 || !CalamityLists.EncryptedSchematicIDRelationship.ContainsKey(HeldSchematicID))
if (HeldSchematicID == 0 || !EncryptedSchematicIDRelationshipDict.TryGet(HeldSchematicID, out var schematicItemType))
return string.Empty;
int schematicType = CalamityLists.EncryptedSchematicIDRelationship[HeldSchematicID];
if (schematicType == ModContent.ItemType<EncryptedSchematicPlanetoid>()
|| schematicType == ModContent.ItemType<EncryptedSchematicJungle>()
|| schematicType == ModContent.ItemType<EncryptedSchematicHell>()
|| schematicType == ModContent.ItemType<EncryptedSchematicIce>())
return CalamityUtils.GetTextValueFromModItem(schematicType, "Content");
if (schematicItemType == ModContent.ItemType<EncryptedSchematicPlanetoid>()
|| schematicItemType == ModContent.ItemType<EncryptedSchematicJungle>()
|| schematicItemType == ModContent.ItemType<EncryptedSchematicHell>()
|| schematicItemType == ModContent.ItemType<EncryptedSchematicIce>())
return CalamityUtils.GetTextValueFromModItem(schematicItemType, "Content");
return string.Empty;
}
@@ -155,8 +153,8 @@ namespace CalamityMod.TileEntities
if (ContainsCoolingCell)
Item.NewItem(source, x * 16, y * 16, 32, 32, ModContent.ItemType<AuricQuantumCoolingCell>());
if (CalamityLists.EncryptedSchematicIDRelationship.ContainsKey(HeldSchematicID))
Item.NewItem(source, x * 16, y * 16, 32, 32, CalamityLists.EncryptedSchematicIDRelationship[HeldSchematicID]);
if (EncryptedSchematicIDRelationshipDict.TryGet(HeldSchematicID, out var schematicItemType))
Item.NewItem(source, x * 16, y * 16, 32, 32, schematicItemType);
while (InputtedCellCount > 0)
{
@@ -233,27 +231,25 @@ namespace CalamityMod.TileEntities
anythingChanged = false;
// Do nothing if no valid schematic is inputted at the moment.
if (!CalamityLists.EncryptedSchematicIDRelationship.ContainsKey(HeldSchematicID))
if (!EncryptedSchematicIDRelationshipDict.TryGet(HeldSchematicID, out var schematicItemType))
return;
int schematicType = CalamityLists.EncryptedSchematicIDRelationship[HeldSchematicID];
if (!RecipeUnlockHandler.HasUnlockedT2ArsenalRecipes && schematicType == ModContent.ItemType<EncryptedSchematicPlanetoid>())
if (!RecipeUnlockHandler.HasUnlockedT2ArsenalRecipes && schematicItemType == ModContent.ItemType<EncryptedSchematicPlanetoid>())
{
RecipeUnlockHandler.HasUnlockedT2ArsenalRecipes = true;
anythingChanged = true;
}
if (!RecipeUnlockHandler.HasUnlockedT3ArsenalRecipes && schematicType == ModContent.ItemType<EncryptedSchematicJungle>())
if (!RecipeUnlockHandler.HasUnlockedT3ArsenalRecipes && schematicItemType == ModContent.ItemType<EncryptedSchematicJungle>())
{
RecipeUnlockHandler.HasUnlockedT3ArsenalRecipes = true;
anythingChanged = true;
}
if (!RecipeUnlockHandler.HasUnlockedT4ArsenalRecipes && schematicType == ModContent.ItemType<EncryptedSchematicHell>())
if (!RecipeUnlockHandler.HasUnlockedT4ArsenalRecipes && schematicItemType == ModContent.ItemType<EncryptedSchematicHell>())
{
RecipeUnlockHandler.HasUnlockedT4ArsenalRecipes = true;
anythingChanged = true;
}
if (!RecipeUnlockHandler.HasUnlockedT5ArsenalRecipes && schematicType == ModContent.ItemType<EncryptedSchematicIce>())
if (!RecipeUnlockHandler.HasUnlockedT5ArsenalRecipes && schematicItemType == ModContent.ItemType<EncryptedSchematicIce>())
{
RecipeUnlockHandler.HasUnlockedT5ArsenalRecipes = true;
anythingChanged = true;
+17 -10
View File
@@ -1,10 +1,10 @@
using System;
using System.Linq;
using System.Text;
using CalamityMod.Items.DraedonMisc;
using CalamityMod.Items.Materials;
using CalamityMod.NPCs.ExoMechs;
using CalamityMod.Packets;
using CalamityMod.Systems.Collections;
using CalamityMod.TileEntities;
using CalamityMod.World;
using Microsoft.Xna.Framework;
@@ -228,7 +228,7 @@ namespace CalamityMod.UI.DraedonSummoning
int schematicType = 0;
if (codebreakerTileEntity.HeldSchematicID > 0)
schematicType = CalamityLists.EncryptedSchematicIDRelationship[codebreakerTileEntity.HeldSchematicID];
schematicType = EncryptedSchematicIDRelationshipDict.Dict[codebreakerTileEntity.HeldSchematicID];
if (schematicType == ModContent.ItemType<EncryptedSchematicPlanetoid>())
schematicIconTexture = ModContent.Request<Texture2D>("CalamityMod/Items/DraedonMisc/EncryptedSchematicPlanetoid").Value;
@@ -422,9 +422,16 @@ namespace CalamityMod.UI.DraedonSummoning
{
// If the player's hand item is empty and the codebreaker has a schematic, grab it.
// This doesn't work if the Codebreaker is busy decrypting the schematic in question.
if (playerHandItem.IsAir && CalamityLists.EncryptedSchematicIDRelationship.ContainsKey(codebreakerTileEntity.HeldSchematicID) && codebreakerTileEntity.DecryptionCountdown <= 0)
bool isAir = playerHandItem.IsAir;
bool countdownDone = codebreakerTileEntity.DecryptionCountdown <= 0;
bool hasValidSchematicID = EncryptedSchematicIDRelationshipDict.TryGet(codebreakerTileEntity.HeldSchematicID, out var schematicItemType);
bool hasHandHoldingValidSchematicItem = EncryptedSchematicIDRelationshipDict.TryGetKey(playerHandItem.type, out var handHoldSchematicID);
bool hasMouseHoldingValidSchematicItem = EncryptedSchematicIDRelationshipDict.TryGetKey(Main.mouseItem.type, out var mouseHoldSchematicID);
if (isAir && countdownDone && hasValidSchematicID)
{
playerHandItem.SetDefaults(CalamityLists.EncryptedSchematicIDRelationship[codebreakerTileEntity.HeldSchematicID]);
playerHandItem.SetDefaults(schematicItemType);
codebreakerTileEntity.HeldSchematicID = 0;
codebreakerTileEntity.DecryptionCountdown = 0;
codebreakerTileEntity.SyncContainedStuff();
@@ -434,9 +441,9 @@ namespace CalamityMod.UI.DraedonSummoning
}
// Otherwise, if the player has an encrypted schematic and the Codebreaker doesn't, insert it into the machine.
else if (CalamityLists.EncryptedSchematicIDRelationship.ContainsValue(playerHandItem.type) && codebreakerTileEntity.HeldSchematicID == 0)
else if (hasHandHoldingValidSchematicItem && hasMouseHoldingValidSchematicItem && codebreakerTileEntity.HeldSchematicID == 0)
{
codebreakerTileEntity.HeldSchematicID = CalamityLists.EncryptedSchematicIDRelationship.First(i => i.Value == Main.mouseItem.type).Key;
codebreakerTileEntity.HeldSchematicID = mouseHoldSchematicID;
playerHandItem.TurnToAir();
codebreakerTileEntity.SyncContainedStuff();
SoundEngine.PlaySound(SoundID.Grab);
@@ -445,15 +452,15 @@ namespace CalamityMod.UI.DraedonSummoning
}
// Lastly, if the player has an encrypted schematic but so does the Codebreaker, swap the two.
else if (CalamityLists.EncryptedSchematicIDRelationship.ContainsValue(playerHandItem.type) && codebreakerTileEntity.HeldSchematicID != 0)
else if (hasHandHoldingValidSchematicItem && hasValidSchematicID)
{
int previouslyHeldSchematic = CalamityLists.EncryptedSchematicIDRelationship[codebreakerTileEntity.HeldSchematicID];
int previouslyHeldSchematic = schematicItemType;
// If the schematics are the same, don't actually do anything, just play the sound as an illusion, to prevent having to send a packet.
SoundEngine.PlaySound(SoundID.Grab);
if (playerHandItem.type != previouslyHeldSchematic)
if (playerHandItem.type != previouslyHeldSchematic && hasMouseHoldingValidSchematicItem)
{
codebreakerTileEntity.HeldSchematicID = CalamityLists.EncryptedSchematicIDRelationship.First(i => i.Value == Main.mouseItem.type).Key;
codebreakerTileEntity.HeldSchematicID = mouseHoldSchematicID;
playerHandItem.SetDefaults(previouslyHeldSchematic);
codebreakerTileEntity.SyncContainedStuff();
AwaitingDecryptionTextClose = false;