Added base stuff for the draedon summoner
No files matched your search
@@ -150,6 +150,9 @@ namespace CalamityMod
|
||||
case CalamityModMessageType.LabHologramProjector:
|
||||
TELabHologramProjector.ReadSyncPacket(mod, reader);
|
||||
break;
|
||||
case CalamityModMessageType.UpdateCodebreakerConstituents:
|
||||
TECodebreaker.ReadConstituentsUpdateSync(mod, reader);
|
||||
break;
|
||||
|
||||
//
|
||||
// Boss Rush
|
||||
@@ -284,6 +287,7 @@ namespace CalamityMod
|
||||
ChargingStationItemChange,
|
||||
Turret,
|
||||
LabHologramProjector,
|
||||
UpdateCodebreakerConstituents,
|
||||
|
||||
// Boss Rush
|
||||
BossRushStage,
|
||||
|
||||
@@ -0,0 +1,64 @@
|
||||
using CalamityMod.Items.Materials;
|
||||
using CalamityMod.Tiles.DraedonSummoner;
|
||||
using Terraria;
|
||||
using Terraria.ID;
|
||||
using Terraria.ModLoader;
|
||||
using Microsoft.Xna.Framework;
|
||||
using CalamityMod.TileEntities;
|
||||
|
||||
namespace CalamityMod.Items.DraedonMisc
|
||||
{
|
||||
public class AdvancedDisplay : ModItem
|
||||
{
|
||||
public override void SetStaticDefaults()
|
||||
{
|
||||
DisplayName.SetDefault("Advanced Display");
|
||||
Tooltip.SetDefault("Can be placed in the Codebreaker");
|
||||
}
|
||||
|
||||
public override void SetDefaults()
|
||||
{
|
||||
item.width = 52;
|
||||
item.height = 52;
|
||||
item.maxStack = 999;
|
||||
item.consumable = true;
|
||||
item.useStyle = ItemUseStyleID.SwingThrow;
|
||||
item.rare = ItemRarityID.Pink;
|
||||
item.useTime = item.useAnimation = 15;
|
||||
}
|
||||
|
||||
public override bool UseItem(Player player) => true;
|
||||
|
||||
public override bool ConsumeItem(Player player)
|
||||
{
|
||||
Point placeTileCoords = Main.MouseWorld.ToTileCoordinates();
|
||||
Tile tile = CalamityUtils.ParanoidTileRetrieval(placeTileCoords.X, placeTileCoords.Y);
|
||||
float checkDistance = ((Player.tileRangeX + Player.tileRangeY) / 2f + player.blockRange) * 16f;
|
||||
|
||||
if (Main.myPlayer == player.whoAmI && player.WithinRange(Main.MouseWorld, checkDistance) && tile.active() && tile.type == ModContent.TileType<CodebreakerTile>())
|
||||
{
|
||||
TECodebreaker codebreakerTileEntity = CalamityUtils.FindTileEntity<TECodebreaker>(placeTileCoords.X, placeTileCoords.Y, CodebreakerTile.Width, CodebreakerTile.Height, CodebreakerTile.SheetSquare);
|
||||
if (codebreakerTileEntity is null || codebreakerTileEntity.ContainsAdvancedDisplay)
|
||||
return false;
|
||||
|
||||
codebreakerTileEntity.ContainsAdvancedDisplay = true;
|
||||
codebreakerTileEntity.SyncConstituents();
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public override void AddRecipes()
|
||||
{
|
||||
ModRecipe recipe = new ModRecipe(mod);
|
||||
recipe.AddIngredient(ModContent.ItemType<MysteriousCircuitry>(), 10);
|
||||
recipe.AddIngredient(ModContent.ItemType<DubiousPlating>(), 10);
|
||||
recipe.AddIngredient(ModContent.ItemType<BarofLife>(), 3);
|
||||
recipe.AddIngredient(ItemID.Glass, 20);
|
||||
recipe.AddTile(TileID.MythrilAnvil);
|
||||
recipe.SetResult(this, 1);
|
||||
recipe.AddRecipe();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
After Width: | Height: | Size: 472 B |
@@ -0,0 +1,69 @@
|
||||
using CalamityMod.Items.Materials;
|
||||
using CalamityMod.Tiles.DraedonSummoner;
|
||||
using CalamityMod.Tiles.Furniture.CraftingStations;
|
||||
using Terraria;
|
||||
using Terraria.ID;
|
||||
using Terraria.ModLoader;
|
||||
using Microsoft.Xna.Framework;
|
||||
using CalamityMod.TileEntities;
|
||||
|
||||
namespace CalamityMod.Items.DraedonMisc
|
||||
{
|
||||
public class AuricQuantumCoolingCell : ModItem
|
||||
{
|
||||
public override void SetStaticDefaults()
|
||||
{
|
||||
DisplayName.SetDefault("Auric Quantum Cooling Cell");
|
||||
Tooltip.SetDefault("Can be placed in the Codebreaker");
|
||||
}
|
||||
|
||||
public override void SetDefaults()
|
||||
{
|
||||
item.width = 26;
|
||||
item.height = 44;
|
||||
item.maxStack = 999;
|
||||
item.consumable = true;
|
||||
item.useStyle = ItemUseStyleID.SwingThrow;
|
||||
item.rare = ItemRarityID.Red;
|
||||
item.useTime = item.useAnimation = 15;
|
||||
item.Calamity().customRarity = CalamityRarity.Violet;
|
||||
}
|
||||
|
||||
public override void Update(ref float gravity, ref float maxFallSpeed)
|
||||
{
|
||||
float brightness = Main.essScale * Main.rand.NextFloat(0.9f, 1.1f);
|
||||
Lighting.AddLight(item.Center, 1.2f * brightness, 0.4f * brightness, 0.8f);
|
||||
}
|
||||
|
||||
public override bool UseItem(Player player) => true;
|
||||
|
||||
public override bool ConsumeItem(Player player)
|
||||
{
|
||||
Point placeTileCoords = Main.MouseWorld.ToTileCoordinates();
|
||||
Tile tile = CalamityUtils.ParanoidTileRetrieval(placeTileCoords.X, placeTileCoords.Y);
|
||||
float checkDistance = ((Player.tileRangeX + Player.tileRangeY) / 2f + player.blockRange) * 16f;
|
||||
|
||||
if (Main.myPlayer == player.whoAmI && player.WithinRange(Main.MouseWorld, checkDistance) && tile.active() && tile.type == ModContent.TileType<CodebreakerTile>())
|
||||
{
|
||||
TECodebreaker codebreakerTileEntity = CalamityUtils.FindTileEntity<TECodebreaker>(placeTileCoords.X, placeTileCoords.Y, CodebreakerTile.Width, CodebreakerTile.Height, CodebreakerTile.SheetSquare);
|
||||
if (codebreakerTileEntity is null || codebreakerTileEntity.ContainsCoolingCell)
|
||||
return false;
|
||||
|
||||
codebreakerTileEntity.ContainsCoolingCell = true;
|
||||
codebreakerTileEntity.SyncConstituents();
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public override void AddRecipes()
|
||||
{
|
||||
ModRecipe recipe = new ModRecipe(mod);
|
||||
recipe.AddIngredient(ModContent.ItemType<AuricBar>(), 5);
|
||||
recipe.AddTile(ModContent.TileType<DraedonsForge>());
|
||||
recipe.SetResult(this);
|
||||
recipe.AddRecipe();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
After Width: | Height: | Size: 887 B |
@@ -0,0 +1,39 @@
|
||||
using Terraria.ModLoader;
|
||||
using Terraria.ID;
|
||||
using CalamityMod.Items.Materials;
|
||||
using CalamityMod.Tiles.DraedonSummoner;
|
||||
using CalamityMod.Items.Placeables.DraedonStructures;
|
||||
|
||||
namespace CalamityMod.Items.DraedonMisc
|
||||
{
|
||||
public class CodebreakerBase : ModItem
|
||||
{
|
||||
public override void SetStaticDefaults() => DisplayName.SetDefault("Codebreaker Base");
|
||||
|
||||
public override void SetDefaults()
|
||||
{
|
||||
item.useStyle = ItemUseStyleID.SwingThrow;
|
||||
item.useTurn = true;
|
||||
item.useAnimation = 15;
|
||||
item.useTime = 10;
|
||||
item.autoReuse = true;
|
||||
item.consumable = true;
|
||||
item.width = 42;
|
||||
item.height = 32;
|
||||
item.maxStack = 999;
|
||||
item.rare = ItemRarityID.Orange;
|
||||
item.createTile = ModContent.TileType<CodebreakerTile>();
|
||||
}
|
||||
|
||||
public override void AddRecipes()
|
||||
{
|
||||
ModRecipe recipe = new ModRecipe(mod);
|
||||
recipe.AddIngredient(ModContent.ItemType<ChargingStationItem>());
|
||||
recipe.AddIngredient(ModContent.ItemType<MysteriousCircuitry>(), 20);
|
||||
recipe.AddIngredient(ModContent.ItemType<DubiousPlating>(), 35);
|
||||
recipe.AddTile(TileID.Anvils);
|
||||
recipe.SetResult(this, 1);
|
||||
recipe.AddRecipe();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
After Width: | Height: | Size: 550 B |
@@ -0,0 +1,63 @@
|
||||
using CalamityMod.Items.Materials;
|
||||
using CalamityMod.Tiles.DraedonSummoner;
|
||||
using Terraria;
|
||||
using Terraria.ID;
|
||||
using Terraria.ModLoader;
|
||||
using Microsoft.Xna.Framework;
|
||||
using CalamityMod.TileEntities;
|
||||
|
||||
namespace CalamityMod.Items.DraedonMisc
|
||||
{
|
||||
public class DecryptionComputer : ModItem
|
||||
{
|
||||
public override void SetStaticDefaults()
|
||||
{
|
||||
DisplayName.SetDefault("Decryption Computer");
|
||||
Tooltip.SetDefault("Can be placed in the Codebreaker");
|
||||
}
|
||||
|
||||
public override void SetDefaults()
|
||||
{
|
||||
item.width = 42;
|
||||
item.height = 40;
|
||||
item.maxStack = 999;
|
||||
item.consumable = true;
|
||||
item.useStyle = ItemUseStyleID.SwingThrow;
|
||||
item.rare = ItemRarityID.Orange;
|
||||
item.useTime = item.useAnimation = 15;
|
||||
}
|
||||
|
||||
public override bool UseItem(Player player) => true;
|
||||
|
||||
public override bool ConsumeItem(Player player)
|
||||
{
|
||||
Point placeTileCoords = Main.MouseWorld.ToTileCoordinates();
|
||||
Tile tile = CalamityUtils.ParanoidTileRetrieval(placeTileCoords.X, placeTileCoords.Y);
|
||||
float checkDistance = ((Player.tileRangeX + Player.tileRangeY) / 2f + player.blockRange) * 16f;
|
||||
|
||||
if (Main.myPlayer == player.whoAmI && player.WithinRange(Main.MouseWorld, checkDistance) && tile.active() && tile.type == ModContent.TileType<CodebreakerTile>())
|
||||
{
|
||||
TECodebreaker codebreakerTileEntity = CalamityUtils.FindTileEntity<TECodebreaker>(placeTileCoords.X, placeTileCoords.Y, CodebreakerTile.Width, CodebreakerTile.Height, CodebreakerTile.SheetSquare);
|
||||
if (codebreakerTileEntity is null || codebreakerTileEntity.ContainsDecryptionComputer)
|
||||
return false;
|
||||
|
||||
codebreakerTileEntity.ContainsDecryptionComputer = true;
|
||||
codebreakerTileEntity.SyncConstituents();
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public override void AddRecipes()
|
||||
{
|
||||
ModRecipe recipe = new ModRecipe(mod);
|
||||
recipe.AddIngredient(ModContent.ItemType<MysteriousCircuitry>(), 18);
|
||||
recipe.AddIngredient(ModContent.ItemType<DubiousPlating>(), 10);
|
||||
recipe.AddIngredient(ItemID.Glass, 5);
|
||||
recipe.AddTile(TileID.Anvils);
|
||||
recipe.SetResult(this, 1);
|
||||
recipe.AddRecipe();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
After Width: | Height: | Size: 476 B |
@@ -0,0 +1,64 @@
|
||||
using CalamityMod.Items.Materials;
|
||||
using CalamityMod.Tiles.DraedonSummoner;
|
||||
using Terraria;
|
||||
using Terraria.ID;
|
||||
using Terraria.ModLoader;
|
||||
using Microsoft.Xna.Framework;
|
||||
using CalamityMod.TileEntities;
|
||||
|
||||
namespace CalamityMod.Items.DraedonMisc
|
||||
{
|
||||
public class LongRangedSensorArray : ModItem
|
||||
{
|
||||
public override void SetStaticDefaults()
|
||||
{
|
||||
DisplayName.SetDefault("Long Ranged Sensor Array");
|
||||
Tooltip.SetDefault("Can be placed in the Codebreaker");
|
||||
}
|
||||
|
||||
public override void SetDefaults()
|
||||
{
|
||||
item.width = 52;
|
||||
item.height = 52;
|
||||
item.maxStack = 999;
|
||||
item.consumable = true;
|
||||
item.useStyle = ItemUseStyleID.SwingThrow;
|
||||
item.rare = ItemRarityID.Pink;
|
||||
item.useTime = item.useAnimation = 15;
|
||||
}
|
||||
|
||||
public override bool UseItem(Player player) => true;
|
||||
|
||||
public override bool ConsumeItem(Player player)
|
||||
{
|
||||
Point placeTileCoords = Main.MouseWorld.ToTileCoordinates();
|
||||
Tile tile = CalamityUtils.ParanoidTileRetrieval(placeTileCoords.X, placeTileCoords.Y);
|
||||
float checkDistance = ((Player.tileRangeX + Player.tileRangeY) / 2f + player.blockRange) * 16f;
|
||||
|
||||
if (Main.myPlayer == player.whoAmI && player.WithinRange(Main.MouseWorld, checkDistance) && tile.active() && tile.type == ModContent.TileType<CodebreakerTile>())
|
||||
{
|
||||
TECodebreaker codebreakerTileEntity = CalamityUtils.FindTileEntity<TECodebreaker>(placeTileCoords.X, placeTileCoords.Y, CodebreakerTile.Width, CodebreakerTile.Height, CodebreakerTile.SheetSquare);
|
||||
if (codebreakerTileEntity is null || codebreakerTileEntity.ContainsSensorArray)
|
||||
return false;
|
||||
|
||||
codebreakerTileEntity.ContainsSensorArray = true;
|
||||
codebreakerTileEntity.SyncConstituents();
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public override void AddRecipes()
|
||||
{
|
||||
ModRecipe recipe = new ModRecipe(mod);
|
||||
recipe.AddIngredient(ModContent.ItemType<MysteriousCircuitry>(), 10);
|
||||
recipe.AddIngredient(ModContent.ItemType<DubiousPlating>(), 10);
|
||||
recipe.AddIngredient(ItemID.HallowedBar, 10);
|
||||
recipe.AddIngredient(ItemID.Wire, 50);
|
||||
recipe.AddTile(TileID.MythrilAnvil);
|
||||
recipe.SetResult(this, 1);
|
||||
recipe.AddRecipe();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
After Width: | Height: | Size: 882 B |
@@ -0,0 +1,65 @@
|
||||
using CalamityMod.Items.Materials;
|
||||
using CalamityMod.Tiles.DraedonSummoner;
|
||||
using Terraria;
|
||||
using Terraria.ID;
|
||||
using Terraria.ModLoader;
|
||||
using Microsoft.Xna.Framework;
|
||||
using CalamityMod.TileEntities;
|
||||
|
||||
namespace CalamityMod.Items.DraedonMisc
|
||||
{
|
||||
public class VoltageRegulationSystem : ModItem
|
||||
{
|
||||
public override void SetStaticDefaults()
|
||||
{
|
||||
DisplayName.SetDefault("Voltage Regulation System");
|
||||
Tooltip.SetDefault("Can be placed in the Codebreaker");
|
||||
}
|
||||
|
||||
public override void SetDefaults()
|
||||
{
|
||||
item.width = 52;
|
||||
item.height = 52;
|
||||
item.maxStack = 999;
|
||||
item.consumable = true;
|
||||
item.useStyle = ItemUseStyleID.SwingThrow;
|
||||
item.rare = ItemRarityID.Purple;
|
||||
item.Calamity().customRarity = CalamityRarity.Turquoise;
|
||||
item.useTime = item.useAnimation = 15;
|
||||
}
|
||||
|
||||
public override bool UseItem(Player player) => true;
|
||||
|
||||
public override bool ConsumeItem(Player player)
|
||||
{
|
||||
Point placeTileCoords = Main.MouseWorld.ToTileCoordinates();
|
||||
Tile tile = CalamityUtils.ParanoidTileRetrieval(placeTileCoords.X, placeTileCoords.Y);
|
||||
float checkDistance = ((Player.tileRangeX + Player.tileRangeY) / 2f + player.blockRange) * 16f;
|
||||
|
||||
if (Main.myPlayer == player.whoAmI && player.WithinRange(Main.MouseWorld, checkDistance) && tile.active() && tile.type == ModContent.TileType<CodebreakerTile>())
|
||||
{
|
||||
TECodebreaker codebreakerTileEntity = CalamityUtils.FindTileEntity<TECodebreaker>(placeTileCoords.X, placeTileCoords.Y, CodebreakerTile.Width, CodebreakerTile.Height, CodebreakerTile.SheetSquare);
|
||||
if (codebreakerTileEntity is null || codebreakerTileEntity.ContainsVoltageRegulationSystem)
|
||||
return false;
|
||||
|
||||
codebreakerTileEntity.ContainsVoltageRegulationSystem = true;
|
||||
codebreakerTileEntity.SyncConstituents();
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public override void AddRecipes()
|
||||
{
|
||||
ModRecipe recipe = new ModRecipe(mod);
|
||||
recipe.AddIngredient(ModContent.ItemType<MysteriousCircuitry>(), 10);
|
||||
recipe.AddIngredient(ModContent.ItemType<DubiousPlating>(), 10);
|
||||
recipe.AddIngredient(ModContent.ItemType<UeliaceBar>(), 5);
|
||||
recipe.AddIngredient(ItemID.LunarBar, 5);
|
||||
recipe.AddTile(TileID.MythrilAnvil);
|
||||
recipe.SetResult(this, 1);
|
||||
recipe.AddRecipe();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
After Width: | Height: | Size: 591 B |
@@ -0,0 +1,149 @@
|
||||
using CalamityMod.Items.DraedonMisc;
|
||||
using CalamityMod.Tiles.DraedonStructures;
|
||||
using CalamityMod.Tiles.DraedonSummoner;
|
||||
using Microsoft.Xna.Framework;
|
||||
using System.IO;
|
||||
using Terraria;
|
||||
using Terraria.DataStructures;
|
||||
using Terraria.ID;
|
||||
using Terraria.ModLoader;
|
||||
using Terraria.ModLoader.IO;
|
||||
|
||||
namespace CalamityMod.TileEntities
|
||||
{
|
||||
public class TECodebreaker : ModTileEntity
|
||||
{
|
||||
public bool ContainsDecryptionComputer;
|
||||
public bool ContainsSensorArray;
|
||||
public bool ContainsAdvancedDisplay;
|
||||
public bool ContainsVoltageRegulationSystem;
|
||||
public bool ContainsCoolingCell;
|
||||
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.
|
||||
public override bool ValidTile(int i, int j)
|
||||
{
|
||||
Tile tile = CalamityUtils.ParanoidTileRetrieval(i, j);
|
||||
return tile.active() && tile.type == ModContent.TileType<CodebreakerTile>() && tile.frameX == 0 && tile.frameY == 0;
|
||||
}
|
||||
|
||||
// This code is called as a hook when the player places the Charging Station tile so that the tile entity may be placed.
|
||||
public override int Hook_AfterPlacement(int i, int j, int type, int style, int direction)
|
||||
{
|
||||
// If in multiplayer, tell the server to place the tile entity and DO NOT place it yourself. That would mismatch IDs.
|
||||
// Also tell the server that you placed the 3x2 tiles that make up the Charging Station.
|
||||
if (Main.netMode == NetmodeID.MultiplayerClient)
|
||||
{
|
||||
NetMessage.SendTileRange(Main.myPlayer, i, j, CodebreakerTile.Width, CodebreakerTile.Height);
|
||||
NetMessage.SendData(MessageID.TileEntityPlacement, -1, -1, null, i, j, Type);
|
||||
return -1;
|
||||
}
|
||||
|
||||
// If in single player, just place the tile entity, no problems.
|
||||
return Place(i, j);
|
||||
}
|
||||
|
||||
// This code is called on dedicated servers only. It is the server-side response to MessageID.TileEntityPlacement.
|
||||
// When the server receives such a message from a client, it sends a MessageID.TileEntitySharing to all clients.
|
||||
// This will cause them to Place the tile entity locally at that position, all with exactly the same ID.
|
||||
public override void OnNetPlace() => NetMessage.SendData(MessageID.TileEntitySharing, -1, -1, null, ID, Position.X, Position.Y);
|
||||
|
||||
public void DropConstituents(int x, int y)
|
||||
{
|
||||
if (ContainsDecryptionComputer)
|
||||
Item.NewItem(x * 16, y * 16, 32, 32, ModContent.ItemType<DecryptionComputer>());
|
||||
if (ContainsSensorArray)
|
||||
Item.NewItem(x * 16, y * 16, 32, 32, ModContent.ItemType<LongRangedSensorArray>());
|
||||
if (ContainsAdvancedDisplay)
|
||||
Item.NewItem(x * 16, y * 16, 32, 32, ModContent.ItemType<AdvancedDisplay>());
|
||||
if (ContainsVoltageRegulationSystem)
|
||||
Item.NewItem(x * 16, y * 16, 32, 32, ModContent.ItemType<VoltageRegulationSystem>());
|
||||
if (ContainsCoolingCell)
|
||||
Item.NewItem(x * 16, y * 16, 32, 32, ModContent.ItemType<AuricQuantumCoolingCell>());
|
||||
}
|
||||
|
||||
public void SyncConstituents()
|
||||
{
|
||||
// Don't bother sending packets in singleplayer.
|
||||
if (Main.netMode == NetmodeID.SinglePlayer)
|
||||
return;
|
||||
|
||||
ModPacket packet = mod.GetPacket();
|
||||
packet.Write((byte)CalamityModMessageType.UpdateCodebreakerConstituents);
|
||||
packet.Write(ID);
|
||||
packet.Write(ContainsDecryptionComputer);
|
||||
packet.Write(ContainsSensorArray);
|
||||
packet.Write(ContainsAdvancedDisplay);
|
||||
packet.Write(ContainsVoltageRegulationSystem);
|
||||
packet.Write(ContainsCoolingCell);
|
||||
}
|
||||
|
||||
public static void ReadConstituentsUpdateSync(Mod mod, BinaryReader reader)
|
||||
{
|
||||
int id = reader.ReadInt32();
|
||||
bool exists = ByID.TryGetValue(id, out TileEntity tileEntity);
|
||||
|
||||
// Continue reading to the end even if a tile entity with the given ID does not exist.
|
||||
// Not doing this will cause errors/bugs.
|
||||
bool containsDecryptionComputer = reader.ReadBoolean();
|
||||
bool containsSensorArray = reader.ReadBoolean();
|
||||
bool containsAdvancedDisplay = reader.ReadBoolean();
|
||||
bool containsVoltageRegulationSystem = reader.ReadBoolean();
|
||||
bool containsCoolingCell = reader.ReadBoolean();
|
||||
|
||||
// After doing reading, check again to see if the tile entity is actually there.
|
||||
// If it isn't don't bother doing anything else.
|
||||
if (!exists)
|
||||
return;
|
||||
|
||||
// Furthermore, verify to ensure that the tile entity is a valid one.
|
||||
if (!(tileEntity is TECodebreaker codebreakerTileEntity))
|
||||
return;
|
||||
|
||||
codebreakerTileEntity.ContainsDecryptionComputer = containsDecryptionComputer;
|
||||
codebreakerTileEntity.ContainsSensorArray = containsSensorArray;
|
||||
codebreakerTileEntity.ContainsAdvancedDisplay = containsAdvancedDisplay;
|
||||
codebreakerTileEntity.ContainsVoltageRegulationSystem = containsVoltageRegulationSystem;
|
||||
codebreakerTileEntity.ContainsCoolingCell = containsCoolingCell;
|
||||
}
|
||||
|
||||
public override TagCompound Save()
|
||||
{
|
||||
return new TagCompound
|
||||
{
|
||||
["ContainsDecryptionComputer"] = ContainsDecryptionComputer,
|
||||
["ContainsSensorArray"] = ContainsSensorArray,
|
||||
["ContainsAdvancedDisplay"] = ContainsAdvancedDisplay,
|
||||
["ContainsVoltageRegulationSystem"] = ContainsVoltageRegulationSystem,
|
||||
["ContainsCoolingCell"] = ContainsCoolingCell
|
||||
};
|
||||
}
|
||||
|
||||
public override void Load(TagCompound tag)
|
||||
{
|
||||
ContainsDecryptionComputer = tag.GetBool("ContainsDecryptionComputer");
|
||||
ContainsSensorArray = tag.GetBool("ContainsSensorArray");
|
||||
ContainsAdvancedDisplay = tag.GetBool("ContainsAdvancedDisplay");
|
||||
ContainsVoltageRegulationSystem = tag.GetBool("ContainsVoltageRegulationSystem");
|
||||
ContainsCoolingCell = tag.GetBool("ContainsCoolingCell");
|
||||
}
|
||||
|
||||
public override void NetSend(BinaryWriter writer, bool lightSend)
|
||||
{
|
||||
writer.Write(ContainsDecryptionComputer);
|
||||
writer.Write(ContainsSensorArray);
|
||||
writer.Write(ContainsAdvancedDisplay);
|
||||
writer.Write(ContainsVoltageRegulationSystem);
|
||||
writer.Write(ContainsCoolingCell);
|
||||
}
|
||||
|
||||
public override void NetReceive(BinaryReader reader, bool lightReceive)
|
||||
{
|
||||
ContainsDecryptionComputer = reader.ReadBoolean();
|
||||
ContainsSensorArray = reader.ReadBoolean();
|
||||
ContainsAdvancedDisplay = reader.ReadBoolean();
|
||||
ContainsVoltageRegulationSystem = reader.ReadBoolean();
|
||||
ContainsCoolingCell = reader.ReadBoolean();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
After Width: | Height: | Size: 8.3 KiB |
|
After Width: | Height: | Size: 4.7 KiB |
|
After Width: | Height: | Size: 9.8 KiB |
|
After Width: | Height: | Size: 13 KiB |
@@ -0,0 +1,127 @@
|
||||
using CalamityMod.Items.DraedonMisc;
|
||||
using CalamityMod.TileEntities;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using Terraria;
|
||||
using Terraria.DataStructures;
|
||||
using Terraria.Enums;
|
||||
using Terraria.ModLoader;
|
||||
using Terraria.ObjectData;
|
||||
|
||||
namespace CalamityMod.Tiles.DraedonSummoner
|
||||
{
|
||||
public class CodebreakerTile : ModTile
|
||||
{
|
||||
public const int Width = 5;
|
||||
public const int Height = 8;
|
||||
public const int OriginOffsetX = 2;
|
||||
public const int OriginOffsetY = 7;
|
||||
public const int SheetSquare = 18;
|
||||
|
||||
public override void SetDefaults()
|
||||
{
|
||||
Main.tileLighted[Type] = true;
|
||||
Main.tileFrameImportant[Type] = true;
|
||||
Main.tileNoAttach[Type] = true;
|
||||
Main.tileLavaDeath[Type] = false;
|
||||
Main.tileWaterDeath[Type] = false;
|
||||
TileObjectData.newTile.CopyFrom(TileObjectData.Style3x2);
|
||||
TileObjectData.newTile.Width = Width;
|
||||
TileObjectData.newTile.Height = Height;
|
||||
TileObjectData.newTile.Origin = new Point16(OriginOffsetX, OriginOffsetY);
|
||||
TileObjectData.newTile.AnchorBottom = new AnchorData(AnchorType.SolidTile | AnchorType.SolidWithTop | AnchorType.SolidSide, TileObjectData.newTile.Width, 0);
|
||||
TileObjectData.newTile.CoordinateHeights = new int[Height];
|
||||
|
||||
// Initialize the coordinate heights of each frame based on the sheet area. The padding is shaved off.
|
||||
for (int i = 0; i < Height; i++)
|
||||
TileObjectData.newTile.CoordinateHeights[i] = SheetSquare - 2;
|
||||
|
||||
TileObjectData.newTile.LavaDeath = false;
|
||||
|
||||
TileObjectData.newTile.HookPostPlaceMyPlayer = new PlacementHook(ModContent.GetInstance<TECodebreaker>().Hook_AfterPlacement, -1, 0, true);
|
||||
|
||||
TileObjectData.addTile(Type);
|
||||
ModTranslation name = CreateMapEntryName();
|
||||
name.SetDefault("The Codebreaker");
|
||||
AddMapEntry(new Color(92, 107, 112), name);
|
||||
animationFrameHeight = 144;
|
||||
}
|
||||
|
||||
public override bool CanExplode(int i, int j) => false;
|
||||
|
||||
public override bool CreateDust(int i, int j, ref int type)
|
||||
{
|
||||
Dust.NewDust(new Vector2(i, j) * 16f, 16, 16, 182);
|
||||
return false;
|
||||
}
|
||||
|
||||
public override void NumDust(int i, int j, bool fail, ref int num) => num = fail ? 1 : 3;
|
||||
|
||||
public override void KillMultiTile(int i, int j, int frameX, int frameY)
|
||||
{
|
||||
// Drop the base of the codebreaker.
|
||||
Item.NewItem(i * 16, j * 16, 32, 32, ModContent.ItemType<CodebreakerBase>());
|
||||
|
||||
Tile t = Main.tile[i, j];
|
||||
int left = i - t.frameX % (Width * SheetSquare) / SheetSquare;
|
||||
int top = j - t.frameY % (Height * SheetSquare) / SheetSquare;
|
||||
|
||||
TECodebreaker codebreakerTileEntity = CalamityUtils.FindTileEntity<TECodebreaker>(i, j, Width, Height, SheetSquare);
|
||||
|
||||
// Drop any any attached components.
|
||||
codebreakerTileEntity?.DropConstituents(i, j);
|
||||
|
||||
// And destroy the tile entity, if it exists.
|
||||
codebreakerTileEntity?.Kill(left, top);
|
||||
}
|
||||
|
||||
// All tile drawcode is done manually because the tile's animation is controlled by a tile entity.
|
||||
public override bool PreDraw(int i, int j, SpriteBatch spriteBatch)
|
||||
{
|
||||
// These offsets start as the tile offsets, i.e. which sub-tile of the FrameImportant structure this specific location is.
|
||||
Tile t = Main.tile[i, j];
|
||||
int frameXPos = t.frameX;
|
||||
int frameYPos = t.frameY;
|
||||
|
||||
// Grab the tile entity because it stores the information regarding what is actually attached.
|
||||
TECodebreaker codebreakerTileEntity = CalamityUtils.FindTileEntity<TECodebreaker>(i, j, Width, Height, SheetSquare);
|
||||
|
||||
Texture2D tex = ModContent.GetTexture("CalamityMod/Tiles/DraedonSummoner/CodebreakerTile");
|
||||
Texture2D computerTexture = ModContent.GetTexture("CalamityMod/Tiles/DraedonSummoner/CodebreakerDecryptionComputer");
|
||||
Texture2D sensorTexture = ModContent.GetTexture("CalamityMod/Tiles/DraedonSummoner/CodebreakerLongRangedSensorArray");
|
||||
Texture2D voltageRegulatorTexture = ModContent.GetTexture("CalamityMod/Tiles/DraedonSummoner/CodebreakerVoltageRegulationSystem");
|
||||
Texture2D voltageRegulatorTexture2 = ModContent.GetTexture("CalamityMod/Tiles/DraedonSummoner/CodebreakerVoltageRegulationSystem2");
|
||||
Texture2D coolingCellTexture = ModContent.GetTexture("CalamityMod/Tiles/DraedonSummoner/CodebreakerAuricQuantumCoolingCell");
|
||||
Vector2 offset = Main.drawToScreen ? Vector2.Zero : new Vector2(Main.offScreenRange);
|
||||
if (t.halfBrick())
|
||||
offset.Y += 8f;
|
||||
Vector2 drawPosition = new Vector2(i * 16 - Main.screenPosition.X, j * 16 - Main.screenPosition.Y) + offset;
|
||||
Color drawColor = Lighting.GetColor(i, j);
|
||||
Rectangle frame = new Rectangle(frameXPos, frameYPos, 16, 16);
|
||||
|
||||
if ((!t.halfBrick() && t.slope() == 0) || t.halfBrick())
|
||||
{
|
||||
spriteBatch.Draw(tex, drawPosition, frame, drawColor, 0f, Vector2.Zero, 1f, SpriteEffects.None, 0f);
|
||||
|
||||
// Place secondary parts.
|
||||
if (codebreakerTileEntity != null)
|
||||
{
|
||||
if (codebreakerTileEntity.ContainsDecryptionComputer)
|
||||
spriteBatch.Draw(computerTexture, drawPosition, frame, drawColor, 0f, Vector2.Zero, 1f, SpriteEffects.None, 0f);
|
||||
if (codebreakerTileEntity.ContainsSensorArray)
|
||||
spriteBatch.Draw(sensorTexture, drawPosition, frame, drawColor, 0f, Vector2.Zero, 1f, SpriteEffects.None, 0f);
|
||||
if (codebreakerTileEntity.ContainsAdvancedDisplay)
|
||||
spriteBatch.Draw(coolingCellTexture, drawPosition, frame, drawColor, 0f, Vector2.Zero, 1f, SpriteEffects.None, 0f);
|
||||
if (codebreakerTileEntity.ContainsVoltageRegulationSystem)
|
||||
{
|
||||
spriteBatch.Draw(voltageRegulatorTexture, drawPosition, frame, drawColor, 0f, Vector2.Zero, 1f, SpriteEffects.None, 0f);
|
||||
spriteBatch.Draw(voltageRegulatorTexture2, drawPosition, frame, drawColor, 0f, Vector2.Zero, 1f, SpriteEffects.None, 0f);
|
||||
}
|
||||
if (codebreakerTileEntity.ContainsCoolingCell)
|
||||
spriteBatch.Draw(coolingCellTexture, drawPosition, frame, drawColor, 0f, Vector2.Zero, 1f, SpriteEffects.None, 0f);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
After Width: | Height: | Size: 14 KiB |
|
After Width: | Height: | Size: 7.2 KiB |
|
After Width: | Height: | Size: 2.6 KiB |