Пример #1
0
        private bool FindVerticalExit(Rectangle wall, bool isUp, out int exitX)
        {
            Point result;
            var   flag = WorldUtils.Find(new Point(wall.X + wall.Width - 3, wall.Y + (isUp ? -5 : 0)),
                                         Searches.Chain(new Searches.Left(wall.Width - 3),
                                                        new Conditions.IsSolid().Not().AreaOr(3, 5)), out result);

            exitX = result.X;
            return(flag);
        }
Пример #2
0
        public override bool Place(Point origin, StructureMap structures)
        {
            if (WorldGen.SolidTile(origin.X, origin.Y) && (int)GenBase._tiles[origin.X, origin.Y].wall == 3)
            {
                return(false);
            }
            if (!WorldUtils.Find(origin, Searches.Chain((GenSearch) new Searches.Down(100), (GenCondition) new Conditions.IsSolid()), out origin))
            {
                return(false);
            }
            Point result;

            if (!WorldUtils.Find(new Point(origin.X - 4, origin.Y), Searches.Chain((GenSearch) new Searches.Down(5), new Conditions.IsTile(new ushort[1]
            {
                (ushort)25
            }).AreaAnd(8, 1)), out result))
            {
                return(false);
            }
            ShapeData data1      = new ShapeData();
            ShapeData shapeData1 = new ShapeData();
            ShapeData shapeData2 = new ShapeData();

            for (int index = 0; index < 6; ++index)
            {
                WorldUtils.Gen(origin, (GenShape) new Shapes.Circle(GenBase._random.Next(10, 12) + index), Actions.Chain((GenAction) new Modifiers.Offset(0, 5 * index + 5), new Modifiers.Blotches(3, 0.3).Output(data1)));
            }
            for (int index = 0; index < 6; ++index)
            {
                WorldUtils.Gen(origin, (GenShape) new Shapes.Circle(GenBase._random.Next(5, 7) + index), Actions.Chain((GenAction) new Modifiers.Offset(0, 2 * index + 18), new Modifiers.Blotches(3, 0.3).Output(shapeData1)));
            }
            for (int index = 0; index < 6; ++index)
            {
                WorldUtils.Gen(origin, (GenShape) new Shapes.Circle(GenBase._random.Next(4, 6) + index / 2), Actions.Chain((GenAction) new Modifiers.Offset(0, (int)(7.5 * (double)index) - 10), new Modifiers.Blotches(3, 0.3).Output(shapeData2)));
            }
            ShapeData data2 = new ShapeData(shapeData1);

            shapeData1.Subtract(shapeData2, origin, origin);
            data2.Subtract(shapeData1, origin, origin);
            Microsoft.Xna.Framework.Rectangle bounds = ShapeData.GetBounds(origin, data1, shapeData2);
            if (!structures.CanPlace(bounds, CorruptionPitBiome.ValidTiles, 2))
            {
                return(false);
            }
            WorldUtils.Gen(origin, (GenShape) new ModShapes.All(data1), Actions.Chain((GenAction) new Actions.SetTile((ushort)25, true, true), (GenAction) new Actions.PlaceWall((byte)3, true)));
            WorldUtils.Gen(origin, (GenShape) new ModShapes.All(shapeData1), (GenAction) new Actions.SetTile((ushort)0, true, true));
            WorldUtils.Gen(origin, (GenShape) new ModShapes.All(shapeData2), (GenAction) new Actions.ClearTile(true));
            WorldUtils.Gen(origin, (GenShape) new ModShapes.All(shapeData1), Actions.Chain((GenAction) new Modifiers.IsTouchingAir(true), (GenAction) new Modifiers.NotTouching(false, new ushort[1]
            {
                (ushort)25
            }), (GenAction) new Actions.SetTile((ushort)23, true, true)));
            WorldUtils.Gen(origin, (GenShape) new ModShapes.All(data2), (GenAction) new Actions.PlaceWall((byte)69, true));
            structures.AddStructure(bounds, 2);
            return(true);
        }
Пример #3
0
 internal static void AgeDefaultRoom(Rectangle room)
 {
     for (int i = 0; i < room.Width * room.Height / 16; i++)
     {
         int x = GenBase._random.Next(1, room.Width - 1) + room.X;
         int y = GenBase._random.Next(1, room.Height - 1) + room.Y;
         WorldUtils.Gen(new Point(x, y), new Shapes.Rectangle(2, 2), Actions.Chain(new Modifiers.Dither(), new Modifiers.Blotches(2, 2.0), new Modifiers.IsEmpty(), new Actions.SetTile(51, setSelfFrames: true)));
     }
     WorldUtils.Gen(new Point(room.X, room.Y), new Shapes.Rectangle(room.Width, room.Height), Actions.Chain(new Modifiers.Dither(0.85000002384185791), new Modifiers.Blotches(), new Modifiers.OnlyWalls(BuildData.Default.Wall), ((double)room.Y > Main.worldSurface) ? ((GenAction) new Actions.ClearWall(frameNeighbors: true)) : ((GenAction) new Actions.PlaceWall(2))));
     WorldUtils.Gen(new Point(room.X, room.Y), new Shapes.Rectangle(room.Width, room.Height), Actions.Chain(new Modifiers.Dither(0.949999988079071), new Modifiers.OnlyTiles(30, 321, 158), new Actions.ClearTile(frameNeighbors: true)));
 }
Пример #4
0
        public override void AI()
        {
            Player player = Main.player[npc.target];

            npc.TargetClosest(true);

            if (frameType == attackFrameType)

            {
                attackTime++;
                npc.velocity.X = (0);
                npc.velocity.Y = (0);

                if (attackTime > ReloadTime)
                {
                    if (secondShot)
                    {
                        if (Main.netMode != 1)
                        {
                            Projectile.NewProjectile(npc.Center.X - (17f * npc.direction), npc.Center.Y - 40f, 0f, -10f, mod.ProjectileType("AntiAirRocket"), damage, 3f, Main.myPlayer);
                        }
                        //Projectile.NewProjectile(npc.Center.X-(17f*npc.direction), npc.Center.Y-40f, 0f, 0f, 102, damage, 3f, Main.myPlayer);
                        secondShot = false;
                        attackTime = 0;
                    }
                    else
                    {
                        if (Main.netMode != 1)
                        {
                            Projectile.NewProjectile(npc.Center.X + (23f * npc.direction), npc.Center.Y - 40f, 0f, -10f, mod.ProjectileType("AntiAirRocket"), damage, 3f, Main.myPlayer);
                        }
                        //Projectile.NewProjectile(npc.Center.X+(23f*npc.direction), npc.Center.Y-40f, 0f, 0f, 102, damage, 3f, Main.myPlayer);
                        secondShot = true;
                        attackTime = 0;
                    }
                }
            }

            float playerPositionSummery = player.Center.Y - npc.Center.Y;
            Point origin = player.Center.ToTileCoordinates();
            Point point;

            if (playerPositionSummery < -200f && !WorldUtils.Find(origin, Searches.Chain(new Searches.Down(12), new GenCondition[]
            {
                new Conditions.IsSolid()
            }), out point))
            {
                frameType = attackFrameType;
            }
            else
            {
                frameType = moveFrameType;
            }
        }
Пример #5
0
        private bool FindVerticalExit(Rectangle wall, bool isUp, out int exitX)
        {
            Point point;
            bool  result = WorldUtils.Find(new Point(wall.X + wall.Width - 3, wall.Y + (isUp ? -5 : 0)), Searches.Chain(new Searches.Left(wall.Width - 3), new GenCondition[]
            {
                new Conditions.IsSolid().Not().AreaOr(3, 5)
            }), out point);

            exitX = point.X;
            return(result);
        }
Пример #6
0
        private bool FindSideExit(Rectangle wall, bool isLeft, out int exitY)
        {
            Point point;
            bool  result = WorldUtils.Find(new Point(wall.X + (isLeft ? -4 : 0), wall.Y + wall.Height - 3), Searches.Chain(new Searches.Up(wall.Height - 3), new GenCondition[]
            {
                new Conditions.IsSolid().Not().AreaOr(4, 3)
            }), out point);

            exitY = point.Y;
            return(result);
        }
Пример #7
0
    private void CreateActor(RTSClient cl)
    {
        var newActor = Instantiate(UserActorPrefab, WorldUtils.L2ToUnityCoords(cl.UserChar.X, cl.UserChar.Y, 0), WorldUtils.ActorDefaultRotation());
        var uas      = newActor.GetComponent <UserActorScript>();

        uas.client = cl;
        var cp = clientProperties[cl];

        cp.gameObject  = newActor;
        cp.actorScript = uas;
    }
Пример #8
0
 protected override void AgeRoom(Rectangle room)
 {
     for (int i = 0; i < room.Width * room.Height / 16; i++)
     {
         int x = WorldGen.genRand.Next(1, room.Width - 1) + room.X;
         int y = WorldGen.genRand.Next(1, room.Height - 1) + room.Y;
         WorldUtils.Gen(new Point(x, y), new Shapes.Rectangle(2, 2), Actions.Chain(new Modifiers.Dither(), new Modifiers.Blotches(2, 2.0), new Modifiers.IsEmpty(), new Actions.SetTile(51, setSelfFrames: true)));
     }
     WorldUtils.Gen(new Point(room.X, room.Y), new Shapes.Rectangle(room.Width, room.Height), Actions.Chain(new Modifiers.Dither(0.85000002384185791), new Modifiers.Blotches(), new Modifiers.OnlyWalls(base.WallType), new Modifiers.SkipTiles(SkipTilesDuringWallAging), ((double)room.Y > Main.worldSurface) ? ((GenAction) new Actions.ClearWall(frameNeighbors: true)) : ((GenAction) new Actions.PlaceWall(2))));
     WorldUtils.Gen(new Point(room.X, room.Y), new Shapes.Rectangle(room.Width, room.Height), Actions.Chain(new Modifiers.Dither(0.949999988079071), new Modifiers.OnlyTiles(30, 321, 158), new Actions.ClearTile(frameNeighbors: true)));
 }
Пример #9
0
        private Rectangle GetRoom(Point origin)
        {
            Point result1;
            bool  flag1 = WorldUtils.Find(origin, Searches.Chain((GenSearch) new Searches.Left(25), (GenCondition) new Conditions.IsSolid()), out result1);
            Point result2;
            bool  flag2 = WorldUtils.Find(origin, Searches.Chain((GenSearch) new Searches.Right(25), (GenCondition) new Conditions.IsSolid()), out result2);

            if (!flag1)
            {
                result1 = new Point(origin.X - 25, (int)origin.Y);
            }
            if (!flag2)
            {
                result2 = new Point(origin.X + 25, (int)origin.Y);
            }
            Rectangle rectangle;

            // ISSUE: explicit reference operation
            ((Rectangle)@rectangle).\u002Ector((int)origin.X, (int)origin.Y, 0, 0);
            if (origin.X - result1.X > result2.X - origin.X)
            {
                rectangle.X     = result1.X;
                rectangle.Width = (__Null)Utils.Clamp <int>((int)(result2.X - result1.X), 15, 30);
            }
            else
            {
                rectangle.Width = (__Null)Utils.Clamp <int>((int)(result2.X - result1.X), 15, 30);
                rectangle.X     = result2.X - rectangle.Width;
            }
            Point result3;
            bool  flag3 = WorldUtils.Find(result1, Searches.Chain((GenSearch) new Searches.Up(10), (GenCondition) new Conditions.IsSolid()), out result3);
            Point result4;
            bool  flag4 = WorldUtils.Find(result2, Searches.Chain((GenSearch) new Searches.Up(10), (GenCondition) new Conditions.IsSolid()), out result4);

            if (!flag3)
            {
                result3 = new Point((int)origin.X, origin.Y - 10);
            }
            if (!flag4)
            {
                result4 = new Point((int)origin.X, origin.Y - 10);
            }
            rectangle.Height = (__Null)Utils.Clamp <int>(Math.Max((int)(origin.Y - result3.Y), (int)(origin.Y - result4.Y)), 8, 12);
            // ISSUE: explicit reference operation
            // ISSUE: variable of a reference type
            Rectangle& local1 = @rectangle;
            // ISSUE: explicit reference operation
            // ISSUE: variable of the null type
            __Null local2 = (^ local1).Y - rectangle.Height;

            // ISSUE: explicit reference operation
            (^ local1).Y = local2;
            return(rectangle);
        }
Пример #10
0
 public override void OnUpdate()
 {
     if (WorldUtils.CalculateDistance(personalAI.client.UserChar, targetSpot) < PersonalAI.MOVE_TO_SPOT_DISTANCE)
     {
         personalAI.SwitchToPreviousInStack();
     }
     else if (DateTime.Now - lastSend >= TimeSpan.FromMilliseconds(1000))
     {
         client.SendMoveToCommand(targetSpot.x, targetSpot.y, targetSpot.z);
         lastSend = DateTime.Now;
     }
 }
Пример #11
0
        private void PlaceSlab(Slab slab, int originX, int originY, int scale)
        {
            ushort num  = 367;
            ushort wall = 178;

            if (WorldGen.drunkWorldGen)
            {
                num  = 368;
                wall = 180;
            }
            int num2 = -1;
            int num3 = scale + 1;
            int num4 = 0;
            int num5 = scale;

            for (int i = num2; i < num3; i++)
            {
                if ((i == num2 || i == num3 - 1) && WorldGen.genRand.Next(2) == 0)
                {
                    continue;
                }
                if (WorldGen.genRand.Next(2) == 0)
                {
                    num4--;
                }
                if (WorldGen.genRand.Next(2) == 0)
                {
                    num5++;
                }
                for (int j = num4; j < num5; j++)
                {
                    Tile tile = GenBase._tiles[originX + i, originY + j];
                    tile.ResetToType(TileID.Sets.Ore[tile.type] ? tile.type : num);
                    bool active = slab.State(i, j, scale);
                    tile.active(active);
                    if (slab.HasWall)
                    {
                        tile.wall = wall;
                    }
                    WorldUtils.TileFrame(originX + i, originY + j, frameNeighbors: true);
                    WorldGen.SquareWallFrame(originX + i, originY + j);
                    Tile.SmoothSlope(originX + i, originY + j);
                    if (WorldGen.SolidTile(originX + i, originY + j - 1) && GenBase._random.Next(4) == 0)
                    {
                        WorldGen.PlaceTight(originX + i, originY + j);
                    }
                    if (WorldGen.SolidTile(originX + i, originY + j) && GenBase._random.Next(4) == 0)
                    {
                        WorldGen.PlaceTight(originX + i, originY + j - 1);
                    }
                }
            }
        }
Пример #12
0
    //private void OnDrawGizmos() {
    //    Vector3 p = lastHit.bpos.ToVector3() / Chunk.BPU;
    //    Debug.DrawLine(lastPos, p, Color.green, 1.0f);
    //    Debug.DrawRay(p, Dirs.GetNormal(lastHit.dir).ToVector3(), Color.magenta, 1.0f);
    //}

    void DrawChunkBorders()
    {
        // local function to add chunks quick
        const float ws = Chunk.SIZE / Chunk.BPU; // world size

        void AddChunkBounds(Chunk c, Color col, float scale)
        {
            if (c != null)
            {
                drawer.AddBounds(new Bounds((c.cp.ToVector3() + Vector3.one * 0.5f) * ws, Vector3.one * ws * scale), col);
            }
        }

        // draw chunk and neighbors and region
        Vector3i cp    = WorldUtils.GetChunkPosFromWorldPos(transform.position);
        Chunk    chunk = world.GetChunk(cp);

        if (chunk != null)
        {
            const float step = 1.0f;
            Vector3     min  = chunk.cp.ToVector3() * ws;
            // draw lines along the edge of chunk in each axis, skip the corners because were just gona draw a bounds cube for that
            for (float f = step; f < ws; f += step)
            {
                // x direction
                drawer.AddLine(new Vector3(min.x, min.y + f, min.z), new Vector3(min.x + ws, min.y + f, min.z), Color.yellow);
                drawer.AddLine(new Vector3(min.x, min.y, min.z + f), new Vector3(min.x + ws, min.y, min.z + f), Color.yellow);
                drawer.AddLine(new Vector3(min.x, min.y + f, min.z + ws), new Vector3(min.x + ws, min.y + f, min.z + ws), Color.yellow);
                drawer.AddLine(new Vector3(min.x, min.y + ws, min.z + f), new Vector3(min.x + ws, min.y + ws, min.z + f), Color.yellow);

                // z direction
                drawer.AddLine(new Vector3(min.x + f, min.y, min.z), new Vector3(min.x + f, min.y, min.z + ws), Color.yellow);
                drawer.AddLine(new Vector3(min.x, min.y + f, min.z), new Vector3(min.x, min.y + f, min.z + ws), Color.yellow);
                drawer.AddLine(new Vector3(min.x + f, min.y + ws, min.z), new Vector3(min.x + f, min.y + ws, min.z + ws), Color.yellow);
                drawer.AddLine(new Vector3(min.x + ws, min.y + f, min.z), new Vector3(min.x + ws, min.y + f, min.z + ws), Color.yellow);

                // y direction
                drawer.AddLine(new Vector3(min.x + f, min.y, min.z), new Vector3(min.x + f, min.y + ws, min.z), Color.yellow);
                drawer.AddLine(new Vector3(min.x, min.y, min.z + f), new Vector3(min.x, min.y + ws, min.z + f), Color.yellow);
                drawer.AddLine(new Vector3(min.x + f, min.y, min.z + ws), new Vector3(min.x + f, min.y + ws, min.z + ws), Color.yellow);
                drawer.AddLine(new Vector3(min.x + ws, min.y, min.z + f), new Vector3(min.x + ws, min.y + ws, min.z + f), Color.yellow);
            }

            AddChunkBounds(chunk, Color.yellow, 1.0f);
            for (int i = 0; i < 6; ++i)
            {
                AddChunkBounds(chunk.neighbors[i], Color.cyan, 0.998f);
            }

            Vector3i rc = WorldUtils.GetRegionCoord(chunk.cp);
            drawer.AddBounds(new Bounds((rc.ToVector3() + Vector3.one * 0.5f) * 16 * ws, Vector3.one * 16 * ws), Color.red);
        }
    }
Пример #13
0
        public override bool UseItem(Player player)
        {
            Tile targetTile = Framing.GetTileSafely(Player.tileTargetX, Player.tileTargetY);

            //check if target is a sapling, if multiplayer send coordinates to server, if singleplayer grow tree
            if (targetTile.type == TileID.Saplings)
            {
                if (Main.netMode != NetmodeID.SinglePlayer)
                {
                    ModPacket growCoord = mod.GetPacket();
                    growCoord.Write((byte)0);
                    growCoord.Write(Player.tileTargetX);
                    growCoord.Write(Player.tileTargetY);
                    growCoord.Send();
                }
                else if ((Main.tile[Player.tileTargetX, Player.tileTargetY].frameX < 324 || Main.tile[Player.tileTargetX, Player.tileTargetY].frameX >= 540)
                    ? WorldGen.GrowTree(Player.tileTargetX, Player.tileTargetY) : WorldGen.GrowPalmTree(Player.tileTargetX, Player.tileTargetY))
                {
                    WorldGen.TreeGrowFXCheck(Player.tileTargetX, Player.tileTargetY);
                }
            }
            //adapted from vanilla code, if target is stone, counts nearby moss tiles and creates the most prominent type or chooses randomly if none are found
            if (targetTile.type == TileID.Stone)
            {
                int   mossID    = 0;
                int   mossCount = 0;
                Point point     = player.Center.ToTileCoordinates();
                Dictionary <ushort, int> dictionary = new Dictionary <ushort, int>();
                WorldUtils.Gen(new Point(point.X - 25, point.Y - 25), new Shapes.Rectangle(50, 50), new Actions.TileScanner(182, 180, 179, 183, 181, 381).Output(dictionary));
                foreach (KeyValuePair <ushort, int> item in dictionary)
                {
                    if (item.Value > mossCount)
                    {
                        mossCount = item.Value;
                        mossID    = item.Key;
                    }
                }
                if (mossCount == 0)
                {
                    mossID = Utils.SelectRandom <int>(Main.rand, 182, 180, 179, 183, 181);
                }
                if (mossID != 0)
                {
                    Main.tile[Player.tileTargetX, Player.tileTargetY].type = (ushort)mossID;
                    WorldGen.SquareTileFrame(Player.tileTargetX, Player.tileTargetY);
                    if (Main.netMode != NetmodeID.SinglePlayer)
                    {
                        NetMessage.SendTileSquare(-1, Player.tileTargetX, Player.tileTargetY, 1);
                    }
                }
            }
            return(true);
        }
Пример #14
0
        public override bool Place(Point origin, StructureMap structures)
        {
            //this handles generating the actual tiles, but you still need to add things like treegen etc. I know next to nothing about treegen so you're on your own there, lol.

            Mod mod         = CelestialMod.instance;
            int worldSize   = GetWorldSize();
            int biomeRadius = worldSize == 3 ? 400 : worldSize == 2 ? 300 : 200;

            Dictionary <Color, int> colorToTile = new Dictionary <Color, int>();

            colorToTile[new Color(0, 0, 255)] = mod.TileType("VoidicGrass");
            colorToTile[new Color(0, 255, 0)] = mod.TileType("VoidicStone");
            colorToTile[new Color(0, 125, 0)] = mod.TileType("VoidicMud");
            colorToTile[new Color(255, 0, 0)] = -2; //turn into air
            colorToTile[Color.Black]          = -1; //don't touch when genning

            Dictionary <Color, int> colorToWall = new Dictionary <Color, int>();

            colorToWall[new Color(0, 0, 255)] = mod.WallType("VoidicSoilWall");
            colorToWall[new Color(255, 0, 0)] = -2;
            colorToWall[Color.Black]          = -1; //don't touch when genning


            Texture2D yeet1 = mod.GetTexture("WorldGeneration/FloweringNightsFiles/FloweringNights");
            Texture2D yeet2 = mod.GetTexture("WorldGeneration/FloweringNightsFiles/FloweringNightsWall");

            if (FloweringNightsBegin == null)
            {
                FloweringNightsBegin = yeet1;

                FloweringNightsWalls = yeet2;
            }

            TexGen gen       = BaseWorldGenTex.GetTexGenerator(FloweringNightsBegin, colorToTile, FloweringNightsWalls, colorToWall);
            Point  newOrigin = new Point(origin.X, origin.Y);                                       //biomeRadius);

            WorldUtils.Gen(newOrigin, new Shapes.Circle(biomeRadius), Actions.Chain(new GenAction[] //remove all fluids in sphere...
            {
                new Modifiers.RadialDither(biomeRadius - 5, biomeRadius),
                new Actions.SetLiquid(0, 0)
            }));
            WorldUtils.Gen(new Point(origin.X, origin.Y - 60), new Shapes.Rectangle(gen.width, gen.height), Actions.Chain(new GenAction[] //remove all fluids in the volcano...
            {
                new Actions.SetLiquid(0, 0)
            }));

            int genX = origin.X;
            int genY = origin.Y - 60;

            gen.Generate(genX, genY, true, true);

            return(true);
        }
Пример #15
0
    void LateUpdate()
    {
        // check how many chunks loaded and queue the ones that couldnt up for generation
        chunksLoaded += Serialization.CheckNewLoaded(chunkGenQueue);

        Serialization.FreeSavedChunks(world.chunkPool);

        UnityEngine.Profiling.Profiler.BeginSample("Update Chunks");
        if (updateChunks)
        {
            UpdateChunks();
        }
        UnityEngine.Profiling.Profiler.EndSample();

        JobHandle.ScheduleBatchedJobs();

        Vector3i pbp = WorldUtils.GetBlockPos(transform.position);
        Vector3i pcp = WorldUtils.GetChunkPosFromBlockPos(pbp.x, pbp.y, pbp.z);

        if (drawDebug)
        {
            text.gameObject.SetActive(true);
            text.text = string.Format(
                "block x:{0} y:{1} z:{2}\n" +
                "chunk x:{3} y:{4} z:{5}\n" +
                "Generat: {6}/{7}\n" +
                "Structr: {8}/{9}\n" +
                "Meshing: {10}/{11}\n" +
                "Light  : {12}/{13}\n" +
                "SLight : {14}/{15}\n" +
                "Free/C : {16}/{17}\n" +
                "Chunks:  {18}\n" +
                "Loaded:  {19}\n" +
                "Greedy:  {20}\n" +
                "v3Pool:  {21}/{22}\n" +
                "intPool: {23}/{24}\n",
                pbp.x, pbp.y, pbp.z, pcp.x, pcp.y, pcp.z,
                JobController.genJobFinished, JobController.genJobScheduled,
                JobController.structureJobFinished, JobController.structureJobScheduled,
                JobController.meshJobFinished, JobController.meshJobScheduled,
                JobController.lightJobFinished, JobController.lightJobScheduled,
                JobController.sunlightJobFinished, JobController.sunlightJobScheduled,
                world.chunkPool.CountFree(), world.chunkPool.Count(),
                world.chunks.Count, chunksLoaded, Chunk.beGreedy,
                Pools.v3N.CountFree(), Pools.v3N.Count(),
                Pools.intN.CountFree(), Pools.intN.Count()
                );
        }
        else
        {
            text.gameObject.SetActive(false);
        }
    }
Пример #16
0
        public WorldState GetStateScope(Player player)
        {
            var actorsInRange = WorldUtils.GetActorsInRange(this, player, player.FieldOfView);

            var disconnectedPlayers = Actors.Where(actor => actor is Player ply && !ConnectedPlayers.Contains(ply));

            return(new WorldState
            {
                Maps = Maps,
                Actors = actorsInRange.Except(disconnectedPlayers).ToList()
            });
        }
Пример #17
0
        public void ChatLocally(string username, string text)
        {
            var player         = (Player)_state.Actors.Single(act => act.Id == username);
            var playersInRange = WorldUtils.GetActorsInRange(_state, player, player.FieldOfView).OfType <Player>();

            var formattedMessage = $"[{username}]: {text}";

            foreach (var otherPlayers in playersInRange)
            {
                otherPlayers.ChatHistory.Add(formattedMessage);
            }
        }
Пример #18
0
        internal static void AgeSnowRoom(Rectangle room)
        {
            WorldUtils.Gen(new Point(room.X, room.Y), new Shapes.Rectangle(room.Width, room.Height), Actions.Chain(new GenAction[]
            {
                new Modifiers.Dither(0.60000002384185791),
                new Modifiers.Blotches(2, 0.60000002384185791),
                new Modifiers.OnlyTiles(new ushort[]
                {
                    CaveHouseBiome.BuildData.Snow.Tile
                }),
                new Actions.SetTile(161, true, true),
                new Modifiers.Dither(0.8),
                new Actions.SetTile(147, true, true)
            }));
            WorldUtils.Gen(new Point(room.X + 1, room.Y), new Shapes.Rectangle(room.Width - 2, 1), Actions.Chain(new GenAction[]
            {
                new Modifiers.Dither(0.5),
                new Modifiers.OnlyTiles(new ushort[]
                {
                    161
                }),
                new Modifiers.Offset(0, 1),
                new ActionStalagtite()
            }));
            WorldUtils.Gen(new Point(room.X + 1, room.Y + room.Height - 1), new Shapes.Rectangle(room.Width - 2, 1), Actions.Chain(new GenAction[]
            {
                new Modifiers.Dither(0.5),
                new Modifiers.OnlyTiles(new ushort[]
                {
                    161
                }),
                new Modifiers.Offset(0, 1),
                new ActionStalagtite()
            }));

            GenAction action;

            if ((double)room.Y > Main.worldSurface)
            {
                action = new Actions.ClearWall(true);
            }
            else
            {
                action = new Actions.PlaceWall(40, true);
            }

            WorldUtils.Gen(new Point(room.X, room.Y), new Shapes.Rectangle(room.Width, room.Height), Actions.Chain(new GenAction[]
            {
                new Modifiers.Dither(0.85000002384185791),
                new Modifiers.Blotches(2, 0.8),
                action
            }));
        }
Пример #19
0
        private float RoomSolidPrecentage(Rectangle room)
        {
            float     num  = (float)(room.Width * room.Height);
            Ref <int> @ref = new Ref <int>(0);

            WorldUtils.Gen(new Point(room.X, room.Y), new Shapes.Rectangle(room.Width, room.Height), Actions.Chain(new GenAction[]
            {
                new Modifiers.IsSolid(),
                new Actions.Count(@ref)
            }));
            return((float)@ref.Value / num);
        }
Пример #20
0
 public void StopAction()
 {
     foreach (var cl in userActorManager.clientProperties.Keys)
     {
         var cp = userActorManager.clientProperties[cl];
         if (cp != null && cp.isSelected)
         {
             Vector3 d = WorldUtils.UnityToL2Coords(cp.gameObject.transform.position);
             cl.SendMoveToCommand((int)d.x, (int)d.y);
         }
     }
 }
Пример #21
0
        private Rectangle GetRoom(Point origin)
        {
            Point result1;
            var   flag1 = WorldUtils.Find(origin,
                                          Searches.Chain(new Searches.Left(25), (GenCondition) new Conditions.IsSolid()),
                                          out result1);
            Point result2;
            var   flag2 = WorldUtils.Find(origin,
                                          Searches.Chain(new Searches.Right(25), (GenCondition) new Conditions.IsSolid()),
                                          out result2);

            if (!flag1)
            {
                result1 = new Point(origin.X - 25, origin.Y);
            }
            if (!flag2)
            {
                result2 = new Point(origin.X + 25, origin.Y);
            }
            var rectangle =
                new Rectangle(origin.X, origin.Y, 0, 0);

            if (origin.X - result1.X > result2.X - origin.X)
            {
                rectangle.X     = result1.X;
                rectangle.Width = Utils.Clamp(result2.X - result1.X, 15, 30);
            }
            else
            {
                rectangle.Width = Utils.Clamp(result2.X - result1.X, 15, 30);
                rectangle.X     = result2.X - rectangle.Width;
            }

            Point result3;
            var   flag3 = WorldUtils.Find(result1,
                                          Searches.Chain(new Searches.Up(10), (GenCondition) new Conditions.IsSolid()), out result3);
            Point result4;
            var   flag4 = WorldUtils.Find(result2,
                                          Searches.Chain(new Searches.Up(10), (GenCondition) new Conditions.IsSolid()), out result4);

            if (!flag3)
            {
                result3 = new Point(origin.X, origin.Y - 10);
            }
            if (!flag4)
            {
                result4 = new Point(origin.X, origin.Y - 10);
            }
            rectangle.Height = Utils.Clamp(Math.Max(origin.Y - result3.Y, origin.Y - result4.Y), 8, 12);
            rectangle.Y     -= rectangle.Height;
            return(rectangle);
        }
Пример #22
0
        private static void PlaceAt(DesertDescription description, Point position, int holeRadius)
        {
            ShapeData data   = new ShapeData();
            Point     origin = new Point(position.X, position.Y + 6);

            WorldUtils.Gen(origin, (GenShape) new Shapes.Tail((float)(holeRadius * 2), new Vector2(0.0f, (float)-holeRadius * 1.5f)), Actions.Chain(new Actions.SetTile((ushort)53, false, true).Output(data)));
            GenShapeActionPair pair1 = new GenShapeActionPair((GenShape) new Shapes.Rectangle(1, 1), Actions.Chain((GenAction) new Modifiers.Blotches(2, 0.3), (GenAction) new Modifiers.IsSolid(), (GenAction) new Actions.Clear(), (GenAction) new Actions.PlaceWall((ushort)187, true)));
            GenShapeActionPair genShapeActionPair = new GenShapeActionPair((GenShape) new Shapes.Rectangle(1, 1), Actions.Chain((GenAction) new Modifiers.IsSolid(), (GenAction) new Actions.Clear(), (GenAction) new Actions.PlaceWall((ushort)187, true)));
            GenShapeActionPair pair2 = new GenShapeActionPair((GenShape) new Shapes.Circle(2, 3), Actions.Chain((GenAction) new Modifiers.IsSolid(), (GenAction) new Actions.SetTile((ushort)397, false, true), (GenAction) new Actions.PlaceWall((ushort)187, true)));
            GenShapeActionPair pair3 = new GenShapeActionPair((GenShape) new Shapes.Circle(holeRadius, 3), Actions.Chain((GenAction) new Modifiers.SkipWalls(new ushort[1]
            {
                (ushort)187
            }), (GenAction) new Actions.SetTile((ushort)53, false, true)));
            GenShapeActionPair pair4 = new GenShapeActionPair((GenShape) new Shapes.Circle(holeRadius - 2, 3), Actions.Chain((GenAction) new Actions.PlaceWall((ushort)187, true)));
            int x  = position.X;
            int y1 = position.Y - holeRadius - 3;

            while (true)
            {
                int num1 = y1;
                Microsoft.Xna.Framework.Rectangle rectangle = description.Hive;
                int top1 = rectangle.Top;
                int y2   = position.Y;
                rectangle = description.Desert;
                int top2 = rectangle.Top;
                int num2 = (y2 - top2) * 2;
                int num3 = top1 + num2 + 12;
                if (num1 < num3)
                {
                    WorldUtils.Gen(new Point(x, y1), y1 < position.Y ? genShapeActionPair : pair1);
                    WorldUtils.Gen(new Point(x, y1), pair2);
                    if (y1 % 3 == 0 && y1 >= position.Y)
                    {
                        x += WorldGen.genRand.Next(-1, 2);
                        WorldUtils.Gen(new Point(x, y1), pair1);
                        if (y1 >= position.Y + 5)
                        {
                            WorldUtils.Gen(new Point(x, y1), pair3);
                            WorldUtils.Gen(new Point(x, y1), pair4);
                        }
                        WorldUtils.Gen(new Point(x, y1), pair2);
                    }
                    ++y1;
                }
                else
                {
                    break;
                }
            }
            WorldUtils.Gen(new Point(origin.X, origin.Y - (int)((double)holeRadius * 1.5) + 3), (GenShape) new Shapes.Circle(holeRadius / 2, holeRadius / 3), Actions.Chain(Actions.Chain((GenAction) new Actions.ClearTile(false), (GenAction) new Modifiers.Expand(1), (GenAction) new Actions.PlaceWall((ushort)0, true))));
            WorldUtils.Gen(origin, (GenShape) new ModShapes.All(data), (GenAction) new Actions.Smooth(false));
        }
Пример #23
0
        private void PlaceSlab(MarbleBiome.Slab slab, int originX, int originY, int scale)
        {
            ushort num1 = 367;
            ushort num2 = 178;

            if (WorldGen.drunkWorldGen)
            {
                num1 = (ushort)368;
                num2 = (ushort)180;
            }
            int num3 = -1;
            int num4 = scale + 1;
            int num5 = 0;
            int num6 = scale;

            for (int x = num3; x < num4; ++x)
            {
                if (x != num3 && x != num4 - 1 || WorldGen.genRand.Next(2) != 0)
                {
                    if (WorldGen.genRand.Next(2) == 0)
                    {
                        --num5;
                    }
                    if (WorldGen.genRand.Next(2) == 0)
                    {
                        ++num6;
                    }
                    for (int y = num5; y < num6; ++y)
                    {
                        Tile tile = GenBase._tiles[originX + x, originY + y];
                        tile.ResetToType(TileID.Sets.Ore[(int)tile.type] ? tile.type : num1);
                        bool active = slab.State(x, y, scale);
                        tile.active(active);
                        if (slab.HasWall)
                        {
                            tile.wall = num2;
                        }
                        WorldUtils.TileFrame(originX + x, originY + y, true);
                        WorldGen.SquareWallFrame(originX + x, originY + y, true);
                        Tile.SmoothSlope(originX + x, originY + y, true, false);
                        if (WorldGen.SolidTile(originX + x, originY + y - 1, false) && GenBase._random.Next(4) == 0)
                        {
                            WorldGen.PlaceTight(originX + x, originY + y, false);
                        }
                        if (WorldGen.SolidTile(originX + x, originY + y, false) && GenBase._random.Next(4) == 0)
                        {
                            WorldGen.PlaceTight(originX + x, originY + y - 1, false);
                        }
                    }
                }
            }
        }
Пример #24
0
    private void DrawUnit(int x, int y)
    {
        boardGridPlaces[boardX, boardY].ChangeState(Place.PlaceState.Idle);
        boardGridPlaces[box1X, box1Y].ChangeState(Place.PlaceState.Idle);
        boardGridPlaces[box3X, box3Y].ChangeState(Place.PlaceState.Idle);
        boardGridPlaces[box2X, box2Y].ChangeState(Place.PlaceState.Idle);

        boardX = x;
        boardY = y;

        // base off of unit.
        var unitGridSize = 4;

        if (unitGridSize == 4)
        {
            // horizontal
            box1Y = y;
            box1X = ReturnBounds(x, _xLength - 1);
            // angle
            box3X = ReturnBounds(x, _xLength - 1);
            box3Y = ReturnBounds(y, _yLength - 1);
            // down
            box2X = x;
            box2Y = ReturnBounds(y, _yLength - 1);

            boardGridPlaces[boardX, boardY].ChangeState(Place.PlaceState.Hover);
            boardGridPlaces[box1X, box1Y].ChangeState(Place.PlaceState.Hover);
            boardGridPlaces[box3X, box3Y].ChangeState(Place.PlaceState.Hover);
            boardGridPlaces[box2X, box2Y].ChangeState(Place.PlaceState.Hover);
        }

        var pos = WorldUtils.GetMidPointOffset(
            boardGridPlaces[x, y].mouseArea.transform.position,
            boardGridPlaces[box3X, box3Y].mouseArea.transform.position,
            returnMidPoint: true
            );
        var distance = Vector3.Distance(UnitGoInHand.transform.position, pos);

        if (distance > 15)
        {
            UnitGoInHand.transform.position = pos;
        }
        else
        {
            if (_moveUnitInHand != null)
            {
                LeanTween.cancel(_moveUnitInHand.id);
            }
            _moveUnitInHand = LeanTween.move(UnitGoInHand, pos, 0.5f).setEase(LeanTweenType.easeOutBack);
        }
        _listenForPlacementConfirmation = true;
    }
Пример #25
0
    public override void OnUpdate()
    {
        if (DateTime.Now - lastSend < TimeSpan.FromMilliseconds(1000))
        {
            return;
        }

        if (WorldUtils.CalculateDistance(personalAI.client.UserChar, target.live) > PersonalAI.MOVE_TO_TARGET_DISTANCE)
        {
            client.SendMoveToCommand(target.live.X, target.live.Y, target.live.Z);
            lastSend = DateTime.Now;
        }
    }
Пример #26
0
 private void PlaceSupportBeams()
 {
     foreach (Rectangle item in CreateSupportBeamList())
     {
         if (item.Height > 1 && _tiles[item.X, item.Y - 1].type != 19)
         {
             WorldUtils.Gen(new Point(item.X, item.Y), new Shapes.Rectangle(item.Width, item.Height), Actions.Chain(new Actions.SetTileKeepWall(BeamType), new Actions.SetFrames(frameNeighbors: true)));
             Tile tile = _tiles[item.X, item.Y + item.Height];
             tile.slope(0);
             tile.halfBrick(halfBrick: false);
         }
     }
 }
Пример #27
0
            public override Task GetTask()
            {
                TargetList targets = WorldUtils.RecipesToComplete(10, this.character);

                if (targets != null && targets.targets.Count != 0)
                {
                    return(new Task(
                               Defs.tasks["haul_recipe"],
                               targets
                               ));
                }
                return(null);
            }
Пример #28
0
 private void PlaceSupportBeams()
 {
     foreach (Microsoft.Xna.Framework.Rectangle supportBeam in this.CreateSupportBeamList())
     {
         if (supportBeam.Height > 1 && this._tiles[supportBeam.X, supportBeam.Y - 1].type != (ushort)19)
         {
             WorldUtils.Gen(new Point(supportBeam.X, supportBeam.Y), (GenShape) new Shapes.Rectangle(supportBeam.Width, supportBeam.Height), Actions.Chain((GenAction) new Actions.SetTileKeepWall(this.BeamType, false, true), (GenAction) new Actions.SetFrames(true)));
             Tile tile = this._tiles[supportBeam.X, supportBeam.Y + supportBeam.Height];
             tile.slope((byte)0);
             tile.halfBrick(false);
         }
     }
 }
            public override void ModifyHitNPC(Item item, NPC target, ref int damage, ref float knockback, ref bool crit)
            {
                Point origin = player.Bottom.ToTileCoordinates();
                Point point;

                if (effect && !WorldUtils.Find(origin, Searches.Chain(new Searches.Down(3), new GenCondition[]
                {
                    new Conditions.IsSolid()
                }), out point) && player.grappling[0] == -1)
                {
                    damage *= 2;
                }
            }
Пример #30
0
        private static void PlaceAt(DesertDescription description, Point position)
        {
            ShapeData shapeData = new ShapeData();
            Point     origin    = new Point(position.X, position.Y + 2);

            WorldUtils.Gen(origin, (GenShape) new Shapes.Circle(24, 12), Actions.Chain((GenAction) new Modifiers.Blotches(2, 0.3), new Actions.SetTile((ushort)53, false, true).Output(shapeData)));
            UnifiedRandom genRand   = WorldGen.genRand;
            ShapeData     data      = new ShapeData();
            int           num1      = description.Hive.Top - position.Y;
            int           direction = genRand.Next(2) == 0 ? -1 : 1;
            List <ChambersEntrance.PathConnection> pathConnectionList = new List <ChambersEntrance.PathConnection>()
            {
                new ChambersEntrance.PathConnection(new Point(position.X + -direction * 26, position.Y - 8), direction)
            };
            int num2 = genRand.Next(2, 4);

            for (int index = 0; index < num2; ++index)
            {
                int y    = (int)((double)(index + 1) / (double)num2 * (double)num1) + genRand.Next(-8, 9);
                int x    = direction * genRand.Next(20, 41);
                int num3 = genRand.Next(18, 29);
                WorldUtils.Gen(position, (GenShape) new Shapes.Circle(num3 / 2, 3), Actions.Chain((GenAction) new Modifiers.Offset(x, y), (GenAction) new Modifiers.Blotches(2, 0.3), new Actions.Clear().Output(data), (GenAction) new Actions.PlaceWall((ushort)187, true)));
                pathConnectionList.Add(new ChambersEntrance.PathConnection(new Point(x + num3 / 2 * -direction + position.X, y + position.Y), -direction));
                direction *= -1;
            }
            WorldUtils.Gen(position, (GenShape) new ModShapes.OuterOutline(data, true, false), Actions.Chain((GenAction) new Modifiers.Expand(1), (GenAction) new Modifiers.OnlyTiles(new ushort[1]
            {
                (ushort)53
            }), (GenAction) new Actions.SetTile((ushort)397, false, true), (GenAction) new Actions.PlaceWall((ushort)187, true)));
            GenShapeActionPair pair = new GenShapeActionPair((GenShape) new Shapes.Rectangle(2, 4), Actions.Chain((GenAction) new Modifiers.IsSolid(), (GenAction) new Modifiers.Blotches(2, 0.3), (GenAction) new Actions.Clear(), (GenAction) new Modifiers.Expand(1), (GenAction) new Actions.PlaceWall((ushort)187, true), (GenAction) new Modifiers.OnlyTiles(new ushort[1]
            {
                (ushort)53
            }), (GenAction) new Actions.SetTile((ushort)397, false, true)));

            for (int index = 1; index < pathConnectionList.Count; ++index)
            {
                ChambersEntrance.PathConnection pathConnection1 = pathConnectionList[index - 1];
                ChambersEntrance.PathConnection pathConnection2 = pathConnectionList[index];
                float num3 = Math.Abs(pathConnection2.Position.X - pathConnection1.Position.X) * 1.5f;
                for (float amount = 0.0f; (double)amount <= 1.0; amount += 0.02f)
                {
                    Vector2 vector2_1 = new Vector2(pathConnection1.Position.X + pathConnection1.Direction * num3 * amount, pathConnection1.Position.Y);
                    Vector2 vector2_2 = new Vector2(pathConnection2.Position.X + (float)((double)pathConnection2.Direction * (double)num3 * (1.0 - (double)amount)), pathConnection2.Position.Y);
                    Vector2 vector2_3 = Vector2.Lerp(pathConnection1.Position, pathConnection2.Position, amount);
                    Vector2 vector2_4 = vector2_3;
                    double  num4      = (double)amount;
                    WorldUtils.Gen(Vector2.Lerp(Vector2.Lerp(vector2_1, vector2_4, (float)num4), Vector2.Lerp(vector2_3, vector2_2, amount), amount).ToPoint(), pair);
                }
            }
            WorldUtils.Gen(origin, (GenShape) new Shapes.Rectangle(new Microsoft.Xna.Framework.Rectangle(-29, -12, 58, 12)), Actions.Chain((GenAction) new Modifiers.NotInShape(shapeData), (GenAction) new Modifiers.Expand(1), (GenAction) new Actions.PlaceWall((ushort)0, true)));
        }