public static TEStorageHeart GetStorageHeart() { var player = Get; if (player.StorageAccess.X < 0 || player.StorageAccess.Y < 0) { return(null); } Tile tile = Main.tile[player.StorageAccess.X, player.StorageAccess.Y]; if (tile == null) { return(null); } int tileType = tile.type; ModTile modTile = TileLoader.GetTile(tileType); if (modTile == null || !(modTile is StorageAccess)) { return(null); } return(((StorageAccess)modTile).GetHeart(player.StorageAccess.X, player.StorageAccess.Y)); }
public override void ResetEffects() { if (player.whoAmI != Main.myPlayer) { return; } if (WhereFlagModifierOpened.X >= 0 && WhereFlagModifierOpened.Y >= 0 && (player.chest != -1 || player.sign != -1 || player.talkNPC != -1)) { CloseFlagModifier(); Main.NewText("ResetEffects: Closed flag modifier in case 1 {Player began an interaction!}"); } else if (WhereFlagModifierOpened.X >= 0 && WhereFlagModifierOpened.Y >= 0) { int playerX = (int)(player.Center.X / 16f); int playerY = (int)(player.Center.Y / 16f); if ((Math.Abs(playerX - WhereFlagModifierOpened.X) > Player.tileRangeX) || (Math.Abs(playerY - WhereFlagModifierOpened.Y) > Player.tileRangeY)) { Main.PlaySound(SoundID.MenuClose); Main.NewText("ResetEffects: Closed flag modifier in case 2 {Player out of range}"); CloseFlagModifier(); } else if (!(TileLoader.GetTile(Main.tile[WhereFlagModifierOpened.X, WhereFlagModifierOpened.Y].type) is FlagModifier)) { Main.PlaySound(SoundID.MenuClose); CloseFlagModifier(); Main.NewText("ResetEffects: Closed flag modifier in case 3 {Tile is not FlagModifier}"); } } }
public override void PostUpdate() { if (Main.dedServ || !DisplayWorldTooltips) { return; } MouseText = String.Empty; SecondLine = false; var modLoaderMod = ModLoader.GetMod("ModLoader"); var tile = Main.tile[Player.tileTargetX, Player.tileTargetY]; if (tile != null) { InitializeTileTypes(); var modTile = TileLoader.GetTile(tile.type); var name = ""; if (modTile != null) { name = modTile.Name; } if (name == "") { _tileTypeToName.TryGetValue(tile.type, out name); } MouseText = "Tile: " + name; } }
public void DropTheGoods(int i, int j, int type) { ModTile modTile = TileLoader.GetTile(type); if (modTile == null) { //Vanilla if (TileID.Sets.Ore[type] && DoubleOreDrop.oreTileToItem.TryGetValue(type, out int item)) { Item.NewItem(i * 16, j * 16, 16, 16, item, 1, false, -1, false, false); } } else { //Modded //modTile.Name.Contains("Ore") is a bad way to detect if it's a modded ore. If the modder is smart he should have added his tile to TileID.Sets.Ore properly //If not, let the modder know of the ore that doesn't work if (TileID.Sets.Ore[type]) { int drop = modTile.drop; if (drop > 0) { Item.NewItem(i * 16, j * 16, 16, 16, drop, 1, false, -1, false, false); } } } }
public static bool DrawStorageGUI() { Player player = Main.player[Main.myPlayer]; StoragePlayer modPlayer = player.GetModPlayer <StoragePlayer>(); Point16 storageAccess = modPlayer.ViewingStorage(); if (!Main.playerInventory || storageAccess.X < 0 || storageAccess.Y < 0) { return(true); } ModTile modTile = TileLoader.GetTile(Main.tile[storageAccess.X, storageAccess.Y].type); if (modTile == null || !(modTile is StorageAccess)) { return(true); } TEStorageHeart heart = ((StorageAccess)modTile).GetHeart(storageAccess.X, storageAccess.Y); if (heart == null) { return(true); } if (modTile is CraftingAccess) { CraftingGUI.Draw(heart); } else { StorageGUI.Draw(heart); } return(true); }
/*public override void RightClick(int i, int j)//Debug * { * Main.NewText("Manual Update"); * TileLoader.GetTile(Main.tile[i, j].type)?.RandomUpdate(i, j); * }*/ public override void RandomUpdate(int i, int j) { for (int k = 0; k < 10; k++) //k = max range up, this checks the area above it { if (Main.tileSolid[Main.tile[i, j - 1 - k].type] && Main.tile[i, j - 1 - k].active() && !Main.tileSolidTop[Main.tile[i, j - 1 - k].type] && Main.tile[i, j - 1 - k].type != Type && Main.tile[i, j - 1 - k].type != TileID.Glass) //maybe check for just blocks that stop light? { break; //breaks if Solid if all of the above checks are true: Solid, active, No solidTop, not This type of block, and not glass } else if (k == 9) { for (int m = 0; m < 10; m++)//k = max range down, if the area above it clear this looks for the first plant below it { if (Main.tileSolid[Main.tile[i, j + 1 + m].type] && Main.tile[i, j + 1 + m].active() && !Main.tileSolidTop[Main.tile[i, j + 1 + m].type]) { break; //breaks if Solid is true, Active is true, and solidTop is false } else if (Main.tile[i, j + 1 + m].active() && Main.tileFrameImportant[Main.tile[i, j + 1 + m].type] && !Main.tileSolid[Main.tile[i, j + 1 + m].type]) //chooses if frameimportant, non-solid, and active { TileLoader.GetTile(Main.tile[i, j + 1 + m].type)?.RandomUpdate(i, j + 1 + m); //runs randomUpdate on selected block //TODO: I believe this doesn't work on vanilla plants since they dont use randomUpdate, figure out a way to fix this or make a case for vanilla plants break; } } } } }
public override void ResetEffects() { if (player.whoAmI != Main.myPlayer) { return; } if (postOpenCleanup) { player.talkNPC = -1; Main.playerInventory = true; postOpenCleanup = false; } if (storageAccess.N0()) { if (player.chest != -1 || !Main.playerInventory || player.sign > -1 || player.talkNPC > -1) { CloseStorage(); Recipe.FindRecipes(); } else { if ((!remoteAccess && !InRange(PlayerPosTiles, storageAccess)) || !(TileLoader.GetTile(Main.tile[storageAccess.X, storageAccess.Y].type) is TStorageAccess)) { Main.PlaySound(SoundID.MenuClose, -1, -1, 1); CloseStorage(); Recipe.FindRecipes(); } } } }
public static bool canActuate(int x, int y) { if (!WorldGen.InWorld(x, y, 1) || !canPlaceActuator(Main.tile[x, y].type)) { return(false); } if (!WorldGen.InWorld(x, y - 1, 1) || !Main.tile[x, y - 1].active()) { return(true); } int topType = Main.tile[x, y - 1].type; if (topType == TileID.Trees || topType == TileID.PalmTree || topType == TileID.MushroomTrees || TileID.Sets.BasicChest[topType] || topType == TileID.Dressers || topType == TileID.DemonAltar || topType == TileID.Hellforge) { return(false); } ModTile tt = TileLoader.GetTile(topType); if (tt != null && (tt.adjTiles.Contains(TileID.Dressers) || tt.adjTiles.Contains(TileID.Containers) || tt.adjTiles.Contains(TileID.Containers2))) { return(false); } return(true); }
// In this example we used Initialize and Unload_Inner in conjunction with Load and Unload to avoid TypeInitializationException, but we could also just check Enabled before calling MagicStorageIntegration.Unload(); and assign MagicStorage and check Enabled before calling MagicStorageIntegration.Load(); // I opted to keep the MagicStorage integration logic in the MagicStorageIntegration class to keep MagicStorage related code as sparse and unobtrusive as possible within the remaining codebase for this mod. // That said, in ItemChecklistPlayer, we see this: // if (ItemChecklistUI.collectChestItems && MagicStorageIntegration.Enabled) // MagicStorageIntegration.FindItemsInStorage(); // I could have changed this to always call FindItemsInStorage and have FindItemsInStorage check Enabled, but that would require a FindItemsInStorage_Inner type class once again to prevent errors. // Whatever approach you do, be aware of what you are doing and be careful. // StoragePlayer and TEStorageHeart are classes in MagicStorage. // Make sure to extract the .dll from the .tmod and then add them to your .csproj as references. // As a convention, I rename the .dll file ModName_v1.2.3.4.dll and place them in Mod Sources/Mods/lib. // I do this for organization and so the .csproj loads properly for others using the GitHub repository. // Remind contributors to download the referenced mod itself if they wish to build the mod. internal static void FindItemsInStorage() { var storagePlayer = Main.LocalPlayer.GetModPlayer <StoragePlayer>(); Point16 storageAccess = storagePlayer.ViewingStorage(); if (storageAccess == previousStorageAccess) { return; } previousStorageAccess = storageAccess; if (!Main.playerInventory || storageAccess.X < 0 || storageAccess.Y < 0) { return; } ModTile modTile = TileLoader.GetTile(Main.tile[storageAccess.X, storageAccess.Y].type); if (modTile == null || !(modTile is StorageAccess)) { return; } TEStorageHeart heart = ((StorageAccess)modTile).GetHeart(storageAccess.X, storageAccess.Y); if (heart == null) { return; } var items = heart.GetStoredItems(); // Will 1000 items crash the chat? foreach (var item in items) { ItemChecklist.instance.GetGlobalItem <ItemChecklistGlobalItem>().ItemReceived(item); } }
public static void RegisterAllEntities() { var types = TechMod.types; foreach (var type in types) { if (type.IsAbstract) { continue; } if (typeof(MachineEntity).IsAssignableFrom(type)) { var entity = TechMod.Instance.GetTileEntity(type.Name) as MachineEntity; var tileType = entity.MachineTile; Type tileTypeInst = TileLoader.GetTile(tileType).GetType(); tileToEntity.Add(tileType, entity); tileToStructureName.Add(tileType, tileTypeInst.Name); TechMod.Instance.Logger.Debug($"Registered tile type \"{tileTypeInst.FullName}\" (ID: {tileType}) with entity \"{type.FullName}\""); } } }
private TileCollection() { tilePickaxeMin = new ushort[TileLoader.TileCount]; // Assign vanilla tiles to 2 (Sand-like is 0, Dirt-like is 1) int i; for (i = 0; i < TileID.Count; i++) { tilePickaxeMin[i] = 2; } tilePickaxeMin.AssignValueToKeys <ushort>(0, TileID.Sand, TileID.Slush, TileID.Silt); tilePickaxeMin.AssignValueToKeys <ushort>(1, TileID.Dirt, TileID.Mud, TileID.ClayBlock, TileID.SnowBlock, TileID.Grass, TileID.CorruptGrass, TileID.FleshGrass, TileID.HallowedGrass, TileID.JungleGrass, TileID.MushroomGrass ); tilePickaxeMin.AssignValueToKeys <ushort>(50, TileID.Meteorite); tilePickaxeMin.AssignValueToKeys <ushort>(55, TileID.Demonite, TileID.Crimtane); tilePickaxeMin.AssignValueToKeys <ushort>(65, TileID.Ebonstone, TileID.Crimstone, TileID.Pearlstone, TileID.Hellstone, TileID.Obsidian, TileID.DesertFossil, TileID.BlueDungeonBrick, TileID.GreenDungeonBrick, TileID.PinkDungeonBrick ); tilePickaxeMin.AssignValueToKeys <ushort>(100, TileID.Cobalt, TileID.Palladium); tilePickaxeMin.AssignValueToKeys <ushort>(110, TileID.Mythril, TileID.Orichalcum); tilePickaxeMin.AssignValueToKeys <ushort>(150, TileID.Adamantite, TileID.Titanium); tilePickaxeMin.AssignValueToKeys <ushort>(200, TileID.Chlorophyte); tilePickaxeMin.AssignValueToKeys <ushort>(210, TileID.LihzahrdBrick, TileID.LihzahrdAltar); for (i = TileID.Count; i < TileLoader.TileCount; i++) { ModTile modTile = TileLoader.GetTile(i); tilePickaxeMin[i] = (ushort)modTile.minPick; } }
public override void ResetEffects() { if (player.whoAmI != Main.myPlayer) { return; } if (timeSinceOpen < 1) { player.talkNPC = -1; Main.playerInventory = true; timeSinceOpen++; } if (storageAccess.X >= 0 && storageAccess.Y >= 0 && (player.chest != -1 || !Main.playerInventory || player.sign > -1 || player.talkNPC > -1)) { CloseStorage(); Recipe.FindRecipes(); } else if (storageAccess.X >= 0 && storageAccess.Y >= 0) { int playerX = (int)(player.Center.X / 16f); int playerY = (int)(player.Center.Y / 16f); if (!remoteAccess && (playerX < storageAccess.X - Player.tileRangeX || playerX > storageAccess.X + Player.tileRangeX + 1 || playerY < storageAccess.Y - Player.tileRangeY || playerY > storageAccess.Y + Player.tileRangeY + 1)) { Main.PlaySound(11, -1, -1, 1); CloseStorage(); Recipe.FindRecipes(); } else if (!(TileLoader.GetTile(Main.tile[storageAccess.X, storageAccess.Y].type) is StorageAccess)) { Main.PlaySound(11, -1, -1, 1); CloseStorage(); Recipe.FindRecipes(); } } }
public override bool UseItem(Player player) { Terraria.Audio.LegacySoundStyle hitSound = SoundID.Item1; Vector2 position = GetLightPosition(player); //Vector2 location = hitbox.Location.ToVector2(); Point tileLocation = position.ToTileCoordinates(); ModTile tile = TileLoader.GetTile(Main.tile[tileLocation.X, tileLocation.Y].type); if (tile == null) { return(false); } switch (tile.soundType & 3) { case 0: hitSound = SoundID.Item11; break; case 1: hitSound = SoundID.Item12; break; case 2: hitSound = SoundID.Item13; break; case 3: hitSound = SoundID.Item14; break; } Main.PlaySound(hitSound, position); return(true); }
/*public override void RightClick(int i, int j)//Debug * { * Main.NewText("Manual Update"); * TileLoader.GetTile(Main.tile[i, j].type)?.RandomUpdate(i, j); * }*/ public override void RandomUpdate(int i, int j) { for (int k = 0; k < 10; k++) //k = max range up, this checks the area above it { if (Main.tileSolid[Main.tile[i, (j - 1) - k].type] && Main.tile[i, (j - 1) - k].active() && !Main.tileSolidTop[Main.tile[i, (j - 1) - k].type] && Main.tile[i, (j - 1) - k].type != Type && Main.tile[i, (j - 1) - k].type != TileID.Glass) //maybe check for just blocks that stop light? { break; //breaks if Solid if all of the above checks are true: Solid, active, No solidTop, not This type of block, and not glass } else if (k == 9) { for (int m = 0; m < 10; m++)//k = max range down, if the area above it clear this looks for the first plant below it { if (Main.tileSolid[Main.tile[i, (j + 1) + m].type] && Main.tile[i, (j + 1) + m].active() && !Main.tileSolidTop[Main.tile[i, (j + 1) + m].type]) { break; //breaks if Solid is true, Active is true, and solidTop is false } else if (Main.tile[i, (j + 1) + m].active() && Main.tileFrameImportant[Main.tile[i, (j + 1) + m].type] && !Main.tileSolid[Main.tile[i, (j + 1) + m].type]) //chooses if frameimportant, non-solid, and active { TileLoader.GetTile(Main.tile[i, (j + 1) + m].type)?.RandomUpdate(i, (j + 1) + m); //runs randomUpdate on selected block break; } } } } }
public override void PostUpdate() { if (Main.dedServ || !DisplayWorldTooltips) { return; } Mod displayMod = null; Mod modLoaderMod = ModLoader.GetMod("ModLoader"); //modmodloadermodmodloadermodmodloader int mysteryTile = modLoaderMod.TileType("MysteryTile"); int mysteryTile2 = modLoaderMod.TileType("PendingMysteryTile"); var tile = Main.tile[Player.tileTargetX, Player.tileTargetY]; if (tile != null) { if (tile.active() && tile.type != mysteryTile && tile.type != mysteryTile2) { var modTile = TileLoader.GetTile(tile.type); if (modTile != null) { displayMod = modTile.mod; } } else { var modWall = WallLoader.GetWall(tile.wall); if (modWall != null) { displayMod = modWall.mod; } } } var mousePos = Main.MouseWorld; for (int i = 0; i < Main.maxNPCs; i++) { var npc = Main.npc[i]; if (mousePos.Between(npc.TopLeft, npc.BottomRight)) { var modNPC = NPCLoader.GetNPC(npc.type); if (modNPC != null && npc.active && !NPCID.Sets.ProjectileNPC[npc.type]) { displayMod = modNPC.mod; SecondLine = true; break; } } } if (displayMod != null) { MouseText = String.Format("[c/{1}:[{0}][c/{1}:]]", displayMod.DisplayName, Colors.RarityBlue.Hex3()); if (Main.mouseText) { SecondLine = true; } } }
internal static TagCompound SaveTiles() { var hasTile = new bool[TileLoader.TileCount]; var hasWall = new bool[WallLoader.WallCount]; using (var ms = new MemoryStream()) using (var writer = new BinaryWriter(ms)) { WriteTileData(writer, hasTile, hasWall); var tileList = new List <TagCompound>(); for (int type = TileID.Count; type < hasTile.Length; type++) { if (!hasTile[type]) { continue; } var modTile = TileLoader.GetTile(type); tileList.Add(new TagCompound { ["value"] = (short)type, ["mod"] = modTile.mod.Name, ["name"] = modTile.Name, ["framed"] = Main.tileFrameImportant[type], }); } var wallList = new List <TagCompound>(); for (int wall = WallID.Count; wall < hasWall.Length; wall++) { if (!hasWall[wall]) { continue; } var modWall = WallLoader.GetWall(wall); wallList.Add(new TagCompound { ["value"] = (short)wall, ["mod"] = modWall.mod.Name, ["name"] = modWall.Name, }); } if (tileList.Count == 0 && wallList.Count == 0) { return(null); } return(new TagCompound { ["tileMap"] = tileList, ["wallMap"] = wallList, ["data"] = ms.ToArray() }); } }
public override void PostUpdate() { if (Main.dedServ || !DisplayWorldTooltips) { return; } MouseText = String.Empty; SecondLine = false; var modLoaderMod = ModLoader.GetMod("ModLoader"); //modmodloadermodmodloadermodmodloader int mysteryTile = modLoaderMod.TileType("MysteryTile"); int mysteryTile2 = modLoaderMod.TileType("PendingMysteryTile"); var tile = Main.tile[Player.tileTargetX, Player.tileTargetY]; if (tile != null) { if (tile.active() && tile.type != mysteryTile && tile.type != mysteryTile2) { var modTile = TileLoader.GetTile(tile.type); if (modTile != null) { MouseText = DisplayTechnicalNames ? (modTile.mod.Name + ":" + modTile.Name) : modTile.mod.DisplayName; } } else { var modWall = WallLoader.GetWall(tile.wall); if (modWall != null) { MouseText = DisplayTechnicalNames ? (modWall.mod.Name + ":" + modWall.Name) : modWall.mod.DisplayName; } } } var mousePos = Main.MouseWorld; for (int i = 0; i < Main.maxNPCs; i++) { var npc = Main.npc[i]; if (mousePos.Between(npc.TopLeft, npc.BottomRight)) { var modNPC = NPCLoader.GetNPC(npc.type); if (modNPC != null && npc.active && !NPCID.Sets.ProjectileNPC[npc.type]) { MouseText = DisplayTechnicalNames ? (modNPC.mod.Name + ":" + modNPC.Name) : modNPC.mod.DisplayName; SecondLine = true; break; } } } if (MouseText != String.Empty && Main.mouseText) { SecondLine = true; } }
public static void SetupConnectors() { for (ushort i = 0; i < TileLoader.TileCount; i++) { ModTile mt = TileLoader.GetTile(i); if (mt is TStorageComponent || mt is TStorageConnector) { tilesToConnect.Add(i); } } }
public static ushort FindTileIDInArray(string whatItNeedToEndWith, string whatItDoesntNeedToContain, IList <int> tile) { foreach (var tileID in tile) { ModTile modTile = TileLoader.GetTile(tileID); if (modTile != null && modTile.Name.EndsWith(whatItNeedToEndWith) && !modTile.Name.Contains(whatItDoesntNeedToContain)) { return(modTile.Type); } } return(0); }
public static IEnumerable <Point16> AdjacentComponents(Point16 point, bool isConnectorCanPlace = false) { List <Point16> points = new List <Point16>(); bool isConnector = Main.tile[point.X, point.Y].type == MagicStorageTwo.Instance.TileType(nameof(TStorageConnector)) || isConnectorCanPlace; bool isLargeSocket = Main.tile[point.X, point.Y].type == MagicStorageTwo.Instance.TileType(nameof(TCraftingTileSocketLarge)); bool isSocket = Main.tile[point.X, point.Y].type == MagicStorageTwo.Instance.TileType(nameof(TCraftingTileSocket)); foreach (Point16 add in (isConnector ? checkNeighbors1x1 : isLargeSocket ? checkNeighbors3x1 : isSocket ? checkNeighbors2x1 : checkNeighbors2x2)) { int checkX = point.X + add.X; int checkY = point.Y + add.Y; Tile tile = Main.tile[checkX, checkY]; if (ModContent.GetInstance <MagicStorageConfig>().DebugDustParticles) { Dust.NewDust(new Vector2(checkX * 16 + 4, checkY * 16 + 4), 1, 1, isConnector ? 60 : isLargeSocket || isSocket ? 61 : 62, Alpha: 0, Scale: 0.3f); } if (!tile.active()) { continue; } if (TileLoader.GetTile(tile.type) is TStorageComponent) { if (tile.frameX == 36 && !(TileLoader.GetTile(tile.type) is TStorageUnit)) { checkX -= 2; } if (tile.frameX % 36 == 18) { checkX--; } if (tile.frameY % 36 == 18) { checkY--; } Point16 check = new Point16(checkX, checkY); if (!points.Contains(check)) { points.Add(check); } } else if (tile.type == MagicStorageTwo.Instance.TileType(nameof(TStorageConnector))) { Point16 check = new Point16(checkX, checkY); if (!points.Contains(check)) { points.Add(check); } } } return(points); }
public override void PreUpdate() { if (!Main.mapFullscreen) { int myX = Player.tileTargetX; int myY = Player.tileTargetY; if (player.position.X / 16f - Player.tileRangeX <= myX && (player.position.X + player.width) / 16f + Player.tileRangeX - 1f >= myX && player.position.Y / 16f - Player.tileRangeY <= myY && (player.position.Y + player.height) / 16f + Player.tileRangeY - 2f >= myY) { if (Main.mouseLeft && Main.mouseLeftRelease) { if (Main.tile[myX, myY] == null) { Main.tile[myX, myY] = new Tile(); } if (Main.tile[myX, myY].active()) { int type = Main.tile[myX, myY].type; ModTile tile = TileLoader.GetTile(type); (tile as BaseTile)?.LeftClick(myX, myY); } } if (Main.mouseRight) { if (Main.tile[myX, myY] == null) { Main.tile[myX, myY] = new Tile(); } if (Main.tile[myX, myY].active()) { int type = Main.tile[myX, myY].type; ModTile tile = TileLoader.GetTile(type); (tile as BaseTile)?.RightClickCont(myX, myY); } } if (Main.mouseLeft) { if (Main.tile[myX, myY] == null) { Main.tile[myX, myY] = new Tile(); } if (Main.tile[myX, myY].active()) { int type = Main.tile[myX, myY].type; ModTile tile = TileLoader.GetTile(type); (tile as BaseTile)?.LeftClickCont(myX, myY); } } } } }
public override bool UseItem(Player player) { Vector2 position = GetLightPosition(player); Point tileLocation = position.ToTileCoordinates(); ModTile tile = TileLoader.GetTile(Main.tile[tileLocation.X, tileLocation.Y].type); if (tile is IInstrument instrument) { instrument.PitchOffset(tileLocation.X, tileLocation.Y); return(true); } return(false); }
internal static bool WriteModMap(BinaryWriter writer) { ISet <ushort> types = new HashSet <ushort>(); for (int i = 0; i < Main.maxTilesX; i++) { for (int j = 0; j < Main.maxTilesY; j++) { ushort type = Main.Map[i, j].Type; if (type >= MapHelper.modPosition) { types.Add(type); } } } if (types.Count == 0) { return(false); } writer.Write((ushort)types.Count); foreach (ushort type in types) { writer.Write(type); if (MapLoader.entryToTile.ContainsKey(type)) { ModTile tile = TileLoader.GetTile(MapLoader.entryToTile[type]); writer.Write(true); writer.Write(tile.Mod.Name); writer.Write(tile.Name); writer.Write((ushort)(type - MapHelper.tileLookup[tile.Type])); } else if (MapLoader.entryToWall.ContainsKey(type)) { ModWall wall = WallLoader.GetWall(MapLoader.entryToWall[type]); writer.Write(false); writer.Write(wall.Mod.Name); writer.Write(wall.Name); writer.Write((ushort)(type - MapHelper.wallLookup[wall.Type])); } else { writer.Write(true); writer.Write(""); writer.Write(""); writer.Write((ushort)0); } } WriteMapData(writer); return(true); }
public override void PostUpdate() { if (Main.dedServ || !ModContent.GetInstance <Config>().DisplayWorldTooltips) { return; } WMITFModSystem.MouseText = String.Empty; WMITFModSystem.SecondLine = false; var tile = Main.tile[Player.tileTargetX, Player.tileTargetY]; if (tile.HasTile && !WMITF.IsUnloadedTile(tile)) { var modTile = TileLoader.GetTile(tile.TileType); if (modTile != null) { WMITFModSystem.MouseText = ModContent.GetInstance <Config>().DisplayTechnicalNames ? (modTile.Mod.Name + ":" + modTile.Name) : modTile.Mod.DisplayName; } } else { var modWall = WallLoader.GetWall(tile.WallType); if (modWall != null) { WMITFModSystem.MouseText = ModContent.GetInstance <Config>().DisplayTechnicalNames ? (modWall.Mod.Name + ":" + modWall.Name) : modWall.Mod.DisplayName; } } var mousePos = Main.MouseWorld; for (int i = 0; i < Main.maxNPCs; i++) { var npc = Main.npc[i]; if (mousePos.Between(npc.TopLeft, npc.BottomRight)) { var modNPC = NPCLoader.GetNPC(npc.type); if (modNPC != null && npc.active && !NPCID.Sets.ProjectileNPC[npc.type]) { WMITFModSystem.MouseText = ModContent.GetInstance <Config>().DisplayTechnicalNames ? (modNPC.Mod.Name + ":" + modNPC.Name) : modNPC.Mod.DisplayName; WMITFModSystem.SecondLine = true; break; } } } if (WMITFModSystem.MouseText != String.Empty && Main.mouseText) { WMITFModSystem.SecondLine = true; } }
public static string GetUniqueKey(int type) { if (type < 0 || type >= TileLoader.TileCount) { throw new ArgumentOutOfRangeException("Invalid type: " + type); } if (type < TileID.Count) { return("Terraria " + TileIdentityHelpers.TileIdSearch.GetName(type)); } ModTile modTile = TileLoader.GetTile(type); return($"{modTile.mod.Name} {modTile.Name}"); }
public static void TestAddTileTranslation() { try { var type = ModLoader.GetMod("Bluemagic").TileType("ElementalBar"); if (type > 0) { TranslateTool.AddTileNameTranslation(TileLoader.GetTile(type), "测试tile名字", GameCulture.Chinese); } } catch (Exception ex) { ErrorLogger.Log(ex.ToString()); } }
public static void Export(Vector2 start, Vector2 end) { Point starttc = start.ToTileCoordinates(); Point endtc = end.ToTileCoordinates(); Tile[,] toexport = new Tile[endtc.X - starttc.X + 1, endtc.Y - starttc.Y + 1]; for (int i = 0; i < toexport.GetLength(0); i++) { for (int j = 0; j < toexport.GetLength(1); j++) { int wi = starttc.X + i; int wj = starttc.Y + j; toexport[i, j] = new Tile(); toexport[i, j].CopyFrom(Main.tile[wi, wj]); } } using (FileStream fs = File.OpenWrite(BuildingSavePath + "1.buildings")) using (DeflateStream ds = new DeflateStream(fs, CompressionMode.Compress)) using (BinaryWriter bw = new BinaryWriter(ds)) { bw.Write(toexport.GetLength(0)); bw.Write(toexport.GetLength(1)); for (int i = 0; i < toexport.GetLength(0); i++) { for (int j = 0; j < toexport.GetLength(1); j++) { var from = toexport[i, j]; bw.Write(from.type); if (TileLoader.GetTile(toexport[i, j].type) != null) { bw.Write(TileLoader.GetTile(toexport[i, j].type).Name); } else { bw.Write(""); } bw.Write(from.wall); bw.Write(from.liquid); bw.Write(from.sTileHeader); bw.Write(from.bTileHeader); bw.Write(from.bTileHeader2); bw.Write(from.bTileHeader3); bw.Write(from.frameX); bw.Write(from.frameY); } } } }
public static ushort FindModdedTileIDInArray(IList <int> tiles, string endsWith = "", string contains = "") { foreach (int tileID in tiles) { ModTile modTile = TileLoader.GetTile(tileID); if (modTile != null && (!string.IsNullOrWhiteSpace(endsWith) && modTile.Name.EndsWith(endsWith)) && (!string.IsNullOrWhiteSpace(contains) && modTile.Name.Contains(contains))) { return(modTile.Type); } } return(ushort.MinValue); }
public static StorageAccess GetStorageAccess() { var player = Get; if (!Main.playerInventory || player.StorageAccess.X < 0 || player.StorageAccess.Y < 0) { return(null); } ModTile result = TileLoader.GetTile(Main.tile[player.StorageAccess.X, player.StorageAccess.Y].type); if (result == null || !(result is StorageAccess)) { return(null); } return(result as StorageAccess); }
private FootstepManager() { int count = TileLoader.TileCount; _tileFootstepSounds = new FootstepSound[count]; // Vanilla tiles _tileFootstepSounds.AssignValueToKeys(FootstepSound.None, TileID.Plants, TileID.Torches, TileID.Trees, TileID.ClosedDoor, TileID.OpenDoor, TileID.Heart, TileID.Bottles, TileID.Saplings, TileID.Chairs, TileID.Furnaces, TileID.Containers, TileID.CorruptPlants, TileID.DemonAltar, TileID.Sunflower, TileID.Pots, TileID.PiggyBank, TileID.ShadowOrbs, TileID.CorruptThorns, TileID.Candles, TileID.Chandeliers, TileID.Jackolanterns, TileID.Presents, TileID.HangingLanterns, TileID.WaterCandle, TileID.Books, TileID.Cobweb, TileID.Vines, TileID.Signs, TileID.JunglePlants, TileID.JungleVines, TileID.JungleThorns, TileID.MushroomPlants, TileID.MushroomTrees, TileID.Plants2, TileID.JunglePlants2, TileID.Hellforge, TileID.ClayPot, TileID.Beds, TileID.Cactus, TileID.Coral, TileID.ImmatureHerbs, TileID.MatureHerbs, TileID.BloomingHerbs, TileID.Tombstones, TileID.Loom, TileID.Bathtubs, TileID.Banners, TileID.Benches, TileID.Lampposts, TileID.Lampposts, TileID.Kegs, TileID.ChineseLanterns, TileID.CookingPots, TileID.Safes, TileID.SkullLanterns, TileID.TrashCan, TileID.Candelabras, TileID.Thrones, TileID.Bowls, TileID.GrandfatherClocks, TileID.Statues, TileID.Sawmill, TileID.HallowedPlants, TileID.HallowedPlants2, TileID.HallowedVines, TileID.WoodenBeam, TileID.CrystalBall, TileID.DiscoBall, TileID.Mannequin, TileID.Crystals, TileID.InactiveStoneBlock, TileID.Lever, TileID.AdamantiteForge, TileID.PressurePlates, TileID.Switches, TileID.MusicBoxes, TileID.Explosives, TileID.InletPump, TileID.OutletPump, TileID.Timers, TileID.HolidayLights, TileID.Stalactite, TileID.ChristmasTree, TileID.Sinks, TileID.PlatinumCandelabra, TileID.PlatinumCandle, TileID.ExposedGems, TileID.GreenMoss, TileID.BrownMoss, TileID.RedMoss, TileID.BlueMoss, TileID.PurpleMoss, TileID.LongMoss, TileID.SmallPiles, TileID.LargePiles, TileID.LargePiles2, TileID.FleshWeeds, TileID.CrimsonVines, TileID.WaterFountain, TileID.Cannon, TileID.LandMine, TileID.SnowballLauncher, TileID.Rope, TileID.Chain, TileID.Campfire, TileID.Firework, TileID.Blendomatic, TileID.MeatGrinder, TileID.Extractinator, TileID.Solidifier, TileID.DyePlants, TileID.DyeVat, TileID.Larva, TileID.PlantDetritus, TileID.LifeFruit, TileID.LihzahrdAltar, TileID.PlanteraBulb, TileID.Painting3X3, TileID.Painting4X3, TileID.Painting6X4, TileID.ImbuingStation, TileID.BubbleMachine, TileID.Painting2X3, TileID.Painting3X2, TileID.Autohammer, TileID.Pumpkins, TileID.Womannequin, TileID.FireflyinaBottle, TileID.LightningBuginaBottle, TileID.BunnyCage, TileID.SquirrelCage, TileID.MallardDuckCage, TileID.DuckCage, TileID.BirdCage, TileID.BlueJay, TileID.CardinalCage, TileID.FishBowl, TileID.HeavyWorkBench, TileID.SnailCage, TileID.GlowingSnailCage, TileID.AmmoBox, TileID.MonarchButterflyJar, TileID.PurpleEmperorButterflyJar, TileID.RedAdmiralButterflyJar, TileID.UlyssesButterflyJar, TileID.SulphurButterflyJar, TileID.TreeNymphButterflyJar, TileID.ZebraSwallowtailButterflyJar, TileID.JuliaButterflyJar, TileID.ScorpionCage, TileID.BlackScorpionCage, TileID.FrogCage, TileID.MouseCage, TileID.BoneWelder, TileID.FleshCloningVat, TileID.GlassKiln, TileID.LihzahrdFurnace, TileID.LivingLoom, TileID.SkyMill, TileID.IceMachine, TileID.SteampunkBoiler, TileID.HoneyDispenser, TileID.PenguinCage, TileID.WormCage, TileID.MinecartTrack, TileID.BlueJellyfishBowl, TileID.GreenJellyfishBowl, TileID.PinkJellyfishBowl, TileID.ShipInABottle, TileID.SeaweedPlanter, TileID.PalmTree, TileID.BeachPiles, TileID.CopperCoinPile, TileID.SilverCoinPile, TileID.GoldCoinPile, TileID.PlatinumCoinPile, TileID.WeaponsRack, TileID.FireworksBox, TileID.LivingFire, TileID.AlphabetStatues, TileID.FireworkFountain, TileID.GrasshopperCage, TileID.LivingCursedFire, TileID.LivingDemonFire, TileID.LivingFrostFire, TileID.LivingIchor, TileID.LivingUltrabrightFire, TileID.MushroomStatue, TileID.ChimneySmoke, TileID.CrimtaneThorns, TileID.VineRope, TileID.BewitchingTable, TileID.AlchemyTable, TileID.Sundial, TileID.GoldBirdCage, TileID.GoldBunnyCage, TileID.GoldButterflyCage, TileID.GoldFrogCage, TileID.GoldGrasshopperCage, TileID.GoldMouseCage, TileID.GoldWormCage, TileID.SilkRope, TileID.WebRope, TileID.PeaceCandle, TileID.WaterDrip, TileID.LavaDrip, TileID.HoneyDrip, TileID.SharpeningStation, TileID.TargetDummy, TileID.Bubble, TileID.PlanterBox, TileID.VineFlowers, TileID.TrapdoorOpen, TileID.TallGateClosed, TileID.TallGateOpen, TileID.LavaLamp, TileID.CageEnchantedNightcrawler, TileID.CageBuggy, TileID.CageGrubby, TileID.CageSluggy, TileID.ItemFrame, TileID.Chimney, TileID.LunarMonolith, TileID.Detonator, TileID.LunarCraftingStation, TileID.SquirrelOrangeCage, TileID.SquirrelGoldCage, TileID.LogicGateLamp, TileID.LogicGate, TileID.LogicSensor, TileID.WirePipe, TileID.AnnouncementBox, TileID.WeightedPressurePlate, TileID.WireBulb, TileID.GemLocks, TileID.FakeContainers, TileID.ProjectilePressurePad, TileID.GeyserTrap, TileID.BeeHive, TileID.PixelBox, TileID.SillyStreamerBlue, TileID.SillyStreamerGreen, TileID.SillyStreamerPink, TileID.SillyBalloonMachine, TileID.Pigronata, TileID.PartyMonolith, TileID.PartyBundleOfBalloonTile, TileID.PartyPresent, TileID.SandDrip, TileID.DjinnLamp, TileID.DefendersForge, TileID.WarTable, TileID.WarTableBanner, TileID.ElderCrystalStand, TileID.Containers2, TileID.FakeContainers2, TileID.Tables2); _tileFootstepSounds.AssignValueToKeys(FootstepSound.Grass, TileID.Dirt, TileID.Grass, TileID.CorruptGrass, TileID.ClayBlock, TileID.Mud, TileID.JungleGrass, TileID.MushroomGrass, TileID.HallowedGrass, TileID.PineTree, TileID.LeafBlock, TileID.FleshGrass, TileID.HayBlock, TileID.LavaMoss, TileID.LivingMahoganyLeaves); _tileFootstepSounds.AssignValueToKeys(FootstepSound.Rock, TileID.Stone, TileID.Iron, TileID.Copper, TileID.Gold, TileID.Silver, TileID.Demonite, TileID.Ebonstone, TileID.Meteorite, TileID.Obsidian, TileID.Hellstone, TileID.Sapphire, TileID.Ruby, TileID.Emerald, TileID.Topaz, TileID.Amethyst, TileID.Diamond, TileID.Cobalt, TileID.Mythril, TileID.Adamantite, TileID.Pearlstone, TileID.ActiveStoneBlock, TileID.Boulder, TileID.IceBlock, TileID.BreakableIce, TileID.CorruptIce, TileID.HallowedIce, TileID.Tin, TileID.Lead, TileID.Tungsten, TileID.Platinum, TileID.BoneBlock, TileID.FleshBlock, TileID.Asphalt, TileID.FleshIce, TileID.Crimstone, TileID.Crimtane, TileID.Chlorophyte, TileID.Palladium, TileID.Orichalcum, TileID.Titanium, TileID.MetalBars, TileID.Cog, TileID.Marble, TileID.Granite, TileID.Sandstone, TileID.HardenedSand, TileID.CorruptHardenedSand, TileID.CrimsonHardenedSand, TileID.CorruptSandstone, TileID.CrimsonSandstone, TileID.HallowHardenedSand, TileID.HallowSandstone, TileID.DesertFossil, TileID.FossilOre, TileID.LunarOre, TileID.LunarBlockSolar, TileID.LunarBlockVortex, TileID.LunarBlockNebula, TileID.LunarBlockStardust); _tileFootstepSounds.AssignValueToKeys(FootstepSound.Wood, TileID.Tables, TileID.WorkBenches, TileID.Platforms, TileID.WoodBlock, TileID.Pianos, TileID.Dressers, TileID.Bookcases, TileID.TinkerersWorkbench, TileID.Ebonwood, TileID.RichMahogany, TileID.Pearlwood, TileID.Shadewood, TileID.WoodenSpikes, TileID.SpookyWood, TileID.DynastyWood, TileID.RedDynastyShingles, TileID.BlueDynastyShingles, TileID.BorealWood, TileID.PalmWood, TileID.FishingCrate, TileID.TrapdoorClosed); _tileFootstepSounds.AssignValueToKeys(FootstepSound.Sand, TileID.Sand, TileID.Ash, TileID.Ebonsand, TileID.Pearlsand, TileID.Silt, TileID.Hive, TileID.CrispyHoneyBlock, TileID.Crimsand); _tileFootstepSounds.AssignValueToKeys(FootstepSound.Snow, TileID.SnowBlock, TileID.RedStucco, TileID.YellowStucco, TileID.GreenStucco, TileID.GrayStucco, TileID.Cloud, TileID.RainCloud, TileID.Slush, TileID.HoneyBlock, TileID.SnowCloud); _tileFootstepSounds.AssignValueToKeys(FootstepSound.Mushroom, TileID.CandyCaneBlock, TileID.GreenCandyCaneBlock, TileID.CactusBlock, TileID.MushroomBlock, TileID.SlimeBlock, TileID.FrozenSlimeBlock, TileID.BubblegumBlock, TileID.PumpkinBlock, TileID.Coralstone, TileID.PinkSlimeBlock, TileID.SillyBalloonPink, TileID.SillyBalloonPurple, TileID.SillyBalloonGreen, TileID.SillyBalloonTile); _tileFootstepSounds.AssignValueToKeys(FootstepSound.LightDark, TileID.Glass, TileID.MagicalIceBlock, TileID.Sunplate, TileID.Teleporter, TileID.AmethystGemsparkOff, TileID.TopazGemsparkOff, TileID.SapphireGemsparkOff, TileID.EmeraldGemsparkOff, TileID.RubyGemsparkOff, TileID.DiamondGemsparkOff, TileID.AmberGemsparkOff, TileID.AmethystGemspark, TileID.TopazGemspark, TileID.SapphireGemspark, TileID.EmeraldGemspark, TileID.RubyGemspark, TileID.DiamondGemspark, TileID.AmberGemspark, TileID.Waterfall, TileID.Lavafall, TileID.Confetti, TileID.ConfettiBlack, TileID.Honeyfall, TileID.CrystalBlock, TileID.LunarBrick, TileID.TeamBlockRed, TileID.TeamBlockRedPlatform, TileID.TeamBlockGreen, TileID.TeamBlockBlue, TileID.TeamBlockYellow, TileID.TeamBlockPink, TileID.TeamBlockWhite, TileID.TeamBlockGreenPlatform, TileID.TeamBlockBluePlatform, TileID.TeamBlockYellowPlatform, TileID.TeamBlockPinkPlatform, TileID.TeamBlockWhitePlatform, TileID.SandFallBlock, TileID.SnowFallBlock); _tileFootstepSounds.AssignValueToKeys(FootstepSound.SpiritTreeRock, TileID.Anvils, TileID.GrayBrick, TileID.RedBrick, TileID.BlueDungeonBrick, TileID.GreenDungeonBrick, TileID.PinkDungeonBrick, TileID.GoldBrick, TileID.SilverBrick, TileID.CopperBrick, TileID.Spikes, TileID.ObsidianBrick, TileID.HellstoneBrick, TileID.PearlstoneBrick, TileID.IridescentBrick, TileID.Mudstone, TileID.CobaltBrick, TileID.MythrilBrick, TileID.MythrilAnvil, TileID.Traps, TileID.DemoniteBrick, TileID.SnowBrick, TileID.AdamantiteBeam, TileID.SandstoneBrick, TileID.EbonstoneBrick, TileID.RainbowBrick, TileID.TinBrick, TileID.TungstenBrick, TileID.PlatinumBrick, TileID.IceBrick, TileID.LihzahrdBrick, TileID.PalladiumColumn, TileID.Titanstone, TileID.StoneSlab, TileID.SandStoneSlab, TileID.CopperPlating, TileID.TinPlating, TileID.ChlorophyteBrick, TileID.CrimtaneBrick, TileID.ShroomitePlating, TileID.MartianConduitPlating, TileID.MarbleBlock, TileID.GraniteBlock, TileID.MeteoriteBrick, TileID.Fireplace, TileID.ConveyorBeltLeft, TileID.ConveyorBeltRight); _tileFootstepSounds.AssignValueToKeys(FootstepSound.SpiritTreeWood, TileID.LivingWood, TileID.LivingMahogany); // Mod tiles int missingSoundCount = 0; for (int i = TileID.Count; i < count; i++) { if (!Main.tileSolid[i] && !Main.tileSolidTop[i]) { _tileFootstepSounds[i] = FootstepSound.None; continue; } string tileName = TileLoader.GetTile(i).Name; string name = tileName.Substring(tileName.LastIndexOf('.') + 1); FootstepSound sound = SoundFromName(name); _tileFootstepSounds[i] = sound; if (sound == FootstepSound.NoModTranslation) { // Print in debug build only, or try implementing more catches for tile names to sounds //OriMod.Log.Warn($"Could not get appropriate sound from mod tile name \"{name}\""); missingSoundCount++; } } if (missingSoundCount > 0) { OriMod.Log.Debug($"Could not guess footstep sounds for {missingSoundCount} tiles."); } }