Exemplo n.º 1
0
        public WallCompiled(WallData wallData)
        {
            Thickness = wallData.Thickness;
            Color = wallData.Color;
            Shape = wallData.Shape;

            var outer = wallData.Verts;

            Verts1 = new Vector2[outer.Length];
            Verts2 = new Vector2[outer.Length];
            Verts3 = new Vector2[outer.Length];
            Verts4 = new Vector2[outer.Length];
            TexesBegin1 = new float[outer.Length];
            TexesBegin2 = new float[outer.Length];
            TexesBegin3 = new float[outer.Length];
            TexesBegin4 = new float[outer.Length];
            TexesEnd1 = new float[outer.Length];
            TexesEnd2 = new float[outer.Length];
            TexesEnd3 = new float[outer.Length];
            TexesEnd4 = new float[outer.Length];

            switch (wallData.Shape) {
            case ShapeData.Open:
                doEnd(outer, 0, 0, 1, true, false);
                break;
            case ShapeData.Closed:
                doAngle(outer, 0, outer.Length-1, 0, 1);
                break;
            }

            for (int i = 1; i<outer.Length-1; i++) {
                doAngle(outer, i, i-1 , i, i+1);
            }

            switch (wallData.Shape) {
            case ShapeData.Open:
                doEnd(outer, outer.Length-1, outer.Length-2, outer.Length-1, false, false);
                break;
            case ShapeData.Closed:
                doAngle(outer, outer.Length-1, outer.Length-2, outer.Length-1, 0);
                break;
            }
        }
Exemplo n.º 2
0
        public override bool Place(Point origin, StructureMap structures)
        {
            if (WorldGen.SolidTile(origin.X, origin.Y, false) || Main.tile[origin.X, origin.Y].wall == (ushort)216 || Main.tile[origin.X, origin.Y].wall == (ushort)187)
            {
                return(false);
            }
            ushort type = Utils.SelectRandom <ushort>(GenBase._random, WorldGen.goldBar == 19 ? (ushort)8 : (ushort)169, WorldGen.silverBar == 21 ? (ushort)9 : (ushort)168, WorldGen.ironBar == 22 ? (ushort)6 : (ushort)167, WorldGen.copperBar == 20 ? (ushort)7 : (ushort)166);
            double num1 = GenBase._random.NextDouble() * 2.0 - 1.0;

            if (!WorldUtils.Find(origin, Searches.Chain(num1 > 0.0 ? (GenSearch) new Searches.Right(40) : (GenSearch) new Searches.Left(40), (GenCondition) new Conditions.IsSolid()), out origin))
            {
                return(false);
            }
            if (!WorldUtils.Find(origin, Searches.Chain((GenSearch) new Searches.Down(80), (GenCondition) new Conditions.IsSolid()), out origin))
            {
                return(false);
            }
            ShapeData shapeData = new ShapeData();
            Ref <int> count1    = new Ref <int>(0);
            Ref <int> count2    = new Ref <int>(0);

            WorldUtils.Gen(origin, new ShapeRunner(10f, 20, new Vector2((float)num1, 1f)).Output(shapeData), Actions.Chain((GenAction) new Modifiers.Blotches(2, 0.3), (GenAction) new Actions.Scanner(count1), (GenAction) new Modifiers.IsSolid(), (GenAction) new Actions.Scanner(count2)));
            if (count2.Value < count1.Value / 2)
            {
                return(false);
            }
            Microsoft.Xna.Framework.Rectangle area = new Microsoft.Xna.Framework.Rectangle(origin.X - 15, origin.Y - 10, 30, 20);
            if (!structures.CanPlace(area, 0))
            {
                return(false);
            }
            WorldUtils.Gen(origin, (GenShape) new ModShapes.All(shapeData), (GenAction) new Actions.SetTile(type, true, true));
            WorldUtils.Gen(new Point(origin.X - (int)(num1 * -5.0), origin.Y - 5), (GenShape) new Shapes.Circle(5), Actions.Chain((GenAction) new Modifiers.Blotches(2, 0.3), (GenAction) new Actions.ClearTile(true)));
            Point result1;
            int   num2 = 1 & (WorldUtils.Find(new Point(origin.X - (num1 > 0.0 ? 3 : -3), origin.Y - 3), Searches.Chain((GenSearch) new Searches.Down(10), (GenCondition) new Conditions.IsSolid()), out result1) ? 1 : 0);
            int   num3 = GenBase._random.Next(4) == 0 ? 3 : 7;
            Point result2;
            int   num4 = WorldUtils.Find(new Point(origin.X - (num1 > 0.0 ? -num3 : num3), origin.Y - 3), Searches.Chain((GenSearch) new Searches.Down(10), (GenCondition) new Conditions.IsSolid()), out result2) ? 1 : 0;

            if ((num2 & num4) == 0)
            {
                return(false);
            }
            --result1.Y;
            --result2.Y;
            Tile tile1 = GenBase._tiles[result1.X, result1.Y + 1];

            tile1.slope((byte)0);
            tile1.halfBrick(false);
            for (int index = -1; index <= 1; ++index)
            {
                WorldUtils.ClearTile(result2.X + index, result2.Y, false);
                Tile tile2 = GenBase._tiles[result2.X + index, result2.Y + 1];
                if (!WorldGen.SolidOrSlopedTile(tile2))
                {
                    tile2.ResetToType((ushort)1);
                    tile2.active(true);
                }
                tile2.slope((byte)0);
                tile2.halfBrick(false);
                WorldUtils.TileFrame(result2.X + index, result2.Y + 1, true);
            }
            WorldGen.PlaceTile(result1.X, result1.Y, 141, false, false, -1, 0);
            WorldGen.PlaceTile(result2.X, result2.Y, 411, true, true, -1, 0);
            WorldUtils.WireLine(result1, result2);
            structures.AddProtectedStructure(area, 5);
            return(true);
        }
Exemplo n.º 3
0
        public override bool Place(Point origin, StructureMap structures)
        {
            Dictionary <ushort, int> resultsOutput = new Dictionary <ushort, int>();

            WorldUtils.Gen(new Point(origin.X - 25, origin.Y - 25), (GenShape) new Shapes.Rectangle(50, 50), (GenAction) new Actions.TileScanner(new ushort[2]
            {
                (ushort)0,
                (ushort)1
            }).Output(resultsOutput));
            if (resultsOutput[(ushort)0] + resultsOutput[(ushort)1] < 1250)
            {
                return(false);
            }
            Point result;
            bool  flag = WorldUtils.Find(origin, Searches.Chain((GenSearch) new Searches.Up(1000), new Conditions.IsSolid().AreaOr(1, 50).Not()), out result);

            if (WorldUtils.Find(origin, Searches.Chain((GenSearch) new Searches.Up(origin.Y - result.Y), (GenCondition) new Conditions.IsTile(new ushort[1]
            {
                (ushort)53
            })), out Point _) || !flag)
            {
                return(false);
            }
            result.Y += 50;
            ShapeData data1     = new ShapeData();
            ShapeData shapeData = new ShapeData();
            Point     point1    = new Point(origin.X, origin.Y + 20);
            Point     point2    = new Point(origin.X, origin.Y + 30);

            bool[] validTiles = new bool[TileID.Sets.GeneralPlacementTiles.Length];
            for (int index = 0; index < validTiles.Length; ++index)
            {
                validTiles[index] = TileID.Sets.GeneralPlacementTiles[index];
            }
            validTiles[21]  = false;
            validTiles[467] = false;
            float xScale = (float)(0.800000011920929 + (double)GenBase._random.NextFloat() * 0.5);

            if (!structures.CanPlace(new Microsoft.Xna.Framework.Rectangle(point1.X - (int)(20.0 * (double)xScale), point1.Y - 20, (int)(40.0 * (double)xScale), 40), validTiles, 0) || !structures.CanPlace(new Microsoft.Xna.Framework.Rectangle(origin.X, result.Y + 10, 1, origin.Y - result.Y - 9), validTiles, 2))
            {
                return(false);
            }
            WorldUtils.Gen(point1, (GenShape) new Shapes.Slime(20, xScale, 1f), Actions.Chain((GenAction) new Modifiers.Blotches(2, 0.4), new Actions.ClearTile(true).Output(data1)));
            WorldUtils.Gen(point2, (GenShape) new Shapes.Mound(14, 14), Actions.Chain((GenAction) new Modifiers.Blotches(2, 1, 0.8), (GenAction) new Actions.SetTile((ushort)0, false, true), new Actions.SetFrames(true).Output(shapeData)));
            data1.Subtract(shapeData, point1, point2);
            WorldUtils.Gen(point1, (GenShape) new ModShapes.InnerOutline(data1, true), Actions.Chain((GenAction) new Actions.SetTile((ushort)2, false, true), (GenAction) new Actions.SetFrames(true)));
            WorldUtils.Gen(point1, (GenShape) new ModShapes.All(data1), Actions.Chain((GenAction) new Modifiers.RectangleMask(-40, 40, 0, 40), (GenAction) new Modifiers.IsEmpty(), (GenAction) new Actions.SetLiquid(0, byte.MaxValue)));
            WorldUtils.Gen(point1, (GenShape) new ModShapes.All(data1), Actions.Chain((GenAction) new Actions.PlaceWall((ushort)68, true), (GenAction) new Modifiers.OnlyTiles(new ushort[1]
            {
                (ushort)2
            }), (GenAction) new Modifiers.Offset(0, 1), (GenAction) new ActionVines(3, 5, 382)));
            if ((double)GenBase._random.NextFloat() <= (double)this._chanceOfEntrance)
            {
                ShapeData data2 = new ShapeData();
                WorldUtils.Gen(new Point(origin.X, result.Y + 10), (GenShape) new Shapes.Rectangle(1, origin.Y - result.Y - 9), Actions.Chain((GenAction) new Modifiers.Blotches(2, 0.2), (GenAction) new Modifiers.SkipTiles(new ushort[2]
                {
                    (ushort)191,
                    (ushort)192
                }), new Actions.ClearTile(false).Output(data2), (GenAction) new Modifiers.Expand(1), (GenAction) new Modifiers.OnlyTiles(new ushort[1]
                {
                    (ushort)53
                }), new Actions.SetTile((ushort)397, false, true).Output(data2)));
                WorldUtils.Gen(new Point(origin.X, result.Y + 10), (GenShape) new ModShapes.All(data2), (GenAction) new Actions.SetFrames(true));
            }
            if ((double)GenBase._random.NextFloat() <= (double)this._chanceOfRealSword)
            {
                WorldGen.PlaceTile(point2.X, point2.Y - 15, 187, true, false, -1, 17);
            }
            else
            {
                WorldGen.PlaceTile(point2.X, point2.Y - 15, 186, true, false, -1, 15);
            }
            WorldUtils.Gen(point2, (GenShape) new ModShapes.All(shapeData), Actions.Chain((GenAction) new Modifiers.Offset(0, -1), (GenAction) new Modifiers.OnlyTiles(new ushort[1]
            {
                (ushort)2
            }), (GenAction) new Modifiers.Offset(0, -1), (GenAction) new ActionGrass()));
            structures.AddProtectedStructure(new Microsoft.Xna.Framework.Rectangle(point1.X - (int)(20.0 * (double)xScale), point1.Y - 20, (int)(40.0 * (double)xScale), 40), 10);
            return(true);
        }
        public override bool Place(Point origin, StructureMap structures)
        {
            Point point;

            if (WorldGen.SolidTile(origin.X, origin.Y) && GenBase._tiles[origin.X, origin.Y].wall == 3)
            {
                return(false);
            }
            Searches.Down  down    = new Searches.Down(100);
            GenCondition[] isSolid = new GenCondition[] { new Conditions.IsSolid() };
            if (!WorldUtils.Find(origin, Searches.Chain(down, isSolid), out origin))
            {
                return(false);
            }
            Point point1 = new Point(origin.X - 4, origin.Y);

            Searches.Down  down1             = new Searches.Down(5);
            GenCondition[] genConditionArray = new GenCondition[1];
            ushort[]       numArray          = new ushort[] { 25 };
            genConditionArray[0] = (new Conditions.IsTile(numArray)).AreaAnd(8, 1);
            if (!WorldUtils.Find(point1, Searches.Chain(down1, genConditionArray), out point))
            {
                return(false);
            }
            ShapeData shapeDatum  = new ShapeData();
            ShapeData shapeDatum1 = new ShapeData();
            ShapeData shapeDatum2 = new ShapeData();

            for (int i = 0; i < 6; i++)
            {
                Shapes.Circle circle = new Shapes.Circle(GenBase._random.Next(10, 12) + i);
                GenAction[]   offset = new GenAction[] { new Modifiers.Offset(0, 5 * i + 5), (new Modifiers.Blotches(3, 0.3)).Output(shapeDatum) };
                WorldUtils.Gen(origin, circle, Actions.Chain(offset));
            }
            for (int j = 0; j < 6; j++)
            {
                Shapes.Circle circle1        = new Shapes.Circle(GenBase._random.Next(5, 7) + j);
                GenAction[]   genActionArray = new GenAction[] { new Modifiers.Offset(0, 2 * j + 18), (new Modifiers.Blotches(3, 0.3)).Output(shapeDatum1) };
                WorldUtils.Gen(origin, circle1, Actions.Chain(genActionArray));
            }
            for (int k = 0; k < 6; k++)
            {
                Shapes.Circle circle2 = new Shapes.Circle(GenBase._random.Next(4, 6) + k / 2);
                GenAction[]   offset1 = new GenAction[] { new Modifiers.Offset(0, (int)(7.5f * (float)k) - 10), (new Modifiers.Blotches(3, 0.3)).Output(shapeDatum2) };
                WorldUtils.Gen(origin, circle2, Actions.Chain(offset1));
            }
            ShapeData shapeDatum3 = new ShapeData(shapeDatum1);

            shapeDatum1.Subtract(shapeDatum2, origin, origin);
            shapeDatum3.Subtract(shapeDatum1, origin, origin);
            ShapeData[] shapeDataArray = new ShapeData[] { shapeDatum, shapeDatum2 };
            Rectangle   bounds         = ShapeData.GetBounds(origin, shapeDataArray);

            if (!structures.CanPlace(bounds, CorruptionPitBiome.ValidTiles, 2))
            {
                return(false);
            }
            ModShapes.All all     = new ModShapes.All(shapeDatum);
            GenAction[]   setTile = new GenAction[] { new Actions.SetTile(25, true, true), new Actions.PlaceWall(3, true) };
            WorldUtils.Gen(origin, all, Actions.Chain(setTile));
            WorldUtils.Gen(origin, new ModShapes.All(shapeDatum1), new Actions.SetTile(0, true, true));
            WorldUtils.Gen(origin, new ModShapes.All(shapeDatum2), new Actions.ClearTile(true));
            ModShapes.All all1          = new ModShapes.All(shapeDatum1);
            GenAction[]   isTouchingAir = new GenAction[] { new Modifiers.IsTouchingAir(true), null, null };
            ushort[]      numArray1     = new ushort[] { 25 };
            isTouchingAir[1] = new Modifiers.NotTouching(false, numArray1);
            isTouchingAir[2] = new Actions.SetTile(23, true, true);
            WorldUtils.Gen(origin, all1, Actions.Chain(isTouchingAir));
            WorldUtils.Gen(origin, new ModShapes.All(shapeDatum3), new Actions.PlaceWall(69, true));
            structures.AddStructure(bounds, 2);
            return(true);
        }
 public Poop_info_page()
 {
     InitializeComponent();
     colorPicker.ItemsSource = ColorExtensions.AccentColors();
     shapePicker.ItemsSource = ShapeData.ShapeNames();
 }
Exemplo n.º 6
0
        public override bool Place(Point origin, StructureMap structures)
        {
            Point     point;
            Ref <int> @ref = new Ref <int>(0);
            Ref <int> ref1 = new Ref <int>(0);

            Shapes.Circle circle  = new Shapes.Circle(10);
            GenAction[]   scanner = new GenAction[] { new Actions.Scanner(ref1), new Modifiers.IsSolid(), new Actions.Scanner(@ref) };
            WorldUtils.Gen(origin, circle, Actions.Chain(scanner));
            if (@ref.Value < ref1.Value - 5)
            {
                return(false);
            }
            int num  = GenBase._random.Next(6, 10);
            int num1 = GenBase._random.Next(5);

            if (!structures.CanPlace(new Rectangle(origin.X - num, origin.Y - num, num * 2, num * 2), 0))
            {
                return(false);
            }
            ShapeData shapeDatum = new ShapeData();

            Shapes.Slime slime    = new Shapes.Slime(num);
            GenAction[]  onlyTile = new GenAction[] { (new Modifiers.Blotches(num1, num1, num1, 1, 0.3)).Output(shapeDatum), new Modifiers.Offset(0, -2), null, null, null, null };
            ushort[]     numArray = new ushort[] { 53 };
            onlyTile[2] = new Modifiers.OnlyTiles(numArray);
            onlyTile[3] = new Actions.SetTile(397, true, true);
            onlyTile[4] = new Modifiers.OnlyWalls(new byte[1]);
            onlyTile[5] = new Actions.PlaceWall(16, true);
            WorldUtils.Gen(origin, slime, Actions.Chain(onlyTile));
            ModShapes.All all       = new ModShapes.All(shapeDatum);
            GenAction[]   clearTile = new GenAction[] { new Actions.ClearTile(false), new Actions.SetLiquid(0, 0), new Actions.SetFrames(true), new Modifiers.OnlyWalls(new byte[1]), new Actions.PlaceWall(16, true) };
            WorldUtils.Gen(origin, all, Actions.Chain(clearTile));
            Searches.Down  down    = new Searches.Down(10);
            GenCondition[] isSolid = new GenCondition[] { new Conditions.IsSolid() };
            if (!WorldUtils.Find(origin, Searches.Chain(down, isSolid), out point))
            {
                return(false);
            }
            int  y    = point.Y - 1;
            bool flag = GenBase._random.Next() % 2 == 0;

            if (GenBase._random.Next() % 10 != 0)
            {
                int num2 = GenBase._random.Next(1, 4);
                int num3 = (flag ? 4 : -(num >> 1));
                for (int i = 0; i < num2; i++)
                {
                    int num4 = GenBase._random.Next(1, 3);
                    for (int j = 0; j < num4; j++)
                    {
                        WorldGen.PlaceTile(origin.X + num3 - i, y - j, 331, false, false, -1, 0);
                    }
                }
            }
            int num5 = (num - 3) * (flag ? -1 : 1);

            if (GenBase._random.Next() % 10 != 0)
            {
                WorldGen.PlaceTile(origin.X + num5, y, 186, false, false, -1, 0);
            }
            if (GenBase._random.Next() % 10 != 0)
            {
                WorldGen.PlaceTile(origin.X, y, 215, true, false, -1, 0);
                if (GenBase._tiles[origin.X, y].active() && GenBase._tiles[origin.X, y].type == 215)
                {
                    Tile tile = GenBase._tiles[origin.X, y];
                    tile.frameY = (short)(tile.frameY + 36);
                    Tile tile1 = GenBase._tiles[origin.X - 1, y];
                    tile1.frameY = (short)(tile1.frameY + 36);
                    Tile tile2 = GenBase._tiles[origin.X + 1, y];
                    tile2.frameY = (short)(tile2.frameY + 36);
                    Tile tile3 = GenBase._tiles[origin.X, y - 1];
                    tile3.frameY = (short)(tile3.frameY + 36);
                    Tile tile4 = GenBase._tiles[origin.X - 1, y - 1];
                    tile4.frameY = (short)(tile4.frameY + 36);
                    Tile tile5 = GenBase._tiles[origin.X + 1, y - 1];
                    tile5.frameY = (short)(tile5.frameY + 36);
                }
            }
            structures.AddStructure(new Rectangle(origin.X - num, origin.Y - num, num * 2, num * 2), 4);
            return(true);
        }
Exemplo n.º 7
0
        ShapeData ConstructAndAddShape(TypeId typeId)
        {
            UIElement element;

            if (typeId == TypeId.Line) {
                var line = new Line {StrokeEndLineCap = PenLineCap.Round};
                element = line;
            }
            else if (typeId == TypeId.Text) {
                element = new TextBlock ();
            }
            else if (typeId == TypeId.Oval) {
                element = new Ellipse ();
            }
            else if (typeId == TypeId.Arc) {
                element = new Path();
            }
            else if (typeId == TypeId.RoundedRect) {
                element = new Rectangle ();
            }
            else if (typeId == TypeId.Rect) {
                element = new Rectangle ();
            }
            else if (typeId == TypeId.Image) {
                element = new Image ();
            }
            else if (typeId == TypeId.Polygon) {
                element = new NativePolygon ();
            }
            else {
                throw new NotSupportedException ("Don't know how to construct: " + typeId);
            }

            var sd = new ShapeData {
                Element = element,
                TypeId = typeId,
            };

            _shapes.Add (sd);

            //
            // Insert it in the right place so it gets drawn in the right order
            //
            if (_lastAddElementIndex >= 0) {
                _lastAddElementIndex++;
                _canvas.Children.Insert(_lastAddElementIndex, element);
            }
            else {
                if (_lastShape != null) {
                    _lastAddElementIndex = _canvas.Children.IndexOf(_lastShape.Element) + 1;
                    _canvas.Children.Insert(_lastAddElementIndex, element);
                }
                else {
                    _lastAddElementIndex = _canvas.Children.Count;
                    _canvas.Children.Add(element);
                }
            }

            return sd;
        }
Exemplo n.º 8
0
 private void saveAsToolStripMenuItem_Click(object sender, EventArgs e)
 {
     ShapeData.SaveAsFile(ref shapes, ref fileName, ref isChanged);
     UpdateTopPanel();
 }
Exemplo n.º 9
0
 public AddShapeEvent(Solid solid, ShapeData shape)
 {
     this.solid = solid;
     this.shape = shape;
 }
Exemplo n.º 10
0
        /// Main collision callback functor.
        static unsafe internal void CollisionCallback(IntPtr data, dGeomID o0, dGeomID o1)
        {
            if (o0.IsSpace || o1.IsSpace)
            {
                // Colliding a space with either a geom or another space.
                Tao.Ode.Ode.dSpaceCollide2(o0, o1, data, CollisionCallbackRunner);

                if (o0.IsSpace)
                {
                    // Colliding all geoms internal to the space.
                    Tao.Ode.Ode.dSpaceCollide(o0, data, CollisionCallbackRunner);
                }

                if (o1.IsSpace)
                {
                    // Colliding all geoms internal to the space.
                    Tao.Ode.Ode.dSpaceCollide(o1, data, CollisionCallbackRunner);
                }
            }
            else
            {
                // Colliding two geoms.

                // The following is a set of special cases where we might
                // want to skip collision detection (but not all are
                // enforced here for various reasons):
                // 1. Two static Solids (neither geom has a body) AND
                //    neither Solid has a CollisionEventHandler AND there are
                //    not global handlers: this is enforced.
                // 2. Two Shapes that are part of the same Solid (they
                //    share a body): this is not enforced because ODE
                //    already takes care of it.
                // 3. Two sleeping Solids (note: both must have bodies to
                //    check this): this is enforced.  (ODE should handle
                //    this, but it doesn't.)
                // 4. Two Solids connected by a fixed Joint: this is
                //    enforced.
                // 5. Two Solids connected by a Joint (besides ODE
                //    contact joints, which should never generate more
                //    contacts) with contacts disabled (note: both must have
                //    bodies to check this): this is enforced.
                // 6. Solid0 is static, Solid1 is dynamic and is sleeping,
                //    static-to-sleeping contacts are ignored by the
                //    Simulator, and neither Solid has a
                //    CollisionEventHandler AND there are no global handlers:
                //    this is enforced.
                // 7. Solid1 is static, Solid0 is dynamic and is sleeping,
                //    static-to-sleeping contacts are ignored by the
                //    Simulator, and neither Solid has a
                //    CollisionEventHandler AND there are no global handlers:
                //    this is enforced.
                // 8. The two Solids' contact groups do not generate
                //    contacts when they collide AND neither Solid has a
                //    CollisionEventHandler AND there are no global handlers.

                // Get the geoms' ODE body IDs.
                dBodyID o0BodyID = o0.RigidBody;
                dBodyID o1BodyID = o1.RigidBody;

                bool solid0Static = PtrWrapper.IsEmpty(o0BodyID); // (mike)
                bool solid1Static = PtrWrapper.IsEmpty(o1BodyID); // {mike}

                // Check if both Solids are dynamic (i.e. have ODE bodies).
                bool bothHaveBodies = true;
                if (solid0Static || solid1Static)
                {
                    bothHaveBodies = false;
                }

                // If the two Solids are connected by a common Joint, get
                // a pointer to that Joint.
                Joint commonJoint = null;

                if (bothHaveBodies)
                {
                    int connExcluding = Tao.Ode.Ode.dAreConnectedExcluding(o0BodyID, o1BodyID, (int)Tao.Ode.Ode.dJointTypes.dJointTypeContact);

                    if (connExcluding != 0)
                    {
                        // This will become non-NULL only if there exists an ODE
                        // joint connecting the two bodies.
                        commonJoint = GetCommonJoint(o0BodyID, o1BodyID);
                    }
                }

                // Get pointers to the geoms' GeomData structures.
                GeomData geomData0 = GCHandle.FromIntPtr(Tao.Ode.Ode.dGeomGetData(o0)).Target as GeomData;
                GeomData geomData1 = GCHandle.FromIntPtr(Tao.Ode.Ode.dGeomGetData(o1)).Target as GeomData;

                // Get pointers to the geoms' ShapeData structures.
                ShapeData shape0 = geomData0.Shape;
                ShapeData shape1 = geomData1.Shape;

                // Get a pointer to the ODESimulator.
                OdeSimulator sim = GCHandle.FromIntPtr(data).Target as OdeSimulator;

                // Check if the two Solids' contact groups generate contacts
                // when they collide.
                bool makeContacts = sim.GroupsMakeContacts(shape0.ContactGroup, shape1.ContactGroup);

                // Find out whether the Simulator has static-to-sleeping
                // contacts disabled.
                bool ignoreStaticSleepingContacts = !sim.IsStaticSleepingContactsEnabled;

                // Get pointers to the geoms' Solids.
                Solid solid0 = geomData0.Solid;
                Solid solid1 = geomData1.Solid;

                // Get pointers to the two Solids' CollisionEventHandlers.
                // These will be NULL if the Solids don't use
                // CollisionEventHandlers.
                CollisionEventProcessor handler0 = solid0.CollisionEventHandler;
                CollisionEventProcessor handler1 = solid1.CollisionEventHandler;

                bool neitherHasEventHandler = !(handler0 != null || handler1 != null);

                bool hasNoGlobalHandler = sim.NumGlobalCollisionEventHandlers == 0;

                // Now do the actual tests to see if we should return early.
                // It is important here that we don't call dBodyIsEnabled on
                // a static body because that crashes ODE.

                bool case1 = neitherHasEventHandler && hasNoGlobalHandler &&
                             solid0Static && solid1Static;
                //bool case2= o0BodyID == o1BodyID;
                bool case3 = bothHaveBodies && Tao.Ode.Ode.dBodyIsEnabled(o0BodyID) == 0 &&
                             Tao.Ode.Ode.dBodyIsEnabled(o1BodyID) == 0;
                bool case4 = commonJoint != null &&
                             commonJoint.Type == JointType.Fixed;
                bool case5 = commonJoint != null &&
                             !commonJoint.ContactsEnabled;
                bool case6 = solid0Static && null != o1BodyID && o1BodyID.IsNotNull() &&
                             Tao.Ode.Ode.dBodyIsEnabled(o1BodyID) == 0 &&
                             ignoreStaticSleepingContacts &&
                             neitherHasEventHandler && hasNoGlobalHandler;
                bool case7 = solid1Static && null != o0BodyID && o0BodyID.IsNotNull() &&
                             Tao.Ode.Ode.dBodyIsEnabled(o0BodyID) == 0 &&
                             ignoreStaticSleepingContacts &&
                             neitherHasEventHandler && hasNoGlobalHandler;
                bool case8 = !makeContacts && neitherHasEventHandler &&
                             hasNoGlobalHandler;

                if (case1 || case3 || case4 || case5 || case6 || case7 || case8)
                {
                    return;
                }

                // Now actually test for collision between the two geoms.
                // This is one of the more expensive operations.
                IntPtr theWorldID      = sim.World;
                IntPtr theJointGroupID = sim.JointGroup;
                int    contGeomSize    = sizeof(Tao.Ode.Ode.dContactGeom);
                Tao.Ode.Ode.dContactGeom[] contactArray = new Tao.Ode.Ode.dContactGeom[sim.MaxContacts];

                int numContacts = 0;

                /*try
                 * {*/
                numContacts = Tao.Ode.Ode.dCollide(o0, o1, sim.MaxContacts /*was 15*/, contactArray, contGeomSize);
                // Was big perfomance problem here (KleMiX)

                /*}
                 * catch(Exception)
                 * {
                 *  return;
                 * }*/

                // If the two objects didn't make any contacts, they weren't
                // touching, so just return.
                if (0 == numContacts)
                {
                    return;
                }

                // If at least one of the Solids has a CollisionEventHandler,
                // send it a CollisionEvent.
                if (handler0 != null || handler1 != null || !hasNoGlobalHandler)
                {
                    // Call the CollisionEventHandlers.  Note that we only
                    // use one contact point per collision: just the first one
                    // in the contact array.  The order of the Solids
                    // passed to the event handlers is important: the first
                    // one should be the one whose event handler is
                    // getting called.

                    CollisionEvent e = new CollisionEvent();

                    e.ThisSolid  = solid0;
                    e.OtherSolid = solid1;
                    e.Position.X = contactArray[0].pos.X;
                    e.Position.Y = contactArray[0].pos.Y;
                    e.Position.Z = contactArray[0].pos.Z;
                    e.Normal.X   = contactArray[0].normal.X;
                    e.Normal.Y   = contactArray[0].normal.Y;
                    e.Normal.Z   = contactArray[0].normal.Z;
                    e.Depth      = contactArray[0].depth;

                    if (handler0 != null)
                    {
                        handler0.HandleCollisionEvent(e);
                    }

                    if (handler1 != null)
                    {
                        // For the other Solid's CollisionEventHandler, we need
                        // to invert the normal and swap the Solid pointers.
                        e.Normal    *= -1;
                        e.ThisSolid  = solid1;
                        e.OtherSolid = solid0;
                        handler1.HandleCollisionEvent(e);
                    }

                    sim.InternalRecordCollision(e);
                }

                if (makeContacts)
                {
                    // Invalidate the "freely-spinning" parameters.
                    ((OdeSolid)solid0).InternalSetFreelySpinning(false);
                    ((OdeSolid)solid1).InternalSetFreelySpinning(false);

                    for (int i = 0; i < numContacts; ++i)
                    {
                        Material m0 = shape0.Material;
                        Material m1 = shape1.Material;

                        Tao.Ode.Ode.dContact tempContact = new Tao.Ode.Ode.dContact();
                        tempContact.surface.mode = (int)Tao.Ode.Ode.dContactFlags.dContactBounce |
                                                   (int)Tao.Ode.Ode.dContactFlags.dContactSoftERP;

                        // Average the hardness of the two materials.
                        float hardness = (m0.Hardness + m1.Hardness) * 0.5f;

                        // Convert hardness to ERP.  As hardness goes from
                        // 0.0 to 1.0, ERP goes from min to max.
                        tempContact.surface.soft_erp = hardness *
                                                       (Defaults.Ode.MaxERP - Defaults.Ode.MinERP) +
                                                       Defaults.Ode.MinERP;

                        // Don't use contact CFM anymore.  Just let it use
                        // the global value set in the ODE world.
                        //tempContact.surface.soft_cfm =
                        //  defaults::ode::minCFM;

                        // As friction goes from 0.0 to 1.0, mu goes from 0.0
                        // to max, though it is set to dInfinity when
                        // friction == 1.0.
                        if (1.0 == m0.Friction && 1.0 == m1.Friction)
                        {
                            tempContact.surface.mu = float.PositiveInfinity;
                        }
                        else
                        {
                            tempContact.surface.mu = (float)Math.Sqrt(m0.Friction * m1.Friction) * Defaults.Ode.MaxFriction;
                        }

                        // Average the bounciness of the two materials.
                        float bounciness = (m0.Bounciness + m1.Bounciness) * 0.5f;

                        // ODE's bounce parameter, a.k.a. restitution.
                        tempContact.surface.bounce = bounciness;

                        // ODE's bounce_vel parameter is a threshold:
                        // the relative velocity of the two objects must be
                        // greater than this for bouncing to occur at all.
                        tempContact.surface.bounce_vel = Defaults.BounceThreshold;

                        tempContact.geom = contactArray[i];
                        //ODE.Joints.Contact contactJoint = new ODE.Joints.Contact(theWorldID, tempContact, theJointGroupID);
                        IntPtr contactJoint = Tao.Ode.Ode.dJointCreateContact(theWorldID, theJointGroupID, ref tempContact);

                        //contactJoint.Attach(o0BodyID, o1BodyID);
                        Tao.Ode.Ode.dJointAttach(contactJoint, o0BodyID, o1BodyID);
                    }
                }
            }
        }
Exemplo n.º 11
0
        /// Special collision callback functor for volume collision
        /// checking.
        static unsafe internal void VolumeCollisionCallback(IntPtr data, IntPtr o0, IntPtr o1)
        {
            if (Tao.Ode.Ode.dGeomIsSpace(o0) != 0 || Tao.Ode.Ode.dGeomIsSpace(o1) != 0)
            {
                // Colliding a space with either a geom or another space.
                Tao.Ode.Ode.dSpaceCollide2(o0, o1, data, VolumeCollisionCallback);
            }
            else
            {
                // Get a pointer to the ODESimulator.
                OdeSimulator sim = GCHandle.FromIntPtr(data).Target as OdeSimulator;

                // Get pointers to the two geoms' GeomData structure.  Both
                // of these should always be non-NULL.

                /*GeomData geomData0 = (GeomData)Tao.Ode.Ode.dGeomGetData(o0);
                *  GeomData geomData1 = (GeomData)Tao.Ode.Ode.dGeomGetData(o1);*/
                // CANYONSHOOTER BEGIN
                dGeomID  g0        = o0;
                dGeomID  g1        = o1;
                GeomData geomData0 = GCHandle.FromIntPtr(Tao.Ode.Ode.dGeomGetData(g0)).Target as GeomData;
                GeomData geomData1 = GCHandle.FromIntPtr(Tao.Ode.Ode.dGeomGetData(g1)).Target as GeomData;

                /*
                 *              GeomData geomData0 = GCHandle.FromIntPtr(o0).Target as GeomData;
                 *              GeomData geomData1 = GCHandle.FromIntPtr(o1).Target as GeomData;
                 */
                // CANYONSHOOTER END

                // Get pointers to the geoms' ShapeData structures.
                ShapeData shape0 = geomData0.Shape;
                ShapeData shape1 = geomData1.Shape;

                // Check if the two Solids' contact groups generate contacts
                // when they collide.
                bool makeContacts = sim.GroupsMakeContacts(shape0.ContactGroup, shape1.ContactGroup);
                if (!makeContacts)
                {
                    return;
                }

                // Now actually test for collision between the two geoms.
                // This is a fairly expensive operation.
                //ODE.Joints.ContactGeom[] contactArray = new ODE.Joints.ContactGeom[1];
                Tao.Ode.Ode.dContactGeom[] contactArray = new Tao.Ode.Ode.dContactGeom[1];
                int numContacts = Tao.Ode.Ode.dCollide(o0, o1, 1, contactArray, sizeof(Tao.Ode.Ode.dContactGeom));

                if (0 == numContacts)
                {
                    return;
                }
                else
                {
                    // These two geoms must be intersecting.

                    // Get pointers to the geoms' Solids.
                    Solid solid0 = geomData0.Solid;
                    Solid solid1 = geomData1.Solid;

                    // Not sure at this point if we can know that o1 is the
                    // volume object, so we'll just call this twice.  It
                    // will automatically keep from adding the same Solid
                    // multiple times by using its collision count.  Later,
                    // the volume Solid will be removed from this list.
                    sim.InternalAddCollidedSolid(solid0);
                    sim.InternalAddCollidedSolid(solid1);
                }
            }
        }
Exemplo n.º 12
0
        public override bool Place(Point origin, StructureMap structures)
        {
            Point result;

            if (!WorldUtils.Find(origin, Searches.Chain(new Searches.Down(200), new Conditions.IsSolid()), out result) || result == origin)
            {
                return(false);
            }
            Rectangle room       = GetRoom(result);
            Rectangle rectangle  = GetRoom(new Point(room.Center.X, room.Y + 1));
            Rectangle rectangle2 = GetRoom(new Point(room.Center.X, room.Y + room.Height + 10));

            rectangle2.Y = room.Y + room.Height - 1;
            float num  = RoomSolidPrecentage(rectangle);
            float num2 = RoomSolidPrecentage(rectangle2);

            room.Y       += 3;
            rectangle.Y  += 3;
            rectangle2.Y += 3;
            List <Rectangle> list = new List <Rectangle>();

            if (GenBase._random.NextFloat() > num + 0.2f)
            {
                list.Add(rectangle);
            }
            else
            {
                rectangle = room;
            }
            list.Add(room);
            if (GenBase._random.NextFloat() > num2 + 0.2f)
            {
                list.Add(rectangle2);
            }
            else
            {
                rectangle2 = room;
            }
            Dictionary <ushort, int> dictionary = new Dictionary <ushort, int>();

            foreach (Rectangle item in list)
            {
                WorldUtils.Gen(new Point(item.X - 5, item.Y - 5), new Shapes.Rectangle(item.Width + 10, item.Height + 10), new Actions.TileScanner(0, 59, 147, 1, 161, 53, 396, 397, 368, 367, 60, 70).Output(dictionary));
            }
            List <Tuple <BuildData, int> > list2 = new List <Tuple <BuildData, int> >();

            list2.Add(Tuple.Create(BuildData.Default, dictionary[0] + dictionary[1]));
            list2.Add(Tuple.Create(BuildData.Jungle, dictionary[59] + dictionary[60] * 10));
            list2.Add(Tuple.Create(BuildData.Mushroom, dictionary[59] + dictionary[70] * 10));
            list2.Add(Tuple.Create(BuildData.Snow, dictionary[147] + dictionary[161]));
            list2.Add(Tuple.Create(BuildData.Desert, dictionary[397] + dictionary[396] + dictionary[53]));
            list2.Add(Tuple.Create(BuildData.Granite, dictionary[368]));
            list2.Add(Tuple.Create(BuildData.Marble, dictionary[367]));
            list2.Sort(SortBiomeResults);
            BuildData ıtem = list2[0].Item1;

            foreach (Rectangle item2 in list)
            {
                Point result2;
                if (ıtem != BuildData.Granite && WorldUtils.Find(new Point(item2.X - 2, item2.Y - 2), Searches.Chain(new Searches.Rectangle(item2.Width + 4, item2.Height + 4).RequireAll(false), new Conditions.HasLava()), out result2))
                {
                    return(false);
                }
                if (!structures.CanPlace(item2, _blacklistedTiles, 5))
                {
                    return(false);
                }
            }
            int num3 = room.X;
            int num4 = room.X + room.Width - 1;
            List <Rectangle> list3 = new List <Rectangle>();

            foreach (Rectangle item3 in list)
            {
                num3 = Math.Min(num3, item3.X);
                num4 = Math.Max(num4, item3.X + item3.Width - 1);
            }
            int num5 = 6;

            while (num5 > 4 && (num4 - num3) % num5 != 0)
            {
                num5--;
            }
            for (int i = num3; i <= num4; i += num5)
            {
                for (int j = 0; j < list.Count; j++)
                {
                    Rectangle rectangle3 = list[j];
                    if (i < rectangle3.X || i >= rectangle3.X + rectangle3.Width)
                    {
                        continue;
                    }
                    int num6 = rectangle3.Y + rectangle3.Height;
                    int num7 = 50;
                    for (int k = j + 1; k < list.Count; k++)
                    {
                        if (i >= list[k].X && i < list[k].X + list[k].Width)
                        {
                            num7 = Math.Min(num7, list[k].Y - num6);
                        }
                    }
                    if (num7 > 0)
                    {
                        Point result3;
                        bool  flag = WorldUtils.Find(new Point(i, num6), Searches.Chain(new Searches.Down(num7), new Conditions.IsSolid()), out result3);
                        if (num7 < 50)
                        {
                            flag    = true;
                            result3 = new Point(i, num6 + num7);
                        }
                        if (flag)
                        {
                            list3.Add(new Rectangle(i, num6, 1, result3.Y - num6));
                        }
                    }
                }
            }
            List <Point> list4 = new List <Point>();

            foreach (Rectangle item4 in list)
            {
                int exitY;
                if (FindSideExit(new Rectangle(item4.X + item4.Width, item4.Y + 1, 1, item4.Height - 2), false, out exitY))
                {
                    list4.Add(new Point(item4.X + item4.Width - 1, exitY));
                }
                if (FindSideExit(new Rectangle(item4.X, item4.Y + 1, 1, item4.Height - 2), true, out exitY))
                {
                    list4.Add(new Point(item4.X, exitY));
                }
            }
            List <Tuple <Point, Point> > list5 = new List <Tuple <Point, Point> >();

            for (int l = 1; l < list.Count; l++)
            {
                Rectangle rectangle4 = list[l];
                Rectangle rectangle5 = list[l - 1];
                int       num8       = rectangle5.X - rectangle4.X;
                int       num9       = rectangle4.X + rectangle4.Width - (rectangle5.X + rectangle5.Width);
                if (num8 > num9)
                {
                    list5.Add(new Tuple <Point, Point>(new Point(rectangle4.X + rectangle4.Width - 1, rectangle4.Y + 1), new Point(rectangle4.X + rectangle4.Width - rectangle4.Height + 1, rectangle4.Y + rectangle4.Height - 1)));
                }
                else
                {
                    list5.Add(new Tuple <Point, Point>(new Point(rectangle4.X, rectangle4.Y + 1), new Point(rectangle4.X + rectangle4.Height - 1, rectangle4.Y + rectangle4.Height - 1)));
                }
            }
            List <Point> list6 = new List <Point>();
            int          exitX;

            if (FindVerticalExit(new Rectangle(rectangle.X + 2, rectangle.Y, rectangle.Width - 4, 1), true, out exitX))
            {
                list6.Add(new Point(exitX, rectangle.Y));
            }
            if (FindVerticalExit(new Rectangle(rectangle2.X + 2, rectangle2.Y + rectangle2.Height - 1, rectangle2.Width - 4, 1), false, out exitX))
            {
                list6.Add(new Point(exitX, rectangle2.Y + rectangle2.Height - 1));
            }
            foreach (Rectangle item5 in list)
            {
                WorldUtils.Gen(new Point(item5.X, item5.Y), new Shapes.Rectangle(item5.Width, item5.Height), Actions.Chain(new Actions.SetTile(ıtem.Tile), new Actions.SetFrames(true)));
                WorldUtils.Gen(new Point(item5.X + 1, item5.Y + 1), new Shapes.Rectangle(item5.Width - 2, item5.Height - 2), Actions.Chain(new Actions.ClearTile(true), new Actions.PlaceWall(ıtem.Wall)));
                structures.AddStructure(item5, 8);
            }
            foreach (Tuple <Point, Point> item6 in list5)
            {
                Point     ıtem2     = item6.Item1;
                Point     ıtem3     = item6.Item2;
                int       num10     = (ıtem3.X > ıtem2.X) ? 1 : (-1);
                ShapeData shapeData = new ShapeData();
                for (int m = 0; m < ıtem3.Y - ıtem2.Y; m++)
                {
                    shapeData.Add(num10 * (m + 1), m);
                }
                WorldUtils.Gen(ıtem2, new ModShapes.All(shapeData), Actions.Chain(new Actions.PlaceTile(19, ıtem.PlatformStyle), new Actions.SetSlope((num10 == 1) ? 1 : 2), new Actions.SetFrames(true)));
                WorldUtils.Gen(new Point(ıtem2.X + ((num10 == 1) ? 1 : (-4)), ıtem2.Y - 1), new Shapes.Rectangle(4, 1), Actions.Chain(new Actions.Clear(), new Actions.PlaceWall(ıtem.Wall), new Actions.PlaceTile(19, ıtem.PlatformStyle), new Actions.SetFrames(true)));
            }
            foreach (Point item7 in list4)
            {
                WorldUtils.Gen(item7, new Shapes.Rectangle(1, 3), new Actions.ClearTile(true));
                WorldGen.PlaceTile(item7.X, item7.Y, 10, true, true, -1, ıtem.DoorStyle);
            }
            foreach (Point item8 in list6)
            {
                WorldUtils.Gen(item8, new Shapes.Rectangle(3, 1), Actions.Chain(new Actions.ClearMetadata(), new Actions.PlaceTile(19, ıtem.PlatformStyle), new Actions.SetFrames(true)));
            }
            foreach (Rectangle item9 in list3)
            {
                if (item9.Height > 1 && GenBase._tiles[item9.X, item9.Y - 1].type != 19)
                {
                    WorldUtils.Gen(new Point(item9.X, item9.Y), new Shapes.Rectangle(item9.Width, item9.Height), Actions.Chain(new Actions.SetTile(124), new Actions.SetFrames(true)));
                    Tile tile = GenBase._tiles[item9.X, item9.Y + item9.Height];
                    tile.slope(0);
                    tile.halfBrick(false);
                }
            }
            Point[] choices = new Point[7]
            {
                new Point(14, ıtem.TableStyle),
                new Point(16, 0),
                new Point(18, ıtem.WorkbenchStyle),
                new Point(86, 0),
                new Point(87, ıtem.PianoStyle),
                new Point(94, 0),
                new Point(101, ıtem.BookcaseStyle)
            };
            foreach (Rectangle item10 in list)
            {
                int num11 = item10.Width / 8;
                int num12 = item10.Width / (num11 + 1);
                int num13 = GenBase._random.Next(2);
                for (int n = 0; n < num11; n++)
                {
                    int num14 = (n + 1) * num12 + item10.X;
                    switch (n + num13 % 2)
                    {
                    case 0:
                    {
                        int     num15  = item10.Y + Math.Min(item10.Height / 2, item10.Height - 5);
                        Vector2 vector = WorldGen.randHousePicture();
                        int     type   = (int)vector.X;
                        int     style  = (int)vector.Y;
                        if (!WorldGen.nearPicture(num14, num15))
                        {
                            WorldGen.PlaceTile(num14, num15, type, true, false, -1, style);
                        }
                        break;
                    }

                    case 1:
                    {
                        int num15 = item10.Y + 1;
                        WorldGen.PlaceTile(num14, num15, 34, true, false, -1, GenBase._random.Next(6));
                        for (int num16 = -1; num16 < 2; num16++)
                        {
                            for (int num17 = 0; num17 < 3; num17++)
                            {
                                GenBase._tiles[num16 + num14, num17 + num15].frameX += 54;
                            }
                        }
                        break;
                    }
                    }
                }
                int num18 = item10.Width / 8 + 3;
                WorldGen.SetupStatueList();
                while (num18 > 0)
                {
                    int num19 = GenBase._random.Next(item10.Width - 3) + 1 + item10.X;
                    int num20 = item10.Y + item10.Height - 2;
                    switch (GenBase._random.Next(4))
                    {
                    case 0:
                        WorldGen.PlaceSmallPile(num19, num20, GenBase._random.Next(31, 34), 1, 185);
                        break;

                    case 1:
                        WorldGen.PlaceTile(num19, num20, 186, true, false, -1, GenBase._random.Next(22, 26));
                        break;

                    case 2:
                    {
                        int num21 = GenBase._random.Next(2, WorldGen.statueList.Length);
                        WorldGen.PlaceTile(num19, num20, WorldGen.statueList[num21].X, true, false, -1, WorldGen.statueList[num21].Y);
                        if (WorldGen.StatuesWithTraps.Contains(num21))
                        {
                            WorldGen.PlaceStatueTrap(num19, num20);
                        }
                        break;
                    }

                    case 3:
                    {
                        Point point = Utils.SelectRandom(GenBase._random, choices);
                        WorldGen.PlaceTile(num19, num20, point.X, true, false, -1, point.Y);
                        break;
                    }
                    }
                    num18--;
                }
            }
            foreach (Rectangle item11 in list)
            {
                ıtem.ProcessRoom(item11);
            }
            bool flag2 = false;

            foreach (Rectangle item12 in list)
            {
                int num22  = item12.Height - 1 + item12.Y;
                int style2 = (num22 > (int)Main.worldSurface) ? ıtem.ChestStyle : 0;
                for (int num23 = 0; num23 < 10; num23++)
                {
                    int i2 = GenBase._random.Next(2, item12.Width - 2) + item12.X;
                    if (flag2 = WorldGen.AddBuriedChest(i2, num22, 0, false, style2))
                    {
                        break;
                    }
                }
                if (flag2)
                {
                    break;
                }
                for (int num24 = item12.X + 2; num24 <= item12.X + item12.Width - 2; num24++)
                {
                    if (flag2 = WorldGen.AddBuriedChest(num24, num22, 0, false, style2))
                    {
                        break;
                    }
                }
                if (flag2)
                {
                    break;
                }
            }
            if (!flag2)
            {
                foreach (Rectangle item13 in list)
                {
                    int num25  = item13.Y - 1;
                    int style3 = (num25 > (int)Main.worldSurface) ? ıtem.ChestStyle : 0;
                    for (int num26 = 0; num26 < 10; num26++)
                    {
                        int i3 = GenBase._random.Next(2, item13.Width - 2) + item13.X;
                        if (flag2 = WorldGen.AddBuriedChest(i3, num25, 0, false, style3))
                        {
                            break;
                        }
                    }
                    if (flag2)
                    {
                        break;
                    }
                    for (int num27 = item13.X + 2; num27 <= item13.X + item13.Width - 2; num27++)
                    {
                        if (flag2 = WorldGen.AddBuriedChest(num27, num25, 0, false, style3))
                        {
                            break;
                        }
                    }
                    if (flag2)
                    {
                        break;
                    }
                }
            }
            if (!flag2)
            {
                for (int num28 = 0; num28 < 1000; num28++)
                {
                    int i4     = GenBase._random.Next(list[0].X - 30, list[0].X + 30);
                    int num29  = GenBase._random.Next(list[0].Y - 30, list[0].Y + 30);
                    int style4 = (num29 > (int)Main.worldSurface) ? ıtem.ChestStyle : 0;
                    if (flag2 = WorldGen.AddBuriedChest(i4, num29, 0, false, style4))
                    {
                        break;
                    }
                }
            }
            if (ıtem == BuildData.Jungle && _sharpenerCount < GenBase._random.Next(2, 5))
            {
                bool flag3 = false;
                foreach (Rectangle item14 in list)
                {
                    int num30 = item14.Height - 2 + item14.Y;
                    for (int num31 = 0; num31 < 10; num31++)
                    {
                        int num32 = GenBase._random.Next(2, item14.Width - 2) + item14.X;
                        WorldGen.PlaceTile(num32, num30, 377, true, true);
                        if (flag3 = (GenBase._tiles[num32, num30].active() && GenBase._tiles[num32, num30].type == 377))
                        {
                            break;
                        }
                    }
                    if (flag3)
                    {
                        break;
                    }
                    for (int num33 = item14.X + 2; num33 <= item14.X + item14.Width - 2; num33++)
                    {
                        if (flag3 = WorldGen.PlaceTile(num33, num30, 377, true, true))
                        {
                            break;
                        }
                    }
                    if (flag3)
                    {
                        break;
                    }
                }
                if (flag3)
                {
                    _sharpenerCount++;
                }
            }
            if (ıtem == BuildData.Desert && _extractinatorCount < GenBase._random.Next(2, 5))
            {
                bool flag4 = false;
                foreach (Rectangle item15 in list)
                {
                    int num34 = item15.Height - 2 + item15.Y;
                    for (int num35 = 0; num35 < 10; num35++)
                    {
                        int num36 = GenBase._random.Next(2, item15.Width - 2) + item15.X;
                        WorldGen.PlaceTile(num36, num34, 219, true, true);
                        if (flag4 = (GenBase._tiles[num36, num34].active() && GenBase._tiles[num36, num34].type == 219))
                        {
                            break;
                        }
                    }
                    if (flag4)
                    {
                        break;
                    }
                    for (int num37 = item15.X + 2; num37 <= item15.X + item15.Width - 2; num37++)
                    {
                        if (flag4 = WorldGen.PlaceTile(num37, num34, 219, true, true))
                        {
                            break;
                        }
                    }
                    if (flag4)
                    {
                        break;
                    }
                }
                if (flag4)
                {
                    _extractinatorCount++;
                }
            }
            return(true);
        }
Exemplo n.º 13
0
 public void Draw(ShapeData shape)
 {
 }
Exemplo n.º 14
0
 public CircleShape()
 {
     Data = new CircleData();
 }
Exemplo n.º 15
0
    //(PhysicsScene.World.ptr, nativeShapeData)
    internal static object BuildNativeShape2(object pWorld, ShapeData pShapeData)
    {
        var world = pWorld as DiscreteDynamicsWorld;
        CollisionShape shape = null;
        switch (pShapeData.Type)
        {
            case BSPhysicsShapeType.SHAPE_BOX:
                shape = new BoxShape(new IndexedVector3(0.5f,0.5f,0.5f));
                break;
            case BSPhysicsShapeType.SHAPE_CONE:
                shape = new ConeShapeZ(0.5f, 1.0f);
                break;
            case BSPhysicsShapeType.SHAPE_CYLINDER:
                shape = new CylinderShapeZ(new IndexedVector3(0.5f, 0.5f, 0.5f));
                break;
            case BSPhysicsShapeType.SHAPE_SPHERE:
                shape = new SphereShape(0.5f);
                break;

        }
        if (shape != null)
        {
            IndexedVector3 scaling = new IndexedVector3(pShapeData.Scale.X, pShapeData.Scale.Y, pShapeData.Scale.Z);
            shape.SetMargin(world.WorldSettings.Params.collisionMargin);
            shape.SetLocalScaling(ref scaling);

        }
        return shape;
    }
        public override bool Place(Point origin, StructureMap structures)
        {
            Point y;
            Point point;
            Dictionary <ushort, int> nums = new Dictionary <ushort, int>();
            Point point1 = new Point(origin.X - 25, origin.Y - 25);

            Shapes.Rectangle rectangle = new Shapes.Rectangle(50, 50);
            ushort[]         numArray  = new ushort[] { 0, 1 };
            WorldUtils.Gen(point1, rectangle, (new Actions.TileScanner(numArray)).Output(nums));
            if (nums[0] + nums[1] < 1250)
            {
                return(false);
            }
            Searches.Up    up = new Searches.Up(1000);
            GenCondition[] genConditionArray = new GenCondition[] { (new Conditions.IsSolid()).AreaOr(1, 50).Not() };
            bool           flag   = WorldUtils.Find(origin, Searches.Chain(up, genConditionArray), out y);
            Point          point2 = origin;

            Searches.Up    up1       = new Searches.Up(origin.Y - y.Y);
            GenCondition[] isTile    = new GenCondition[1];
            ushort[]       numArray1 = new ushort[] { 53 };
            isTile[0] = new Conditions.IsTile(numArray1);
            if (WorldUtils.Find(point2, Searches.Chain(up1, isTile), out point))
            {
                return(false);
            }
            if (!flag)
            {
                return(false);
            }
            y.Y = y.Y + 50;
            ShapeData shapeDatum  = new ShapeData();
            ShapeData shapeDatum1 = new ShapeData();
            Point     point3      = new Point(origin.X, origin.Y + 20);
            Point     point4      = new Point(origin.X, origin.Y + 30);
            float     single      = 0.8f + GenBase._random.NextFloat() * 0.5f;

            if (!structures.CanPlace(new Rectangle(point3.X - (int)(20f * single), point3.Y - 20, (int)(40f * single), 40), 0))
            {
                return(false);
            }
            if (!structures.CanPlace(new Rectangle(origin.X, y.Y + 10, 1, origin.Y - y.Y - 9), 2))
            {
                return(false);
            }
            Shapes.Slime slime  = new Shapes.Slime(20, single, 1f);
            GenAction[]  blotch = new GenAction[] { new Modifiers.Blotches(2, 0.4), (new Actions.ClearTile(true)).Output(shapeDatum) };
            WorldUtils.Gen(point3, slime, Actions.Chain(blotch));
            Shapes.Mound mound          = new Shapes.Mound(14, 14);
            GenAction[]  genActionArray = new GenAction[] { new Modifiers.Blotches(2, 1, 0.8), new Actions.SetTile(0, false, true), (new Actions.SetFrames(true)).Output(shapeDatum1) };
            WorldUtils.Gen(point4, mound, Actions.Chain(genActionArray));
            shapeDatum.Subtract(shapeDatum1, point3, point4);
            ModShapes.InnerOutline innerOutline = new ModShapes.InnerOutline(shapeDatum, true);
            GenAction[]            setTile      = new GenAction[] { new Actions.SetTile(2, false, true), new Actions.SetFrames(true) };
            WorldUtils.Gen(point3, innerOutline, Actions.Chain(setTile));
            ModShapes.All all           = new ModShapes.All(shapeDatum);
            GenAction[]   rectangleMask = new GenAction[] { new Modifiers.RectangleMask(-40, 40, 0, 40), new Modifiers.IsEmpty(), new Actions.SetLiquid(0, 255) };
            WorldUtils.Gen(point3, all, Actions.Chain(rectangleMask));
            ModShapes.All all1      = new ModShapes.All(shapeDatum);
            GenAction[]   placeWall = new GenAction[] { new Actions.PlaceWall(68, true), null, null, null };
            ushort[]      numArray2 = new ushort[] { 2 };
            placeWall[1] = new Modifiers.OnlyTiles(numArray2);
            placeWall[2] = new Modifiers.Offset(0, 1);
            placeWall[3] = new ActionVines(3, 5, 52);
            WorldUtils.Gen(point3, all1, Actions.Chain(placeWall));
            ShapeData shapeDatum2 = new ShapeData();
            Point     point5      = new Point(origin.X, y.Y + 10);

            Shapes.Rectangle rectangle1 = new Shapes.Rectangle(1, origin.Y - y.Y - 9);
            GenAction[]      onlyTile   = new GenAction[] { new Modifiers.Blotches(2, 0.2), (new Actions.ClearTile(false)).Output(shapeDatum2), new Modifiers.Expand(1), null, null };
            ushort[]         numArray3  = new ushort[] { 53 };
            onlyTile[3] = new Modifiers.OnlyTiles(numArray3);
            onlyTile[4] = (new Actions.SetTile(397, false, true)).Output(shapeDatum2);
            WorldUtils.Gen(point5, rectangle1, Actions.Chain(onlyTile));
            WorldUtils.Gen(new Point(origin.X, y.Y + 10), new ModShapes.All(shapeDatum2), new Actions.SetFrames(true));
            if (GenBase._random.Next(3) != 0)
            {
                WorldGen.PlaceTile(point4.X, point4.Y - 15, 186, true, false, -1, 15);
            }
            else
            {
                WorldGen.PlaceTile(point4.X, point4.Y - 15, 187, true, false, -1, 17);
            }
            ModShapes.All all2      = new ModShapes.All(shapeDatum1);
            GenAction[]   offset    = new GenAction[] { new Modifiers.Offset(0, -1), null, null, null };
            ushort[]      numArray4 = new ushort[] { 2 };
            offset[1] = new Modifiers.OnlyTiles(numArray4);
            offset[2] = new Modifiers.Offset(0, -1);
            offset[3] = new ActionGrass();
            WorldUtils.Gen(point4, all2, Actions.Chain(offset));
            structures.AddStructure(new Rectangle(point3.X - (int)(20f * single), point3.Y - 20, (int)(40f * single), 40), 4);
            return(true);
        }
Exemplo n.º 17
0
 public void EndLines()
 {
     if (polyline != null) {
         var n = polylinePoints.Count;
         while (n > polylineLength) {
             polylinePoints.RemoveAt (n - 1);
             n--;
         }
         polylineShape = null;
         polyline = null;
         polylinePoints = null;
         polylineLength = 0;
     }
 }
Exemplo n.º 18
0
        // Token: 0x06000FC5 RID: 4037 RVA: 0x003FA5C4 File Offset: 0x003F87C4
        public override bool Place(Point origin, StructureMap structures)
        {
            if (WorldGen.SolidTile(origin.X, origin.Y) && GenBase._tiles[origin.X, origin.Y].wall == 3)
            {
                return(false);
            }
            if (!WorldUtils.Find(origin, Searches.Chain(new Searches.Down(100), new GenCondition[]
            {
                new Conditions.IsSolid()
            }), out origin))
            {
                return(false);
            }
            Point point;

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

            for (int i = 0; i < 6; i++)
            {
                WorldUtils.Gen(origin, new Shapes.Circle(GenBase._random.Next(10, 12) + i), Actions.Chain(new GenAction[]
                {
                    new Modifiers.Offset(0, 5 * i + 5),
                    new Modifiers.Blotches(3, 0.3).Output(shapeData)
                }));
            }
            for (int j = 0; j < 6; j++)
            {
                WorldUtils.Gen(origin, new Shapes.Circle(GenBase._random.Next(5, 7) + j), Actions.Chain(new GenAction[]
                {
                    new Modifiers.Offset(0, 2 * j + 18),
                    new Modifiers.Blotches(3, 0.3).Output(shapeData2)
                }));
            }
            for (int k = 0; k < 6; k++)
            {
                WorldUtils.Gen(origin, new Shapes.Circle(GenBase._random.Next(4, 6) + k / 2), Actions.Chain(new GenAction[]
                {
                    new Modifiers.Offset(0, (int)(7.5f * (float)k) - 10),
                    new Modifiers.Blotches(3, 0.3).Output(shapeData3)
                }));
            }
            ShapeData shapeData4 = new ShapeData(shapeData2);

            shapeData2.Subtract(shapeData3, origin, origin);
            shapeData4.Subtract(shapeData2, origin, origin);
            Rectangle bounds = ShapeData.GetBounds(origin, new ShapeData[]
            {
                shapeData,
                shapeData3
            });

            if (!structures.CanPlace(bounds, CorruptionPitBiome.ValidTiles, 2))
            {
                return(false);
            }
            WorldUtils.Gen(origin, new ModShapes.All(shapeData), Actions.Chain(new GenAction[]
            {
                new Actions.SetTile(25, true, true),
                new Actions.PlaceWall(3, true)
            }));
            WorldUtils.Gen(origin, new ModShapes.All(shapeData2), new Actions.SetTile(0, true, true));
            WorldUtils.Gen(origin, new ModShapes.All(shapeData3), new Actions.ClearTile(true));
            WorldUtils.Gen(origin, new ModShapes.All(shapeData2), Actions.Chain(new GenAction[]
            {
                new Modifiers.IsTouchingAir(true),
                new Modifiers.NotTouching(false, new ushort[]
                {
                    25
                }),
                new Actions.SetTile(23, true, true)
            }));
            WorldUtils.Gen(origin, new ModShapes.All(shapeData4), new Actions.PlaceWall(69, true));
            structures.AddStructure(bounds, 2);
            return(true);
        }
Exemplo n.º 19
0
 public void Begin()
 {
     _currentColor = Colors.Black;
     _shapeIndex = 0;
     _lastShape = null;
     _lastAddElementIndex = -1;
 }
Exemplo n.º 20
0
 /// <summary>
 /// Initializes a new instance of the <see cref="SqlGeometry"/> class.
 /// </summary>
 public SqlGeometry()
 {
     _geometry = new ShapeData();
 }
Exemplo n.º 21
0
    //(PhysicsScene.World.ptr, nativeShapeData)
    public override BulletShape BuildNativeShape(BulletWorld pWorld, ShapeData pShapeData)
    {
        DiscreteDynamicsWorld world = (pWorld as BulletWorldXNA).world;
        CollisionShape shape = null;
        switch (pShapeData.Type)
        {
            case BSPhysicsShapeType.SHAPE_BOX:
                shape = new BoxShape(new IndexedVector3(0.5f,0.5f,0.5f));
                break;
            case BSPhysicsShapeType.SHAPE_CONE:
                shape = new ConeShapeZ(0.5f, 1.0f);
                break;
            case BSPhysicsShapeType.SHAPE_CYLINDER:
                shape = new CylinderShapeZ(new IndexedVector3(0.5f, 0.5f, 0.5f));
                break;
            case BSPhysicsShapeType.SHAPE_SPHERE:
                shape = new SphereShape(0.5f);
                break;

        }
        if (shape != null)
        {
            IndexedVector3 scaling = new IndexedVector3(pShapeData.Scale.X, pShapeData.Scale.Y, pShapeData.Scale.Z);
            shape.SetMargin(world.WorldSettings.Params.collisionMargin);
            shape.SetLocalScaling(ref scaling);

        }
        return new BulletShapeXNA(shape, pShapeData.Type);
    }
Exemplo n.º 22
0
 internal SqlGeometry(ShapeData g, int srid)
 {
     this.srid      = srid;
     this._geometry = g;
 }
Exemplo n.º 23
0
 public GenModShape(ShapeData data)
 {
     this._data = data;
 }
    // public override void Cleanup() => CoreUtils.Destroy(m_Material);

    void CreateScene()
    {
        List <Shape> allShapes = new List <Shape> (FindObjectsOfType <Shape> ());

        allShapes.Sort((a, b) => a.operation.CompareTo(b.operation));

        List <Shape> orderedShapes = new List <Shape> ();

        for (int i = 0; i < allShapes.Count; i++)
        {
            // Add top-level shapes (those without a parent)
            if (allShapes[i].transform.parent == null)
            {
                Transform parentShape = allShapes[i].transform;
                orderedShapes.Add(allShapes[i]);
                allShapes[i].numChildren = parentShape.childCount;
                // Add all children of the shape (nested children not supported currently)
                for (int j = 0; j < parentShape.childCount; j++)
                {
                    if (parentShape.GetChild(j).GetComponent <Shape> () != null)
                    {
                        orderedShapes.Add(parentShape.GetChild(j).GetComponent <Shape> ());
                        orderedShapes[orderedShapes.Count - 1].numChildren = 0;
                    }
                }
            }
        }

        ShapeData[] shapeData = new ShapeData[orderedShapes.Count];
        for (int i = 0; i < orderedShapes.Count; i++)
        {
            var     s   = orderedShapes[i];
            Vector3 col = new Vector3(s.colour.r, s.colour.g, s.colour.b);
            shapeData[i] = new ShapeData()
            {
                position      = s.Position,
                scale         = s.Scale, colour = col,
                shapeType     = (int)s.shapeType,
                operation     = (int)s.operation,
                blendStrength = s.blendStrength * 3,
                numChildren   = s.numChildren
            };
        }

        int           kernelHandle = raymarching.FindKernel("CSMain");
        ComputeBuffer shapeBuffer  = new ComputeBuffer(shapeData.Length, ShapeData.GetSize());

        shapeBuffer.SetData(shapeData);
        raymarching.SetBuffer(kernelHandle, "shapes", shapeBuffer);
        raymarching.SetInt("numShapes", shapeData.Length);

        buffersToDispose.Add(shapeBuffer);


        // do lights
        LightData[] lightData = new LightData[lightSources.Length];
        // get positions of lights
        for (int i = 0; i < lightSources.Length; i++)
        {
            lightData[i] = new LightData()
            {
                position   = lightSources[i].transform.position,
                pointLight = lightSources[i].type != LightType.Directional ? 1 : 0,
                scale      = Vector3.one
            };
        }
        ComputeBuffer lightBuffer = new ComputeBuffer(lightData.Length, LightData.GetSize());

        lightBuffer.SetData(lightData);
        raymarching.SetBuffer(kernelHandle, "lights", lightBuffer);
        raymarching.SetInt("numLights", lightData.Length);
        buffersToDispose.Add(lightBuffer);

        // do depth texture
        // Get (update only if necessary, check for null)
        // RenderTexture depth = Shader.GetGlobalTexture( "_CameraDepthTexture" ) as RenderTexture;
        // Texture gBuffer2 = Shader.GetGlobalTexture( "_CameraGBufferTexture2" );

        // Set
        // int kernelHandle = raymarching.FindKernel("CSMain");
        // raymarching.SetTextureFromGlobal(kernelHandle, Shader.PropertyToID("_CameraDepthTexture"), Shader.PropertyToID("_CameraDepthTexture"));
        // raymarching.SetTexture( 0, "_CameraGBufferTexture2", gBuffer2 );

        // raymarching.SetTextureFromGlobal(0, "_DepthTexture", "_CameraDepthTexture");
    }
Exemplo n.º 25
0
        public override bool Place(Point origin, StructureMap structures)
        {
            Point result1;

            if (!WorldUtils.Find(origin,
                                 Searches.Chain(new Searches.Down(200), (GenCondition) new Conditions.IsSolid()),
                                 out result1) || result1 == origin)
            {
                return(false);
            }
            var room1 = GetRoom(result1);
            var room2 = GetRoom(new Point(room1.Center.X, room1.Y + 1));
            var room3 =
                GetRoom(new Point(room1.Center.X, room1.Y + room1.Height + 10));

            room3.Y = room1.Y + room1.Height - 1;
            var num1 = RoomSolidPrecentage(room2);
            var num2 = RoomSolidPrecentage(room3);

            room1.Y += 3;
            room2.Y += 3;
            room3.Y += 3;
            var rectangleList1 = new List <Rectangle>();

            if (_random.NextFloat() > num1 + 0.200000002980232)
            {
                rectangleList1.Add(room2);
            }
            else
            {
                room2 = room1;
            }
            rectangleList1.Add(room1);
            if (_random.NextFloat() > num2 + 0.200000002980232)
            {
                rectangleList1.Add(room3);
            }
            else
            {
                room3 = room1;
            }
            foreach (var rectangle in rectangleList1)
            {
                if (rectangle.Y + rectangle.Height > Main.maxTilesY - 220)
                {
                    return(false);
                }
            }

            var resultsOutput = new Dictionary <ushort, int>();

            foreach (var rectangle in rectangleList1)
            {
                WorldUtils.Gen(new Point(rectangle.X - 10, rectangle.Y - 10),
                               new Shapes.Rectangle(rectangle.Width + 20, rectangle.Height + 20),
                               new Actions.TileScanner((ushort)0, (ushort)59, (ushort)147, (ushort)1, (ushort)161,
                                                       (ushort)53, (ushort)396, (ushort)397, (ushort)368, (ushort)367, (ushort)60,
                                                       (ushort)70)
                               .Output(resultsOutput));
            }
            var tupleList1 = new List <Tuple <BuildData, int> >();

            tupleList1.Add(Tuple.Create(BuildData.Default,
                                        resultsOutput[0] + resultsOutput[1]));
            tupleList1.Add(Tuple.Create(BuildData.Jungle,
                                        resultsOutput[59] + resultsOutput[60] * 10));
            tupleList1.Add(Tuple.Create(BuildData.Mushroom,
                                        resultsOutput[59] + resultsOutput[70] * 10));
            tupleList1.Add(Tuple.Create(BuildData.Snow,
                                        resultsOutput[147] + resultsOutput[161]));
            tupleList1.Add(Tuple.Create(BuildData.Desert,
                                        resultsOutput[397] + resultsOutput[396] + resultsOutput[53]));
            tupleList1.Add(Tuple.Create(BuildData.Granite,
                                        resultsOutput[368]));
            tupleList1.Add(Tuple.Create(BuildData.Marble,
                                        resultsOutput[367]));
            tupleList1.Sort(SortBiomeResults);
            var buildData = tupleList1[0].Item1;

            foreach (var area in rectangleList1)
            {
                if (buildData != BuildData.Granite)
                {
                    Point result2;
                    if (WorldUtils.Find(new Point(area.X - 2, area.Y - 2),
                                        Searches.Chain(new Searches.Rectangle(area.Width + 4, area.Height + 4).RequireAll(false),
                                                       (GenCondition) new Conditions.HasLava()), out result2))
                    {
                        return(false);
                    }
                }

                if (!structures.CanPlace(area, _blacklistedTiles, 5))
                {
                    return(false);
                }
            }

            var val1_1         = room1.X;
            var val1_2         = room1.X + room1.Width - 1;
            var rectangleList2 = new List <Rectangle>();

            foreach (var rectangle in rectangleList1)
            {
                val1_1 = Math.Min(val1_1, rectangle.X);
                val1_2 = Math.Max(val1_2, rectangle.X + rectangle.Width - 1);
            }

            var num3 = 6;

            while (num3 > 4 && (val1_2 - val1_1) % num3 != 0)
            {
                --num3;
            }
            var x1 = val1_1;

            while (x1 <= val1_2)
            {
                for (var index1 = 0; index1 < rectangleList1.Count; ++index1)
                {
                    var rectangle = rectangleList1[index1];
                    if (x1 >= rectangle.X && x1 < rectangle.X + rectangle.Width)
                    {
                        var y    = rectangle.Y + rectangle.Height;
                        var num4 = 50;
                        for (var index2 = index1 + 1; index2 < rectangleList1.Count; ++index2)
                        {
                            if (x1 >= rectangleList1[index2].X &&
                                x1 < rectangleList1[index2].X + rectangleList1[index2].Width)
                            {
                                num4 = Math.Min(num4, rectangleList1[index2].Y - y);
                            }
                        }

                        if (num4 > 0)
                        {
                            Point result2;
                            var   flag = WorldUtils.Find(new Point(x1, y),
                                                         Searches.Chain(new Searches.Down(num4),
                                                                        (GenCondition) new Conditions.IsSolid()), out result2);
                            if (num4 < 50)
                            {
                                flag    = true;
                                result2 = new Point(x1, y + num4);
                            }

                            if (flag)
                            {
                                rectangleList2.Add(new Rectangle(x1, y, 1, result2.Y - y));
                            }
                        }
                    }
                }

                x1 += num3;
            }

            var pointList1 = new List <Point>();

            foreach (var rectangle in rectangleList1)
            {
                int exitY;
                if (FindSideExit(
                        new Rectangle(rectangle.X + rectangle.Width, rectangle.Y + 1, 1,
                                      rectangle.Height - 2), false, out exitY))
                {
                    pointList1.Add(new Point(rectangle.X + rectangle.Width - 1, exitY));
                }
                if (FindSideExit(
                        new Rectangle(rectangle.X, rectangle.Y + 1, 1, rectangle.Height - 2), true,
                        out exitY))
                {
                    pointList1.Add(new Point(rectangle.X, exitY));
                }
            }

            var tupleList2 = new List <Tuple <Point, Point> >();

            for (var index = 1; index < rectangleList1.Count; ++index)
            {
                var rectangle1 = rectangleList1[index];
                var rectangle2 = rectangleList1[index - 1];
                if (rectangle2.X - rectangle1.X > rectangle1.X + rectangle1.Width - (rectangle2.X + rectangle2.Width))
                {
                    tupleList2.Add(new Tuple <Point, Point>(
                                       new Point(rectangle1.X + rectangle1.Width - 1, rectangle1.Y + 1),
                                       new Point(rectangle1.X + rectangle1.Width - rectangle1.Height + 1,
                                                 rectangle1.Y + rectangle1.Height - 1)));
                }
                else
                {
                    tupleList2.Add(new Tuple <Point, Point>(new Point(rectangle1.X, rectangle1.Y + 1),
                                                            new Point(rectangle1.X + rectangle1.Height - 1, rectangle1.Y + rectangle1.Height - 1)));
                }
            }

            var pointList2 = new List <Point>();
            int exitX;

            if (FindVerticalExit(new Rectangle(room2.X + 2, room2.Y, room2.Width - 4, 1),
                                 true, out exitX))
            {
                pointList2.Add(new Point(exitX, room2.Y));
            }
            if (FindVerticalExit(
                    new Rectangle(room3.X + 2, room3.Y + room3.Height - 1, room3.Width - 4, 1),
                    false, out exitX))
            {
                pointList2.Add(new Point(exitX, room3.Y + room3.Height - 1));
            }
            foreach (var area in rectangleList1)
            {
                WorldUtils.Gen(new Point(area.X, area.Y), new Shapes.Rectangle(area.Width, area.Height),
                               Actions.Chain((GenAction) new Actions.SetTile(buildData.Tile, false, true),
                                             (GenAction) new Actions.SetFrames(true)));
                WorldUtils.Gen(new Point(area.X + 1, area.Y + 1),
                               new Shapes.Rectangle(area.Width - 2, area.Height - 2),
                               Actions.Chain((GenAction) new Actions.ClearTile(true),
                                             (GenAction) new Actions.PlaceWall(buildData.Wall, true)));
                structures.AddStructure(area, 8);
            }

            foreach (var tuple in tupleList2)
            {
                var origin1 = tuple.Item1;
                var point   = tuple.Item2;
                var num4    = point.X > origin1.X ? 1 : -1;
                var data    = new ShapeData();
                for (var y = 0; y < point.Y - origin1.Y; ++y)
                {
                    data.Add(num4 * (y + 1), y);
                }
                WorldUtils.Gen(origin1, new ModShapes.All(data),
                               Actions.Chain((GenAction) new Actions.PlaceTile(19, buildData.PlatformStyle),
                                             (GenAction) new Actions.SetSlope(num4 == 1 ? 1 : 2), (GenAction) new Actions.SetFrames(true)));
                WorldUtils.Gen(new Point(origin1.X + (num4 == 1 ? 1 : -4), origin1.Y - 1),
                               new Shapes.Rectangle(4, 1),
                               Actions.Chain((GenAction) new Actions.Clear(),
                                             (GenAction) new Actions.PlaceWall(buildData.Wall, true),
                                             (GenAction) new Actions.PlaceTile(19, buildData.PlatformStyle),
                                             (GenAction) new Actions.SetFrames(true)));
            }

            foreach (var origin1 in pointList1)
            {
                WorldUtils.Gen(origin1, new Shapes.Rectangle(1, 3), new Actions.ClearTile(true));
                WorldGen.PlaceTile(origin1.X, origin1.Y, 10, true, true, -1, buildData.DoorStyle);
            }

            foreach (var origin1 in pointList2)
            {
                var rectangle = new Shapes.Rectangle(3, 1);
                var action    = Actions.Chain((GenAction) new Actions.ClearMetadata(),
                                              (GenAction) new Actions.PlaceTile(19, buildData.PlatformStyle),
                                              (GenAction) new Actions.SetFrames(true));
                WorldUtils.Gen(origin1, rectangle, action);
            }

            foreach (var rectangle in rectangleList2)
            {
                if (rectangle.Height > 1 && _tiles[rectangle.X, rectangle.Y - 1].type != 19)
                {
                    WorldUtils.Gen(new Point(rectangle.X, rectangle.Y),
                                   new Shapes.Rectangle(rectangle.Width, rectangle.Height),
                                   Actions.Chain((GenAction) new Actions.SetTile(124, false, true),
                                                 (GenAction) new Actions.SetFrames(true)));
                    var tile = _tiles[rectangle.X, rectangle.Y + rectangle.Height];
                    tile.slope(0);
                    tile.halfBrick(false);
                }
            }

            var pointArray = new Point[7]
            {
                new Point(14, buildData.TableStyle), new Point(16, 0), new Point(18, buildData.WorkbenchStyle),
                new Point(86, 0), new Point(87, buildData.PianoStyle), new Point(94, 0),
                new Point(101, buildData.BookcaseStyle)
            };

            foreach (var rectangle in rectangleList1)
            {
                var num4 = rectangle.Width / 8;
                var num5 = rectangle.Width / (num4 + 1);
                var num6 = _random.Next(2);
                for (var index1 = 0; index1 < num4; ++index1)
                {
                    var num7 = (index1 + 1) * num5 + rectangle.X;
                    switch (index1 + num6 % 2)
                    {
                    case 0:
                        var num8    = rectangle.Y + Math.Min(rectangle.Height / 2, rectangle.Height - 5);
                        var vector2 = WorldGen.randHousePicture();
                        var x2      = (int)vector2.X;
                        var y       = (int)vector2.Y;
                        if (!WorldGen.nearPicture(num7, num8))
                        {
                            WorldGen.PlaceTile(num7, num8, x2, true, false, -1, y);
                        }

                        break;

                    case 1:
                        var j = rectangle.Y + 1;
                        WorldGen.PlaceTile(num7, j, 34, true, false, -1, _random.Next(6));
                        for (var index2 = -1; index2 < 2; ++index2)
                        {
                            for (var index3 = 0; index3 < 3; ++index3)
                            {
                                _tiles[index2 + num7, index3 + j].frameX += 54;
                            }
                        }

                        break;
                    }
                }

                var num9 = rectangle.Width / 8 + 3;
                WorldGen.SetupStatueList();
                for (; num9 > 0; --num9)
                {
                    var num7 = _random.Next(rectangle.Width - 3) + 1 + rectangle.X;
                    var num8 = rectangle.Y + rectangle.Height - 2;
                    switch (_random.Next(4))
                    {
                    case 0:
                        WorldGen.PlaceSmallPile(num7, num8, _random.Next(31, 34), 1, 185);
                        break;

                    case 1:
                        WorldGen.PlaceTile(num7, num8, 186, true, false, -1, _random.Next(22, 26));
                        break;

                    case 2:
                        var index = _random.Next(2, WorldGen.statueList.Length);
                        WorldGen.PlaceTile(num7, num8, WorldGen.statueList[index].X, true, false, -1,
                                           WorldGen.statueList[index].Y);
                        if (WorldGen.StatuesWithTraps.Contains(index))
                        {
                            WorldGen.PlaceStatueTrap(num7, num8);
                        }

                        break;

                    case 3:
                        var point = Utils.SelectRandom(_random, pointArray);
                        WorldGen.PlaceTile(num7, num8, point.X, true, false, -1, point.Y);
                        break;
                    }
                }
            }

            foreach (var room4 in rectangleList1)
            {
                buildData.ProcessRoom(room4);
            }
            var flag1 = false;

            foreach (var rectangle in rectangleList1)
            {
                var j     = rectangle.Height - 1 + rectangle.Y;
                var Style = j > (int)Main.worldSurface ? buildData.ChestStyle : 0;
                var num4  = 0;
                while (num4 < 10 && !(flag1 =
                                          WorldGen.AddBuriedChest(_random.Next(2, rectangle.Width - 2) + rectangle.X, j, 0,
                                                                  false, Style)))
                {
                    ++num4;
                }
                if (!flag1)
                {
                    var i = rectangle.X + 2;
                    while (i <= rectangle.X + rectangle.Width - 2 &&
                           !(flag1 = WorldGen.AddBuriedChest(i, j, 0, false, Style)))
                    {
                        ++i;
                    }
                    if (flag1)
                    {
                        break;
                    }
                }
                else
                {
                    break;
                }
            }

            if (!flag1)
            {
                foreach (var rectangle in rectangleList1)
                {
                    var j     = rectangle.Y - 1;
                    var Style = j > (int)Main.worldSurface ? buildData.ChestStyle : 0;
                    var num4  = 0;
                    while (num4 < 10 && !(flag1 =
                                              WorldGen.AddBuriedChest(_random.Next(2, rectangle.Width - 2) + rectangle.X, j, 0,
                                                                      false, Style)))
                    {
                        ++num4;
                    }
                    if (!flag1)
                    {
                        var i = rectangle.X + 2;
                        while (i <= rectangle.X + rectangle.Width - 2 &&
                               !(flag1 = WorldGen.AddBuriedChest(i, j, 0, false, Style)))
                        {
                            ++i;
                        }
                        if (flag1)
                        {
                            break;
                        }
                    }
                    else
                    {
                        break;
                    }
                }
            }

            if (!flag1)
            {
                for (var index = 0; index < 1000; ++index)
                {
                    var i     = _random.Next(rectangleList1[0].X - 30, rectangleList1[0].X + 30);
                    var j     = _random.Next(rectangleList1[0].Y - 30, rectangleList1[0].Y + 30);
                    var Style = j > (int)Main.worldSurface ? buildData.ChestStyle : 0;
                    if (WorldGen.AddBuriedChest(i, j, 0, false, Style))
                    {
                        break;
                    }
                }
            }

            if (buildData == BuildData.Jungle && _sharpenerCount < _random.Next(2, 5))
            {
                var flag2 = false;
                foreach (var rectangle in rectangleList1)
                {
                    var j = rectangle.Height - 2 + rectangle.Y;
                    for (var index = 0; index < 10; ++index)
                    {
                        var i = _random.Next(2, rectangle.Width - 2) + rectangle.X;
                        WorldGen.PlaceTile(i, j, 377, true, true, -1, 0);
                        if (flag2 = _tiles[i, j].active() && _tiles[i, j].type == 377)
                        {
                            break;
                        }
                    }

                    if (!flag2)
                    {
                        var i = rectangle.X + 2;
                        while (i <= rectangle.X + rectangle.Width - 2 &&
                               !(flag2 = WorldGen.PlaceTile(i, j, 377, true, true, -1, 0)))
                        {
                            ++i;
                        }
                        if (flag2)
                        {
                            break;
                        }
                    }
                    else
                    {
                        break;
                    }
                }

                if (flag2)
                {
                    ++_sharpenerCount;
                }
            }

            if (buildData == BuildData.Desert && _extractinatorCount < _random.Next(2, 5))
            {
                var flag2 = false;
                foreach (var rectangle in rectangleList1)
                {
                    var j = rectangle.Height - 2 + rectangle.Y;
                    for (var index = 0; index < 10; ++index)
                    {
                        var i = _random.Next(2, rectangle.Width - 2) + rectangle.X;
                        WorldGen.PlaceTile(i, j, 219, true, true, -1, 0);
                        if (flag2 = _tiles[i, j].active() && _tiles[i, j].type == 219)
                        {
                            break;
                        }
                    }

                    if (!flag2)
                    {
                        var i = rectangle.X + 2;
                        while (i <= rectangle.X + rectangle.Width - 2 &&
                               !(flag2 = WorldGen.PlaceTile(i, j, 219, true, true, -1, 0)))
                        {
                            ++i;
                        }
                        if (flag2)
                        {
                            break;
                        }
                    }
                    else
                    {
                        break;
                    }
                }

                if (flag2)
                {
                    ++_extractinatorCount;
                }
            }

            return(true);
        }
Exemplo n.º 26
0
        public override bool Place(Point origin, StructureMap structures)
        {
            Point point;
            bool  flag = WorldUtils.Find(origin, Searches.Chain(new Searches.Down(200), new GenCondition[]
            {
                new Conditions.IsSolid()
            }), out point);

            if (!flag || point == origin)
            {
                return(false);
            }
            Rectangle room       = this.GetRoom(point);
            Rectangle rectangle  = this.GetRoom(new Point(room.Center.X, room.Y + 1));
            Rectangle rectangle2 = this.GetRoom(new Point(room.Center.X, room.Y + room.Height + 10));

            rectangle2.Y = room.Y + room.Height - 1;
            float num  = this.RoomSolidPrecentage(rectangle);
            float num2 = this.RoomSolidPrecentage(rectangle2);

            room.Y       += 3;
            rectangle.Y  += 3;
            rectangle2.Y += 3;
            List <Rectangle> list = new List <Rectangle>();

            if (GenBase._random.NextFloat() > num + 0.2f)
            {
                list.Add(rectangle);
            }
            else
            {
                rectangle = room;
            }
            list.Add(room);
            if (GenBase._random.NextFloat() > num2 + 0.2f)
            {
                list.Add(rectangle2);
            }
            else
            {
                rectangle2 = room;
            }
            foreach (Rectangle current in list)
            {
                if (current.Y + current.Height > Main.maxTilesY - 220)
                {
                    bool result = false;
                    return(result);
                }
            }
            Dictionary <ushort, int> dictionary = new Dictionary <ushort, int>();

            foreach (Rectangle current2 in list)
            {
                WorldUtils.Gen(new Point(current2.X - 10, current2.Y - 10), new Shapes.Rectangle(current2.Width + 20, current2.Height + 20), new Actions.TileScanner(new ushort[]
                {
                    0,
                    59,
                    147,
                    1,
                    161,
                    53,
                    396,
                    397,
                    368,
                    367,
                    60,
                    70
                }).Output(dictionary));
            }
            List <Tuple <CaveHouseBiome.BuildData, int> > list2 = new List <Tuple <CaveHouseBiome.BuildData, int> >();

            list2.Add(Tuple.Create <CaveHouseBiome.BuildData, int>(CaveHouseBiome.BuildData.Default, dictionary[0] + dictionary[1]));
            list2.Add(Tuple.Create <CaveHouseBiome.BuildData, int>(CaveHouseBiome.BuildData.Jungle, dictionary[59] + dictionary[60] * 10));
            list2.Add(Tuple.Create <CaveHouseBiome.BuildData, int>(CaveHouseBiome.BuildData.Mushroom, dictionary[59] + dictionary[70] * 10));
            list2.Add(Tuple.Create <CaveHouseBiome.BuildData, int>(CaveHouseBiome.BuildData.Snow, dictionary[147] + dictionary[161]));
            list2.Add(Tuple.Create <CaveHouseBiome.BuildData, int>(CaveHouseBiome.BuildData.Desert, dictionary[397] + dictionary[396] + dictionary[53]));
            list2.Add(Tuple.Create <CaveHouseBiome.BuildData, int>(CaveHouseBiome.BuildData.Granite, dictionary[368]));
            list2.Add(Tuple.Create <CaveHouseBiome.BuildData, int>(CaveHouseBiome.BuildData.Marble, dictionary[367]));
            list2.Sort(new Comparison <Tuple <CaveHouseBiome.BuildData, int> >(this.SortBiomeResults));
            CaveHouseBiome.BuildData item = list2[0].Item1;
            foreach (Rectangle current3 in list)
            {
                if (item != CaveHouseBiome.BuildData.Granite)
                {
                    Point point2;
                    bool  flag2 = WorldUtils.Find(new Point(current3.X - 2, current3.Y - 2), Searches.Chain(new Searches.Rectangle(current3.Width + 4, current3.Height + 4).RequireAll(false), new GenCondition[]
                    {
                        new Conditions.HasLava()
                    }), out point2);
                    if (flag2)
                    {
                        bool result = false;
                        return(result);
                    }
                }
                if (!structures.CanPlace(current3, CaveHouseBiome._blacklistedTiles, 5))
                {
                    bool result = false;
                    return(result);
                }
            }
            int num3 = room.X;
            int num4 = room.X + room.Width - 1;
            List <Rectangle> list3 = new List <Rectangle>();

            foreach (Rectangle current4 in list)
            {
                num3 = Math.Min(num3, current4.X);
                num4 = Math.Max(num4, current4.X + current4.Width - 1);
            }
            int num5 = 6;

            while (num5 > 4 && (num4 - num3) % num5 != 0)
            {
                num5--;
            }
            for (int i = num3; i <= num4; i += num5)
            {
                for (int j = 0; j < list.Count; j++)
                {
                    Rectangle rectangle3 = list[j];
                    if (i >= rectangle3.X && i < rectangle3.X + rectangle3.Width)
                    {
                        int num6 = rectangle3.Y + rectangle3.Height;
                        int num7 = 50;
                        for (int k = j + 1; k < list.Count; k++)
                        {
                            if (i >= list[k].X && i < list[k].X + list[k].Width)
                            {
                                num7 = Math.Min(num7, list[k].Y - num6);
                            }
                        }
                        if (num7 > 0)
                        {
                            Point point3;
                            bool  flag3 = WorldUtils.Find(new Point(i, num6), Searches.Chain(new Searches.Down(num7), new GenCondition[]
                            {
                                new Conditions.IsSolid()
                            }), out point3);
                            if (num7 < 50)
                            {
                                flag3  = true;
                                point3 = new Point(i, num6 + num7);
                            }
                            if (flag3)
                            {
                                list3.Add(new Rectangle(i, num6, 1, point3.Y - num6));
                            }
                        }
                    }
                }
            }
            List <Point> list4 = new List <Point>();

            foreach (Rectangle current5 in list)
            {
                int  y;
                bool flag4 = this.FindSideExit(new Rectangle(current5.X + current5.Width, current5.Y + 1, 1, current5.Height - 2), false, out y);
                if (flag4)
                {
                    list4.Add(new Point(current5.X + current5.Width - 1, y));
                }
                flag4 = this.FindSideExit(new Rectangle(current5.X, current5.Y + 1, 1, current5.Height - 2), true, out y);
                if (flag4)
                {
                    list4.Add(new Point(current5.X, y));
                }
            }
            List <Tuple <Point, Point> > list5 = new List <Tuple <Point, Point> >();

            for (int l = 1; l < list.Count; l++)
            {
                Rectangle rectangle4 = list[l];
                Rectangle rectangle5 = list[l - 1];
                int       num8       = rectangle5.X - rectangle4.X;
                int       num9       = rectangle4.X + rectangle4.Width - (rectangle5.X + rectangle5.Width);
                if (num8 > num9)
                {
                    list5.Add(new Tuple <Point, Point>(new Point(rectangle4.X + rectangle4.Width - 1, rectangle4.Y + 1), new Point(rectangle4.X + rectangle4.Width - rectangle4.Height + 1, rectangle4.Y + rectangle4.Height - 1)));
                }
                else
                {
                    list5.Add(new Tuple <Point, Point>(new Point(rectangle4.X, rectangle4.Y + 1), new Point(rectangle4.X + rectangle4.Height - 1, rectangle4.Y + rectangle4.Height - 1)));
                }
            }
            List <Point> list6 = new List <Point>();
            int          x;
            bool         flag5 = this.FindVerticalExit(new Rectangle(rectangle.X + 2, rectangle.Y, rectangle.Width - 4, 1), true, out x);

            if (flag5)
            {
                list6.Add(new Point(x, rectangle.Y));
            }
            flag5 = this.FindVerticalExit(new Rectangle(rectangle2.X + 2, rectangle2.Y + rectangle2.Height - 1, rectangle2.Width - 4, 1), false, out x);
            if (flag5)
            {
                list6.Add(new Point(x, rectangle2.Y + rectangle2.Height - 1));
            }
            foreach (Rectangle current6 in list)
            {
                WorldUtils.Gen(new Point(current6.X, current6.Y), new Shapes.Rectangle(current6.Width, current6.Height), Actions.Chain(new GenAction[]
                {
                    new Actions.SetTile(item.Tile, false, true),
                    new Actions.SetFrames(true)
                }));
                WorldUtils.Gen(new Point(current6.X + 1, current6.Y + 1), new Shapes.Rectangle(current6.Width - 2, current6.Height - 2), Actions.Chain(new GenAction[]
                {
                    new Actions.ClearTile(true),
                    new Actions.PlaceWall(item.Wall, true)
                }));
                structures.AddStructure(current6, 8);
            }
            foreach (Tuple <Point, Point> current7 in list5)
            {
                Point     item2     = current7.Item1;
                Point     item3     = current7.Item2;
                int       num10     = (item3.X > item2.X) ? 1 : -1;
                ShapeData shapeData = new ShapeData();
                for (int m = 0; m < item3.Y - item2.Y; m++)
                {
                    shapeData.Add(num10 * (m + 1), m);
                }
                WorldUtils.Gen(item2, new ModShapes.All(shapeData), Actions.Chain(new GenAction[]
                {
                    new Actions.PlaceTile(19, item.PlatformStyle),
                    new Actions.SetSlope((num10 == 1) ? 1 : 2),
                    new Actions.SetFrames(true)
                }));
                WorldUtils.Gen(new Point(item2.X + ((num10 == 1) ? 1 : -4), item2.Y - 1), new Shapes.Rectangle(4, 1), Actions.Chain(new GenAction[]
                {
                    new Actions.Clear(),
                    new Actions.PlaceWall(item.Wall, true),
                    new Actions.PlaceTile(19, item.PlatformStyle),
                    new Actions.SetFrames(true)
                }));
            }
            foreach (Point current8 in list4)
            {
                WorldUtils.Gen(current8, new Shapes.Rectangle(1, 3), new Actions.ClearTile(true));
                WorldGen.PlaceTile(current8.X, current8.Y, 10, true, true, -1, item.DoorStyle);
            }
            foreach (Point current9 in list6)
            {
                WorldUtils.Gen(current9, new Shapes.Rectangle(3, 1), Actions.Chain(new GenAction[]
                {
                    new Actions.ClearMetadata(),
                    new Actions.PlaceTile(19, item.PlatformStyle),
                    new Actions.SetFrames(true)
                }));
            }
            foreach (Rectangle current10 in list3)
            {
                if (current10.Height > 1 && GenBase._tiles[current10.X, current10.Y - 1].type != 19)
                {
                    WorldUtils.Gen(new Point(current10.X, current10.Y), new Shapes.Rectangle(current10.Width, current10.Height), Actions.Chain(new GenAction[]
                    {
                        new Actions.SetTile(124, false, true),
                        new Actions.SetFrames(true)
                    }));
                    Tile tile = GenBase._tiles[current10.X, current10.Y + current10.Height];
                    tile.slope(0);
                    tile.halfBrick(false);
                }
            }
            Point[] choices = new Point[]
            {
                new Point(14, item.TableStyle),
                new Point(16, 0),
                new Point(18, item.WorkbenchStyle),
                new Point(86, 0),
                new Point(87, item.PianoStyle),
                new Point(94, 0),
                new Point(101, item.BookcaseStyle)
            };
            foreach (Rectangle current11 in list)
            {
                int num11 = current11.Width / 8;
                int num12 = current11.Width / (num11 + 1);
                int num13 = GenBase._random.Next(2);
                for (int n = 0; n < num11; n++)
                {
                    int num14 = (n + 1) * num12 + current11.X;
                    switch (n + num13 % 2)
                    {
                    case 0:
                    {
                        int     num15  = current11.Y + Math.Min(current11.Height / 2, current11.Height - 5);
                        Vector2 vector = WorldGen.randHousePicture();
                        int     type   = (int)vector.X;
                        int     style  = (int)vector.Y;
                        if (!WorldGen.nearPicture(num14, num15))
                        {
                            WorldGen.PlaceTile(num14, num15, type, true, false, -1, style);
                        }
                        break;
                    }

                    case 1:
                    {
                        int num15 = current11.Y + 1;
                        WorldGen.PlaceTile(num14, num15, 34, true, false, -1, GenBase._random.Next(6));
                        for (int num16 = -1; num16 < 2; num16++)
                        {
                            for (int num17 = 0; num17 < 3; num17++)
                            {
                                Tile expr_E7C = GenBase._tiles[num16 + num14, num17 + num15];
                                expr_E7C.frameX += 54;
                            }
                        }
                        break;
                    }
                    }
                }
                int num18 = current11.Width / 8 + 3;
                WorldGen.SetupStatueList();
                while (num18 > 0)
                {
                    int num19 = GenBase._random.Next(current11.Width - 3) + 1 + current11.X;
                    int num20 = current11.Y + current11.Height - 2;
                    switch (GenBase._random.Next(4))
                    {
                    case 0:
                        WorldGen.PlaceSmallPile(num19, num20, GenBase._random.Next(31, 34), 1, 185);
                        break;

                    case 1:
                        WorldGen.PlaceTile(num19, num20, 186, true, false, -1, GenBase._random.Next(22, 26));
                        break;

                    case 2:
                    {
                        int num21 = GenBase._random.Next(2, WorldGen.statueList.Length);
                        WorldGen.PlaceTile(num19, num20, (int)WorldGen.statueList[num21].X, true, false, -1, (int)WorldGen.statueList[num21].Y);
                        if (WorldGen.StatuesWithTraps.Contains(num21))
                        {
                            WorldGen.PlaceStatueTrap(num19, num20);
                        }
                        break;
                    }

                    case 3:
                    {
                        Point point4 = Utils.SelectRandom <Point>(GenBase._random, choices);
                        WorldGen.PlaceTile(num19, num20, point4.X, true, false, -1, point4.Y);
                        break;
                    }
                    }
                    num18--;
                }
            }
            foreach (Rectangle current12 in list)
            {
                item.ProcessRoom(current12);
            }
            bool flag6 = false;

            foreach (Rectangle current13 in list)
            {
                int num22  = current13.Height - 1 + current13.Y;
                int style2 = (num22 > (int)Main.worldSurface) ? item.ChestStyle : 0;
                for (int num23 = 0; num23 < 10; num23++)
                {
                    int i2 = GenBase._random.Next(2, current13.Width - 2) + current13.X;
                    if (flag6 = WorldGen.AddBuriedChest(i2, num22, 0, false, style2))
                    {
                        break;
                    }
                }
                if (flag6)
                {
                    break;
                }
                int num24 = current13.X + 2;
                while (num24 <= current13.X + current13.Width - 2 && !(flag6 = WorldGen.AddBuriedChest(num24, num22, 0, false, style2)))
                {
                    num24++;
                }
                if (flag6)
                {
                    break;
                }
            }
            if (!flag6)
            {
                foreach (Rectangle current14 in list)
                {
                    int num25  = current14.Y - 1;
                    int style3 = (num25 > (int)Main.worldSurface) ? item.ChestStyle : 0;
                    for (int num26 = 0; num26 < 10; num26++)
                    {
                        int i3 = GenBase._random.Next(2, current14.Width - 2) + current14.X;
                        if (flag6 = WorldGen.AddBuriedChest(i3, num25, 0, false, style3))
                        {
                            break;
                        }
                    }
                    if (flag6)
                    {
                        break;
                    }
                    int num27 = current14.X + 2;
                    while (num27 <= current14.X + current14.Width - 2 && !(flag6 = WorldGen.AddBuriedChest(num27, num25, 0, false, style3)))
                    {
                        num27++;
                    }
                    if (flag6)
                    {
                        break;
                    }
                }
            }
            if (!flag6)
            {
                for (int num28 = 0; num28 < 1000; num28++)
                {
                    int i4     = GenBase._random.Next(list[0].X - 30, list[0].X + 30);
                    int num29  = GenBase._random.Next(list[0].Y - 30, list[0].Y + 30);
                    int style4 = (num29 > (int)Main.worldSurface) ? item.ChestStyle : 0;
                    if (flag6 = WorldGen.AddBuriedChest(i4, num29, 0, false, style4))
                    {
                        break;
                    }
                }
            }
            if (item == CaveHouseBiome.BuildData.Jungle && this._sharpenerCount < GenBase._random.Next(2, 5))
            {
                bool flag7 = false;
                foreach (Rectangle current15 in list)
                {
                    int num30 = current15.Height - 2 + current15.Y;
                    for (int num31 = 0; num31 < 10; num31++)
                    {
                        int num32 = GenBase._random.Next(2, current15.Width - 2) + current15.X;
                        WorldGen.PlaceTile(num32, num30, 377, true, true, -1, 0);
                        if (flag7 = (GenBase._tiles[num32, num30].active() && GenBase._tiles[num32, num30].type == 377))
                        {
                            break;
                        }
                    }
                    if (flag7)
                    {
                        break;
                    }
                    int num33 = current15.X + 2;
                    while (num33 <= current15.X + current15.Width - 2 && !(flag7 = WorldGen.PlaceTile(num33, num30, 377, true, true, -1, 0)))
                    {
                        num33++;
                    }
                    if (flag7)
                    {
                        break;
                    }
                }
                if (flag7)
                {
                    this._sharpenerCount++;
                }
            }
            if (item == CaveHouseBiome.BuildData.Desert && this._extractinatorCount < GenBase._random.Next(2, 5))
            {
                bool flag8 = false;
                foreach (Rectangle current16 in list)
                {
                    int num34 = current16.Height - 2 + current16.Y;
                    for (int num35 = 0; num35 < 10; num35++)
                    {
                        int num36 = GenBase._random.Next(2, current16.Width - 2) + current16.X;
                        WorldGen.PlaceTile(num36, num34, 219, true, true, -1, 0);
                        if (flag8 = (GenBase._tiles[num36, num34].active() && GenBase._tiles[num36, num34].type == 219))
                        {
                            break;
                        }
                    }
                    if (flag8)
                    {
                        break;
                    }
                    int num37 = current16.X + 2;
                    while (num37 <= current16.X + current16.Width - 2 && !(flag8 = WorldGen.PlaceTile(num37, num34, 219, true, true, -1, 0)))
                    {
                        num37++;
                    }
                    if (flag8)
                    {
                        break;
                    }
                }
                if (flag8)
                {
                    this._extractinatorCount++;
                }
            }
            return(true);
        }
Exemplo n.º 27
0
 /// <summary>
 /// Register <see cref="ShapeData"/> to be managed by Morro.
 /// </summary>
 /// <param name="name">The name that the shape data being registered will be referenced as.</param>
 /// <param name="shapeData">The shape data you want to be registered.</param>
 public static void RegisterShapeData(string name, ShapeData shapeData)
 {
     shapes.Register(name, shapeData);
 }
Exemplo n.º 28
0
        public override bool Place(Point origin, StructureMap structures)
        {
            Ref <int> count1 = new Ref <int>(0);
            Ref <int> count2 = new Ref <int>(0);

            WorldUtils.Gen(origin, (GenShape) new Shapes.Circle(10), Actions.Chain((GenAction) new Actions.Scanner(count2), (GenAction) new Modifiers.IsSolid(), (GenAction) new Actions.Scanner(count1)));
            if (count1.Value < count2.Value - 5)
            {
                return(false);
            }
            int radius = GenBase._random.Next(6, 10);
            int num1   = GenBase._random.Next(5);

            if (!structures.CanPlace(new Microsoft.Xna.Framework.Rectangle(origin.X - radius, origin.Y - radius, radius * 2, radius * 2), 0))
            {
                return(false);
            }
            ShapeData data = new ShapeData();

            WorldUtils.Gen(origin, (GenShape) new Shapes.Slime(radius), Actions.Chain(new Modifiers.Blotches(num1, num1, num1, 1, 0.3).Output(data), (GenAction) new Modifiers.Offset(0, -2), (GenAction) new Modifiers.OnlyTiles(new ushort[1]
            {
                (ushort)53
            }), (GenAction) new Actions.SetTile((ushort)397, true, true), (GenAction) new Modifiers.OnlyWalls(new byte[1]), (GenAction) new Actions.PlaceWall((byte)16, true)));
            WorldUtils.Gen(origin, (GenShape) new ModShapes.All(data), Actions.Chain((GenAction) new Actions.ClearTile(false), (GenAction) new Actions.SetLiquid(0, (byte)0), (GenAction) new Actions.SetFrames(true), (GenAction) new Modifiers.OnlyWalls(new byte[1]), (GenAction) new Actions.PlaceWall((byte)16, true)));
            Point result;

            if (!WorldUtils.Find(origin, Searches.Chain((GenSearch) new Searches.Down(10), (GenCondition) new Conditions.IsSolid()), out result))
            {
                return(false);
            }
            int  j    = result.Y - 1;
            bool flag = GenBase._random.Next() % 2 == 0;

            if (GenBase._random.Next() % 10 != 0)
            {
                int num2 = GenBase._random.Next(1, 4);
                int num3 = flag ? 4 : -(radius >> 1);
                for (int index1 = 0; index1 < num2; ++index1)
                {
                    int num4 = GenBase._random.Next(1, 3);
                    for (int index2 = 0; index2 < num4; ++index2)
                    {
                        WorldGen.PlaceTile(origin.X + num3 - index1, j - index2, 331, false, false, -1, 0);
                    }
                }
            }
            int num5 = (radius - 3) * (flag ? -1 : 1);

            if (GenBase._random.Next() % 10 != 0)
            {
                WorldGen.PlaceTile(origin.X + num5, j, 186, false, false, -1, 0);
            }
            if (GenBase._random.Next() % 10 != 0)
            {
                WorldGen.PlaceTile(origin.X, j, 215, true, false, -1, 0);
                if (GenBase._tiles[origin.X, j].active() && (int)GenBase._tiles[origin.X, j].type == 215)
                {
                    GenBase._tiles[origin.X, j].frameY         += (short)36;
                    GenBase._tiles[origin.X - 1, j].frameY     += (short)36;
                    GenBase._tiles[origin.X + 1, j].frameY     += (short)36;
                    GenBase._tiles[origin.X, j - 1].frameY     += (short)36;
                    GenBase._tiles[origin.X - 1, j - 1].frameY += (short)36;
                    GenBase._tiles[origin.X + 1, j - 1].frameY += (short)36;
                }
            }
            structures.AddStructure(new Microsoft.Xna.Framework.Rectangle(origin.X - radius, origin.Y - radius, radius * 2, radius * 2), 4);
            return(true);
        }
Exemplo n.º 29
0
 private static IEnumerable <PointZM> GetVertices(ShapeData g)
 {
     return(Enumerable.Range(1, g.NumPoints).Select(s => g.GetPointN(s)));
 }
Exemplo n.º 30
0
        ShapeData ConstructAndAddShape(TypeId typeId)
        {
            UIElement element;

            if (typeId == TypeId.Line)
            {
                var line = new Line {
                    StrokeEndLineCap   = PenLineCap.Round,
                    StrokeStartLineCap = PenLineCap.Round,
                };
                element = line;
            }
            else if (typeId == TypeId.Polyline)
            {
                var line = new Polyline {
                    StrokeEndLineCap   = PenLineCap.Round,
                    StrokeStartLineCap = PenLineCap.Round,
                    StrokeLineJoin     = PenLineJoin.Round,
                };
                element = line;
            }
            else if (typeId == TypeId.Text)
            {
                element = new TextBlock();
            }
            else if (typeId == TypeId.Oval)
            {
                element = new Ellipse();
            }
            else if (typeId == TypeId.Arc)
            {
                element = new Path {
                    StrokeEndLineCap = PenLineCap.Round, StrokeStartLineCap = PenLineCap.Round,
                };
            }
            else if (typeId == TypeId.RoundedRect)
            {
                element = new Rectangle();
            }
            else if (typeId == TypeId.Rect)
            {
                element = new Rectangle();
            }
            else if (typeId == TypeId.Image)
            {
                element = new NativeImage();
            }
            else if (typeId == TypeId.Polygon)
            {
                element = new NativePolygon();
            }
            else
            {
                throw new NotSupportedException("Don't know how to construct: " + typeId);
            }

            var sd = new ShapeData {
                Element = element,
                TypeId  = typeId,
            };

            _shapes.Add(sd);

            //
            // Insert it in the right place so it gets drawn in the right order
            //
            if (_lastAddElementIndex >= 0)
            {
                _lastAddElementIndex++;
                _canvas.Children.Insert(_lastAddElementIndex, element);
            }
            else
            {
                if (_lastShape != null)
                {
                    _lastAddElementIndex = _canvas.Children.IndexOf(_lastShape.Element) + 1;
                    _canvas.Children.Insert(_lastAddElementIndex, element);
                }
                else
                {
                    _lastAddElementIndex = _canvas.Children.Count;
                    _canvas.Children.Add(element);
                }
            }

            return(sd);
        }
Exemplo n.º 31
0
        void PushToWorld()
        {
            if( Shapes.Length == 0 )
                return;

            shapesData = new ShapeData[ Shapes.Length ];

            //position, rotation
            Vec3 position = Position;
            Quat rotation = Rotation;
            nativeBody = PhysXNativeWorld.CreateBody( scene.nativeScene, Static, ref position, ref rotation );

            if( !Static )
            {
                PhysXNativeBody.SetLinearDamping( nativeBody, LinearDamping );
                PhysXNativeBody.SetAngularDamping( nativeBody, AngularDamping );

                Vec3 linearVelocity = LinearVelocity;
                PhysXNativeBody.SetLinearVelocity( nativeBody, ref linearVelocity );

                Vec3 angularVelocity = AngularVelocity;
                PhysXNativeBody.SetAngularVelocity( nativeBody, ref angularVelocity );

                if( !EnableGravity )
                    PhysXNativeBody.SetGravity( nativeBody, false );

                UpdateMaxAngularVelocity();

                PhysXNativeBody.SetSolverIterationCounts( nativeBody, PhysX_SolverPositionIterations,
                    PhysX_SolverVelocityIterations );

                if( PhysX_Kinematic )
                    PhysXNativeBody.SetKinematicFlag( nativeBody, true );
            }

            int[] nativeShapesCount = new int[ Shapes.Length ];
            List<ushort> materialIndexes = new List<ushort>( Shapes.Length );

            //shapes

            float totalVolume = 0;
            if( MassMethod == MassMethods.Manually && !Static )
            {
                for( int nShape = 0; nShape < Shapes.Length; nShape++ )
                    totalVolume += Shapes[ nShape ].Volume;
                if( totalVolume == 0 )
                    totalVolume = .001f;
            }

            for( int nShape = 0; nShape < Shapes.Length; nShape++ )
            {
                Shape shape = Shapes[ nShape ];

                ShapeData shapeData = new ShapeData();
                shapesData[ nShape ] = shapeData;

                switch( shape.ShapeType )
                {
                case Shape.Type.Box:
                    {
                        BoxShape boxShape = (BoxShape)shape;
                        CreateBoxShape( boxShape, totalVolume );
                        nativeShapesCount[ nShape ] = 1;
                    }
                    break;

                case Shape.Type.Sphere:
                    {
                        SphereShape sphereShape = (SphereShape)shape;
                        CreateSphereShape( sphereShape, totalVolume );
                        nativeShapesCount[ nShape ] = 1;
                    }
                    break;

                case Shape.Type.Capsule:
                    {
                        CapsuleShape capsuleShape = (CapsuleShape)shape;
                        CreateCapsuleShape( capsuleShape, totalVolume );
                        nativeShapesCount[ nShape ] = 1;
                    }
                    break;

                case Shape.Type.Cylinder:
                    Log.Warning( "PhysXBody: Cylinders are not supported by PhysX." );
                    //skip creation of this shape
                    continue;

                case Shape.Type.Mesh:
                    {
                        MeshShape meshShape = (MeshShape)shape;

                        if( !Static && meshShape.MeshType == MeshShape.MeshTypes.TriangleMesh )
                        {
                            Log.Warning( "PhysXBody: Dynamic triangle meshes are not supported by PhysX. " +
                                "You can consider using of convex hulls. See MeshShape.MeshType property." );
                            //skip creation of this shape
                            continue;
                        }

                        //get mesh geometry from cache
                        PhysicsWorld._MeshGeometry geometry = meshShape._GetMeshGeometry();

                        //skip creation of this shape
                        if( geometry == null )
                        {
                            Log.Info( "PhysXBody: Mesh is not initialized. ({0}).", meshShape.MeshName );
                            continue;
                        }

                        PhysXPhysicsWorld.MeshGeometryPhysXData data;

                        if( geometry.UserData == null )
                        {
                            //generate MeshGeometryPhysXData data
                            data = new PhysXPhysicsWorld.MeshGeometryPhysXData();

                            if( meshShape.MeshType == MeshShape.MeshTypes.ConvexHullDecomposition ||
                                meshShape.MeshType == MeshShape.MeshTypes.ConvexHull )
                            {
                                //convex mesh, convex mesh decomposition

                                PhysicsWorld.ConvexHullDecompositionDataItem[] items;
                                if( meshShape.MeshType == MeshShape.MeshTypes.ConvexHullDecomposition )
                                {
                                    items = geometry.GetConvexHullDecompositionData();
                                    if( items == null )
                                    {
                                        Log.Warning( "PhysXBody: Unable to do convex hull decomposite for \"{0}\".",
                                            meshShape.MeshName );
                                        //skip creation of this shape
                                        continue;
                                    }
                                }
                                else
                                {
                                    //Log.Warning( "START:" );
                                    //Log.Warning( "Before, vertices: {0}, triangles: {1}", geometry.Vertices.Length,
                                    //   geometry.Indices.Length / 3 );
                                    //if( FindNonConvexVertices( geometry.Vertices, geometry.Indices ) )
                                    //{
                                    //   Log.Warning( "FindNonConvexVertices found: " + meshShape.MeshName );
                                    //}

                                    Vec3[] vertices2;
                                    int[] indices2;
                                    float epsilon;
                                    {
                                        Bounds bounds = Bounds.Cleared;
                                        foreach( Vec3 vertex in geometry.Vertices )
                                            bounds.Add( vertex );
                                        Vec3 size = bounds.GetSize();
                                        float maxSide = Math.Max( Math.Max( size.X, size.Y ), size.Z );
                                        epsilon = maxSide / 10000;
                                    }
                                    MergeCloseVertices( geometry.Vertices, geometry.Indices, epsilon, out vertices2, out indices2 );

                                    //Log.Warning( "After, vertices: {0}, triangles: {1}", vertices2.Length, indices2.Length / 3 );

                                    items = new PhysicsWorld.ConvexHullDecompositionDataItem[] {
                                        new PhysicsWorld.ConvexHullDecompositionDataItem( vertices2, indices2 ) };
                                }

                                data.convexMeshes = new IntPtr[ items.Length ];

                                bool error = false;

                                for( int nItem = 0; nItem < items.Length; nItem++ )
                                {
                                    PhysicsWorld.ConvexHullDecompositionDataItem item = items[ nItem ];

                                    //create PxConvexMesh
                                    IntPtr pxConvexMesh = CreateConvexMesh( item );

                                    if( pxConvexMesh == IntPtr.Zero )
                                    {
                                        Log.Warning( "PhysXBody: Unable to cook a convex mesh for \"{0}\".",
                                            meshShape.MeshName );
                                        //skip creation of this shape
                                        error = true;
                                        break;
                                    }

                                    data.convexMeshes[ nItem ] = pxConvexMesh;
                                }

                                if( error )
                                {
                                    //skip creation of this shape
                                    continue;
                                }
                            }
                            else
                            {
                                //triangle mesh

                                DateTime startTime = DateTime.Now;

                                data.triangleMesh = CreateTriangleMesh( geometry );
                                if( data.triangleMesh == IntPtr.Zero )
                                {
                                    Log.Warning( "PhysXBody: Unable to cook a triangle mesh. ({0})", meshShape.MeshName );

                                    //skip creation of this shape
                                    continue;
                                }

                                cookTriangleMeshTotalTime += ( DateTime.Now - startTime ).TotalSeconds;
                                //Log.Info( "total time: " + cookTriangleMeshTotalTime.ToString() );
                            }

                            geometry.UserData = data;
                        }
                        else
                            data = (PhysXPhysicsWorld.MeshGeometryPhysXData)geometry.UserData;

                        //add PhysX shapes
                        if( data.convexMeshes != null )
                        {
                            //convex meshes
                            for( int n = 0; n < data.convexMeshes.Length; n++ )
                            {
                                CreateConvexMeshShape( shape, data.convexMeshes[ n ], totalVolume );
                            }
                            nativeShapesCount[ nShape ] = data.convexMeshes.Length;
                        }
                        else
                        {
                            //triangle mesh
                            CreateTriangleMeshShape( meshShape, data.triangleMesh, totalVolume );
                            nativeShapesCount[ nShape ] = 1;
                        }

                        data.checkRefCounter++;

                        shapeData.shapesMeshData = data;
                    }
                    break;

                case Shape.Type.HeightField:
                    {
                        HeightFieldShape heightFieldShape = (HeightFieldShape)shape;
                        CreateHeightFieldShape( heightFieldShape, totalVolume );
                        nativeShapesCount[ nShape ] = 1;
                    }
                    break;

                case Shape.Type._Custom1:
                    {
                        //create box as example
                        _Custom1Shape boxShape = (_Custom1Shape)shape;
                        CreateCustomShape( boxShape, totalVolume );
                        nativeShapesCount[ nShape ] = 1;
                    }
                    break;
                }
            }

            if( !Static )
            {
                Vec3 centerOfMassPosition = CenterOfMassPosition;
                Quat centerOfMassRotation = CenterOfMassRotation;
                Vec3 inertiaTensorFactor = InertiaTensorFactor;
                PhysXNativeBody.SetMassAndInertia( nativeBody, CenterOfMassAuto, ref centerOfMassPosition,
                    ref centerOfMassRotation, ref inertiaTensorFactor );
            }

            int totalPxShapes = 0;
            foreach( int count in nativeShapesCount )
                totalPxShapes += count;

            //no shapes
            if( totalPxShapes == 0 )
            {
                PhysXNativeWorld.DestroyBody( nativeBody );
                nativeBody = IntPtr.Zero;
                return;
            }

            //generate nativeShapes
            {
                int physXShapeCount = PhysXNativeBody.GetShapeCount( nativeBody );
                int currentShape = 0;
                for( int nShape = 0; nShape < Shapes.Length; nShape++ )
                {
                    ShapeData shapeData = shapesData[ nShape ];
                    int count = nativeShapesCount[ nShape ];
                    shapeData.nativeShapes = new IntPtr[ count ];
                    for( int n = 0; n < count; n++ )
                    {
                        shapeData.nativeShapes[ n ] = (IntPtr)PhysXNativeBody.GetShape( nativeBody, currentShape );
                        currentShape++;
                    }
                }
                if( physXShapeCount != currentShape )
                    Log.Fatal( "PhysXBody: PushToWorld: physXShapeCount != currentShape." );
            }

            //configure shapes dictionary
            for( int n = 0; n < Shapes.Length; n++ )
            {
                Shape shape = Shapes[ n ];
                ShapeData shapeData = shapesData[ n ];

                int dictionaryIdentifier = PhysXPhysicsWorld.Instance.shapesDictionary.Add( shape );
                foreach( IntPtr pxShape in shapeData.nativeShapes )
                    PhysXNativeShape.SetIdentifier( pxShape, dictionaryIdentifier );
            }

            //set contact pairs
            for( int n = 0; n < Shapes.Length; n++ )
            {
                Shape shape = Shapes[ n ];
                Dictionary<Shape, ShapePairFlags> list = shape._GetShapePairFlags();
                if( list != null )
                {
                    ShapeData shapeData = shapesData[ n ];

                    foreach( KeyValuePair<Shape, ShapePairFlags> pair in list )
                    {
                        Shape otherShape = pair.Key;
                        ShapePairFlags flags = pair.Value;

                        if( otherShape.Body.PushedToWorld && ( flags & ShapePairFlags.DisableContacts ) != 0 )
                        {
                            PhysXBody otherBody = (PhysXBody)otherShape.Body;

                            if( otherBody.nativeBody != null )
                            {
                                ShapeData otherShapeData = otherBody.shapesData[ otherShape.BodyIndex ];
                                foreach( IntPtr nativeShape in shapeData.nativeShapes )
                                {
                                    foreach( IntPtr nativeOtherShape in otherShapeData.nativeShapes )
                                        PhysXNativeScene.SetShapePairFlags( scene.nativeScene, nativeShape, nativeOtherShape, true );
                                }
                            }
                        }
                    }
                }
            }

            PhysXNativeWrapper.PhysXNativeScene.AddBody( scene.nativeScene, nativeBody );

            if( !Static )
            {
                UpdateSleepiness();

                if( Sleeping )
                    PhysXNativeBody.PutToSleep( nativeBody );
                else
                    PhysXNativeBody.WakeUp( nativeBody, PhysXNativeWorld.SLEEP_INTERVAL );
            }

            if( CCD && !Static )
                PhysXNativeBody.EnableCCD( nativeBody, true );

            RecreateAttachedJoints();
        }
Exemplo n.º 32
0
        public override bool Place(Point origin, StructureMap structures)
        {
            var resultsOutput = new Dictionary <ushort, int>();

            WorldUtils.Gen(new Point(origin.X - 25, origin.Y - 25), new Shapes.Rectangle(50, 50),
                           new Actions.TileScanner((ushort)0, (ushort)1).Output(resultsOutput));
            if (resultsOutput[0] + resultsOutput[1] < 1250)
            {
                return(false);
            }
            Point result1;
            var   flag = WorldUtils.Find(origin,
                                         Searches.Chain(new Searches.Up(1000), new Conditions.IsSolid().AreaOr(1, 50).Not()),
                                         out result1);
            Point result2;

            if (WorldUtils.Find(origin,
                                Searches.Chain(new Searches.Up(origin.Y - result1.Y),
                                               (GenCondition) new Conditions.IsTile((ushort)53)), out result2) || !flag)
            {
                return(false);
            }
            result1.Y += 50;
            var data1     = new ShapeData();
            var shapeData = new ShapeData();
            var point1    = new Point(origin.X, origin.Y + 20);
            var point2    = new Point(origin.X, origin.Y + 30);
            var xScale    = (float)(0.800000011920929 + _random.NextFloat() * 0.5);

            if (!structures.CanPlace(
                    new Rectangle(point1.X - (int)(20.0 * xScale), point1.Y - 20,
                                  (int)(40.0 * xScale), 40), 0) || !structures.CanPlace(
                    new Rectangle(origin.X, result1.Y + 10, 1, origin.Y - result1.Y - 9), 2))
            {
                return(false);
            }
            WorldUtils.Gen(point1, new Shapes.Slime(20, xScale, 1f),
                           Actions.Chain((GenAction) new Modifiers.Blotches(2, 0.4), new Actions.ClearTile(true).Output(data1)));
            WorldUtils.Gen(point2, new Shapes.Mound(14, 14),
                           Actions.Chain((GenAction) new Modifiers.Blotches(2, 1, 0.8),
                                         (GenAction) new Actions.SetTile(0, false, true),
                                         new Actions.SetFrames(true).Output(shapeData)));
            data1.Subtract(shapeData, point1, point2);
            WorldUtils.Gen(point1, new ModShapes.InnerOutline(data1, true),
                           Actions.Chain((GenAction) new Actions.SetTile(2, false, true),
                                         (GenAction) new Actions.SetFrames(true)));
            WorldUtils.Gen(point1, new ModShapes.All(data1),
                           Actions.Chain((GenAction) new Modifiers.RectangleMask(-40, 40, 0, 40),
                                         (GenAction) new Modifiers.IsEmpty(), (GenAction) new Actions.SetLiquid(0, byte.MaxValue)));
            WorldUtils.Gen(point1, new ModShapes.All(data1), Actions.Chain(
                               (GenAction) new Actions.PlaceWall(68, true), (GenAction) new Modifiers.OnlyTiles((ushort)2),
                               (GenAction) new Modifiers.Offset(0, 1), (GenAction) new ActionVines(3, 5, 52)));
            var data2 = new ShapeData();

            WorldUtils.Gen(new Point(origin.X, result1.Y + 10),
                           new Shapes.Rectangle(1, origin.Y - result1.Y - 9), Actions.Chain(
                               (GenAction) new Modifiers.Blotches(2, 0.2), new Actions.ClearTile(false).Output(data2),
                               (GenAction) new Modifiers.Expand(1), (GenAction) new Modifiers.OnlyTiles((ushort)53),
                               new Actions.SetTile(397, false, true).Output(data2)));
            WorldUtils.Gen(new Point(origin.X, result1.Y + 10), new ModShapes.All(data2),
                           new Actions.SetFrames(true));
            if (_random.Next(3) == 0)
            {
                WorldGen.PlaceTile(point2.X, point2.Y - 15, 187, true, false, -1, 17);
            }
            else
            {
                WorldGen.PlaceTile(point2.X, point2.Y - 15, 186, true, false, -1, 15);
            }
            WorldUtils.Gen(point2, new ModShapes.All(shapeData), Actions.Chain(
                               (GenAction) new Modifiers.Offset(0, -1), (GenAction) new Modifiers.OnlyTiles((ushort)2),
                               (GenAction) new Modifiers.Offset(0, -1), (GenAction) new ActionGrass()));
            structures.AddStructure(
                new Rectangle(point1.X - (int)(20.0 * xScale), point1.Y - 20,
                              (int)(40.0 * xScale), 40), 4);
            return(true);
        }
Exemplo n.º 33
0
 public void BeginLines()
 {
     polylineShape = GetNextShape (TypeId.Polyline);
     polyline = (Polyline)polylineShape.Element;
     polylinePoints = polyline.Points;
     polylineLength = 0;
 }
Exemplo n.º 34
0
 public GenModShape(ShapeData data)
 {
     _data = data;
 }
Exemplo n.º 35
0
		/// <summary>
		/// Generates areas, incl (client) props and events.
		/// </summary>
		private void GenerateAreas()
		{
			this.Data = new RegionInfoData();

			var areaId = 2;
			var floor = this.Floor;

			for (int x = 0; x < floor.MazeGenerator.Width; ++x)
			{
				for (int y = 0; y < floor.MazeGenerator.Height; ++y)
				{
					var room = floor.MazeGenerator.GetRoom(x, y);
					var roomTrait = floor.GetRoom(x, y);

					if (!room.Visited)
						continue;

					var isStart = (roomTrait.RoomType == RoomType.Start);
					var isEnd = (roomTrait.RoomType == RoomType.End);
					var isRoom = (roomTrait.RoomType >= RoomType.Start);
					var isBossRoom = (floor.HasBossRoom && isEnd);
					var eventId = 0L;

					if (!isBossRoom)
					{
						var areaData = new AreaData();
						areaData.Id = areaId++;
						areaData.Name = "Tile" + areaData.Id;

						areaData.X1 = x * Dungeon.TileSize;
						areaData.Y1 = y * Dungeon.TileSize;
						areaData.X2 = x * Dungeon.TileSize + Dungeon.TileSize;
						areaData.Y2 = y * Dungeon.TileSize + Dungeon.TileSize;

						this.Data.Areas.Add(areaData);

						var type = (isRoom ? DungeonBlockType.Room : DungeonBlockType.Alley);

						var propEntityId = MabiId.ClientProps | ((long)this.Id << 32) | ((long)areaData.Id << 16) | 1;
						var block = this.Dungeon.Data.Style.Get(type, room.Directions);
						var tileCenter = new Point(x * Dungeon.TileSize + Dungeon.TileSize / 2, y * Dungeon.TileSize + Dungeon.TileSize / 2);

						var prop = new Prop(propEntityId, block.PropId, this.Id, tileCenter.X, tileCenter.Y, MabiMath.DegreeToRadian(block.Rotation), 1, 0, "", "", "");
						this.AddProp(prop);

						// Debug
						//foreach (var points in prop.Shapes)
						//{
						//	foreach (var point in points)
						//	{
						//		var pole = new Prop(30, this.Id, point.X, point.Y, 0, 1, 0, "", "", "");
						//		pole.Shapes.Clear();
						//		this.AddProp(pole);
						//	}
						//}

						// TODO: This region/data stuff is a mess... create
						//   proper classes, put them in the regions and be
						//   done with it.

						if (isStart || isEnd)
						{
							var xp = tileCenter.X;
							var yp = tileCenter.Y;

							if (roomTrait.DoorType[Direction.Up] >= 3000)
								yp += 400;
							else if (roomTrait.DoorType[Direction.Right] >= 3000)
								xp += 400;
							else if (roomTrait.DoorType[Direction.Down] >= 3000)
								yp -= 400;
							else if (roomTrait.DoorType[Direction.Left] >= 3000)
								xp -= 400;

							var eventData = new EventData();
							eventData.Id = MabiId.AreaEvents | ((long)this.Id << 32) | ((long)areaData.Id << 16) | eventId++;
							eventData.Name = (isStart ? "Indoor_RDungeon_SB" : "Indoor_RDungeon_EB");
							eventData.X = xp;
							eventData.Y = yp;

							var shape = new ShapeData();
							shape.DirX1 = 1;
							shape.DirY2 = 1;
							shape.LenX = 100;
							shape.LenY = 100;
							shape.PosX = xp;
							shape.PosY = yp;
							eventData.Shapes.Add(shape);

							areaData.Events.Add(eventData.Id, eventData);
							_clientEvents.Add(eventData.Id, new ClientEvent(eventData, this.Data.Name, areaData.Name));
						}
					}
					else
					{
						// Big main room
						var areaData = new AreaData();
						areaData.Id = areaId++;
						areaData.Name = "Tile" + areaData.Id;

						areaData.X1 = x * Dungeon.TileSize - Dungeon.TileSize;
						areaData.Y1 = y * Dungeon.TileSize;
						areaData.X2 = x * Dungeon.TileSize + Dungeon.TileSize * 2;
						areaData.Y2 = y * Dungeon.TileSize + Dungeon.TileSize * 2;

						this.Data.Areas.Add(areaData);

						var block = this.Dungeon.Data.Style.Get(DungeonBlockType.BossRoom);
						var propEntityId = MabiId.ClientProps | ((long)this.Id << 32) | ((long)areaData.Id << 16) | 1;
						var tileCenter = new Point(x * Dungeon.TileSize + Dungeon.TileSize / 2, y * Dungeon.TileSize + Dungeon.TileSize);

						var prop = new Prop(propEntityId, block.PropId, this.Id, tileCenter.X, tileCenter.Y, MabiMath.DegreeToRadian(block.Rotation), 1, 0, "", "", "");
						this.AddProp(prop);

						// Debug
						//foreach (var points in prop.Shapes)
						//{
						//	foreach (var point in points)
						//	{
						//		var pole = new Prop(30, this.Id, point.X, point.Y, 0, 1, 0, "", "", "");
						//		pole.Shapes.Clear();
						//		this.AddProp(pole);
						//	}
						//}

						// Treasure room
						areaData = new AreaData();
						areaData.Id = areaId++;
						areaData.Name = "Tile" + areaData.Id;

						areaData.X1 = x * Dungeon.TileSize;
						areaData.Y1 = y * Dungeon.TileSize + Dungeon.TileSize * 2;
						areaData.X2 = x * Dungeon.TileSize + Dungeon.TileSize;
						areaData.Y2 = y * Dungeon.TileSize + Dungeon.TileSize * 2 + Dungeon.TileSize;

						this.Data.Areas.Add(areaData);
					}
				}
			}
		}
Exemplo n.º 36
0
        public override bool Place(Point origin, StructureMap structures)
        {
            if (WorldGen.SolidTile(origin.X, origin.Y))
            {
                return(false);
            }
            if (Main.tile[origin.X, origin.Y].wall == 216 || Main.tile[origin.X, origin.Y].wall == 187)
            {
                return(false);
            }
            ushort type = Utils.SelectRandom <ushort>(GenBase._random, (ushort)((WorldGen.goldBar == 19) ? 8 : 169), (ushort)((WorldGen.silverBar == 21) ? 9 : 168), (ushort)((WorldGen.ironBar == 22) ? 6 : 167), (ushort)((WorldGen.copperBar == 20) ? 7 : 166));
            double num  = GenBase._random.NextDouble() * 2.0 - 1.0;

            if (!WorldUtils.Find(origin, Searches.Chain((num > 0.0) ? ((GenSearch) new Searches.Right(40)) : ((GenSearch) new Searches.Left(40)), new Conditions.IsSolid()), out origin))
            {
                return(false);
            }
            if (!WorldUtils.Find(origin, Searches.Chain(new Searches.Down(80), new Conditions.IsSolid()), out origin))
            {
                return(false);
            }
            ShapeData shapeData = new ShapeData();
            Ref <int> @ref      = new Ref <int>(0);
            Ref <int> ref2      = new Ref <int>(0);

            WorldUtils.Gen(origin, new ShapeRunner(10f, 20, new Vector2((float)num, 1f)).Output(shapeData), Actions.Chain(new Modifiers.Blotches(), new Actions.Scanner(@ref), new Modifiers.IsSolid(), new Actions.Scanner(ref2)));
            if (ref2.Value < @ref.Value / 2)
            {
                return(false);
            }
            Rectangle area = new Rectangle(origin.X - 15, origin.Y - 10, 30, 20);

            if (!structures.CanPlace(area))
            {
                return(false);
            }
            WorldUtils.Gen(origin, new ModShapes.All(shapeData), new Actions.SetTile(type, setSelfFrames: true));
            WorldUtils.Gen(new Point(origin.X - (int)(num * -5.0), origin.Y - 5), new Shapes.Circle(5), Actions.Chain(new Modifiers.Blotches(), new Actions.ClearTile(frameNeighbors: true)));
            Point result;
            int   num2 = 1 & (WorldUtils.Find(new Point(origin.X - ((num > 0.0) ? 3 : (-3)), origin.Y - 3), Searches.Chain(new Searches.Down(10), new Conditions.IsSolid()), out result) ? 1 : 0);
            int   num3 = ((GenBase._random.Next(4) == 0) ? 3 : 7);

            if (((uint)num2 & (WorldUtils.Find(new Point(origin.X - ((num > 0.0) ? (-num3) : num3), origin.Y - 3), Searches.Chain(new Searches.Down(10), new Conditions.IsSolid()), out var result2) ? 1u : 0u)) == 0)
            {
                return(false);
            }
            result.Y--;
            result2.Y--;
            Tile tile = GenBase._tiles[result.X, result.Y + 1];

            tile.slope(0);
            tile.halfBrick(halfBrick: false);
            for (int i = -1; i <= 1; i++)
            {
                WorldUtils.ClearTile(result2.X + i, result2.Y);
                Tile tile2 = GenBase._tiles[result2.X + i, result2.Y + 1];
                if (!WorldGen.SolidOrSlopedTile(tile2))
                {
                    tile2.ResetToType(1);
                    tile2.active(active: true);
                }
                tile2.slope(0);
                tile2.halfBrick(halfBrick: false);
                WorldUtils.TileFrame(result2.X + i, result2.Y + 1, frameNeighbors: true);
            }
            WorldGen.PlaceTile(result.X, result.Y, 141);
            WorldGen.PlaceTile(result2.X, result2.Y, 411, mute: true, forced: true);
            WorldUtils.WireLine(result, result2);
            structures.AddProtectedStructure(area, 5);
            return(true);
        }
Exemplo n.º 37
0
        ShapeData GetNextShape(TypeId typeId)
        {
            ShapeData s = null;

            //typeCounts[(int)typeId]++;

            if (_shapeIndex >= _shapes.Count) {
                if (LogNewShapes) {
                    Debug.WriteLine("Adding shape " + typeId + " for " + _entity);
                }
                s = ConstructAndAddShape(typeId);
            }
            else if (_shapes[_shapeIndex].TypeId != typeId) {
                if (LogBadShapes) {
                    Debug.WriteLine("Bad shape " + _shapeIndex + "! Wanted " + typeId + " got " + _shapes[_shapeIndex].TypeId + " for " + _entity);
                }
                TrimShapes();
                s = ConstructAndAddShape(typeId);
            }
            else {
                s = _shapes[_shapeIndex];
            }

            _shapeIndex++;

            _lastShape = s;

            return s;
        }
Exemplo n.º 38
0
 public GenModShape(ShapeData data)
 {
     _data = data;
 }
Exemplo n.º 39
0
 public void Clear()
 {
     _shapeIndex = 0;
     _lastShape = null;
     _lastAddElementIndex = -1;
     TrimShapes ();
 }
Exemplo n.º 40
0
        // Token: 0x06000FCE RID: 4046 RVA: 0x003FB420 File Offset: 0x003F9620
        public override bool Place(Point origin, StructureMap structures)
        {
            Dictionary <ushort, int> dictionary = new Dictionary <ushort, int>();

            WorldUtils.Gen(new Point(origin.X - 25, origin.Y - 25), new Shapes.Rectangle(50, 50), new Actions.TileScanner(new ushort[]
            {
                0,
                1
            }).Output(dictionary));
            if (dictionary[0] + dictionary[1] < 1250)
            {
                return(false);
            }
            Point point;
            bool  flag = WorldUtils.Find(origin, Searches.Chain(new Searches.Up(1000), new GenCondition[]
            {
                new Conditions.IsSolid().AreaOr(1, 50).Not()
            }), out point);
            Point point2;

            if (WorldUtils.Find(origin, Searches.Chain(new Searches.Up(origin.Y - point.Y), new GenCondition[]
            {
                new Conditions.IsTile(new ushort[]
                {
                    53
                })
            }), out point2))
            {
                return(false);
            }
            if (!flag)
            {
                return(false);
            }
            point.Y += 50;
            ShapeData shapeData  = new ShapeData();
            ShapeData shapeData2 = new ShapeData();
            Point     point3     = new Point(origin.X, origin.Y + 20);
            Point     point4     = new Point(origin.X, origin.Y + 30);
            float     num        = 0.8f + GenBase._random.NextFloat() * 0.5f;

            if (!structures.CanPlace(new Rectangle(point3.X - (int)(20f * num), point3.Y - 20, (int)(40f * num), 40), 0))
            {
                return(false);
            }
            if (!structures.CanPlace(new Rectangle(origin.X, point.Y + 10, 1, origin.Y - point.Y - 9), 2))
            {
                return(false);
            }
            WorldUtils.Gen(point3, new Shapes.Slime(20, num, 1f), Actions.Chain(new GenAction[]
            {
                new Modifiers.Blotches(2, 0.4),
                new Actions.ClearTile(true).Output(shapeData)
            }));
            WorldUtils.Gen(point4, new Shapes.Mound(14, 14), Actions.Chain(new GenAction[]
            {
                new Modifiers.Blotches(2, 1, 0.8),
                new Actions.SetTile(0, false, true),
                new Actions.SetFrames(true).Output(shapeData2)
            }));
            shapeData.Subtract(shapeData2, point3, point4);
            WorldUtils.Gen(point3, new ModShapes.InnerOutline(shapeData, true), Actions.Chain(new GenAction[]
            {
                new Actions.SetTile(2, false, true),
                new Actions.SetFrames(true)
            }));
            WorldUtils.Gen(point3, new ModShapes.All(shapeData), Actions.Chain(new GenAction[]
            {
                new Modifiers.RectangleMask(-40, 40, 0, 40),
                new Modifiers.IsEmpty(),
                new Actions.SetLiquid(0, 255)
            }));
            WorldUtils.Gen(point3, new ModShapes.All(shapeData), Actions.Chain(new GenAction[]
            {
                new Actions.PlaceWall(68, true),
                new Modifiers.OnlyTiles(new ushort[]
                {
                    2
                }),
                new Modifiers.Offset(0, 1),
                new ActionVines(3, 5, 52)
            }));
            ShapeData data = new ShapeData();

            WorldUtils.Gen(new Point(origin.X, point.Y + 10), new Shapes.Rectangle(1, origin.Y - point.Y - 9), Actions.Chain(new GenAction[]
            {
                new Modifiers.Blotches(2, 0.2),
                new Actions.ClearTile(false).Output(data),
                new Modifiers.Expand(1),
                new Modifiers.OnlyTiles(new ushort[]
                {
                    53
                }),
                new Actions.SetTile(397, false, true).Output(data)
            }));
            WorldUtils.Gen(new Point(origin.X, point.Y + 10), new ModShapes.All(data), new Actions.SetFrames(true));
            if (GenBase._random.Next(3) == 0)
            {
                WorldGen.PlaceTile(point4.X, point4.Y - 15, 187, true, false, -1, 17);
            }
            else
            {
                WorldGen.PlaceTile(point4.X, point4.Y - 15, 186, true, false, -1, 15);
            }
            WorldUtils.Gen(point4, new ModShapes.All(shapeData2), Actions.Chain(new GenAction[]
            {
                new Modifiers.Offset(0, -1),
                new Modifiers.OnlyTiles(new ushort[]
                {
                    2
                }),
                new Modifiers.Offset(0, -1),
                new ActionGrass()
            }));
            structures.AddStructure(new Rectangle(point3.X - (int)(20f * num), point3.Y - 20, (int)(40f * num), 40), 4);
            return(true);
        }
Exemplo n.º 41
0
 public DecoratorDrawerData(ShapeData shape, IconData icon)
 {
     Shape = shape;
     Icon = icon;
 }
Exemplo n.º 42
0
        /// <summary>
        /// Generates areas, incl (client) props and events.
        /// </summary>
        private void GenerateAreas()
        {
            this.Data = new RegionInfoData();

            var areaId = 2;
            var floor  = this.Floor;

            for (int x = 0; x < floor.MazeGenerator.Width; ++x)
            {
                for (int y = 0; y < floor.MazeGenerator.Height; ++y)
                {
                    var room      = floor.MazeGenerator.GetRoom(x, y);
                    var roomTrait = floor.GetRoom(x, y);

                    if (!room.Visited)
                    {
                        continue;
                    }

                    var isStart    = (roomTrait.RoomType == RoomType.Start);
                    var isEnd      = (roomTrait.RoomType == RoomType.End);
                    var isRoom     = (roomTrait.RoomType >= RoomType.Start);
                    var isBossRoom = (floor.HasBossRoom && isEnd);
                    var eventId    = 0L;

                    if (!isBossRoom)
                    {
                        var areaData = new AreaData();
                        areaData.Id   = areaId++;
                        areaData.Name = "Tile" + areaData.Id;

                        areaData.X1 = x * Dungeon.TileSize;
                        areaData.Y1 = y * Dungeon.TileSize;
                        areaData.X2 = x * Dungeon.TileSize + Dungeon.TileSize;
                        areaData.Y2 = y * Dungeon.TileSize + Dungeon.TileSize;

                        this.Data.Areas.Add(areaData);

                        var type = (isRoom ? DungeonBlockType.Room : DungeonBlockType.Alley);

                        var propEntityId = MabiId.ClientProps | ((long)this.Id << 32) | ((long)areaData.Id << 16) | 1;
                        var block        = this.Dungeon.Data.Style.Get(type, room.Directions);
                        var tileCenter   = new Point(x * Dungeon.TileSize + Dungeon.TileSize / 2, y * Dungeon.TileSize + Dungeon.TileSize / 2);

                        var prop = new Prop(propEntityId, block.PropId, this.Id, tileCenter.X, tileCenter.Y, MabiMath.DegreeToRadian(block.Rotation), 1, 0, "", "", "");
                        this.AddProp(prop);

                        // Debug
                        //foreach (var points in prop.Shapes)
                        //{
                        //	foreach (var point in points)
                        //	{
                        //		var pole = new Prop(30, this.Id, point.X, point.Y, 0, 1, 0, "", "", "");
                        //		pole.Shapes.Clear();
                        //		this.AddProp(pole);
                        //	}
                        //}

                        // TODO: This region/data stuff is a mess... create
                        //   proper classes, put them in the regions and be
                        //   done with it.

                        if (isStart || isEnd)
                        {
                            var xp = tileCenter.X;
                            var yp = tileCenter.Y;

                            if (roomTrait.DoorType[Direction.Up] >= 3000)
                            {
                                yp += 400;
                            }
                            else if (roomTrait.DoorType[Direction.Right] >= 3000)
                            {
                                xp += 400;
                            }
                            else if (roomTrait.DoorType[Direction.Down] >= 3000)
                            {
                                yp -= 400;
                            }
                            else if (roomTrait.DoorType[Direction.Left] >= 3000)
                            {
                                xp -= 400;
                            }

                            var eventData = new EventData();
                            eventData.Id   = MabiId.AreaEvents | ((long)this.Id << 32) | ((long)areaData.Id << 16) | eventId++;
                            eventData.Name = (isStart ? "Indoor_RDungeon_SB" : "Indoor_RDungeon_EB");
                            eventData.X    = xp;
                            eventData.Y    = yp;

                            var shape = new ShapeData();
                            shape.DirX1 = 1;
                            shape.DirY2 = 1;
                            shape.LenX  = 100;
                            shape.LenY  = 100;
                            shape.PosX  = xp;
                            shape.PosY  = yp;
                            eventData.Shapes.Add(shape);

                            areaData.Events.Add(eventData.Id, eventData);
                            _clientEvents.Add(eventData.Id, new ClientEvent(eventData, this.Data.Name, areaData.Name));
                        }
                    }
                    else
                    {
                        // Big main room
                        var areaData = new AreaData();
                        areaData.Id   = areaId++;
                        areaData.Name = "Tile" + areaData.Id;

                        areaData.X1 = x * Dungeon.TileSize - Dungeon.TileSize;
                        areaData.Y1 = y * Dungeon.TileSize;
                        areaData.X2 = x * Dungeon.TileSize + Dungeon.TileSize * 2;
                        areaData.Y2 = y * Dungeon.TileSize + Dungeon.TileSize * 2;

                        this.Data.Areas.Add(areaData);

                        var block        = this.Dungeon.Data.Style.Get(DungeonBlockType.BossRoom);
                        var propEntityId = MabiId.ClientProps | ((long)this.Id << 32) | ((long)areaData.Id << 16) | 1;
                        var tileCenter   = new Point(x * Dungeon.TileSize + Dungeon.TileSize / 2, y * Dungeon.TileSize + Dungeon.TileSize);

                        var prop = new Prop(propEntityId, block.PropId, this.Id, tileCenter.X, tileCenter.Y, MabiMath.DegreeToRadian(block.Rotation), 1, 0, "", "", "");
                        this.AddProp(prop);

                        // Debug
                        //foreach (var points in prop.Shapes)
                        //{
                        //	foreach (var point in points)
                        //	{
                        //		var pole = new Prop(30, this.Id, point.X, point.Y, 0, 1, 0, "", "", "");
                        //		pole.Shapes.Clear();
                        //		this.AddProp(pole);
                        //	}
                        //}

                        // Treasure room
                        areaData      = new AreaData();
                        areaData.Id   = areaId++;
                        areaData.Name = "Tile" + areaData.Id;

                        areaData.X1 = x * Dungeon.TileSize;
                        areaData.Y1 = y * Dungeon.TileSize + Dungeon.TileSize * 2;
                        areaData.X2 = x * Dungeon.TileSize + Dungeon.TileSize;
                        areaData.Y2 = y * Dungeon.TileSize + Dungeon.TileSize * 2 + Dungeon.TileSize;

                        this.Data.Areas.Add(areaData);
                    }
                }
            }
        }
Exemplo n.º 43
0
        public void AddCube(Matrix worldTransform, Color color, Texture2D texture)
        {
            if (sShapeList.Count >= MAX_SHAPES)
            {
                return;
            }

            ShapeData shapeData = new ShapeData();
            shapeData.mType = ShapeType.Cube;
            shapeData.mWorldMatrix = worldTransform;
            shapeData.mColor = color;
            shapeData.mTexture = texture;
            sShapeList.Add(shapeData);
        }
Exemplo n.º 44
0
 public RectangleShape()
 {
     Data = new RectangleShapeData();
 }