Generates the minecraft world and renders it to the scene.
Inheritance: MonoBehaviour
Exemple #1
0
 private void MoveToTarget(NeedAIData data)
 {
     if (!HasMoved && m_PathfindingData.Count > 0)
     {
         Vector2Int    nextPoint     = m_PathfindingData.Peek();
         PhysicsResult physicsResult = PhysicsManager.IsCollision(WorldPosition, nextPoint, MyWorld);
         if (physicsResult != PhysicsResult.EntityCollision)
         {
             m_PathfindingData.Dequeue();
             Move(nextPoint);
             HasMoved = true;
         }
         else if (physicsResult == PhysicsResult.EntityCollision)
         {
             MyWorld.SwapPosition(this, MyWorld.GetEntity(nextPoint));
             m_PathfindingData.Dequeue();
             Move(nextPoint);
             HasMoved = true;
         }
     }
     else if (m_PathfindingData.Count == 0)
     {
         if (data.target != null)
         {
             m_PathfindingData = m_Pathfinder.FindPath(WorldPosition, data.target.WorldPosition, MyWorld);
         }
         else if (data.targetPoint != Vector2Int.zero)
         {
             m_PathfindingData = m_Pathfinder.FindPath(WorldPosition, data.targetPoint, MyWorld);
         }
     }
 }
        private int GenerateLab(int s, int structX, int structY)
        {
            if (MyWorld.TileCheckSafe(structX, structY))
            {
                if (!Chest.NearOtherChests(structX, structY))
                {
                    if (structY < Main.maxTilesY - 220)
                    {
                        bool mirrored = false;
                        if (Main.rand.Next(2) == 0)
                        {
                            mirrored = true;
                        }

                        PickLab(s, structX, structY, mirrored);
                        s++;
                        if (s > 11)
                        {
                            s = 0; // this should never happen but just to be safe
                        }
                    }
                }
            }
            return(s);
        }
        /// <summary>
        /// Server resyncs any recent exp changes
        /// </summary>
        /// <param name="mod"></param>
        /// <param name="toWho"></param>
        /// <param name="toIgnore"></param>
        public static void ServerSyncExp(Mod mod, bool full = false)
        {
            if (Main.netMode != 2)
            {
                return;
            }

            if (full)
            {
                MyWorld.FlagAllForSyncExp();
            }

            if (MyWorld.clientNeedsExpUpdate_counter <= 0)
            {
                return;
            }

            Player   player;
            MyPlayer myPlayer;

            ModPacket packet = mod.GetPacket();

            packet.Write((byte)ExpModMessageType.ServerSyncExp);
            packet.Write(full);
            packet.Write(MyWorld.clientNeedsExpUpdate_counter); //number of clients updated
            for (int ind = 0; ind < MyWorld.clientNeedsExpUpdate_counter; ind++)
            {
                player = Main.player[MyWorld.clientNeedsExpUpdate_who[ind]];
                packet.Write(player.whoAmI); //who dis
                if (player.active)
                {
                    myPlayer = player.GetModPlayer <MyPlayer>(mod);
                    packet.Write(myPlayer.GetExp()); //xp

                    int kill_id = myPlayer.kill_count_track_id;
                    if (NPCs.MyGlobalNPC.kill_counts.ContainsKey(kill_id))
                    {
                        packet.Write((int)NPCs.MyGlobalNPC.kill_counts.GetByIndex(NPCs.MyGlobalNPC.kill_counts.IndexOfKey(kill_id))); //kill count (int32)
                    }
                    else
                    {
                        packet.Write(0); //kill count
                    }
                }
                else
                {
                    packet.Write(-1); //xp
                    packet.Write(-1); //kill count
                }

                //reset
                MyWorld.clientNeedsExpUpdate_who[ind]       = 0;
                MyWorld.clientNeedsExpUpdate[player.whoAmI] = false;
            }
            packet.Send();

            //reset
            MyWorld.clientNeedsExpUpdate_counter = 0;
        }
Exemple #4
0
 public GamePhase(GameContainer container) : base(PhaseType.InGame, null)
 {
     cam = new Camera(container.GraphicsDevice.Viewport);
     w   = new MyWorld(cam);
     w.Load(@".\Content\Level\Maps\smallRoom.xml", container.GraphicsDevice);
     cam.Follow  = w.npcs[0];
     followedNPC = 0;
     debug       = false;
 }
        public void CreateWorld(Type worldType)
        {
            DisconnectWorld();

            World       = Activator.CreateInstance(worldType) as MyWorld;
            World.Owner = this;
            World.Init();

            World.Name = "World";

            ConnectWorld();
        }
        public void worldButton_Click(object sender, EventArgs e)
        {
            Desktop.FocusElement = null;
            MyWorld world = m_mainForm.Project.World;

            m_mainForm.NodePropertyView.Target = world;
            m_mainForm.MemoryBlocksView.Target = world;
            m_mainForm.TaskView.Target         = world;
            m_mainForm.HelpView.Target         = world;

            worldButtonPanel.BackColor = Color.DarkOrange;
            groupButtonPanel.BackColor = SystemColors.Control;
        }
Exemple #7
0
        private void SelectWorldInWorldList(MyWorld world)
        {
            if (Properties.Settings.Default.ToolBarNodes == null)
            {
                Properties.Settings.Default.ToolBarNodes = new System.Collections.Specialized.StringCollection();
            }

            // if the world is not present in the combo box, add it first
            if (!Properties.Settings.Default.ToolBarNodes.Contains(world.GetType().Name))
            {
                Properties.Settings.Default.ToolBarNodes.Add(world.GetType().Name);
                worldList.Items.Add(MyConfiguration.KnownWorlds[Project.World.GetType()]);
            }

            worldList.SelectedItem = MyConfiguration.KnownWorlds[Project.World.GetType()];
        }
Exemple #8
0
        public void StartAnimation(GameObject item, MyWorld world)
        {
            uint t = world.ExecutionBlock.SimulationStep;

            // default condition - run for 1 step only
            Condition = Condition ?? (() =>
            {
                if (world.ExecutionBlock.SimulationStep > t)
                {
                    return(false);
                }
                return(true);
            });

            IsStarted = true;
        }
        public void CreatesAndRunsMNIST()
        {
            using (var runner = new MyProjectRunner())
            {
                MyProject project = runner.CreateProject(typeof(MyMNISTWorld));

                MyWorld world = project.World;

                var neuralGroup = project.CreateNode <MyNeuralNetworkGroup>();
                project.Network.AddChild(neuralGroup);

                var hiddenLayer = project.CreateNode <MyHiddenLayer>();
                neuralGroup.AddChild(hiddenLayer);

                var outputLayer = project.CreateNode <MyOutputLayer>();
                neuralGroup.AddChild(outputLayer);

                var accumulator = project.CreateNode <MyAccumulator>();
                neuralGroup.AddChild(accumulator);

                // Connect the nodes.

                project.Connect(project.Network.GroupInputNodes[0], neuralGroup, 0, 0);
                project.Connect(project.Network.GroupInputNodes[1], neuralGroup, 0, 1);

                project.Connect(neuralGroup.GroupInputNodes[0], hiddenLayer, 0, 0);

                project.Connect(neuralGroup.GroupInputNodes[1], outputLayer, 0, 1);

                project.Connect(hiddenLayer, outputLayer, 0, 0);

                project.Connect(outputLayer, accumulator, 1, 0);

                // Setup the nodes.

                MyTask sendMnistData = world.GetTaskByPropertyName("SendTrainingMNISTData");
                Assert.NotNull(sendMnistData);
                sendMnistData.GetType().GetProperty("RandomEnumerate").SetValue(sendMnistData, true);
                sendMnistData.GetType().GetProperty("ExpositionTime").SetValue(sendMnistData, 1);

                world.GetType().GetProperty("Binary").SetValue(world, true);

                hiddenLayer.Neurons = 40;

                accumulator.ApproachValue.ApproachMethod = MyAccumulator.MyApproachValueTask.SequenceType.Momentum;
                accumulator.ApproachValue.Delta          = 0.1f;
                accumulator.ApproachValue.Target         = 0;
                accumulator.ApproachValue.Factor         = 0.9f;

                // Enable tasks.
                project.World.EnableDefaultTasks();

                neuralGroup.EnableDefaultTasks();
                neuralGroup.RMS.Enabled = true;

                hiddenLayer.EnableDefaultTasks();

                outputLayer.EnableDefaultTasks();

                accumulator.EnableDefaultTasks();
                accumulator.ApproachValue.Enabled = true;

                // Run the simulation.

                runner.RunAndPause(100);

                float error = runner.GetValues(accumulator.Id)[0];
                Assert.True(error < 0.5f);
                //runner.SaveProject(@"c:\foobar.brain");
            }
        }
 public void ChangeName()
 {
     MyWorld.ChangeName();
     LoadData();
 }
        public override bool Generate()
        {
            shingleColor = WorldGen.genRand.NextBool() ? TileID.RedDynastyShingles : TileID.BlueDynastyShingles;
            bool placed   = false;
            int  attempts = 0;

            while (!placed && attempts++ < 100000)
            {
                // Select a place in the first 6th of the world, avoiding the oceans
                int towerX = WorldGen.genRand.Next(300, Main.maxTilesX / 6);                 // from 50 since there's a unaccessible area at the world's borders
                // 50% of choosing the last 6th of the world
                // Choose which side of the world to be on randomly
                if (WorldGen.genRand.NextBool())
                {
                    towerX = Main.maxTilesX - towerX;
                }

                //Start at 200 tiles above the surface instead of 0, to exclude floating islands
                int towerY = (int)Main.worldSurface - 200;

                // We go down until we hit a solid tile or go under the world's surface
                while (!WorldGen.SolidTile(towerX, towerY) && towerY <= Main.worldSurface)
                {
                    towerY++;
                }

                // If we went under the world's surface, try again
                if (towerY > Main.worldSurface)
                {
                    continue;
                }
                Tile tile = Main.tile[towerX, towerY];
                // If the type of the tile we are placing the tower on doesn't match what we want, try again
                if (!(tile.type == TileID.Dirt ||
                      tile.type == TileID.Grass ||
                      tile.type == TileID.Stone ||
                      tile.type == TileID.Mud ||
                      tile.type == TileID.FleshGrass ||
                      tile.type == TileID.CorruptGrass ||
                      tile.type == TileID.JungleGrass ||
                      tile.type == TileID.Sand ||
                      tile.type == TileID.Crimsand ||
                      tile.type == TileID.Ebonsand))
                {
                    continue;
                }

                // Don't place the tower if the area isn't flat
                if (!MyWorld.CheckFlat(towerX, towerY, Tiles.GetLength(1), 3))
                {
                    continue;
                }

                // place the tower
                Place(towerX, towerY);
                // extend the base a bit
                for (int i = towerX - 2; i < towerX + Tiles.GetLength(1) - 4; i++)
                {
                    for (int k = towerY + 3; k < towerY + 12; k++)
                    {
                        WorldGen.PlaceTile(i, k, TileID.StoneSlab, mute: true, forced: true);
                        WorldGen.SlopeTile(i, k);
                    }
                }
                // place the Rogue
                int num = NPC.NewNPC((towerX + 12) * 16, (towerY - 24) * 16, ModContent.NPCType <BoundGambler>(), 0, 0f, 0f, 0f, 0f, 255);
                Main.npc[num].homeTileX = -1;
                Main.npc[num].homeTileY = -1;
                Main.npc[num].direction = 1;
                Main.npc[num].homeless  = true;
                placed = true;
            }
            if (!placed)
            {
                SpiritMod.instance.Logger.Error("Worldgen: FAILED to place Goblin Tower, ground not flat enough?");
            }
            return(placed);
        }
Exemple #12
0
 public void PlaceItemInWorld(ItemInstance item)
 {
     m_Backpack.Remove(item);
     item.Move(WorldPosition);
     MyWorld.AddObject(item);
 }
Exemple #13
0
 // Use this for initialization
 public override void Start()
 {
     world = new MyWorld();
 }
Exemple #14
0
        public void UpdateMe()
        {
            if (this.MyWorld.IsDirty)
            {
                FOVBasicBoard board = (FOVBasicBoard)m_FOVHandler.Do(this.WorldPosition, this.MyWorld.Dimensions, this.VisionMod, this.MyWorld.Walls.Keys.ToList());
                m_Vision = board.Vision;
            }
            else
            {
                FOVBasicBoard board = (FOVBasicBoard)m_FOVHandler.Do(this.WorldPosition, this.VisionMod);
                m_Vision = board.Vision;
            }

            HasMoved = false;

            if (!PlayerControlled)
            {
                //Attack immediate threats

                /*
                 * REDO THIS TO BE IN LUA
                 * //List<NeedAIData> targets = MyWorld.SearchForEntities(this, "Any", Intent.Attack, EntityTypeSearch.Any, EntitySentienceSearch.Any);
                 * //List<NeedAIData> validTargets = targets.Where(x => this.HasRelationship(x.target.GUID) < ATTACK_THRESHOLD).ToList();
                 * if(validTargets.Count > 0 && CurrentTarget.target == null)
                 * {
                 *  //TODO: Write a threat assessment system
                 *  //For now, choose a random target and go after them
                 *  int result = RNG.Roll(0, validTargets.Count - 1);
                 *  NeedAIData data = validTargets[result];
                 *
                 *  CurrentTarget = data;
                 *  m_PathfindingData = m_Pathfinder.FindPath(this.WorldPosition, CurrentTarget.target.WorldPosition, this.MyWorld);
                 * }
                 */

                //If you're idle
                if (CurrentTarget.idle == true)
                {
                    //Let's find something to do
                    List <EntityNeed> needs = m_Needs.Values.OrderByDescending(x => x.priority).ToList();
                    //Act on first need

                    bool idle = true;
                    foreach (EntityNeed need in needs)
                    {
                        if (need.contributingHappiness)
                        {
                            continue;
                        }

                        Debug.Log("Running LUA script: FindFulfilmentObject (" + need.name + ") requested by: " + this.JoyName);
                        ScriptingEngine.RunScript(need.InteractionFileContents, need.name, "FindFulfilmentObject", new object[] { new MoonEntity(this) });
                        idle = false;
                        break;
                    }
                    m_CurrentTarget.idle = idle;
                }
                //Otherwise, carry on with what you're doing
                else
                {
                    if (WorldPosition == CurrentTarget.targetPoint || (CurrentTarget.target != null && WorldPosition == CurrentTarget.target.WorldPosition))
                    {
                        //If we have a target
                        if (CurrentTarget.target != null)
                        {
                            //We're interacting with an entity here
                            if (CurrentTarget.intent == Intent.Interact)
                            {
                                //TODO: WRITE AN ENTITY INTERACTION
                                EntityNeed need = this.Needs[CurrentTarget.need];

                                Debug.Log("Running LUA script: FindFulfilmentObject (" + need.name + ") requested by: " + this.JoyName);
                                ScriptingEngine.RunScript(need.InteractionFileContents, need.name, "FindFulfilmentObject", new object[] { new MoonEntity(this) });
                            }
                            else if (CurrentTarget.intent == Intent.Attack)
                            {
                                CombatEngine.SwingWeapon(this, CurrentTarget.target);
                            }
                        }
                    }
                    //If we've not arrived at our target
                    else if (WorldPosition != CurrentTarget.targetPoint || (CurrentTarget.target != null && AdjacencyHelper.IsAdjacent(WorldPosition, CurrentTarget.target.WorldPosition) == false))
                    {
                        //Move to target
                        MoveToTarget(CurrentTarget);
                    }
                }
            }
            else
            {
                if (!HasMoved && m_PathfindingData.Count > 0)
                {
                    Vector2Int    nextPoint     = m_PathfindingData.Peek();
                    PhysicsResult physicsResult = PhysicsManager.IsCollision(WorldPosition, nextPoint, MyWorld);
                    if (physicsResult != PhysicsResult.EntityCollision)
                    {
                        m_PathfindingData.Dequeue();
                        Move(nextPoint);
                        HasMoved = true;
                    }
                    else if (physicsResult == PhysicsResult.EntityCollision)
                    {
                        MyWorld.SwapPosition(this, MyWorld.GetEntity(nextPoint));

                        m_PathfindingData.Dequeue();
                        Move(nextPoint);
                        HasMoved = true;
                    }
                }
            }
        }
Exemple #15
0
        public override bool Generate()
        {
            bool placed   = false;
            int  attempts = 0;

            while (!placed && attempts++ < 100000)
            {
                // Select a place in the first 4th of the world, avoiding the oceans
                int towerX = WorldGen.genRand.Next(300, Main.maxTilesX / 4);                 // from 50 since there's a unaccessible area at the world's borders
                // 50% of choosing the last 4th of the world
                // Choose which side of the world to be on randomly
                if (WorldGen.genRand.NextBool())
                {
                    towerX = Main.maxTilesX - towerX;
                }

                //Start at 200 tiles above the surface instead of 0, to exclude floating islands
                int towerY = (int)Main.worldSurface - 200;

                // We go down until we hit a solid tile or go under the world's surface
                while (!WorldGen.SolidTile(towerX, towerY) && towerY <= Main.worldSurface)
                {
                    towerY++;
                }

                // If we went under the world's surface, try again
                if (towerY > Main.worldSurface)
                {
                    continue;
                }
                Tile tile = Main.tile[towerX, towerY];
                // If the type of the tile we are placing the hideout on doesn't match what we want, try again
                if (!(tile.type == TileID.Dirt ||
                      tile.type == TileID.Grass ||
                      tile.type == TileID.Stone ||
                      tile.type == TileID.Mud ||
                      tile.type == TileID.FleshGrass ||
                      tile.type == TileID.CorruptGrass ||
                      tile.type == TileID.JungleGrass ||
                      tile.type == TileID.Sand ||
                      tile.type == TileID.Crimsand ||
                      tile.type == TileID.Ebonsand ||
                      tile.type == TileID.SnowBlock))
                {
                    continue;
                }

                // Don't place the hideout if the area isn't flat
                if (!MyWorld.CheckFlat(towerX, towerY, Tiles.GetLength(1), 3))
                {
                    continue;
                }

                Place(towerX, towerY);
                int num = NPC.NewNPC((towerX + 31) * 16, (towerY - 20) * 16, ModContent.NPCType <BoundRogue>());
                Main.npc[num].homeTileX = -1;
                Main.npc[num].homeTileY = -1;
                Main.npc[num].direction = 1;
                Main.npc[num].homeless  = true;

                placed = true;
            }
            if (!placed)
            {
                SpiritMod.instance.Logger.Error("Worldgen: FAILED to place Bandit Hideout, ground not flat enough?");
            }
            return(placed);
        }
 public double Arithmetic(double F)
 {
     return MyUniverse.Add() - MyWorld.Subtract(F); // will trivially equal F
 }
 public void AddStation()
 {
     MyWorld.AddStation();
     LoadData();
 }
Exemple #18
0
        public void Test_Destroy()
        {
            var wld = new MyWorld ("World");
            var node1 = new MyNode ("Node1");
            var node2 = new MyNode ("Node2");
            var node3 = new MyNode ("Node3");
            wld.AddChild (node1);
            node1.AddChild (node2);
            node2.AddChild (node3);

            // 即時ファイナライズ
            wld.Destroy ();

            Assert.AreEqual (true, node1.IsDestroyed);
            Assert.AreEqual (true, node2.IsDestroyed);
            Assert.AreEqual (true, node3.IsDestroyed);

            Assert.AreEqual (true, node1.IsFinalized);
            Assert.AreEqual (true, node2.IsFinalized);
            Assert.AreEqual (true, node3.IsFinalized);

            Assert.AreEqual (true, node1.IsDisposed);
            Assert.AreEqual (true, node2.IsDisposed);
            Assert.AreEqual (true, node3.IsDisposed);

            Assert.AreEqual (true, wld.IsDestroyed);
            Assert.AreEqual (true, wld.IsFinalized);
            Assert.AreEqual (true, wld.IsDisposed);
            Assert.AreEqual (0, wld.ChildCount);
        }
        public static void StructureGen(int xPosO, int yPosO, bool mirrored)
        {
            /**
             * 0 = Do Nothing
             * 1 = Locker
             * 2 = Platinum Brick - 177
             * 3 = Smooth Marble - 357
             * 4 =
             * 5 =
             * 6 = Platinum brick wall - 47
             * 7 = Martian conduit wall - 176
             * 8 = Luminite Wall - 224
             * 9 = Kill tile
             **/


            for (int i = 0; i < StructureArray.GetLength(1); i++)
            {
                for (int j = 0; j < StructureArray.GetLength(0); j++)
                {
                    if (mirrored)
                    {
                        if (TileCheckSafe((int)(xPosO + StructureArray.GetLength(1) - i), (int)(yPosO + j)))
                        {
                            if (StructureArray[j, i] == 1) // Locker
                            {
                                MyWorld.PlaceLabLocker(xPosO + StructureArray.GetLength(1) - i - 1, yPosO + j, 177);
                                WorldGen.KillWall(xPosO + StructureArray.GetLength(1) - i, yPosO + j);
                                WorldGen.PlaceWall(xPosO + StructureArray.GetLength(1) - i, yPosO + j, WallID.PlatinumBrick, true);
                            }
                            if (StructureArray[j, i] == 2) // Platinum Brick
                            {
                                WorldGen.KillTile(xPosO + StructureArray.GetLength(1) - i, yPosO + j);
                                WorldGen.PlaceTile(xPosO + StructureArray.GetLength(1) - i, yPosO + j, TileID.PlatinumBrick, true, true);
                            }
                            if (StructureArray[j, i] == 3) // Marble Block
                            {
                                WorldGen.KillTile(xPosO + StructureArray.GetLength(1) - i, yPosO + j);
                                WorldGen.PlaceTile(xPosO + StructureArray.GetLength(1) - i, yPosO + j, TileID.MarbleBlock, true, true, -1, 13);
                            }
                            if (StructureArray[j, i] == 4) // platform
                            {
                            }
                            if (StructureArray[j, i] == 5) // Drive
                            {
                            }
                            if (StructureArray[j, i] == 6) // Platinum Brick Wall
                            {
                                WorldGen.KillTile(xPosO + StructureArray.GetLength(1) - i, yPosO + j);
                                Main.tile[xPosO + StructureArray.GetLength(1) - i, yPosO + j].liquid = 0;
                                WorldGen.KillWall(xPosO + StructureArray.GetLength(1) - i, yPosO + j);
                                WorldGen.PlaceWall(xPosO + StructureArray.GetLength(1) - i, yPosO + j, WallID.PlatinumBrick, true);
                            }
                            if (StructureArray[j, i] == 7) // martian wall
                            {
                                WorldGen.KillTile(xPosO + StructureArray.GetLength(1) - i, yPosO + j);
                                Main.tile[xPosO + StructureArray.GetLength(1) - i, yPosO + j].liquid = 0;
                                WorldGen.KillWall(xPosO + StructureArray.GetLength(1) - i, yPosO + j);
                                WorldGen.PlaceWall(xPosO + StructureArray.GetLength(1) - i, yPosO + j, WallID.MartianConduit, true);
                            }
                            if (StructureArray[j, i] == 8) // luminite wall
                            {
                                WorldGen.KillTile(xPosO + StructureArray.GetLength(1) - i, yPosO + j);
                                Main.tile[xPosO + StructureArray.GetLength(1) - i, yPosO + j].liquid = 0;
                                WorldGen.KillWall(xPosO + StructureArray.GetLength(1) - i, yPosO + j);
                                WorldGen.PlaceWall(xPosO + StructureArray.GetLength(1) - i, yPosO + j, WallID.LunarBrickWall, true);
                            }
                            if (StructureArray[j, i] == 9) // destroy everything >:)
                            {
                                Main.tile[xPosO + StructureArray.GetLength(1) - i, yPosO + j].liquid = 0;
                                WorldGen.KillTile(xPosO + StructureArray.GetLength(1) - i, yPosO + j);
                            }
                        }
                    }
                    else
                    {
                        if (TileCheckSafe((int)(xPosO + i), (int)(yPosO + j)))
                        {
                            if (StructureArray[j, i] == 1)
                            {
                                MyWorld.PlaceLabLocker(xPosO + i, yPosO + j, 177);

                                WorldGen.KillWall(xPosO + i, yPosO + j);
                                WorldGen.PlaceWall(xPosO + i, yPosO + j, WallID.PlatinumBrick, true);
                            }
                            if (StructureArray[j, i] == 2)
                            {
                                WorldGen.KillTile(xPosO + i, yPosO + j);
                                WorldGen.PlaceTile(xPosO + i, yPosO + j, TileID.PlatinumBrick, true, true);
                            }
                            if (StructureArray[j, i] == 3)
                            {
                                WorldGen.KillTile(xPosO + i, yPosO + j);
                                WorldGen.PlaceTile(xPosO + i, yPosO + j, TileID.MarbleBlock, true, true);
                            }
                            if (StructureArray[j, i] == 4)
                            {
                            }
                            if (StructureArray[j, i] == 5)
                            {
                            }
                            if (StructureArray[j, i] == 6)
                            {
                                WorldGen.KillTile(xPosO + i, yPosO + j);
                                Main.tile[xPosO + i, yPosO + j].liquid = 0;
                                WorldGen.KillWall(xPosO + i, yPosO + j);
                                WorldGen.PlaceWall(xPosO + i, yPosO + j, WallID.PlatinumBrick, true);
                            }
                            if (StructureArray[j, i] == 7)
                            {
                                WorldGen.KillTile(xPosO + i, yPosO + j);
                                Main.tile[xPosO + i, yPosO + j].liquid = 0;
                                WorldGen.KillWall(xPosO + i, yPosO + j);
                                WorldGen.PlaceWall(xPosO + i, yPosO + j, WallID.MartianConduit, true);
                            }
                            if (StructureArray[j, i] == 8)
                            {
                                WorldGen.KillTile(xPosO + i, yPosO + j);
                                Main.tile[xPosO + i, yPosO + j].liquid = 0;
                                WorldGen.KillWall(xPosO + i, yPosO + j);
                                WorldGen.PlaceWall(xPosO + i, yPosO + j, WallID.LunarBrickWall, true);
                            }
                            if (StructureArray[j, i] == 9)
                            {
                                Main.tile[xPosO + i, yPosO + j].liquid = 0;
                                WorldGen.KillTile(xPosO + i, yPosO + j);
                            }
                        }
                    }
                }
            }
        }
Exemple #20
0
        public static void FurnitureGen(int xPosO, int yPosO, bool mirrored)
        {
            /**
             * 0 = Do Nothing
             * 1 = Desk, Drive & Computer
             * 2 = Office Chair
             * 3 = Lab Light
             * 4 = Door
             * 5 = Locker
             * 6 = Bench & Crystal
             * 7 = Dead Scientist
             * 9 = Kill Tile
             **/

            for (int i = 0; i < FurnitureArray.GetLength(1); i++)
            {
                for (int j = 0; j < FurnitureArray.GetLength(0); j++)
                {
                    if (mirrored)
                    {
                        if (TileCheckSafe((int)(xPosO + FurnitureArray.GetLength(1) - i), (int)(yPosO + j)))
                        {
                            if (FurnitureArray[j, i] == 1) // Desk
                            {
                                // origin in bottom middle
                                WorldGen.Place3x2(xPosO + FurnitureArray.GetLength(1) - i, yPosO + j, (ushort)ElementsAwoken.instance.TileType("Desk"), 1);
                                WorldGen.PlaceObject(xPosO + FurnitureArray.GetLength(1) - i + 1, yPosO + j - 2, (ushort)ElementsAwoken.instance.TileType("Computer"), false, 0, 1, -1, 0);
                                WorldGen.PlaceObject(xPosO + FurnitureArray.GetLength(1) - i - 1, yPosO + j - 2, ElementsAwoken.instance.TileType("AncientsDrive"), false, 0);
                            }
                            if (FurnitureArray[j, i] == 2) // Chair
                            {
                                // origin in bottom right
                                WorldGen.PlaceObject(xPosO + FurnitureArray.GetLength(1) - i + 1, yPosO + j, (ushort)ElementsAwoken.instance.TileType("OfficeChair"), false, 0, 1, -1, 1);
                            }
                            if (FurnitureArray[j, i] == 3) // Lab Light
                            {
                                WorldGen.PlaceObject(xPosO + FurnitureArray.GetLength(1) - i, yPosO + j, ElementsAwoken.instance.TileType("LabLight"), false, 0);
                            }
                            if (FurnitureArray[j, i] == 4) // Door
                            {
                                WorldGen.PlaceDoor(xPosO + FurnitureArray.GetLength(1) - i, yPosO + j, 10, 20);
                            }
                            if (FurnitureArray[j, i] == 5) // Locker
                            {
                                MyWorld.PlaceLabLocker(xPosO + FurnitureArray.GetLength(1) - i - 1, yPosO + j, 177);
                            }
                            if (FurnitureArray[j, i] == 6) // Desk
                            {
                                // origin in bottom middle
                                WorldGen.Place4x2(xPosO + FurnitureArray.GetLength(1) - i - 1, yPosO + j, (ushort)ElementsAwoken.instance.TileType("LabBench"));
                                WorldGen.PlaceObject(xPosO + FurnitureArray.GetLength(1) - i, yPosO + j - 2, (ushort)ElementsAwoken.instance.TileType("CrystalContainer"), false, 0, 1, -1, 0);
                            }
                            if (FurnitureArray[j, i] == 7) // Scientist
                            {
                                // origin on left
                                WorldGen.PlaceObject(xPosO + FurnitureArray.GetLength(1) - i - 2, yPosO + j, ElementsAwoken.instance.TileType("DeadScientist"), false, 0, 1, -1, 1);
                            }
                            if (FurnitureArray[j, i] == 9) // destroy everything >:)
                            {
                                Main.tile[xPosO + FurnitureArray.GetLength(1) - i, yPosO + j].liquid = 0;
                                WorldGen.KillTile(xPosO + FurnitureArray.GetLength(1) - i, yPosO + j);
                            }
                        }
                    }
                    else
                    {
                        if (TileCheckSafe((int)(xPosO + i), (int)(yPosO + j)))
                        {
                            if (FurnitureArray[j, i] == 1) // Desk
                            {
                                WorldGen.Place3x2(xPosO + i, yPosO + j, (ushort)ElementsAwoken.instance.TileType("Desk"), 0);
                                WorldGen.PlaceObject(xPosO + i, yPosO + j - 2, (ushort)ElementsAwoken.instance.TileType("Computer"), false, 0, 1, -1, 1);
                                WorldGen.PlaceObject(xPosO + i + 1, yPosO + j - 2, ElementsAwoken.instance.TileType("AncientsDrive"), false, 0);
                            }
                            if (FurnitureArray[j, i] == 2) // Chair
                            {
                                WorldGen.PlaceObject(xPosO + i, yPosO + j, (ushort)ElementsAwoken.instance.TileType("OfficeChair"), false, 0, 1, -1, 0);
                            }
                            if (FurnitureArray[j, i] == 3) // Lab Light
                            {
                                WorldGen.PlaceObject(xPosO + i, yPosO + j, ElementsAwoken.instance.TileType("LabLight"), false, 0);
                            }
                            if (FurnitureArray[j, i] == 4) // Door
                            {
                                WorldGen.PlaceDoor(xPosO + i, yPosO + j, 10, 20);
                            }
                            if (FurnitureArray[j, i] == 5) // Locker
                            {
                                MyWorld.PlaceLabLocker(xPosO + i, yPosO + j, 177);
                            }
                            if (FurnitureArray[j, i] == 6) // Desk
                            {
                                WorldGen.Place4x2(xPosO + i, yPosO + j, (ushort)ElementsAwoken.instance.TileType("LabBench"));
                                WorldGen.PlaceObject(xPosO + i + 1, yPosO + j - 2, (ushort)ElementsAwoken.instance.TileType("CrystalContainer"), false, 0, 1, -1, 0);
                            }
                            if (FurnitureArray[j, i] == 7) // Scientist
                            {
                                WorldGen.PlaceObject(xPosO + i, yPosO + j, ElementsAwoken.instance.TileType("DeadScientist"), false, 0, 1, -1, 0);
                            }
                            if (FurnitureArray[j, i] == 9)
                            {
                                Main.tile[xPosO + i, yPosO + j].liquid = 0;
                                WorldGen.KillTile(xPosO + i, yPosO + j);
                            }
                        }
                    }
                }
            }
        }