コード例 #1
0
 public void Read(BinaryReader reader)
 {
     tile   = reader.ReadBoolean();
     modded = reader.ReadBoolean();
     if (modded)
     {
         type       = 9999;
         modAndName = reader.ReadString();
         string[] args = modAndName.Split('#');
         Mod      mod  = ModLoader.GetMod(args[0]);
         if (mod != null)
         {
             if (tile)
             {
                 ModTile mtile = mod.GetTile(args[1]);
                 if (mtile != null)
                 {
                     type = mtile.Type;
                 }
             }
             else
             {
                 ModWall mwall = mod.GetWall(args[1]);
                 if (mwall != null)
                 {
                     type = mwall.Type;
                 }
             }
         }
     }
     else
     {
         type = reader.ReadUInt16();
     }
 }
コード例 #2
0
 public static void QuickSetWall(this ModWall wall, int dustType, int soundType, int drop, bool safe, Color mapColor)
 {
     wall.dustType             = dustType;
     wall.soundType            = soundType;
     wall.drop                 = drop;
     Main.wallHouse[wall.Type] = safe;
     wall.AddMapEntry(mapColor);
 }
コード例 #3
0
        public static void SimpleWall(this ModWall wall, int drop, int soundType, int dustType, Color mapColor, bool house = false)
        {
            Main.wallHouse[wall.Type] = house;

            wall.drop      = drop;
            wall.soundType = soundType;
            wall.dustType  = dustType;

            wall.AddMapEntry(mapColor);
        }
コード例 #4
0
        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 static string GetUniqueKey(int type)
        {
            if (type < 0 || type >= WallLoader.WallCount)
            {
                throw new ArgumentOutOfRangeException("Invalid type: " + type);
            }
            if (type < WallID.Count)
            {
                return("Terraria " + TileWallIdentityHelpers.WallIdSearch.GetName(type));
            }

            ModWall modWall = WallLoader.GetWall(type);

            return($"{modWall.mod.Name} {modWall.Name}");
        }
コード例 #6
0
ファイル: TileIO.cs プロジェクト: nilfisk/tModLoader
        internal static bool WriteTiles(BinaryWriter writer)
        {
            ISet <ushort> types = new HashSet <ushort>();
            ISet <ushort> walls = new HashSet <ushort>();

            for (int i = 0; i < Main.maxTilesX; i++)
            {
                for (int j = 0; j < Main.maxTilesY; j++)
                {
                    Tile tile = Main.tile[i, j];
                    if (tile.active() && tile.type >= TileID.Count)
                    {
                        types.Add(tile.type);
                    }
                    if (tile.wall >= WallID.Count)
                    {
                        walls.Add(tile.wall);
                    }
                }
            }
            if (types.Count > 0 || walls.Count > 0)
            {
                writer.Write((ushort)types.Count);
                foreach (ushort type in types)
                {
                    writer.Write(type);
                    ModTile modTile = TileLoader.GetTile(type);
                    writer.Write(modTile.mod.Name);
                    writer.Write(modTile.Name);
                    writer.Write(Main.tileFrameImportant[type]);
                }
                writer.Write((ushort)walls.Count);
                foreach (ushort wall in walls)
                {
                    writer.Write(wall);
                    ModWall modWall = WallLoader.GetWall(wall);
                    writer.Write(modWall.mod.Name);
                    writer.Write(modWall.Name);
                }
                WriteTileData(writer);
                return(true);
            }
            return(false);
        }
コード例 #7
0
        public void QueryModOrigin()
        {
            Point mouseTile = Main.MouseWorld.ToTileCoordinates();

            int   closestNPCIndex    = -1;
            float closestNPCDistance = float.MaxValue;

            for (int l = 0; l < 200; l++)
            {
                if (Main.npc[l].active)
                {
                    float distance = Utils.Distance(Main.npc[l].getRect(), Main.MouseWorld);
                    if (distance < closestNPCDistance)
                    {
                        closestNPCDistance = distance;
                        closestNPCIndex    = l;
                    }
                }
            }

            int   closestItemIndex    = -1;
            float closestItemDistance = float.MaxValue;

            for (int i = 0; i < 400; i++)
            {
                if (Main.item[i].active)
                {
                    float distance = Utils.Distance(Main.item[i].getRect(), Main.MouseWorld);
                    if (distance < closestItemDistance)
                    {
                        closestItemDistance = distance;
                        closestItemIndex    = i;
                    }
                }
            }


            int hoverBuffIndex = -1;
            int hoverBuffID    = -1;

            for (int k = 0; k < 22; k++)
            {
                if (Main.player[Main.myPlayer].buffType[k] > 0)
                {
                    int buffID = Main.player[Main.myPlayer].buffType[k];
                    int buffX  = 32 + k * 38;
                    int buffY  = 76;
                    if (k >= 11)
                    {
                        buffX  = 32 + (k - 11) * 38;
                        buffY += 50;
                    }

                    if (Main.mouseX < buffX + Main.buffTexture[buffID].Width && Main.mouseY <buffY + Main.buffTexture[buffID].Height && Main.mouseX> buffX && Main.mouseY > buffY)
                    {
                        hoverBuffIndex = k;
                        hoverBuffID    = buffID;
                    }
                }
            }

            //Top to Bottom:

            // Hover Buff
            if (hoverBuffIndex > -1 && !Main.playerInventory)
            {
                if (hoverBuffID >= BuffID.Count)
                {
                    ModBuff hoverBuff = BuffLoader.GetBuff(hoverBuffID);
                    Main.NewText("This buff is from: " + hoverBuff.mod.DisplayName);
                    if (HelpfulHotkeysClientConfig.Instance.ShowDeveloperInfoQueryModOrigin)
                    {
                        Main.NewText($"Developer Info: ModName: {hoverBuff.mod.Name}, InternalName: {hoverBuff.Name}, FullName: {hoverBuff.GetType().FullName}");
                    }
                }
                else
                {
                    Main.NewText("This is a vanilla buff.");
                }
            }

            // Item in inventory
            else if (Main.HoverItem.type > 0 && Main.HoverItem != null)
            {
                if (Main.HoverItem.modItem != null)
                {
                    Main.NewText("This item is from: " + Main.HoverItem.modItem.mod.DisplayName);
                    if (HelpfulHotkeysClientConfig.Instance.ShowDeveloperInfoQueryModOrigin)
                    {
                        Main.NewText($"Developer Info: ModName: {Main.HoverItem.modItem.mod.Name}, InternalName: {Main.HoverItem.modItem.Name}, FullName: {Main.HoverItem.modItem.GetType().FullName}");
                    }
                }
                else
                {
                    Main.NewText("This is a vanilla item.");
                    if (HelpfulHotkeysClientConfig.Instance.ShowDeveloperInfoQueryModOrigin)
                    {
                        Main.NewText($"Developer Info: ItemID: {ItemID.Search.GetName(Main.HoverItem.type)}, ItemID#: {Main.HoverItem.type}");
                    }
                }
            }

            // NPC
            else if (closestNPCDistance < 30)
            {
                NPC closestNPC = Main.npc[closestNPCIndex];
                if (closestNPC.modNPC != null)
                {
                    Main.NewText("This npc is from: " + closestNPC.modNPC.mod.DisplayName);
                    if (HelpfulHotkeysClientConfig.Instance.ShowDeveloperInfoQueryModOrigin)
                    {
                        Main.NewText($"Developer Info: ModName: {closestNPC.modNPC.mod.Name}, InternalName: {closestNPC.modNPC.Name}, FullName: {closestNPC.modNPC.GetType().FullName}");
                    }
                }
                else
                {
                    Main.NewText("This is a vanilla npc.");
                    if (HelpfulHotkeysClientConfig.Instance.ShowDeveloperInfoQueryModOrigin)
                    {
                        Main.NewText($"Developer Info: NPCID: {NPCID.Search.GetName(closestNPC.type)}, NPCID#: {closestNPC.type}");
                    }
                }
            }

            // Tile
            else if (Main.tile[mouseTile.X, mouseTile.Y].type >= TileID.Count)
            {
                ModTile modTile = TileLoader.GetTile(Main.tile[mouseTile.X, mouseTile.Y].type);
                Main.NewText("This tile is from: " + modTile.mod.DisplayName);
                if (HelpfulHotkeysClientConfig.Instance.ShowDeveloperInfoQueryModOrigin)
                {
                    Main.NewText($"Developer Info: ModName: {modTile.mod.Name}, InternalName: {modTile.Name}, FullName: {modTile.GetType().FullName}");
                }
                //Main.NewText("This tile is active: " + Main.tile[mouseTile.X, mouseTile.Y].active());
                //Main.NewText("This tile is inactive: " + Main.tile[mouseTile.X, mouseTile.Y].inActive());
                //Main.NewText("This tile is nactive: " + Main.tile[mouseTile.X, mouseTile.Y].nactive());
            }

            // Wall
            else if (Main.tile[mouseTile.X, mouseTile.Y].wall >= WallID.Count)
            {
                ModWall modWall = WallLoader.GetWall(Main.tile[mouseTile.X, mouseTile.Y].wall);
                Main.NewText("This wall is from: " + modWall.mod.DisplayName);
                if (HelpfulHotkeysClientConfig.Instance.ShowDeveloperInfoQueryModOrigin)
                {
                    Main.NewText($"Developer Info: ModName: {modWall.mod.Name}, InternalName: {modWall.Name}, FullName: {modWall.GetType().FullName}");
                }
            }

            // Item on ground
            else if (closestItemDistance < 5)
            {
                if (Main.item[closestItemIndex].modItem != null)
                {
                    ModItem modItem = Main.item[closestItemIndex].modItem;
                    Main.NewText("This item is from: " + modItem.mod.DisplayName);
                    if (HelpfulHotkeysClientConfig.Instance.ShowDeveloperInfoQueryModOrigin)
                    {
                        Main.NewText($"Developer Info: ModName: {modItem.mod.Name}, InternalName: {modItem.Name}, FullName: {modItem.GetType().FullName}");
                    }
                }
                else
                {
                    Main.NewText("This is a vanilla item.");
                    if (HelpfulHotkeysClientConfig.Instance.ShowDeveloperInfoQueryModOrigin)
                    {
                        Main.NewText($"Developer Info: ItemID: {ItemID.Search.GetName(Main.item[closestItemIndex].type)}, ItemID#: {Main.item[closestItemIndex].type}");
                    }
                }
            }

            // How to Use
            else if (true)
            {
                Main.NewText("Hover over an item, npc, tile, or wall to identify which mod it is from.");
            }
        }
コード例 #8
0
        public override void PreUpdate()
        {
            //if (SGAWorld.CutsceneActive)
            if (SpaceBoss.film.IsActive || CaliburnGuardianHardmode.film.IsActive)
            {
                player.AddBuff(ModContent.BuffType <Buffs.InvincibleBuff>(), 2);
            }


            if (!Main.gameMenu)
            {
                bool spacey = Spacey;

                enterlimbo += 1;

                SGAmod.anysubworld = SGAPocketDim.WhereAmI != null;

                if (Main.netMode != NetmodeID.Server && !Main.dedServ && Main.LocalPlayer == player)
                {
                    Projectile.NewProjectile(Main.screenPosition + new Vector2(Main.screenWidth, Main.screenHeight) / 2, Vector2.Zero, mod.ProjectileType("DrawOverride"), 0, 0f);
                    if (spacey)
                    {
                        Projectile.NewProjectile(Main.screenPosition + new Vector2(Main.screenWidth, Main.screenHeight) / 2, Vector2.Zero, mod.ProjectileType("AsteriodDraw"), 0, 0f);
                    }
                }

                if (SGAPocketDim.WhereAmI != null)
                {
                    if (SLWorld.currentSubworld is SGAPocketDim sub)
                    {
                        SLWorld.noReturn = false;
                        int limit = sub.LimitPlayers;
                        if (limit % 16 == 0 && limit > 0)
                        {
                            player.AddBuff(BuffID.NoBuilding, 2);
                        }
                        player.GetModPlayer <SGAPlayer>().noModTeleport = true;

                        if (sub.GetType() == typeof(SpaceDim))
                        {
                            Point loc = new Point((int)(player.Center.X) >> 4, (int)(player.Center.Y) >> 4);
                            if (WorldGen.InWorld(loc.X, loc.Y))
                            {
                                Tile tilez = Framing.GetTileSafely(loc.X, loc.Y);
                                if (tilez != null)
                                {
                                    if (tilez.wall >= 0)
                                    {
                                        ModWall wallz = WallLoader.GetWall(tilez.wall);
                                        if (wallz != null && wallz is IBreathableWallType)
                                        {
                                            goto movingOn;
                                        }
                                    }
                                }
                            }
                            player.AddBuff(ModContent.BuffType <SharkvernDrown>(), 3);
                        }
                    }

movingOn:

                    if (spacey)
                    {
                        SLWorld.noReturn = true;
                        player.gravity   = 0.12f;
                        if (spacevar < 1)//Arriving in Space now
                        {
                            player.velocity = new Vector2(0, -16);
                            player.Center   = new Vector2(spaceX * (Main.maxTilesX * 16f), (Main.maxTilesY * 16f) - (16 * 50));
                        }
                        if (player.velocity.Y > 0 && player.Center.Y > (Main.maxTilesY * 16f) - (16 * 50) && spacevar == 1)
                        {
                            //SGAPocketDim.EnterSubworld(mod.GetType().Name + "_SpaceDim");
                            SGAPocketDim.Exit();
                        }
                        targetedAsteriod = null;

                        if (player.HeldItem.pick > 0)
                        {
                            List <Projectile> allAsteriods2 = Main.projectile.Where(testby => testby.active && testby?.modProjectile is IMineableAsteriod).ToList();
                            List <Projectile> allAsteriods  = new List <Projectile>();
                            if (allAsteriods2.Count > 0)
                            {
                                foreach (Projectile proj in allAsteriods2)
                                {
                                    double length3 = Math.Sqrt((Math.Abs(proj.Center.X - player.Center.X) * Math.Abs(proj.Center.X - player.Center.X)) + (Math.Abs(proj.Center.Y - player.Center.Y) * Math.Abs(proj.Center.Y - player.Center.Y)));
                                    if (length3 < (Math.Sqrt(Player.tileRangeX * Player.tileRangeY) + player.blockRange) * 48)
                                    {
                                        allAsteriods.Add(proj);
                                    }
                                }

                                Vector2 from = Main.MouseWorld;

                                if (Main.SmartCursorEnabled)
                                {
                                    from = player.MountedCenter + Vector2.Normalize(from) * 16f;
                                }

                                //Main.NewText(allAsteriods.Count);
                                allAsteriods = allAsteriods.OrderBy(testby => ((Math.Abs(from.X - testby.Center.X) * Math.Abs(from.X - testby.Center.X)) + (Math.Abs(from.Y - testby.Center.Y) * Math.Abs(from.Y - testby.Center.Y)))
                                                                    + 0).ToList();

restartHere:
                                if (allAsteriods.Count > 0)
                                {
                                    MineableAsteriod targetedasteriod = allAsteriods[0].modProjectile as MineableAsteriod;

                                    //double length2 = Math.Sqrt(Math.Abs(targetedasteriod.projectile.Center.X - player.Center.X) * Math.Abs(targetedasteriod.projectile.Center.Y - player.Center.Y));

                                    // if (length2 < (Math.Sqrt(Player.tileRangeX * Player.tileRangeY) + player.blockRange) * 16)
                                    // {
                                    targetedAsteriod = targetedasteriod;
                                    targetedasteriod.miningTargeted = targetedasteriod.miningTargeted + 2;
                                    //break;
                                    // }
                                }
                            }
                        }

                        spacevar = 1;
                    }

                    if (SGAPocketDim.WhereAmI == typeof(LimboDim))
                    {
                        SLWorld.noReturn = true;
                    }
                }
                else //No subworld entered atm
                {
                    if (spacevar > 0)//dropping out of Space
                    {
                        player.Center   = new Vector2(spaceX * (Main.maxTilesX * 16f), 48);
                        player.velocity = new Vector2(0, 16);
                    }

                    if (player.wings > 0 && player.velocity.Y < 0 && player.Center.Y < (16 * 50) && spacevar == 0 && player.controlJump && !IdgNPC.bossAlive)
                    {
                        SpaceDim.postMoonLord = NPC.downedMoonlord;
                        SGAPocketDim.EnterSubworld(mod.GetType().Name + "_SpaceDim");
                    }
                    spacevar = 0;
                }

                spaceX = player.Center.X / (Main.maxTilesX * 16f);

                if (SGAPocketDim.WhereAmI == typeof(LimboDim))
                {
                    player.AddBuff(Idglib.Instance.BuffType("LimboFading"), 1);
                    if (enterlimbo > 0)
                    {
                        enterlimbo = -6;
                    }
                    if (enterlimbo == -5)
                    {
                        Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/crack"), new Vector2(-1, -1));
                        player.Center = new Vector2(Main.rand.Next(200, Main.maxTilesX - 400) * 16, 64);
                    }
                    if (enterlimbo > -2)
                    {
                        enterlimbo = -2;
                        if (Framing.GetTileSafely((int)(player.Center.X / 16f), (int)(player.Center.Y / 16f)).wall == mod.WallType("NullWall") && DimDingeonsWorld.ancientLockedFabric)
                        {
                            enterlimbo = -6;
                        }
                    }
                }
                if (SGAPocketDim.WhereAmI == typeof(Limborinth))
                {
                    if (Framing.GetTileSafely((int)(player.Center.X / 16f), (int)(player.Center.Y / 16f)).wall == mod.WallType("NullWallBossArena"))
                    {
                        if (NullBossArenaSpot == default)
                        {
                            Idglib.Chat("There's no turning back now...", 120, 15, 15);
                        }
                        NullBossArenaSpot = player.Center;
                    }
                    else
                    {
                        if (NullBossArenaSpot != default)
                        {
                            player.velocity = Vector2.Normalize(NullBossArenaSpot - player.Center) * 12f;
                            player.Center   = NullBossArenaSpot;
                        }
                    }
                }
                else
                {
                    NullBossArenaSpot = default;
                }
            }
        }
コード例 #9
0
 public WallEntry(ModWall wall) : base(wall)
 {
 }