Schematic expansion stuff

This commit is contained in:
Dominic committed 2021-05-31 17:38:57 -05:00
1 parent 49ec48d577
commit 394b37f4be
17 files changed
+295 -24

No files matched your search

+13
View File
@@ -5,6 +5,7 @@ using CalamityMod.Items.Accessories;
using CalamityMod.Items.Accessories.Wings;
using CalamityMod.Items.Ammo.FiniteUse;
using CalamityMod.Items.Armor.Vanity;
using CalamityMod.Items.DraedonMisc;
using CalamityMod.Items.Fishing.AstralCatches;
using CalamityMod.Items.Fishing.BrimstoneCragCatches;
using CalamityMod.Items.Fishing.FishingRods;
@@ -155,6 +156,8 @@ namespace CalamityMod
public static List<int> ZeroMinionSlotExceptionList;
public static List<int> DontCopyOriginalMinionAIList;
public static Dictionary<int, int> EncryptedSchematicIDRelationship;
public static void LoadLists()
{
donatorList = new List<string>()
@@ -2506,6 +2509,14 @@ namespace CalamityMod
{
ProjectileType<GammaHead>()
};
EncryptedSchematicIDRelationship = new Dictionary<int, int>()
{
[1] = ItemType<EncryptedSchematicPlanetoid>(),
[2] = ItemType<EncryptedSchematicJungle>(),
[3] = ItemType<EncryptedSchematicHell>(),
[4] = ItemType<EncryptedSchematicIce>(),
};
}
public static void UnloadLists()
@@ -2594,6 +2605,8 @@ namespace CalamityMod
MinionsToNotResurrectList = null;
ZeroMinionSlotExceptionList = null;
DontCopyOriginalMinionAIList = null;
EncryptedSchematicIDRelationship = null;
}
}
}
+28
View File
@@ -0,0 +1,28 @@
using Terraria.ModLoader;
namespace CalamityMod.CustomRecipes
{
public class ArsenalTierGatedRecipe : ModRecipe
{
public int Tier;
public ArsenalTierGatedRecipe(Mod mod, int tier) : base(mod) => Tier = tier;
public override bool RecipeAvailable()
{
switch (Tier)
{
case 1:
return RecipeUnlockHandler.HasUnlockedT1ArsenalRecipes;
case 2:
return RecipeUnlockHandler.HasUnlockedT2ArsenalRecipes;
case 3:
return RecipeUnlockHandler.HasUnlockedT3ArsenalRecipes;
case 4:
return RecipeUnlockHandler.HasUnlockedT4ArsenalRecipes;
case 5:
return RecipeUnlockHandler.HasUnlockedT5ArsenalRecipes;
}
return false;
}
}
}
+55
View File
@@ -0,0 +1,55 @@
using System.Collections.Generic;
using System.IO;
using Terraria;
namespace CalamityMod.CustomRecipes
{
public static class RecipeUnlockHandler
{
public static bool HasUnlockedT1ArsenalRecipes = false;
public static bool HasUnlockedT2ArsenalRecipes = false;
public static bool HasUnlockedT3ArsenalRecipes = false;
public static bool HasUnlockedT4ArsenalRecipes = false;
public static bool HasUnlockedT5ArsenalRecipes = false;
public static void Save(List<string> boolTagContainer)
{
boolTagContainer.AddWithCondition("HasUnlockedT1ArsenalRecipes", HasUnlockedT1ArsenalRecipes);
boolTagContainer.AddWithCondition("HasUnlockedT2ArsenalRecipes", HasUnlockedT2ArsenalRecipes);
boolTagContainer.AddWithCondition("HasUnlockedT3ArsenalRecipes", HasUnlockedT3ArsenalRecipes);
boolTagContainer.AddWithCondition("HasUnlockedT4ArsenalRecipes", HasUnlockedT4ArsenalRecipes);
boolTagContainer.AddWithCondition("HasUnlockedT5ArsenalRecipes", HasUnlockedT5ArsenalRecipes);
}
public static void Load(IList<string> boolTagContainer)
{
HasUnlockedT1ArsenalRecipes = boolTagContainer.Contains("HasUnlockedT1ArsenalRecipes");
HasUnlockedT2ArsenalRecipes = boolTagContainer.Contains("HasUnlockedT2ArsenalRecipes");
HasUnlockedT3ArsenalRecipes = boolTagContainer.Contains("HasUnlockedT3ArsenalRecipes");
HasUnlockedT4ArsenalRecipes = boolTagContainer.Contains("HasUnlockedT4ArsenalRecipes");
HasUnlockedT5ArsenalRecipes = boolTagContainer.Contains("HasUnlockedT5ArsenalRecipes");
}
public static void SendData(BinaryWriter writer)
{
BitsByte flags = new BitsByte();
flags[0] = HasUnlockedT1ArsenalRecipes;
flags[1] = HasUnlockedT2ArsenalRecipes;
flags[2] = HasUnlockedT3ArsenalRecipes;
flags[3] = HasUnlockedT4ArsenalRecipes;
flags[4] = HasUnlockedT5ArsenalRecipes;
writer.Write(flags);
}
public static void ReceiveData(BinaryReader reader)
{
BitsByte flags = reader.ReadByte();
HasUnlockedT1ArsenalRecipes = flags[0];
HasUnlockedT2ArsenalRecipes = flags[1];
HasUnlockedT3ArsenalRecipes = flags[2];
HasUnlockedT4ArsenalRecipes = flags[3];
HasUnlockedT5ArsenalRecipes = flags[4];
}
}
}
@@ -0,0 +1,23 @@
using Terraria.ID;
using Terraria.ModLoader;
namespace CalamityMod.Items.DraedonMisc
{
public class EncryptedSchematicHell : ModItem
{
public override void SetStaticDefaults()
{
DisplayName.SetDefault("Encrypted Schematic");
Tooltip.SetDefault("Requires a Codebreaker with a sophisticated display to decrypt");
}
public override void SetDefaults()
{
item.width = 42;
item.height = 42;
item.rare = ItemRarityID.Red;
item.Calamity().customRarity = CalamityRarity.DraedonRust;
item.maxStack = 1;
}
}
}
File renamed without changes.

Before

Width:  |  Height:  |  Size: 611 B

After

Width:  |  Height:  |  Size: 611 B

@@ -0,0 +1,23 @@
using Terraria.ID;
using Terraria.ModLoader;
namespace CalamityMod.Items.DraedonMisc
{
public class EncryptedSchematicIce : ModItem
{
public override void SetStaticDefaults()
{
DisplayName.SetDefault("Encrypted Schematic");
Tooltip.SetDefault("Requires a Codebreaker with a complex voltage regulation system to decrypt");
}
public override void SetDefaults()
{
item.width = 42;
item.height = 42;
item.rare = ItemRarityID.Red;
item.Calamity().customRarity = CalamityRarity.DraedonRust;
item.maxStack = 1;
}
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 611 B

@@ -0,0 +1,23 @@
using Terraria.ID;
using Terraria.ModLoader;
namespace CalamityMod.Items.DraedonMisc
{
public class EncryptedSchematicJungle : ModItem
{
public override void SetStaticDefaults()
{
DisplayName.SetDefault("Encrypted Schematic");
Tooltip.SetDefault("Requires a Codebreaker with a fine tuned, long range sensor to decrypt");
}
public override void SetDefaults()
{
item.width = 42;
item.height = 42;
item.rare = ItemRarityID.Red;
item.Calamity().customRarity = CalamityRarity.DraedonRust;
item.maxStack = 1;
}
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 611 B

@@ -3,12 +3,12 @@ using Terraria.ModLoader;
namespace CalamityMod.Items.DraedonMisc
{
public class EncryptedSchematic : ModItem
public class EncryptedSchematicPlanetoid : ModItem
{
public override void SetStaticDefaults()
{
DisplayName.SetDefault("Encrypted Schematic");
Tooltip.SetDefault("May be deciphered at the Codebreaker if it is upgraded enough");
Tooltip.SetDefault("Requires a Codebreaker with a computer to decrypt");
}
public override void SetDefaults()
@@ -17,7 +17,7 @@ namespace CalamityMod.Items.DraedonMisc
item.height = 42;
item.rare = ItemRarityID.Red;
item.Calamity().customRarity = CalamityRarity.DraedonRust;
item.maxStack = 999;
item.maxStack = 1;
}
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 611 B

@@ -0,0 +1,24 @@
using Terraria.ID;
using Terraria.ModLoader;
namespace CalamityMod.Items.DraedonMisc
{
public class EncryptedSchematicSunkenSea : ModItem
{
public override void SetStaticDefaults()
{
DisplayName.SetDefault("Schematic");
Tooltip.SetDefault("You can barely make out its text. It states:\n" +
"Something idk");
}
public override void SetDefaults()
{
item.width = 42;
item.height = 42;
item.rare = ItemRarityID.Red;
item.Calamity().customRarity = CalamityRarity.DraedonRust;
item.maxStack = 1;
}
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 611 B

+59 -7
View File
@@ -13,7 +13,7 @@ namespace CalamityMod.TileEntities
public class TECodebreaker : ModTileEntity
{
public int InputtedCellCount;
public bool HasSchematic;
public int HeldSchematicID;
public int DecryptionCountdown;
public int DecryptionTotalTime => 1800;
@@ -24,6 +24,51 @@ namespace CalamityMod.TileEntities
public bool ContainsAdvancedDisplay;
public bool ContainsVoltageRegulationSystem;
public bool ContainsCoolingCell;
public bool CanDecryptHeldSchematic
{
get
{
// You can't decrypt nothing.
if (HeldSchematicID == 0)
return false;
int schematicType = CalamityLists.EncryptedSchematicIDRelationship[HeldSchematicID];
if (schematicType == ModContent.ItemType<EncryptedSchematicPlanetoid>())
return ContainsDecryptionComputer;
if (schematicType == ModContent.ItemType<EncryptedSchematicJungle>())
return ContainsDecryptionComputer && ContainsSensorArray;
if (schematicType == ModContent.ItemType<EncryptedSchematicHell>())
return ContainsDecryptionComputer && ContainsSensorArray && ContainsAdvancedDisplay;
if (schematicType == ModContent.ItemType<EncryptedSchematicIce>())
return ContainsDecryptionComputer && ContainsSensorArray && ContainsAdvancedDisplay && ContainsVoltageRegulationSystem;
return false;
}
}
public string UnderlyingSchematicText
{
get
{
// You can't decrypt nothing.
if (HeldSchematicID == 0)
return string.Empty;
int schematicType = CalamityLists.EncryptedSchematicIDRelationship[HeldSchematicID];
if (schematicType == ModContent.ItemType<EncryptedSchematicPlanetoid>())
return "test1";
if (schematicType == ModContent.ItemType<EncryptedSchematicJungle>())
return "test2";
if (schematicType == ModContent.ItemType<EncryptedSchematicHell>())
return "test3";
if (schematicType == ModContent.ItemType<EncryptedSchematicIce>())
return "test4";
return string.Empty;
}
}
public Vector2 Center => Position.ToWorldCoordinates(8f * CodebreakerTile.Width, 8f * CodebreakerTile.Height);
// This guarantees that this tile entity will not persist if not placed directly on the top left corner of a Charging Station tile.
@@ -56,7 +101,7 @@ namespace CalamityMod.TileEntities
public override void Update() => UpdateTime();
public void DropConstituents(int x, int y)
public void DropConstituents(int x, int y)
{
if (ContainsDecryptionComputer)
Item.NewItem(x * 16, y * 16, 32, 32, ModContent.ItemType<DecryptionComputer>());
@@ -68,7 +113,10 @@ namespace CalamityMod.TileEntities
Item.NewItem(x * 16, y * 16, 32, 32, ModContent.ItemType<VoltageRegulationSystem>());
if (ContainsCoolingCell)
Item.NewItem(x * 16, y * 16, 32, 32, ModContent.ItemType<AuricQuantumCoolingCell>());
}
if (HeldSchematicID != 0)
Item.NewItem(x * 16, y * 16, 32, 32, CalamityLists.EncryptedSchematicIDRelationship[HeldSchematicID]);
}
public void SyncConstituents()
{
@@ -125,7 +173,7 @@ namespace CalamityMod.TileEntities
packet.Write((byte)CalamityModMessageType.UpdateCodebreakerContainedStuff);
packet.Write(ID);
packet.Write(InputtedCellCount);
packet.Write(HasSchematic);
packet.Write(HeldSchematicID);
}
public static void ReadContainmentSync(Mod mod, BinaryReader reader)
@@ -136,7 +184,7 @@ namespace CalamityMod.TileEntities
// Continue reading to the end even if a tile entity with the given ID does not exist.
// Not doing this will cause errors/bugs.
int cellCount = reader.ReadInt32();
bool hasSchematic = reader.ReadBoolean();
int schematicID = reader.ReadInt32();
// After doing reading, check again to see if the tile entity is actually there.
// If it isn't don't bother doing anything else.
@@ -148,7 +196,7 @@ namespace CalamityMod.TileEntities
return;
codebreakerTileEntity.InputtedCellCount = cellCount;
codebreakerTileEntity.HasSchematic = hasSchematic;
codebreakerTileEntity.HeldSchematicID = schematicID;
}
public void UpdateTime()
@@ -165,7 +213,8 @@ namespace CalamityMod.TileEntities
["ContainsSensorArray"] = ContainsSensorArray,
["ContainsAdvancedDisplay"] = ContainsAdvancedDisplay,
["ContainsVoltageRegulationSystem"] = ContainsVoltageRegulationSystem,
["ContainsCoolingCell"] = ContainsCoolingCell
["ContainsCoolingCell"] = ContainsCoolingCell,
["HeldSchematicID"] = HeldSchematicID
};
}
@@ -176,6 +225,7 @@ namespace CalamityMod.TileEntities
ContainsAdvancedDisplay = tag.GetBool("ContainsAdvancedDisplay");
ContainsVoltageRegulationSystem = tag.GetBool("ContainsVoltageRegulationSystem");
ContainsCoolingCell = tag.GetBool("ContainsCoolingCell");
HeldSchematicID = tag.GetInt("HeldSchematicID");
}
public override void NetSend(BinaryWriter writer, bool lightSend)
@@ -185,6 +235,7 @@ namespace CalamityMod.TileEntities
writer.Write(ContainsAdvancedDisplay);
writer.Write(ContainsVoltageRegulationSystem);
writer.Write(ContainsCoolingCell);
writer.Write(HeldSchematicID);
}
public override void NetReceive(BinaryReader reader, bool lightReceive)
@@ -194,6 +245,7 @@ namespace CalamityMod.TileEntities
ContainsAdvancedDisplay = reader.ReadBoolean();
ContainsVoltageRegulationSystem = reader.ReadBoolean();
ContainsCoolingCell = reader.ReadBoolean();
HeldSchematicID = reader.ReadInt32();
}
}
}
+29 -9
View File
@@ -3,6 +3,7 @@ using CalamityMod.TileEntities;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using System;
using System.Linq;
using System.Text;
using Terraria;
using Terraria.DataStructures;
@@ -69,12 +70,19 @@ namespace CalamityMod.UI
Texture2D emptySchematicIconTexture = ModContent.GetTexture("CalamityMod/ExtraTextures/UI/EncryptedSchematicSlot_Empty");
Texture2D occupiedSchematicIconTexture = ModContent.GetTexture("CalamityMod/ExtraTextures/UI/EncryptedSchematicSlot_Full");
Texture2D schematicTexture = codebreakerTileEntity.HasSchematic ? occupiedSchematicIconTexture : emptySchematicIconTexture;
Texture2D schematicTexture = codebreakerTileEntity.HeldSchematicID != 0 ? occupiedSchematicIconTexture : emptySchematicIconTexture;
spriteBatch.Draw(schematicTexture, schematicSlotDrawCenter, null, Color.White, 0f, schematicTexture.Size() * 0.5f, 1f, SpriteEffects.None, 0f);
HandleSchematicSlotInteractions(codebreakerTileEntity, schematicSlotDrawCenter, cellTexture.Size());
// Display some error text if the codebreaker isn't strong enough to decrypt the text.
if (codebreakerTileEntity.HeldSchematicID != 0 && !codebreakerTileEntity.CanDecryptHeldSchematic)
{
Vector2 errorDisplayLocation = schematicSlotDrawCenter + Vector2.UnitY * 20f;
DisplayNotStrongEnoughErrorText(errorDisplayLocation);
}
// Handle decryption costs.
if (codebreakerTileEntity.HasSchematic && codebreakerTileEntity.DecryptionCountdown == 0)
else if (codebreakerTileEntity.HeldSchematicID != 0 && codebreakerTileEntity.DecryptionCountdown == 0)
{
int cost = 30;
Vector2 costDisplayLocation = schematicSlotDrawCenter + Vector2.UnitY * 20f;
@@ -91,17 +99,20 @@ namespace CalamityMod.UI
Vector2 textPanelCenter = backgroundTopLeft + Vector2.UnitX * backgroundTexture.Width + textPanelTexture.Size() * new Vector2(-0.5f, 0.5f);
spriteBatch.Draw(textPanelTexture, textPanelCenter, null, Color.White, 0f, textPanelTexture.Size() * 0.5f, 1f, SpriteEffects.None, 0f);
// Generate gibberish and use slowly insert the real text at the beginning.
// Generate gibberish and use slowly insert the real text.
// When decryption is done the gibberish will go away and only the underlying text will remain.
int textPadding = 6;
string trueMessage = "The FitnessGram Pacer Test is a multistage aerobic capacity test that progressively gets more difficult as it continues. The 20 meter pacer test will begin in 30 seconds. Line up at the start. The running speed starts slowly, but gets faster each minute after you hear this signal.";
string trueMessage = codebreakerTileEntity.UnderlyingSchematicText;
StringBuilder text = new StringBuilder(codebreakerTileEntity.DecryptionCountdown == 0 ? trueMessage : CalamityUtils.GenerateRandomAlphanumericString(500));
// Don't mess with whitespace characters. Doing so can cause the word-wrap to "jump" around.
for (int i = 0; i < trueMessage.Length; i++)
{
if (char.IsWhiteSpace(trueMessage[i]))
text[i] = trueMessage[i];
}
// Insert the necessary amount of true text.
for (int i = 0; i < (int)(trueMessage.Length * codebreakerTileEntity.DecryptionCompletion); i++)
text[i] = trueMessage[i];
@@ -204,21 +215,23 @@ namespace CalamityMod.UI
if (Main.mouseLeft && Main.mouseLeftRelease)
{
if (playerHandItem.IsAir && codebreakerTileEntity.HasSchematic)
if (playerHandItem.IsAir && codebreakerTileEntity.HeldSchematicID != 0)
{
playerHandItem.SetDefaults(ModContent.ItemType<EncryptedSchematic>());
codebreakerTileEntity.HasSchematic = false;
playerHandItem.SetDefaults(CalamityLists.EncryptedSchematicIDRelationship[codebreakerTileEntity.HeldSchematicID]);
codebreakerTileEntity.HeldSchematicID = 0;
codebreakerTileEntity.DecryptionCountdown = 0;
codebreakerTileEntity.SyncContainedStuff();
Main.PlaySound(SoundID.Grab);
AwaitingDecryptionTextClose = false;
}
else if (playerHandItem.type == ModContent.ItemType<EncryptedSchematic>())
else if (CalamityLists.EncryptedSchematicIDRelationship.ContainsValue(playerHandItem.type))
{
codebreakerTileEntity.HeldSchematicID = CalamityLists.EncryptedSchematicIDRelationship.First(i => i.Value == Main.mouseItem.type).Key;
playerHandItem.TurnToAir();
codebreakerTileEntity.HasSchematic = true;
codebreakerTileEntity.SyncContainedStuff();
Main.PlaySound(SoundID.Grab);
AwaitingDecryptionTextClose = false;
}
}
@@ -257,5 +270,12 @@ namespace CalamityMod.UI
Main.spriteBatch.Draw(confirmationTexture, drawPosition, null, Color.White, 0f, confirmationTexture.Size() * 0.5f, VerificationButtonScale, SpriteEffects.None, 0f);
}
public static void DisplayNotStrongEnoughErrorText(Vector2 drawPosition)
{
string text = "Encryption unsolveable: Upgrades required.";
drawPosition.X -= 30f;
Utils.DrawBorderStringFourWay(Main.spriteBatch, Main.fontMouseText, text, drawPosition.X, drawPosition.Y + 20f, Color.IndianRed * (Main.mouseTextColor / 255f), Color.Black, Vector2.Zero, 1f);
}
}
}
+10
View File
@@ -1,4 +1,5 @@
using CalamityMod.CalPlayer;
using CalamityMod.CustomRecipes;
using CalamityMod.DataStructures;
using CalamityMod.Events;
using CalamityMod.NPCs;
@@ -456,6 +457,8 @@ namespace CalamityMod.World
if (HasGeneratedLuminitePlanetoids)
downed.Add("HasGeneratedLuminitePlanetoids");
RecipeUnlockHandler.Save(downed);
return new TagCompound
{
{
@@ -560,6 +563,8 @@ namespace CalamityMod.World
encounteredOldDuke = downed.Contains("encounteredOldDuke");
HasGeneratedLuminitePlanetoids = downed.Contains("HasGeneratedLuminitePlanetoids");
RecipeUnlockHandler.Load(downed);
abyssChasmBottom = tag.GetInt("abyssChasmBottom");
acidRainPoints = tag.GetInt("acidRainPoints");
Reforges = tag.GetInt("Reforges");
@@ -803,6 +808,9 @@ namespace CalamityMod.World
writer.Write(flags8);
writer.Write(flags9);
writer.Write(flags10);
RecipeUnlockHandler.SendData(writer);
writer.Write(abyssChasmBottom);
writer.Write(acidRainPoints);
writer.Write(Reforges);
@@ -914,6 +922,8 @@ namespace CalamityMod.World
_ = flags10[6];
_ = flags10[7];
RecipeUnlockHandler.ReceiveData(reader);
abyssChasmBottom = reader.ReadInt32();
acidRainPoints = reader.ReadInt32();
Reforges = reader.ReadInt32();
+5 -5
View File
@@ -227,7 +227,7 @@ namespace CalamityMod.World
{
contents.Insert(0, new ChestItem(ModContent.ItemType<DraedonsLogHell>(), 1));
contents.Insert(1, new ChestItem(ModContent.ItemType<Murasama>(), 1));
contents.Insert(2, new ChestItem(ModContent.ItemType<EncryptedSchematic>(), 1));
contents.Insert(2, new ChestItem(ModContent.ItemType<EncryptedSchematicHell>(), 1));
}
for (int i = 0; i < contents.Count; i++)
{
@@ -298,7 +298,7 @@ namespace CalamityMod.World
if (!hasPlacedLogAndSchematic)
{
contents.Insert(0, new ChestItem(ModContent.ItemType<DraedonsLogSunkenSea>(), 1));
contents.Insert(1, new ChestItem(ModContent.ItemType<EncryptedSchematic>(), 1));
contents.Insert(1, new ChestItem(ModContent.ItemType<EncryptedSchematicSunkenSea>(), 1));
}
for (int i = 0; i < contents.Count; i++)
{
@@ -365,7 +365,7 @@ namespace CalamityMod.World
if (!hasPlacedLogAndSchematic)
{
contents.Insert(0, new ChestItem(ModContent.ItemType<DraedonsLogSnowBiome>(), 1));
contents.Insert(1, new ChestItem(ModContent.ItemType<EncryptedSchematic>(), 1));
contents.Insert(1, new ChestItem(ModContent.ItemType<EncryptedSchematicIce>(), 1));
}
// If it's a frozen chest.
if (type == TileID.Containers)
@@ -448,7 +448,7 @@ namespace CalamityMod.World
if (!hasPlacedLogAndSchematic)
{
contents.Insert(0, new ChestItem(ModContent.ItemType<DraedonsLogJungle>(), 1));
contents.Insert(1, new ChestItem(ModContent.ItemType<EncryptedSchematic>(), 1));
contents.Insert(1, new ChestItem(ModContent.ItemType<EncryptedSchematicJungle>(), 1));
}
for (int i = 0; i < contents.Count; i++)
{
@@ -541,7 +541,7 @@ namespace CalamityMod.World
if (!hasPlacedLogAndSchematic)
{
contents.Insert(0, new ChestItem(ModContent.ItemType<DraedonsLogPlanetoid>(), 1));
contents.Insert(1, new ChestItem(ModContent.ItemType<EncryptedSchematic>(), 1));
contents.Insert(1, new ChestItem(ModContent.ItemType<EncryptedSchematicPlanetoid>(), 1));
}
for (int i = 0; i < contents.Count; i++)
{