コード例 #1
0
 public override void PreUpdate()
 {
     if (Subworld.IsActive <Moon>())
     {
         Main.time += 0.125;
     }
 }
コード例 #2
0
 public void OnEntityInteract(Entity ent)
 {
     if (ent is Player)
     {
         return;
     }
     if (Data is IOnEntityInteract)
     {
         (Data as IOnEntityInteract).OnEntityInteract(ent);
     }
     else if (Data is ISubworldEntranceObject)
     {
         ISubworldEntranceObject ob = Data as ISubworldEntranceObject;
         Key key = ob.GetSubworldKey();
         if (key == null || ent.Inventory.ContainsItemStack(key) != null)
         {
             Subworld current = ent.GetSubworld();
             if (current == null)
             {
                 WorldManager.Instance.EntityEnterSubworld(ent, ob.GetSubworld());
             }
             else
             {
                 WorldManager.Instance.EntityExitSubworld(ent, ob.GetSubworld());
             }
         }
     }
 }
コード例 #3
0
    public void LoadSubworldChunks(Subworld sub)
    {
        CurrentSubworld = sub;


        if (sub.ShouldUnloadWorldOnEnter())
        {
            UnloadAllChunks();
        }
        else
        {
            foreach (KeyValuePair <Vec2i, LoadedChunk2> kvp in LoadedChunks)
            {
                kvp.Value.gameObject.SetActive(false);
            }
        }



        SubworldChunks.Clear();

        foreach (ChunkData cd in sub.SubworldChunks)
        {
            //Debug.Log("Object count:" + cd.WorldObjects.Count);
            SubworldChunks.Add(cd.Position, ChunkLoader.GetLoadedChunk(cd, 1));
            //Debug.Log("sub chunk: " + cd.Position);
            //ChunkLoader.LoadChunk(cd);
        }
        CurrentSubworld = sub;
        //ChunkLoader.ForceLoadAll();

        //TODO - fix this bad boy
        return;
    }
コード例 #4
0
    public void LeaveSubworld()
    {
        UnloadSubworldChunks();

        if (!CurrentSubworld.ShouldUnloadWorldOnEnter())
        {
            foreach (KeyValuePair <Vec2i, LoadedChunk2> kvp in LoadedChunks)
            {
                kvp.Value.gameObject.SetActive(true);
                EntityManager.Instance?.LoadChunk(kvp.Key);
            }
        }

        CurrentSubworld    = null;
        LoadedChunksCentre = null;
        return;

        /*
         * InSubworld = false;
         * foreach (KeyValuePair<Vec2i, LoadedChunk> kvp in SubworldChunks)
         * {
         *  Destroy(kvp.Value.gameObject);
         *
         * }
         * SubworldChunks.Clear();*/
    }
コード例 #5
0
 public override void ModifySunLightColor(ref Color tileColor, ref Color backgroundColor)
 {
     if (Subworld.IsActive <DreamBattleWorld>())
     {
         backgroundColor = Color.DarkGray;
     }
 }
コード例 #6
0
        public static void EnterSubworld(string whereto, bool vote = false)
        {
            if (Main.netMode != NetmodeID.SinglePlayer)
            {
                return;
            }


            DimDungeonsProxy.DungeonSeeds = (int)(System.DateTime.Now.Millisecond * 1370.3943162338);
            //DimDungeons.DungeonSeeds = (int)((Main.time+SGAWorld.dungeonlevel) * (double)(Math.PI*17));
            SGAmod.cachedata = true;
            if (SGAPocketDim.WhereAmI != null)
            {
                if (SGAPocketDim.WhereAmI == typeof(LimboDim))
                {
                    SGAWorld.dungeonlevel = 0;
                    SLWorld.noReturn      = true;
                }
            }
            Subworld.Enter(whereto, !vote);
            if (SGAPocketDim.WhereAmI == typeof(DeeperDungeon))
            {
                SGAWorld.dungeonlevel += 1;
            }

            SGAWorld.highestDimDungeonFloor = (byte)Math.Max(SGAWorld.dungeonlevel, SGAWorld.highestDimDungeonFloor);
        }
コード例 #7
0
 public static void KillMeForGoodHook(On.Terraria.Player.orig_KillMeForGood orig, Player self)
 {
     if (!Subworld.IsActive <DreamBattleWorld>())
     {
         orig.Invoke(self);
     }
 }
コード例 #8
0
 public void LoadSubworld(Subworld subworld)
 {
     Subworld             = subworld;
     SubworldSize         = subworld.ChunkSize * World.ChunkSize;
     CurrentSubworldTiles = new float[SubworldSize.x, SubworldSize.z];
     for (int x = 0; x < subworld.ChunkSize.x; x++)
     {
         for (int z = 0; z < subworld.ChunkSize.z; z++)
         {
             for (int x_ = 0; x_ < World.ChunkSize; x_++)
             {
                 for (int z_ = 0; z_ < World.ChunkSize; z_++)
                 {
                     ChunkData cd  = subworld.SubworldChunks[x, z];
                     float     val = cd.GetTile(x_, z_).SpeedMultiplier;
                     if (cd.Objects != null && cd.GetObject(x_, z_) != null)
                     {
                         val = Mathf.Infinity;
                     }
                     CurrentSubworldTiles[x * World.ChunkSize + x_, z *World.ChunkSize + z_] = val;
                 }
             }
         }
     }
 }
コード例 #9
0
 public static void DropItemsHook(On.Terraria.Player.orig_DropItems orig, Player self)
 {
     if (!Subworld.IsActive <DreamBattleWorld>())
     {
         orig.Invoke(self);
     }
 }
コード例 #10
0
 public static void DropTombstoneHook(On.Terraria.Player.orig_DropTombstone orig, Player self, int coinowned, NetworkText deathText, int hitDirection)
 {
     if (!Subworld.IsActive <DreamBattleWorld>())
     {
         orig.Invoke(self, coinowned, deathText, hitDirection);
     }
 }
コード例 #11
0
 public void EntityEnterSubworld(Entity entity, Subworld subworld)
 {
     if (subworld != null)
     {
         entity.MoveEntity(subworld.InternalEntrancePos.AsVector3(), subworld.SubworldID);
     }
 }
コード例 #12
0
 public override void PreUpdate()
 {
     /*
      *          while (0 < Main.maxTilesX * Main.maxTilesY * (3E-05f * Main.worldRate))
      *          {
      *                  int tileX = WorldGen.genRand.Next(10, Main.maxTilesX - 10); //a random x tile
      *                  int tileY = WorldGen.genRand.Next(10, (int)Main.worldSurface - 1); //a psuedo random y tile based on the world surface
      *
      *                  int tileYAbovetileY = tileY - 1 < 10 ? 10 : tileY - 1; //the tile above the psuedo random tile y position
      *
      *                  Tile groundTile = Framing.GetTileSafely(tileX, tileY); //the ground tile that the new tile will be placed on
      *
      *                  //an array of all the tiles that will need to be free
      *                  Tile[] spaceRequired = new Tile[]
      *                  {
      *                          Framing.GetTileSafely(tileX, tileYAbovetileY), //bottom left
      *                          Framing.GetTileSafely(tileX, tileYAbovetileY - 1), //top left
      *                          Framing.GetTileSafely(tileX + 1, tileYAbovetileY), //bottom right
      *                          Framing.GetTileSafely(tileX + 1, tileYAbovetileY - 1) //top right
      *                  };
      *
      *                  //if the ground tile isnt null and its grass
      *                  if (groundTile != null && groundTile.type == TileID.Grass)
      *                  {
      *                          //loop through every required tile
      *                          foreach (Tile tile in spaceRequired)
      *                          {
      *                                  //if the tile isnt active; there is space for the new tile
      *                                  if (!tile.active())
      *                                  {
      *                                          if (WorldGen.genRand.NextBool(50)) //Random amount to slow down growing
      *                                          {
      *                                                  //place the 2x2 strawberry multitile
      *                                                  WorldGen.Place2x2(tileX, tileYAbovetileY - 1, (ushort)ModContent.TileType<StrawberryPlantTile>(), 0);
      *
      *                                                  //if its still active
      *                                                  if (tile.active())
      *                                                  {
      *                                                          //set the paint color to the ground tiles paint color
      *                                                          tile.color(groundTile.color());
      *
      *                                                          //Synce the multitile placement
      *                                                          if (Main.netMode == NetmodeID.Server)
      *                                                                  NetMessage.SendTileRange(-1, tileX, tileYAbovetileY - 1, 2, 2);
      *                                                  }
      *                                          }
      *                                  }
      *                          }
      *                  }
      *          }*/
     if (Subworld.IsActive <Dimensions.PlasmaDesert>())
     {
         if (++Liquid.skipCount > 1)
         {
             Liquid.UpdateLiquid();
             Liquid.skipCount = 0;
         }
     }
 }
コード例 #13
0
 private static void Main_DrawBG(On.Terraria.Main.orig_DrawBG orig, Main self)
 {
     orig(self);
     if (Subworld.IsActive <Moon>())
     {
         var earthTexture = MacrocosmMod.GetTexture("Assets/Earth");
         var sb           = Main.spriteBatch;
         sb.Draw(earthTexture, new Vector2(Main.screenWidth / 2, 200), null, Color.White, 0.4101524f, earthTexture.Size() / 2, 1f, default, 0f); // 0.4101524 is earth's axial tilt to radians
コード例 #14
0
 public void AddSubworld(ISubworldEntranceObject obj, Subworld subworld)
 {
     if (Subworlds == null)
     {
         Subworlds = new Dictionary <Subworld, ISubworldEntranceObject>();
     }
     Subworlds.Add(subworld, obj);
 }
コード例 #15
0
ファイル: World.cs プロジェクト: the8thbit/ProceduralRPG
    public int AddSubworld(Subworld subworld)
    {
        int id = WorldSubWorlds.Count;

        WorldSubWorlds.Add(id, subworld);
        subworld.SetSubworldID(id);
        return(id);
    }
コード例 #16
0
 private static void NPC_UpdateNPC_UpdateGravity(On.Terraria.NPC.orig_UpdateNPC_UpdateGravity orig, NPC self, out float maxFallSpeed)
 {
     orig(self, out maxFallSpeed);
     if (Subworld.IsActive <Moon>())
     {
         NPCGravity.SetValue(null, 0.05f);
     }
 }
コード例 #17
0
 public override void PostUpdateMiscEffects()
 {
     if (Subworld.IsActive <Moon>())
     {
         ZoneMoon       = true;
         player.gravity = 0.068f;
     }
 }
コード例 #18
0
 public override void PostAI()
 {
     base.PostAI();
     if (!Subworld.IsActive <Moon>())
     {
         npc.active = false;
     }
 }
コード例 #19
0
 public void LeaveSubworld()
 {
     if (Subworld != null)
     {
         Subworld = null;
         UnloadAllEntities();
     }
 }
コード例 #20
0
 public override void PostDraw(int i, int j, SpriteBatch spriteBatch)             //debug drawing
 {
     if (Main.tile[i, j].frameX >= 0 && !Subworld.IsActive <Ship.ShipSubworld>()) // to be completely commented out when done
     {
         Vector2   zero     = new Vector2(Main.offScreenRange, Main.offScreenRange);
         Texture2D texture2 = ModContent.GetTexture("PlanetMod/Tiles/BarrierOverlay");                 //Overlay
         Main.spriteBatch.Draw(texture2, new Vector2(i * 16 - (int)Main.screenPosition.X, j * 16 - (int)Main.screenPosition.Y) + zero, new Rectangle(0, 0, texture2.Width, texture2.Height), Color.White, 0f, Vector2.Zero, 1f, SpriteEffects.None, 0f);
     }
 }
コード例 #21
0
 public override void PostUpdateBuffs()
 {
     if (Subworld.IsActive <Moon>())
     {
         if (!player.GetModPlayer <MacrocosmPlayer>().accMoonArmor)
         {
             player.AddBuff(ModContent.BuffType <SuitBreach>(), 2);
         }
     }
 }
コード例 #22
0
 public override void ModifyScreenPosition()
 {
     if (Subworld.AnyActive(mod))
     {
         if (Main.screenPosition.Y >= 11864f) // Ignore the magic numbers :peepohappy:
         {
             Main.screenPosition = new Vector2(Main.screenPosition.X, 11864f);
         }
     }
 }
コード例 #23
0
ファイル: DreamBattleWorld.cs プロジェクト: DarthHA/HKBoss
 public override void AI(NPC npc)
 {
     if (Subworld.IsActive <DreamBattleWorld>())
     {
         if (npc.type != ModContent.NPCType <Marx>())
         {
             npc.active = false;
         }
     }
 }
コード例 #24
0
        public override void PostUpdateEverything()
        {
            _anySubworldActive = Subworld.AnyActive(this);
            if (_anySubworldActive && !_anySubworldActiveLastTick)
            {
                INTERNAL_SubworldTileFraming();
            }

            _anySubworldActiveLastTick = _anySubworldActive;
        }
コード例 #25
0
 public void SetSubworld(Subworld subworld)
 {
     if (subworld == null)
     {
         CurrentSubworldID = -1;
     }
     else
     {
         CurrentSubworldID = subworld.SubworldID;
     }
 }
コード例 #26
0
 public MoonGen(Subworld sw)
 {
     subworld = sw;
     Add(new SubworldGenPass(GroundPass));
     Add(new SubworldGenPass(CraterPass));
     Add(new SubworldGenPass(BackgroundPass));
     Add(new SubworldGenPass(RegolithPass));
     Add(new SubworldGenPass(OrePass));
     Add(new SubworldGenPass(CavePass));
     Add(new SubworldGenPass(ScuffedSmoothPass));
 }
コード例 #27
0
 public override bool UseItem(Player player)
 {
     if (!Subworld.AnyActive <Macrocosm>())
     {
         Subworld.Enter <Moon>();
     }
     else
     {
         Subworld.Exit();
     }
     return(true);
 }
コード例 #28
0
    public void EnterSubworld(Subworld subworld)
    {
        if (subworld != null) //If we are entering a new subworld
        {
            Debug.Log("HEREHEHREHHER");
            PastSubworldID = -1;

            Debug.Log("LE count:" + LoadedEntities.Count);

            PastSubworldEntities.Clear();
            UnloadedUpdatableEntities.Clear();
            foreach (LoadedEntity le in LoadedEntities)
            {
                UnloadedUpdatableEntities.Add(le.Entity.ID);
                PastSubworldEntities.Add(le.Entity);
            }
            Debug.Log(PastSubworldEntities.Count);
            UnloadAllChunks();
            UnloadAllEntities();

            for (int x = 0; x < subworld.SubworldChunks.GetLength(0); x++)
            {
                for (int z = 0; z < subworld.SubworldChunks.GetLength(1); z++)
                {
                    LoadedChunks.Add(new Vec2i(x, z));
                }
            }
        }
        if (subworld.HasEntities)
        {
            foreach (Entity e in subworld.Entities)
            {
                if (e.IsAlive)
                {
                    LoadEntity(e);
                }
            }
        }


        Debug.Log(subworld);
        if (subworld is Dungeon)
        {
            Debug.Log("test");
            Dungeon dun = subworld as Dungeon;
            foreach (Entity e in dun.DungeonEntities)
            {
                LoadEntity(e);
            }
            LoadEntity(dun.Boss);
        }
        Subworld = subworld;
    }
コード例 #29
0
        public override void OnInitialize()
        {                                  // 1
            UIPanel panel = new UIPanel(); // 2

            panel.Width.Set(1000, 0);      // 3
            panel.Height.Set(1000, 0);     // 3
            panel.HAlign = 0.5f;
            panel.VAlign = 0.5f;
            Append(panel); // 4
            UIList worldSelect = new UIList();

            worldSelect.Width.Set(800, 0);
            worldSelect.Height.Set(800, 0);
            worldSelect.HAlign = 0.5f;
            worldSelect.VAlign = 0.5f;
            int i = 5;
            UIClickableButton worldButton;

            foreach (string name in SubworldManager.WorldsEnter.Keys)
            {
                void OnButtonClick(UIMouseEvent evt, UIElement listeningElement)
                {
                    if (Main.netMode != NetmodeID.Server)
                    {
                        Subworld.Enter(SubworldManager.WorldsEnter[name]);
                    }
                    Multiverse.instance.HideMyUI();
                }

                worldButton = new UIClickableButton(name, OnButtonClick);
                worldButton.Width.Set(600, 0);
                worldButton.Height.Set(100, 0);
                worldButton.HAlign = 0.5f;
                worldButton.Top.Set(i, 0);
                i += 105;
                worldSelect.Add(worldButton);
            }
            panel.Append(worldSelect);
            UIImageButton closeButton = new UIImageButton(ModContent.GetTexture("Terraria/UI/ButtonDelete"));

            closeButton.OnClick += OnCloseClick;
            closeButton.Width.Set(22, 0);  // 5
            closeButton.Height.Set(22, 0); // 5
            closeButton.HAlign = 1.0f;
            closeButton.VAlign = 0.0f;
            void OnCloseClick(UIMouseEvent evt, UIElement listeningElement)
            {
                Multiverse.instance.HideMyUI();
            }

            panel.Append(closeButton);
        }
コード例 #30
0
ファイル: DreamBattleWorld.cs プロジェクト: DarthHA/HKBoss
 public override void AI(Projectile projectile)
 {
     if (Subworld.IsActive <DreamBattleWorld>())
     {
         if (projectile.type == ProjectileID.SandBallFalling || projectile.type == ProjectileID.SandBallGun ||
             projectile.type == ProjectileID.PearlSandBallFalling || projectile.type == ProjectileID.PearlSandBallGun ||
             projectile.type == ProjectileID.EbonsandBallFalling || projectile.type == ProjectileID.EbonsandBallGun ||
             projectile.type == ProjectileID.CrimsandBallFalling || projectile.type == ProjectileID.CrimsandBallGun || projectile.type == ProjectileID.IceBlock)
         {
             projectile.active = false;
         }
     }
 }