internal static void ResizeArrays(bool unloading = false) { //Textures Array.Resize(ref TextureAssets.Wall, nextWall); //Sets LoaderUtils.ResetStaticMembers(typeof(WallID), true); //Etc Array.Resize(ref Main.wallHouse, nextWall); Array.Resize(ref Main.wallDungeon, nextWall); Array.Resize(ref Main.wallLight, nextWall); Array.Resize(ref Main.wallBlend, nextWall); Array.Resize(ref Main.wallLargeFrames, nextWall); Array.Resize(ref Main.wallFrame, nextWall); Array.Resize(ref Main.wallFrameCounter, nextWall); ModLoader.BuildGlobalHook(ref HookKillSound, globalWalls, g => g.KillSound); ModLoader.BuildGlobalHook(ref HookNumDust, globalWalls, g => g.NumDust); ModLoader.BuildGlobalHook(ref HookCreateDust, globalWalls, g => g.CreateDust); ModLoader.BuildGlobalHook(ref HookDrop, globalWalls, g => g.Drop); ModLoader.BuildGlobalHook(ref HookKillWall, globalWalls, g => g.KillWall); ModLoader.BuildGlobalHook(ref HookCanExplode, globalWalls, g => g.CanExplode); ModLoader.BuildGlobalHook(ref HookModifyLight, globalWalls, g => g.ModifyLight); ModLoader.BuildGlobalHook(ref HookRandomUpdate, globalWalls, g => g.RandomUpdate); ModLoader.BuildGlobalHook(ref HookPreDraw, globalWalls, g => g.PreDraw); ModLoader.BuildGlobalHook(ref HookPostDraw, globalWalls, g => g.PostDraw); ModLoader.BuildGlobalHook(ref HookPlaceInWorld, globalWalls, g => g.PlaceInWorld); if (!unloading) { loaded = true; } }
internal static void ResizeArrays() { //Sets LoaderUtils.ResetStaticMembers(typeof(MountID), true); //Etc Array.Resize(ref Mount.mounts, MountCount); }
internal static void ResizeArrays(bool unloading) { //Textures Array.Resize(ref TextureAssets.Npc, nextNPC); //Sets LoaderUtils.ResetStaticMembers(typeof(NPCID), true); //Etc Array.Resize(ref Main.townNPCCanSpawn, nextNPC); Array.Resize(ref Main.slimeRainNPC, nextNPC); Array.Resize(ref Main.npcCatchable, nextNPC); Array.Resize(ref Main.npcFrameCount, nextNPC); Array.Resize(ref Main.SceneMetrics.NPCBannerBuff, nextNPC); Array.Resize(ref NPC.killCount, nextNPC); Array.Resize(ref NPC.npcsFoundForCheckActive, nextNPC); Array.Resize(ref Lang._npcNameCache, nextNPC); Array.Resize(ref EmoteBubble.CountNPCs, nextNPC); Array.Resize(ref WorldGen.TownManager._hasRoom, nextNPC); foreach (var player in Main.player) { Array.Resize(ref player.npcTypeNoAggro, nextNPC); } for (int k = NPCID.Count; k < nextNPC; k++) { Main.npcFrameCount[k] = 1; Lang._npcNameCache[k] = LocalizedText.Empty; } globalNPCsArray = globalNPCs .Select(g => new Instanced <GlobalNPC>(g.index, g)) .ToArray(); foreach (var hook in hooks) { hook.Update(globalNPCs); } if (!unloading) { loaded = true; } }
//change initial size of Terraria.Player.npcTypeNoAggro and NPCBannerBuff to NPCLoader.NPCCount() //in Terraria.Main.MouseText replace 251 with NPCLoader.NPCCount() //in Terraria.Main.DrawNPCs and Terraria.NPC.NPCLoot remove type too high check //replace a lot of 540 immediates //in Terraria.GameContent.UI.EmoteBubble make CountNPCs internal internal static void ResizeArrays(bool unloading) { //Textures Array.Resize(ref TextureAssets.Npc, nextNPC); //Sets LoaderUtils.ResetStaticMembers(typeof(NPCID), true); //Etc Array.Resize(ref Main.townNPCCanSpawn, nextNPC); Array.Resize(ref Main.slimeRainNPC, nextNPC); Array.Resize(ref Main.npcCatchable, nextNPC); Array.Resize(ref Main.npcFrameCount, nextNPC); Array.Resize(ref NPC.killCount, nextNPC); Array.Resize(ref NPC.npcsFoundForCheckActive, nextNPC); Array.Resize(ref Lang._npcNameCache, nextNPC); Array.Resize(ref EmoteBubble.CountNPCs, nextNPC); Array.Resize(ref WorldGen.TownManager._hasRoom, nextNPC); for (int k = NPCID.Count; k < nextNPC; k++) { Main.npcFrameCount[k] = 1; Lang._npcNameCache[k] = LocalizedText.Empty; } InstancedGlobals = globalNPCs.Where(g => g.InstancePerEntity).ToArray(); for (int i = 0; i < InstancedGlobals.Length; i++) { InstancedGlobals[i].instanceIndex = i; } foreach (var hook in hooks) { hook.arr = ModLoader.BuildGlobalHook(globalNPCs, hook.method); } if (!unloading) { loaded = true; } }
//in Terraria.GameContent.ChildSafety make SafeGore internal and not readonly internal static void ResizeAndFillArrays() { //Textures Array.Resize(ref TextureAssets.Gore, GoreCount); //Sets LoaderUtils.ResetStaticMembers(typeof(GoreID), true); Array.Resize(ref ChildSafety.SafeGore, GoreCount); for (int k = GoreID.Count; k < GoreCount; k++) { GoreID.Sets.DisappearSpeed[k] = 1; GoreID.Sets.DisappearSpeedAlpha[k] = 1; } foreach (var pair in gores) { TextureAssets.Gore[pair.Key] = ModContent.GetTexture(pair.Value.Texture); } }
//in Terraria.GameContent.ChildSafety make SafeGore internal and not readonly internal static void ResizeAndFillArrays() { //Textures Array.Resize(ref TextureAssets.Gore, nextGore); //Sets LoaderUtils.ResetStaticMembers(typeof(GoreID), true); Array.Resize(ref ChildSafety.SafeGore, nextGore); for (int k = GoreID.Count; k < nextGore; k++) { GoreID.Sets.DisappearSpeed[k] = 1; GoreID.Sets.DisappearSpeedAlpha[k] = 1; } foreach (string texture in gores.Keys) { TextureAssets.Gore[gores[texture]] = ModContent.GetTexture(texture); } }
//change initial size of Terraria.Player.ownedProjectileCounts to ProjectileLoader.ProjectileCount() internal static void ResizeArrays() { //Textures Array.Resize(ref TextureAssets.Projectile, nextProjectile); //Sets LoaderUtils.ResetStaticMembers(typeof(ProjectileID), true); //Etc Array.Resize(ref Main.projHostile, nextProjectile); Array.Resize(ref Main.projHook, nextProjectile); Array.Resize(ref Main.projFrames, nextProjectile); Array.Resize(ref Main.projPet, nextProjectile); Array.Resize(ref Lang._projectileNameCache, nextProjectile); for (int k = ProjectileID.Count; k < nextProjectile; k++) { Main.projFrames[k] = 1; Lang._projectileNameCache[k] = LocalizedText.Empty; } Array.Resize(ref Projectile.perIDStaticNPCImmunity, nextProjectile); for (int i = 0; i < nextProjectile; i++) { Projectile.perIDStaticNPCImmunity[i] = new uint[200]; } InstancedGlobals = globalProjectiles.Where(g => g.InstancePerEntity).ToArray(); for (int i = 0; i < InstancedGlobals.Length; i++) { InstancedGlobals[i].instanceIndex = i; } foreach (var hook in hooks) { hook.arr = ModLoader.BuildGlobalHook(globalProjectiles, hook.method); } }
internal static void ResizeArrays() { //Textures Array.Resize(ref TextureAssets.Buff, nextBuff); //Sets LoaderUtils.ResetStaticMembers(typeof(BuffID), true); //Etc Array.Resize(ref Main.pvpBuff, nextBuff); Array.Resize(ref Main.persistentBuff, nextBuff); Array.Resize(ref Main.vanityPet, nextBuff); Array.Resize(ref Main.lightPet, nextBuff); Array.Resize(ref Main.meleeBuff, nextBuff); Array.Resize(ref Main.debuff, nextBuff); Array.Resize(ref Main.buffNoSave, nextBuff); Array.Resize(ref Main.buffNoTimeDisplay, nextBuff); Array.Resize(ref Main.buffDoubleApply, nextBuff); Array.Resize(ref Main.buffAlpha, nextBuff); Array.Resize(ref Lang._buffNameCache, nextBuff); Array.Resize(ref Lang._buffDescriptionCache, nextBuff); for (int k = BuffID.Count; k < nextBuff; k++) { Lang._buffNameCache[k] = LocalizedText.Empty; Lang._buffDescriptionCache[k] = LocalizedText.Empty; } extraPlayerBuffCount = ModLoader.Mods.Any() ? ModLoader.Mods.Max(m => (int)m.ExtraPlayerBuffSlots) : 0; //Hooks ModLoader.BuildGlobalHook(ref HookUpdatePlayer, globalBuffs, g => g.Update); ModLoader.BuildGlobalHook(ref HookUpdateNPC, globalBuffs, g => g.Update); ModLoader.BuildGlobalHook(ref HookReApplyPlayer, globalBuffs, g => g.ReApply); ModLoader.BuildGlobalHook(ref HookReApplyNPC, globalBuffs, g => g.ReApply); ModLoader.BuildGlobalHook(ref HookModifyBuffTip, globalBuffs, g => g.ModifyBuffTip); ModLoader.BuildGlobalHook(ref HookCustomBuffTipSize, globalBuffs, g => g.CustomBuffTipSize); ModLoader.BuildGlobalHook(ref HookDrawCustomBuffTip, globalBuffs, g => g.DrawCustomBuffTip); }
//change initial size of Terraria.Player.ownedProjectileCounts to ProjectileLoader.ProjectileCount() internal static void ResizeArrays() { //Textures Array.Resize(ref TextureAssets.Projectile, nextProjectile); //Sets LoaderUtils.ResetStaticMembers(typeof(ProjectileID), true); //Etc Array.Resize(ref Main.projHostile, nextProjectile); Array.Resize(ref Main.projHook, nextProjectile); Array.Resize(ref Main.projFrames, nextProjectile); Array.Resize(ref Main.projPet, nextProjectile); Array.Resize(ref Lang._projectileNameCache, nextProjectile); for (int k = ProjectileID.Count; k < nextProjectile; k++) { Main.projFrames[k] = 1; Lang._projectileNameCache[k] = LocalizedText.Empty; } Array.Resize(ref Projectile.perIDStaticNPCImmunity, nextProjectile); for (int i = 0; i < nextProjectile; i++) { Projectile.perIDStaticNPCImmunity[i] = new uint[200]; } globalProjectilesArray = globalProjectiles .Select(g => new Instanced <GlobalProjectile>(g.index, g)) .ToArray(); foreach (var hook in hooks) { hook.Update(globalProjectiles); } }
internal static void ResizeAndFillArrays() { //Textures Array.Resize(ref TextureAssets.ArmorHead, nextEquip[EquipType.Head]); Array.Resize(ref TextureAssets.ArmorBody, nextEquip[EquipType.Body]); Array.Resize(ref TextureAssets.FemaleBody, nextEquip[EquipType.Body]); Array.Resize(ref TextureAssets.ArmorArm, nextEquip[EquipType.Body]); Array.Resize(ref TextureAssets.ArmorLeg, nextEquip[EquipType.Legs]); Array.Resize(ref TextureAssets.AccHandsOn, nextEquip[EquipType.HandsOn]); Array.Resize(ref TextureAssets.AccHandsOff, nextEquip[EquipType.HandsOff]); Array.Resize(ref TextureAssets.AccBack, nextEquip[EquipType.Back]); Array.Resize(ref TextureAssets.AccFront, nextEquip[EquipType.Front]); Array.Resize(ref TextureAssets.AccShoes, nextEquip[EquipType.Shoes]); Array.Resize(ref TextureAssets.AccWaist, nextEquip[EquipType.Waist]); Array.Resize(ref TextureAssets.Wings, nextEquip[EquipType.Wings]); Array.Resize(ref TextureAssets.AccShield, nextEquip[EquipType.Shield]); Array.Resize(ref TextureAssets.AccNeck, nextEquip[EquipType.Neck]); Array.Resize(ref TextureAssets.AccFace, nextEquip[EquipType.Face]); Array.Resize(ref TextureAssets.AccBalloon, nextEquip[EquipType.Balloon]); //Sets LoaderUtils.ResetStaticMembers(typeof(ArmorIDs), true); WingStatsInitializer.Load(); foreach (EquipType type in EquipTypes) { foreach (var entry in equipTextures[type]) { int slot = entry.Key; EquipTexture texture = entry.Value; GetTextureArray(type)[slot] = ModContent.GetTexture(texture.Texture); if (type == EquipType.Body) { TextureAssets.FemaleBody[slot] = ModContent.GetTexture(femaleTextures[slot]); TextureAssets.ArmorArm[slot] = ModContent.GetTexture(armTextures[slot]); } } } Array.Resize(ref Item.headType, nextEquip[EquipType.Head]); foreach (var entry in slotToId[EquipType.Head]) { Item.headType[entry.Key] = entry.Value; } Array.Resize(ref Item.bodyType, nextEquip[EquipType.Body]); foreach (var entry in slotToId[EquipType.Body]) { Item.bodyType[entry.Key] = entry.Value; } Array.Resize(ref Item.legType, nextEquip[EquipType.Legs]); foreach (var entry in slotToId[EquipType.Legs]) { Item.legType[entry.Key] = entry.Value; } }
internal static void ResizeArrays(bool unloading = false) { //Textures Array.Resize(ref TextureAssets.Tile, nextTile); Array.Resize(ref TextureAssets.HighlightMask, nextTile); //Sets LoaderUtils.ResetStaticMembers(typeof(TileID), true); //Etc Array.Resize(ref Main.SceneMetrics._tileCounts, nextTile); Array.Resize(ref Main.PylonSystem._sceneMetrics._tileCounts, nextTile); Array.Resize(ref Main.tileLighted, nextTile); Array.Resize(ref Main.tileMergeDirt, nextTile); Array.Resize(ref Main.tileCut, nextTile); Array.Resize(ref Main.tileAlch, nextTile); Array.Resize(ref Main.tileShine, nextTile); Array.Resize(ref Main.tileShine2, nextTile); Array.Resize(ref Main.tileStone, nextTile); Array.Resize(ref Main.tileAxe, nextTile); Array.Resize(ref Main.tileHammer, nextTile); Array.Resize(ref Main.tileWaterDeath, nextTile); Array.Resize(ref Main.tileLavaDeath, nextTile); Array.Resize(ref Main.tileTable, nextTile); Array.Resize(ref Main.tileBlockLight, nextTile); Array.Resize(ref Main.tileNoSunLight, nextTile); Array.Resize(ref Main.tileDungeon, nextTile); Array.Resize(ref Main.tileSpelunker, nextTile); Array.Resize(ref Main.tileSolidTop, nextTile); Array.Resize(ref Main.tileSolid, nextTile); Array.Resize(ref Main.tileBouncy, nextTile); Array.Resize(ref Main.tileLargeFrames, nextTile); Array.Resize(ref Main.tileRope, nextTile); Array.Resize(ref Main.tileBrick, nextTile); Array.Resize(ref Main.tileMoss, nextTile); Array.Resize(ref Main.tileNoAttach, nextTile); Array.Resize(ref Main.tileNoFail, nextTile); Array.Resize(ref Main.tileObsidianKill, nextTile); Array.Resize(ref Main.tileFrameImportant, nextTile); Array.Resize(ref Main.tilePile, nextTile); Array.Resize(ref Main.tileBlendAll, nextTile); Array.Resize(ref Main.tileContainer, nextTile); Array.Resize(ref Main.tileSign, nextTile); Array.Resize(ref Main.tileSand, nextTile); Array.Resize(ref Main.tileFlame, nextTile); Array.Resize(ref Main.tileFrame, nextTile); Array.Resize(ref Main.tileFrameCounter, nextTile); Array.Resize(ref Main.tileMerge, nextTile); Array.Resize(ref Main.tileOreFinderPriority, nextTile); Array.Resize(ref Main.tileGlowMask, nextTile); Array.Resize(ref Main.tileCracked, nextTile); Array.Resize(ref WorldGen.tileCounts, nextTile); Array.Resize(ref WorldGen.houseTile, nextTile); //Array.Resize(ref GameContent.Biomes.CaveHouseBiome._blacklistedTiles, nextTile); Array.Resize(ref GameContent.Biomes.CorruptionPitBiome.ValidTiles, nextTile); Array.Resize(ref HouseUtils.BlacklistedTiles, nextTile); Array.Resize(ref HouseUtils.BeelistedTiles, nextTile); for (int i = 0; i < nextTile; i++) //oh dear { Array.Resize(ref Main.tileMerge[i], nextTile); } for (int i = TileID.Count; i < nextTile; i++) { Main.tileGlowMask[i] = -1; //If we don't this, every modded tile will have a glowmask by default. } while (TileObjectData._data.Count < nextTile) { TileObjectData._data.Add(null); } //Hooks ModLoader.BuildGlobalHook(ref HookKillSound, globalTiles, g => g.KillSound); ModLoader.BuildGlobalHook(ref HookNumDust, globalTiles, g => g.NumDust); ModLoader.BuildGlobalHook(ref HookCreateDust, globalTiles, g => g.CreateDust); ModLoader.BuildGlobalHook(ref HookDropCritterChance, globalTiles, g => g.DropCritterChance); ModLoader.BuildGlobalHook(ref HookDrop, globalTiles, g => g.Drop); ModLoader.BuildGlobalHook(ref HookCanKillTile, globalTiles, g => g.CanKillTile); ModLoader.BuildGlobalHook(ref HookKillTile, globalTiles, g => g.KillTile); ModLoader.BuildGlobalHook(ref HookCanExplode, globalTiles, g => g.CanExplode); ModLoader.BuildGlobalHook(ref HookNearbyEffects, globalTiles, g => g.NearbyEffects); ModLoader.BuildGlobalHook(ref HookModifyLight, globalTiles, g => g.ModifyLight); ModLoader.BuildGlobalHook(ref HookDangersense, globalTiles, g => g.Dangersense); ModLoader.BuildGlobalHook(ref HookSetSpriteEffects, globalTiles, g => g.SetSpriteEffects); ModLoader.BuildGlobalHook(ref HookAnimateTile, globalTiles, g => g.AnimateTile); ModLoader.BuildGlobalHook(ref HookPreDraw, globalTiles, g => g.PreDraw); ModLoader.BuildGlobalHook(ref HookDrawEffects, globalTiles, g => g.DrawEffects); ModLoader.BuildGlobalHook(ref HookPostDraw, globalTiles, g => g.PostDraw); ModLoader.BuildGlobalHook(ref HookSpecialDraw, globalTiles, g => g.SpecialDraw); ModLoader.BuildGlobalHook(ref HookRandomUpdate, globalTiles, g => g.RandomUpdate); ModLoader.BuildGlobalHook(ref HookTileFrame, globalTiles, g => g.TileFrame); ModLoader.BuildGlobalHook(ref HookCanPlace, globalTiles, g => g.CanPlace); ModLoader.BuildGlobalHook(ref HookAdjTiles, globalTiles, g => g.AdjTiles); ModLoader.BuildGlobalHook(ref HookRightClick, globalTiles, g => g.RightClick); ModLoader.BuildGlobalHook(ref HookMouseOver, globalTiles, g => g.MouseOver); ModLoader.BuildGlobalHook(ref HookMouseOverFar, globalTiles, g => g.MouseOverFar); ModLoader.BuildGlobalHook(ref HookAutoSelect, globalTiles, g => g.AutoSelect); ModLoader.BuildGlobalHook(ref HookPreHitWire, globalTiles, g => g.PreHitWire); ModLoader.BuildGlobalHook(ref HookHitWire, globalTiles, g => g.HitWire); ModLoader.BuildGlobalHook(ref HookSlope, globalTiles, g => g.Slope); ModLoader.BuildGlobalHook(ref HookFloorVisuals, globalTiles, g => g.FloorVisuals); ModLoader.BuildGlobalHook(ref HookChangeWaterfallStyle, globalTiles, g => g.ChangeWaterfallStyle); ModLoader.BuildGlobalHook(ref HookSaplingGrowthType, globalTiles, g => g.SaplingGrowthType); ModLoader.BuildGlobalHook(ref HookPlaceInWorld, globalTiles, g => g.PlaceInWorld); if (!unloading) { loaded = true; } }