示例#1
0
 public Scope(BodyType bodyType, Scope parent, ReadOnlyArray<string> parameters)
 {
     _bodyType = bodyType;
     Parent = parent;
     _parameters = parameters;
     _rootScope = parent != null ? parent._rootScope : this;
 }
 public FarseerObject(FarseerWorld world, Shape shape, BodyType BodyType = BodyType.Dynamic)
 {            
     body = new Body(world.World);
     body.BodyType = BodyType;
     body.CreateFixture(shape);
     body.Enabled = false;            
 }
示例#3
0
 public GameCharacter(Game game, World world, Vector2 position, Vector2 size, SpriteAnimation animation, BodyType bodyType)
     : base(game, world, position, size, animation, bodyType)
 {
     // Don't allow characters to rotate
     this.body.FixedRotation = true;
     this.jumpState = 0;
 }
示例#4
0
 public static Body CreateCompoundPolygon(World world, List<Vertices> list, float density, Vector2 position = new Vector2(), float rotation = 0, BodyType bodyType = BodyType.Static, object userData = null)
 {
     //We create a single body
     Body polygonBody = CreateBody(world, position, rotation, bodyType);
     FixtureFactory.AttachCompoundPolygon(list, density, polygonBody, userData);
     return polygonBody;
 }
示例#5
0
        public HazardBox( CubeGame game,
                          World world,
                          RectangleF rec,
                          BodyType bodyType = BodyType.Static,
                          float density = 1,
                          Category categories = Constants.Categories.DEFAULT,
                          Category killCategories = Constants.Categories.ACTORS )
            : base(game, world, rec.Center.ToUnits(), 0, new HazardBoxMaker( rec.Width, rec.Height ))
        {
            mWidth = rec.Width;
            mHeight = rec.Height;

            Fixture box = FixtureFactory.AttachRectangle(
                    mWidth.ToUnits(),
                    mHeight.ToUnits(),
                    density,
                    Vector2.Zero,
                    Body,
                    new Flat() );

            Fixture killBox = box.CloneOnto( Body );
            killBox.IsSensor = true;
            killBox.UserData = new Hazard( "killbox" );

            Body.BodyType = bodyType;
            Body.CollisionCategories = categories;

            killBox.CollidesWith = killCategories;
            box.CollidesWith ^= killCategories;
        }
示例#6
0
        /// <summary>
        /// Duplicates the given Body along the given path for approximatly the given copies.
        /// </summary>
        /// <param name="world">The world.</param>
        /// <param name="path">The path.</param>
        /// <param name="shapes">The shapes.</param>
        /// <param name="type">The type.</param>
        /// <param name="copies">The copies.</param>
        /// <param name="userData"></param>
        /// <returns></returns>
        public static List<Body> EvenlyDistributeShapesAlongPath(World world, Path path, IEnumerable<Shape> shapes, BodyType type, int copies, object userData = null)
        {
            List<Vector3> centers = path.SubdivideEvenly(copies);
            List<Body> bodyList = new List<Body>();

            for (int i = 0; i < centers.Count; i++)
            {
                Body b = new Body(world);

                // copy the type from original body
                b.BodyType = type;
                b.Position = new Vector2(centers[i].X, centers[i].Y);
                b.Rotation = centers[i].Z;
                b.UserData = userData;

                foreach (Shape shape in shapes)
                {
                    b.CreateFixture(shape);
                }

                bodyList.Add(b);
            }

            return bodyList;
        }
示例#7
0
        public Quarterpipe( CubeGame game,
                            World world,
                            float radius,
                            Vector2 position,
                            Type type,
                            BodyType bodyType = BodyType.Static,
                            float density = 1,
                            Category categories = Constants.Categories.DEFAULT )
            : base(game, world, position.ToUnits(), AngleFromType( type ), new QuarterpipeMaker( radius ))
        {
            mRadius = radius;

            FixtureFactory.AttachChainShape(
                MakeArc( 100, radius.ToUnits(), 0 ),
                Body,
                new Concave() );

            var fixtureList = FixtureFactory.AttachCompoundPolygon(
                Triangulate.ConvexPartition(
                    MakeArc( 10, radius.ToUnits(), 0 ),
                    TriangulationAlgorithm.Earclip ),
                density,
                Body );

            foreach ( var f in fixtureList )
                f.CollidesWith = Category.None;

            Body.BodyType = bodyType;
            Body.CollisionCategories = categories;

            Initialize();
        }
示例#8
0
        public BodyType GetBodyType()
        {
            if (bodyType == BodyType.None && bodyState != null)
            {
                switch (sex)
                {
                    case Models.Sex.Female:
                        if (bodyState.Wrist < 15)
                            bodyType = BodyType.Asthenic;
                        else if (bodyState.Wrist >= 15 && bodyState.Wrist < 17)
                            bodyType = BodyType.Normal;
                        else
                            bodyType = BodyType.Hypersthenic;

                        break;
                    case Models.Sex.Male:
                        if (bodyState.Wrist < 18)
                            bodyType = BodyType.Asthenic;
                        else if (bodyState.Wrist >= 18 && bodyState.Wrist < 20)
                            bodyType = BodyType.Normal;
                        else
                            bodyType = BodyType.Hypersthenic;

                        break;
                }


            }

            return bodyType;
        }
 public AirlinerPassengerType(Manufacturer manufacturer, string name,string family, int seating, int cockpitcrew, int cabincrew, double speed, long range, double wingspan, double length, double consumption, long price, int maxAirlinerClasses, long minRunwaylength, long fuelcapacity, BodyType body, TypeRange rangeType, EngineType engine, Period<DateTime> produced, int prodRate, Boolean standardType = true)
     : base(manufacturer,TypeOfAirliner.Passenger,name,family,cockpitcrew,speed,range,wingspan,length,consumption,price,minRunwaylength,fuelcapacity,body,rangeType,engine,produced, prodRate,standardType)
 {
     this.MaxSeatingCapacity = seating;
     this.CabinCrew = cabincrew;
     this.MaxAirlinerClasses = maxAirlinerClasses;
 }
示例#10
0
			public static Body createPolygon( World world, Vertices vertices, float density, Vector2 position = new Vector2(), float rotation = 0, BodyType bodyType = BodyType.Static, object userData = null )
			{
				for( var i = 0; i < vertices.Count; i++ )
					vertices[i] *= FSConvert.displayToSim;

				return FarseerPhysics.Factories.BodyFactory.CreatePolygon( world, vertices, density, FSConvert.toSimUnits( position ), rotation, bodyType, userData );
			}
 /// <summary>
 /// Constructs a FPE Body from the given list of vertices and density
 /// </summary>
 /// <param name="game"></param>
 /// <param name="world"></param>
 /// <param name="vertices">The collection of vertices in display units (pixels)</param>
 /// <param name="bodyType"></param>
 /// <param name="density"></param>
 public PhysicsGameEntity(Game game, World world, Category collisionCategory, Vertices vertices, BodyType bodyType, float density)
     : this(game,world,collisionCategory)
 {
     ConstructFromVertices(world,vertices,density);
     Body.BodyType = bodyType;
     Body.CollisionCategories = collisionCategory;
 }
示例#12
0
        public Sprite(
            string Name,
            Vector2 location,
            Texture2D texture,
            Rectangle initialFrame,
            Vector2 velocity,
            BodyType bodytype,
            bool AddFixture
            ) // True
        {
            this.location = location;
            Texture = texture;

            this.name = Name;
            this.dead = false;

            frames.Add(initialFrame);
            frameWidth = initialFrame.Width;
            frameHeight = initialFrame.Height;
            origin = new Vector2(frameWidth / 2, frameHeight / 2);

            tag = null;

            body = BodyFactory.CreateBody(GameWorld.world);
            body.BodyType = bodytype;
            body.SleepingAllowed = false;
            //body.UserData = this; // NO!!!!

            spriteEffects = new SpriteEffects();
            flipType = new FlipType();
            flipType = FlipType.NONE;


            body.Restitution = .2f;
            body.Mass = 100;
            body.Friction = 10;
            //body.LinearDamping = 2.4f;
            //body.AngularDamping = 6.4f;
            /*body.Rotation = 1.3f;
            //            box.AngularVelocity = 0.1f;
            body.Inertia = 25.5f;
            */
            this.Fade = false;
            this.Location = location;
            //            body.Position = ConvertUnits.ToSimUnits(this.Location);
            body.IgnoreGravity = false;

            if (AddFixture)
            {
                bodyfixture = FixtureFactory.AttachRectangle(ConvertUnits.ToSimUnits(initialFrame.Width), ConvertUnits.ToSimUnits(initialFrame.Height), 10, Vector2.Zero, body);
                bodyfixture.Restitution = .5f;
                bodyfixture.Friction = 1;

                bodyfixture.OnCollision += new OnCollisionEventHandler(HandleCollision);
                PhysicsBodyFixture = bodyfixture;
            }

            this.Velocity = ConvertUnits.ToSimUnits(velocity);
        }
示例#13
0
文件: Bullet.cs 项目: Jamsterx1/Titan
 public override void createBody(World _physics, BodyType _type)
 {
     base.createBody(_physics, _type);
     mBody.UserData = this;
     mBody.OnCollision += new OnCollisionEventHandler(collision);
     mBody.CollisionCategories = Category.Cat3;
     mBody.CollidesWith = Category.All & ~Category.Cat3;
 }
示例#14
0
		public FSRigidBody setBodyType( BodyType bodyType )
		{
			if( body != null )
				body.bodyType = bodyType;
			else
				_bodyDef.bodyType = bodyType;
			return this;
		}
 public FarseerObject(FarseerWorld world, Vertices vertices, float density = 1, BodyType BodyType = BodyType.Dynamic)
 {
     Shape shape = new PolygonShape(vertices, density);
     body = new Body(world.World);
     body.BodyType = BodyType;
     body.CreateFixture(shape);
     body.Enabled = false;
 }
示例#16
0
 public PhysicalObject(World world, Vector2 position, BodyType bodyType, Texture2D texture, Vector2 size, float mass)
 {
     _body = BodyFactory.CreateRectangle(world, size.X * _pixelToUnit, size.Y * _pixelToUnit, mass);
     _body.BodyType = bodyType;
     Position = position;
     this.Size = size;
     this._texture = texture;
 }
示例#17
0
 public BodyFromTexture(ObservableProperty<Texture2D> textureData, BodyType type = 0, float density = 1f)
     : base(Physic.World)
 {
     _textureData = textureData;
     _density = density;
     BodyType = type;
     Centroid = this.AttachPolyFromTexture(textureData.Value, density);
     textureData.Changed += Reload;
 }
示例#18
0
			public static Body createCapsule( World world, float height, float topRadius, int topEdges, float bottomRadius, int bottomEdges, float density, Vector2 position = new Vector2(), float rotation = 0, BodyType bodyType = BodyType.Static, object userData = null )
			{
				height *= FSConvert.displayToSim;
				topRadius *= FSConvert.displayToSim;
				bottomRadius *= FSConvert.displayToSim;
				position *= FSConvert.displayToSim;

				return FarseerPhysics.Factories.BodyFactory.CreateCapsule( world, height, topRadius, topEdges, bottomRadius, bottomEdges, density, position, rotation, bodyType, userData );
			}
示例#19
0
		/// <summary>
        /// Default constructor.
        /// </summary>
        /// <param name="sessionID">Session ID.</param>
        /// <param name="socket">Server connected socket.</param>
        /// <param name="bindInfo">BindInfo what accepted socket.</param>
        /// <param name="server">Reference to server.</param>
        internal SMTP_Session(string sessionID,SocketEx socket,IPBindInfo bindInfo,SMTP_Server server) : base(sessionID,socket,bindInfo,server)
        {	        
            m_pServer      = server;
			m_BodyType     = BodyType.x7_bit;
			m_Forward_path = new Hashtable();
			m_CmdValidator = new SMTP_Cmd_Validator();

			// Start session proccessing
			StartSession();
		}
        /// <summary>
        /// Reads attributes from XML.
        /// </summary>
        /// <param name="reader">The reader.</param>
        internal override void ReadAttributesFromXml(EwsServiceXmlReader reader)
        {
            this.bodyType = reader.ReadAttributeValue<BodyType>(XmlAttributeNames.BodyType);

            string attributeValue = reader.ReadAttributeValue(XmlAttributeNames.IsTruncated);
            if (!string.IsNullOrEmpty(attributeValue))
            {
                this.isTruncated = bool.Parse(attributeValue);
            }
        }
示例#21
0
        public BodySyntax(BodyType bodyType, ReadOnlyArray<SyntaxNode> statements, ReadOnlyArray<IIdentifier> identifiers, bool isStrict, Closure closure)
            : base(statements)
        {
            if (identifiers == null)
                throw new ArgumentNullException("identifiers");

            BodyType = bodyType;
            Identifiers = identifiers;
            IsStrict = isStrict;
            Closure = closure;
        }
示例#22
0
 public void RpcChangeBody(BodyType bodyType)
 {
     if (bodyType == BodyType.PixelBody)
     {
         body.SetActive(true);
         bodyText.SetActive(false);
     }
     else
     {
         body.SetActive(false);
         bodyText.SetActive(true);
     }
 }
示例#23
0
        public static Body CreateCapsule(World world, float height, float topRadius, int topEdges, float bottomRadius, int bottomEdges, float density, Vector2 position = new Vector2(), float rotation = 0, BodyType bodyType = BodyType.Static, object userData = null)
        {
            Vertices verts = PolygonTools.CreateCapsule(height, topRadius, topEdges, bottomRadius, bottomEdges);

            //There are too many vertices in the capsule. We decompose it.
            if (verts.Count >= Settings.MaxPolygonVertices)
            {
                List<Vertices> vertList = Triangulate.ConvexPartition(verts, TriangulationAlgorithm.Earclip);
                return CreateCompoundPolygon(world, vertList, density, position, rotation, bodyType, userData);
            }

            return CreatePolygon(world, verts, density, position, rotation, bodyType, userData);
        }
        /// <summary>
        /// Construct a FPE Body from the given texture and density
        /// </summary>
        /// <param name="game"></param>
        /// <param name="world"></param>
        /// <param name="texture"></param>
        /// <param name="bodyType"></param>
        /// <param name="density"></param>
        public PhysicsGameEntity(Game game, World world, Category collisionCategory, Texture2D texture, BodyType bodyType, float density)
            : this(game,world,collisionCategory)
        {
            //Create an array to hold the data from the texture
            uint[] data = new uint[texture.Width * texture.Height];

            //Transfer the texture data to the array
            texture.GetData(data);

            var vertices = PolygonTools.CreatePolygon(data, texture.Width, true);
            ConstructFromVertices(world,vertices,density);
            Body.BodyType = bodyType;
            Body.CollisionCategories = collisionCategory;
        }
示例#25
0
        public XAttribute ToXAttribute(BodyType entity, XName xName)
        {
            switch (entity)
            {
                case BodyType.Dynamic:
                    return new XAttribute(xName, STR_Dynamic);
                case BodyType.Kinematic:
                    return new XAttribute(xName, STR_Kinematic);
                case BodyType.Static:
                    return new XAttribute(xName, STR_Static);
                default:
                    throw new NotSupportedException(String.Format("BodyType '{0}' is not supported.", entity.ToString()));

            }
        }
示例#26
0
 public EditorCircleActor(EditorLevel level, XElement data)
     : base(level, data)
 {
     _bodyType = (BodyType)Loader.loadEnum(typeof(BodyType), data.Attribute("body_type"), (int)BodyType.Static);
     _destructible = Loader.loadBool(data.Attribute("destructible"), false);
     _chunkSpacingX = Loader.loadFloat(data.Attribute("chunk_spacing_x"), 1f);
     _chunkSpacingY = Loader.loadFloat(data.Attribute("chunk_spacing_y"), 1f);
     _destructibleSeed = Loader.loadInt(data.Attribute("destructible_seed"), 12345);
     _position = Loader.loadVector2(data.Attribute("position"), Vector2.Zero);
     _radius = Loader.loadFloat(data.Attribute("radius"), 1f);
     _density = Loader.loadFloat(data.Attribute("density"), 0.5f);
     _friction = Loader.loadFloat(data.Attribute("friction"), 1f);
     _restitution = Loader.loadFloat(data.Attribute("restitution"), 0f);
     _materialUID = Loader.loadString(data.Attribute("material_uid"), "default");
 }
示例#27
0
        public static Body CreateGear(World world, float radius, int numberOfTeeth, float tipPercentage, float toothHeight, float density, Vector2 position = new Vector2(), float rotation = 0, BodyType bodyType = BodyType.Static, object userData = null)
        {
            Vertices gearPolygon = PolygonTools.CreateGear(radius, numberOfTeeth, tipPercentage, toothHeight);

            //Gears can in some cases be convex
            if (!gearPolygon.IsConvex())
            {
                //Decompose the gear:
                List<Vertices> list = Triangulate.ConvexPartition(gearPolygon, TriangulationAlgorithm.Earclip);

                return CreateCompoundPolygon(world, list, density, position, rotation, bodyType, userData);
            }

            return CreatePolygon(world, gearPolygon, density, position, rotation, bodyType, userData);
        }
示例#28
0
        public static Body CreateRectangle(World world, float width, float height, float density, Vector2 position = new Vector2(), float rotation = 0, BodyType bodyType = BodyType.Static, object userData = null)
        {
            if (width <= 0)
                throw new ArgumentOutOfRangeException("width", "Width must be more than 0 meters");

            if (height <= 0)
                throw new ArgumentOutOfRangeException("height", "Height must be more than 0 meters");

            Body body = CreateBody(world, position, rotation, bodyType, userData);

            Vertices rectangleVertices = PolygonTools.CreateRectangle(width / 2, height / 2);
            FixtureFactory.AttachPolygon(rectangleVertices, density, body);

            return body;
        }
示例#29
0
 public EditorCircleActor(EditorLevel level)
     : base(level, ActorType.Circle, level.controller.getUnusedActorID())
 {
     _bodyType = BodyType.Static;
     _destructible = false;
     _chunkSpacingX = 1f;
     _chunkSpacingY = 1f;
     _destructibleSeed = 12345;
     _position = level.controller.worldMouse;
     _radius = 1f;
     _density = 0.5f;
     _friction = 1f;
     _restitution = 0f;
     _layerDepth = 0.1f;
     _materialUID = "default";
 }
示例#30
0
 public EditorTerrainActor(EditorLevel level)
     : base(level, ActorType.Terrain)
 {
     _bodyType = BodyType.Static;
     _destructible = false;
     _chunkSpacingX = 1f;
     _chunkSpacingY = 1f;
     _chunkJitterX = 0.2f;
     _chunkJitterY = 0.2f;
     _destructibleSeed = 12345;
     _density = 0.5f;
     _friction = 1f;
     _restitution = 0f;
     _materialUID = "default";
     _blockTreeLimbs = false;
 }
示例#31
0
 public static List <Body> EvenlyDistributeShapesAlongPath(World world, Path path, Shape shape, BodyType type, int copies)
 {
     return(EvenlyDistributeShapesAlongPath(world, path, shape, type, copies, null));
 }
示例#32
0
        public static Body CreateGear(World world, float radius, int numberOfTeeth, float tipPercentage, float toothHeight, float density, Vector2 position = new Vector2(), float rotation = 0, BodyType bodyType = BodyType.Static, object userData = null)
        {
            Vertices gearPolygon = PolygonUtils.CreateGear(radius, numberOfTeeth, tipPercentage, toothHeight);

            //Gears can in some cases be convex
            if (!gearPolygon.IsConvex())
            {
                //Decompose the gear:
                List <Vertices> list = Triangulate.ConvexPartition(gearPolygon, TriangulationAlgorithm.Earclip);

                return(CreateCompoundPolygon(world, list, density, position, rotation, bodyType, userData));
            }

            return(CreatePolygon(world, gearPolygon, density, position, rotation, bodyType, userData));
        }
示例#33
0
 public Body(int id,
             BodyType type,
             in Vector2 position,
示例#34
0
 /// <summary>
 /// Initializes a new instance of the <see cref="MessageBody"/> class.
 /// </summary>
 /// <param name="bodyType">The type of the message body's text.</param>
 /// <param name="text">The text of the message body.</param>
 public MessageBody(BodyType bodyType, string text)
     : this()
 {
     this.bodyType = bodyType;
     this.text     = text;
 }
示例#35
0
        public static Body CreateBody(World world, Vector2 position = new Vector2(), float rotation = 0, BodyType bodyType = BodyType.Static, object userData = null)
        {
            BodyTemplate template = new BodyTemplate();

            template.Position = position;
            template.Angle    = rotation;
            template.Type     = bodyType;
            template.UserData = userData;

            return(world.CreateBody(template));
        }
        public async Task BodyParser_Parse_ContentTypeIsNull(string contentType, string bodyAsString, BodyType detectedBodyType, BodyType detectedBodyTypeFromContentType)
        {
            // Assign
            var memoryStream = new MemoryStream(Encoding.UTF8.GetBytes(bodyAsString));

            // Act
            var body = await BodyParser.Parse(memoryStream, contentType);

            // Assert
            Check.That(body.BodyAsBytes).IsNotNull();
            Check.That(body.BodyAsJson).IsNull();
            Check.That(body.BodyAsString).Equals(bodyAsString);
            Check.That(body.DetectedBodyType).IsEqualTo(detectedBodyType);
            Check.That(body.DetectedBodyTypeFromContentType).IsEqualTo(detectedBodyTypeFromContentType);
        }
        /// <summary>
        /// Send a message
        /// <para> Permission Scope: (Send mail as user)</para>
        /// </summary>
        /// <param name="cancellationToken">The <see cref="CancellationToken"/> for the request.</param>
        /// <param name="subject">The subject of the message.</param>
        /// <param name="content">The text or HTML content.</param>
        /// <param name="contentType">The content type: Text = 0, HTML = 1</param>
        /// <param name="to">The To recipients for the message.</param>
        /// <param name="cc">The Cc recipients for the message.</param>
        /// <param name="importance">The importance of the message: Low = 0, Normal = 1, High = 2.</param>
        /// <returns><see cref="Task"/> representing the asynchronous operation.</returns>
        public Task SendEmailAsync(CancellationToken cancellationToken, string subject, string content, BodyType contentType, string[] to, string[] cc = null, Importance importance = Importance.Normal)
        {
            if (_currentUser == null)
            {
                throw new ServiceException(new Error {
                    Message = "No user connected", Code = "NoUserConnected", ThrowSite = "Windows Community Toolkit"
                });
            }

            List <Recipient> ccRecipients = null;

            if (to == null)
            {
                throw new ArgumentNullException(nameof(to));
            }

            ItemBody body = new ItemBody
            {
                Content     = content,
                ContentType = contentType
            };
            List <Recipient> toRecipients = new List <Recipient>();

            to.CopyTo(toRecipients);

            if (cc != null)
            {
                ccRecipients = new List <Recipient>();
                cc.CopyTo(ccRecipients);
            }

            Message coreMessage = new Message
            {
                Subject       = subject,
                Body          = body,
                Importance    = importance,
                ToRecipients  = toRecipients,
                CcRecipients  = ccRecipients,
                BccRecipients = null,
                IsDeliveryReceiptRequested = false,
            };

            var userBuilder = _graphProvider.Users[_currentUser.Id];

            return(userBuilder.SendMail(coreMessage, false).Request().PostAsync(cancellationToken));
        }
示例#38
0
        public static Body CreateSolidArc(World world, float density, float radians, int sides, float radius, Vector2 position = new Vector2(), float rotation = 0, BodyType bodyType = BodyType.Static)
        {
            Body body = CreateBody(world, position, rotation, bodyType);

            FixtureFactory.AttachSolidArc(density, radians, sides, radius, body);

            return(body);
        }
示例#39
0
        public static Body CreateRectangle(World world, float width, float height, float density, Vector2 position = new Vector2(), float rotation = 0, BodyType bodyType = BodyType.Static, object userData = null)
        {
            if (width <= 0)
            {
                throw new ArgumentOutOfRangeException("width", "Width must be more than 0 meters");
            }

            if (height <= 0)
            {
                throw new ArgumentOutOfRangeException("height", "Height must be more than 0 meters");
            }

            Body newBody = CreateBody(world, position, rotation, bodyType);

            newBody.UserData = userData;

            Vertices     rectangleVertices = PolygonTools.CreateRectangle(width / 2, height / 2);
            PolygonShape rectangleShape    = new PolygonShape(rectangleVertices, density);

            newBody.CreateFixture(rectangleShape);

            return(newBody);
        }
示例#40
0
        public static Body CreateRoundedRectangle(World world, float width, float height, float xRadius, float yRadius, int segments, float density, Vector2 position = new Vector2(), float rotation = 0, BodyType bodyType = BodyType.Static, object userData = null)
        {
            Vertices verts = PolygonTools.CreateRoundedRectangle(width, height, xRadius, yRadius, segments);

            //There are too many vertices in the capsule. We decompose it.
            if (verts.Count >= Settings.MaxPolygonVertices)
            {
                List <Vertices> vertList = Triangulate.ConvexPartition(verts, TriangulationAlgorithm.Earclip);
                return(CreateCompoundPolygon(world, vertList, density, position, rotation, bodyType, userData));
            }

            return(CreatePolygon(world, verts, density, position, rotation, bodyType, userData));
        }
示例#41
0
        public static Body CreateLineArc(World world, float radians, int sides, float radius, bool closed = false, Vector2 position = new Vector2(), float rotation = 0, BodyType bodyType = BodyType.Static)
        {
            Body body = CreateBody(world, position, rotation, bodyType);

            FixtureFactory.AttachLineArc(radians, sides, radius, closed, body);
            return(body);
        }
示例#42
0
        public static Body CreateCapsule(World world, float height, float endRadius, float density, Vector2 position = new Vector2(), float rotation = 0, BodyType bodyType = BodyType.Static, object userData = null)
        {
            //Create the middle rectangle
            Vertices rectangle = PolygonTools.CreateRectangle(endRadius, height / 2);

            List <Vertices> list = new List <Vertices>();

            list.Add(rectangle);

            Body body = CreateCompoundPolygon(world, list, density, position, rotation, bodyType, userData);

            FixtureFactory.AttachCircle(endRadius, density, body, new Vector2(0, height / 2));
            FixtureFactory.AttachCircle(endRadius, density, body, new Vector2(0, -(height / 2)));

            //Create the two circles
            //CircleShape topCircle = new CircleShape(endRadius, density);
            //topCircle.Position = new Vector2(0, height / 2);
            //body.CreateFixture(topCircle);

            //CircleShape bottomCircle = new CircleShape(endRadius, density);
            //bottomCircle.Position = new Vector2(0, -(height / 2));
            //body.CreateFixture(bottomCircle);
            return(body);
        }
示例#43
0
 public static Body CreateBody(World world, Vector2 position = new Vector2(), float rotation = 0, BodyType bodyType = BodyType.Static, object userData = null)
 {
     return(new Body(world, position, rotation, bodyType, userData));
 }
示例#44
0
        /// <summary>
        /// Duplicates the given Body along the given path for approximatly the given copies.
        /// </summary>
        /// <param name="world">The world.</param>
        /// <param name="path">The path.</param>
        /// <param name="shapes">The shapes.</param>
        /// <param name="type">The type.</param>
        /// <param name="copies">The copies.</param>
        /// <param name="userData"></param>
        /// <returns></returns>
        public static List <Body> EvenlyDistributeShapesAlongPath(World world, Path path, IEnumerable <Shape> shapes, BodyType type, int copies, object userData = null)
        {
            List <Vector3> centers  = path.SubdivideEvenly(copies);
            List <Body>    bodyList = new List <Body>();

            for (int i = 0; i < centers.Count; i++)
            {
                Body b = new Body(world);

                // copy the type from original body
                b.BodyType = type;
                b.Position = new Vector2(centers[i].X, centers[i].Y);
                b.Rotation = centers[i].Z;
                b.UserData = userData;

                foreach (Shape shape in shapes)
                {
                    b.CreateFixture(shape);
                }

                bodyList.Add(b);
            }

            return(bodyList);
        }
示例#45
0
        public static Body CreateCompoundPolygon(World world, List <Vertices> list, float density,
                                                 Vector2 position = new Vector2(), float rotation = 0, BodyType bodyType = BodyType.Static,
                                                 object userData  = null)
        {
            //We create a single body
            var body = CreateBody(world, position, rotation, bodyType, userData);

            FixtureFactory.AttachCompoundPolygon(list, density, body);
            return(body);
        }
示例#46
0
        public static Body CreateCircle(World world, float radius, float density, Vector2 position = new Vector2(), BodyType bodyType = BodyType.Static, object userData = null)
        {
            Body body = CreateBody(world, position, 0, bodyType);

            FixtureFactory.AttachCircle(radius, density, body, userData);
            return(body);
        }
示例#47
0
        public static Body CreatePolygon(World world, Vertices vertices, float density,
                                         Vector2 position = new Vector2(), float rotation = 0, BodyType bodyType = BodyType.Static,
                                         object userData  = null)
        {
            var body = CreateBody(world, position, rotation, bodyType, userData);

            FixtureFactory.AttachPolygon(vertices, density, body);
            return(body);
        }
示例#48
0
        public static Body CreateEllipse(World world, float xRadius, float yRadius, int edges, float density, Vector2 position = new Vector2(), float rotation = 0, BodyType bodyType = BodyType.Static, object userData = null)
        {
            Body body = CreateBody(world, position, rotation, bodyType);

            FixtureFactory.AttachEllipse(xRadius, yRadius, edges, density, body, userData);
            return(body);
        }
 /// <summary>
 /// Send an message
 /// <para> Permission Scope: (Send mail as user)</para>
 /// </summary>
 /// <param name="subject">The subject of the message.</param>
 /// <param name="content">The text or HTML content.</param>
 /// <param name="contentType">The content type: Text = 0, HTML = 1</param>
 /// <param name="to">The To recipients for the message.</param>
 /// <param name="cc">The Cc recipients for the message.</param>
 /// <param name="importance">The importance of the message: Low = 0, Normal = 1, High = 2.</param>
 /// <returns><see cref="Task"/> representing the asynchronous operation.</returns>
 public Task SendEmailAsync(string subject, string content, BodyType contentType, string[] to, string[] cc = null, Importance importance = Importance.Normal)
 {
     return(SendEmailAsync(CancellationToken.None, subject, content, contentType, to, cc, importance));
 }
示例#50
0
 public void AddBody(BodyType bodyType)
 {
     Console.WriteLine("{0} Body Added", Enum.GetName(typeof(BodyType), bodyType));
 }
示例#51
0
 /// <summary>
 /// Reads attributes from XML.
 /// </summary>
 /// <param name="reader">The reader.</param>
 internal override void ReadAttributesFromXml(EwsServiceXmlReader reader)
 {
     this.bodyType = reader.ReadAttributeValue <BodyType>(XmlAttributeNames.BodyType);
 }
示例#52
0
        public Body(BodyDef bd, World world)
        {
            Debug.Assert(bd.Position.Valid);
            Debug.Assert(bd.LinearVelocity.Valid);
            Debug.Assert(bd.GravityScale >= 0.0f);
            Debug.Assert(bd.AngularDamping >= 0.0f);
            Debug.Assert(bd.LinearDamping >= 0.0f);

            Flags = TypeFlags.None;

            if (bd.Bullet)
            {
                Flags |= TypeFlags.Bullet;
            }
            if (bd.FixedRotation)
            {
                Flags |= TypeFlags.FixedRotation;
            }
            if (bd.AllowSleep)
            {
                Flags |= TypeFlags.AutoSleep;
            }
            if (bd.Awake)
            {
                Flags |= TypeFlags.Awake;
            }
            if (bd.Active)
            {
                Flags |= TypeFlags.Active;
            }

            World = world;

            Xf.P.Set(bd.Position);
            Xf.Q.Set(bd.Angle);

            Sweep.LocalCenter.SetZero();
            Sweep.C0.Set(Xf.P);
            Sweep.C.Set(Xf.P);
            Sweep.A0     = bd.Angle;
            Sweep.A      = bd.Angle;
            Sweep.Alpha0 = 0.0f;

            JointList   = null;
            ContactList = null;
            Prev        = null;
            Next        = null;

            m_linearVelocity.Set(bd.LinearVelocity);
            m_angularVelocity = bd.AngularVelocity;

            LinearDamping  = bd.LinearDamping;
            AngularDamping = bd.AngularDamping;
            GravityScale   = bd.GravityScale;

            Force.SetZero();
            Torque = 0.0f;

            SleepTime = 0.0f;

            m_type = bd.Type;

            if (m_type == BodyType.Dynamic)
            {
                Mass    = 1f;
                InvMass = 1f;
            }
            else
            {
                Mass    = 0f;
                InvMass = 0f;
            }

            I    = 0.0f;
            InvI = 0.0f;

            UserData = bd.UserData;

            FixtureList  = null;
            FixtureCount = 0;
        }
示例#53
0
        public Dictionary <string, Person> GetPeople(HashSet <String> ids, HashSet <String> fields, CollectionOptions options)
        {
            var result = new Dictionary <string, Person>();

            using (var db = new AzureRayaDataContext())
            {
                // TODO filter first then fill dictionary
                foreach (var id in ids)
                {
                    var p = db.persons.Where(x => x.PartitionKey == id).SingleOrDefault();
                    if (p == null)
                    {
                        continue;
                    }
                    string personId = p.id;
                    var    name     = new Name();
                    var    person   = new Person();

                    name.givenName     = p.first_name;
                    name.familyName    = p.last_name;
                    name.formatted     = p.first_name + " " + p.last_name;
                    person.displayName = name.formatted;
                    person.name        = name;
                    person.id          = personId;
                    if (fields.Contains("about_me") || fields.Contains("@all"))
                    {
                        person.aboutMe = p.about_me;
                    }
                    if (fields.Contains("age") || fields.Contains("@all"))
                    {
                        person.age = p.age;
                    }
                    if (fields.Contains("children") || fields.Contains("@all"))
                    {
                        person.children = p.children;
                    }
                    if (fields.Contains("date_of_birth") || fields.Contains("@all"))
                    {
                        if (p.date_of_birth.HasValue)
                        {
                            person.birthday = UnixTime.ToDateTime(p.date_of_birth.Value);
                        }
                    }
                    if (fields.Contains("ethnicity") || fields.Contains("@all"))
                    {
                        person.ethnicity = p.ethnicity;
                    }
                    if (fields.Contains("fashion") || fields.Contains("@all"))
                    {
                        person.fashion = p.fashion;
                    }
                    if (fields.Contains("happiest_when") || fields.Contains("@all"))
                    {
                        person.happiestWhen = p.happiest_when;
                    }
                    if (fields.Contains("humor") || fields.Contains("@all"))
                    {
                        person.humor = p.humor;
                    }
                    if (fields.Contains("job_interests") || fields.Contains("@all"))
                    {
                        person.jobInterests = p.job_interests;
                    }
                    if (fields.Contains("living_arrangement") || fields.Contains("@all"))
                    {
                        person.livingArrangement = p.living_arrangement;
                    }
                    if (fields.Contains("looking_for") || fields.Contains("@all"))
                    {
                        person._lookingFor = p.looking_for;
                    }
                    if (fields.Contains("nickname") || fields.Contains("@all"))
                    {
                        person.nickname = p.nickname;
                    }
                    if (fields.Contains("pets") || fields.Contains("@all"))
                    {
                        person.pets = p.pets;
                    }
                    if (fields.Contains("political_views") || fields.Contains("@all"))
                    {
                        person.politicalViews = p.political_views;
                    }
                    if (fields.Contains("profile_song") || fields.Contains("@all"))
                    {
                        if (!string.IsNullOrEmpty(p.profile_song))
                        {
                            person.profileSong = new Url(p.profile_song, "", "");
                        }
                    }
                    if (fields.Contains("profileUrl") || fields.Contains("@all"))
                    {
                        person.profileUrl = urlPrefix + "/profile/" + personId;
                    }
                    if (fields.Contains("profile_video") || fields.Contains("@all"))
                    {
                        if (!string.IsNullOrEmpty(p.profile_video))
                        {
                            person.profileVideo = new Url(p.profile_video, "", "");
                        }
                    }
                    if (fields.Contains("relationship_status") || fields.Contains("@all"))
                    {
                        person.relationshipStatus = p.relationship_status;
                    }
                    if (fields.Contains("religion") || fields.Contains("@all"))
                    {
                        person.religion = p.religion;
                    }
                    if (fields.Contains("romance") || fields.Contains("@all"))
                    {
                        person.romance = p.romance;
                    }
                    if (fields.Contains("scared_of") || fields.Contains("@all"))
                    {
                        person.scaredOf = p.scared_of;
                    }
                    if (fields.Contains("sexual_orientation") || fields.Contains("@all"))
                    {
                        person.sexualOrientation = p.sexual_orientation;
                    }
                    if (fields.Contains("status") || fields.Contains("@all"))
                    {
                        person.status = p.status;
                    }
                    if (fields.Contains("thumbnailUrl") || fields.Contains("@all"))
                    {
                        person.thumbnailUrl = !string.IsNullOrEmpty(p.thumbnail_url) ? urlPrefix + p.thumbnail_url : "";
                        if (!string.IsNullOrEmpty(p.thumbnail_url))
                        {
                            person.photos = new List <ListField>
                            {
                                new Url(urlPrefix + p.thumbnail_url, "thumbnail", "thumbnail")
                            };
                        }
                    }
                    if (fields.Contains("time_zone") || fields.Contains("@all"))
                    {
                        person.utcOffset = p.time_zone; // force "-00:00" utc-offset format
                    }
                    if (fields.Contains("drinker") || fields.Contains("@all"))
                    {
                        if (!String.IsNullOrEmpty(p.drinker))
                        {
                            person.drinker = (Drinker)Enum.Parse(typeof(Drinker), p.drinker);
                        }
                    }
                    if (fields.Contains("gender") || fields.Contains("@all"))
                    {
                        if (!String.IsNullOrEmpty(p.gender))
                        {
                            person.gender = (Person.Gender)Enum.Parse(typeof(Person.Gender), p.gender, true);
                        }
                    }
                    if (fields.Contains("smoker") || fields.Contains("@all"))
                    {
                        if (!String.IsNullOrEmpty(p.smoker))
                        {
                            person.smoker = (Smoker)Enum.Parse(typeof(Smoker), p.smoker);
                        }
                    }
                    if (fields.Contains("activities") || fields.Contains("@all"))
                    {
                        var activities = db.activities.Where(a => a.PartitionKey == personId);
                        person.activities = new List <string>();
                        foreach (var act in activities)
                        {
                            person.activities.Add(act.title);
                        }
                    }

                    if (fields.Contains("addresses") || fields.Contains("@all"))
                    {
                        var personAddresses = db.addressesPerson
                                              .Where(x => x.PartitionKey == personId);
                        List <Address> addresses = new List <Address>();
                        foreach (var row in personAddresses)
                        {
                            if (String.IsNullOrEmpty(row.unstructured_address))
                            {
                                row.unstructured_address = (row.street_address + " " + row.region + " " + row.country).Trim();
                            }
                            var addr = new Address(row.unstructured_address);
                            addr.country       = row.country;
                            addr.latitude      = row.latitude;
                            addr.longitude     = row.longitude;
                            addr.locality      = row.locality;
                            addr.postalCode    = row.postal_code;
                            addr.region        = row.region;
                            addr.streetAddress = row.street_address;
                            addr.type          = row.address_type;
                            //FIXME quick and dirty hack to demo PC
                            addr.primary = true;
                            addresses.Add(addr);
                        }
                        person.addresses = addresses;
                    }

                    if (fields.Contains("bodyType") || fields.Contains("@all"))
                    {
                        var row = db.personBodyTypes.Where(x => x.PartitionKey == personId).SingleOrDefault();
                        if (row != null)
                        {
                            BodyType bodyType = new BodyType();
                            bodyType.build     = row.build;
                            bodyType.eyeColor  = row.eye_color;
                            bodyType.hairColor = row.hair_color;
                            bodyType.height    = row.height;
                            bodyType.weight    = row.weight;
                            person.bodyType    = bodyType;
                        }
                    }

                    if (fields.Contains("books") || fields.Contains("@all"))
                    {
                        var books    = db.personBooks.Where(x => x.PartitionKey == personId);
                        var bookList = new List <string>();
                        foreach (var book in books)
                        {
                            bookList.Add(book.book);
                        }
                        person.books = bookList;
                    }

                    if (fields.Contains("cars") || fields.Contains("@all"))
                    {
                        var cars    = db.personCars.Where(x => x.PartitionKey == personId);
                        var carList = new List <string>();
                        foreach (var car in cars)
                        {
                            carList.Add(car.car);
                        }
                        person.cars = carList;
                    }

                    if (fields.Contains("currentLocation") || fields.Contains("@all"))
                    {
                        var row = db.personCurrentLocations
                                  .Where(x => x.PartitionKey == personId).SingleOrDefault();
                        if (row != null)
                        {
                            if (string.IsNullOrEmpty(row.unstructured_address))
                            {
                                row.unstructured_address = (row.street_address + " " + row.region + " " + row.country).Trim();
                            }
                            var addr = new Address(row.unstructured_address);
                            addr.country           = row.country;
                            addr.latitude          = row.latitude;
                            addr.longitude         = row.longitude;
                            addr.locality          = row.locality;
                            addr.postalCode        = row.postal_code;
                            addr.region            = row.region;
                            addr.streetAddress     = row.street_address;
                            addr.type              = row.address_type;
                            person.currentLocation = addr;
                        }
                    }

                    if (fields.Contains("emails") || fields.Contains("@all"))
                    {
                        var emails = db.personEmails.Where(x => x.PartitionKey == personId);
                        List <ListField> emailList = new List <ListField>();
                        foreach (var email in emails)
                        {
                            emailList.Add(new ListField(email.email_type, email.address)); // TODO: better email canonicalization; remove dups
                        }
                        person.emails = emailList;
                    }

                    if (fields.Contains("food") || fields.Contains("@all"))
                    {
                        var foods    = db.personFoods.Where(x => x.PartitionKey == personId);
                        var foodList = new List <string>();
                        foreach (var food in foods)
                        {
                            foodList.Add(food.food);
                        }
                        person.food = foodList;
                    }

                    if (fields.Contains("heroes") || fields.Contains("@all"))
                    {
                        var heroes   = db.personHeroes.Where(x => x.PartitionKey == personId);
                        var heroList = new List <string>();
                        foreach (var hero in heroes)
                        {
                            heroList.Add(hero.hero);
                        }
                        person.heroes = heroList;
                    }

                    if (fields.Contains("interests") || fields.Contains("@all"))
                    {
                        var interests    = db.personInterests.Where(x => x.PartitionKey == personId);
                        var interestList = new List <string>();
                        foreach (var interest in interests)
                        {
                            interestList.Add(interest.interest);
                        }
                        person.interests = interestList;
                    }
                    List <Organization> organizations = new List <Organization>();
                    bool fetchedOrg = false;
                    if (fields.Contains("jobs") || fields.Contains("@all"))
                    {
                        var jobs = db.personJobs
                                   .Where(x => x.PartitionKey == personId);
                        foreach (var job in jobs)
                        {
                            var organization = new Organization();
                            organization.description = job.description;
                            if (job.end_date.HasValue)
                            {
                                organization.endDate = UnixTime.ToDateTime(job.end_date.Value);
                            }
                            organization.field  = job.field;
                            organization.name   = job.name;
                            organization.salary = job.salary;
                            if (job.start_date.HasValue)
                            {
                                organization.startDate = UnixTime.ToDateTime(job.start_date.Value);
                            }
                            organization.subField = job.sub_field;
                            organization.title    = job.title;
                            organization.webpage  = job.webpage;
                            organization.type     = "job";
                            if (!string.IsNullOrEmpty(job.id))
                            {
                                var addresses = db.addressesOrganization.Where(x => x.organization_id == job.id).Single();
                                if (string.IsNullOrEmpty(addresses.unstructured_address))
                                {
                                    addresses.unstructured_address = (addresses.street_address + " " + addresses.region + " " + addresses.country).Trim();
                                }
                                var addr = new Address(addresses.unstructured_address);
                                addr.country         = addresses.country;
                                addr.latitude        = addresses.latitude;
                                addr.longitude       = addresses.longitude;
                                addr.locality        = addresses.locality;
                                addr.postalCode      = addresses.postal_code;
                                addr.region          = addresses.region;
                                addr.streetAddress   = addresses.street_address;
                                addr.type            = addresses.address_type;
                                organization.address = addr;
                            }
                            organizations.Add(organization);
                        }
                        fetchedOrg = true;
                    }

                    if (fields.Contains("schools") || fields.Contains("@all"))
                    {
                        var schools = db.personSchools
                                      .Where(x => x.PartitionKey == personId);
                        foreach (var school in schools)
                        {
                            var organization = new Organization();
                            organization.description = school.description;
                            if (school.end_date.HasValue)
                            {
                                organization.endDate = UnixTime.ToDateTime(school.end_date.Value);
                            }
                            organization.field  = school.field;
                            organization.name   = school.name;
                            organization.salary = school.salary;
                            if (school.start_date.HasValue)
                            {
                                organization.startDate = UnixTime.ToDateTime(school.start_date.Value);
                            }
                            organization.subField = school.sub_field;
                            organization.title    = school.title;
                            organization.webpage  = school.webpage;
                            organization.type     = "school";
                            if (!string.IsNullOrEmpty(school.id))
                            {
                                var res3 = db.addressesOrganization.Where(x => x.organization_id == school.id).Single();
                                if (string.IsNullOrEmpty(res3.unstructured_address))
                                {
                                    res3.unstructured_address = (res3.street_address + " " + res3.region + " " + res3.country).Trim();
                                }
                                var addres = new Address(res3.unstructured_address);
                                addres.country       = res3.country;
                                addres.latitude      = res3.latitude;
                                addres.longitude     = res3.longitude;
                                addres.locality      = res3.locality;
                                addres.postalCode    = res3.postal_code;
                                addres.region        = res3.region;
                                addres.streetAddress = res3.street_address;
                                addres.type          = res3.address_type;
                                organization.address = addres;
                            }
                            organizations.Add(organization);
                        }
                        fetchedOrg = true;
                    }
                    if (fetchedOrg)
                    {
                        person.organizations = organizations;
                    }
                    //TODO languagesSpoken, currently missing the languages / countries tables so can"t do this yet

                    if (fields.Contains("movies") || fields.Contains("@all"))
                    {
                        var movies    = db.personMovies.Where(x => x.PartitionKey == personId);
                        var movieList = new List <string>();
                        foreach (var movie in movies)
                        {
                            movieList.Add(movie.movie);
                        }
                        person.movies = movieList;
                    }
                    if (fields.Contains("music") || fields.Contains("@all"))
                    {
                        var musics    = db.personMusics.Where(x => x.PartitionKey == personId);
                        var musicList = new List <string>();
                        foreach (var music in musics)
                        {
                            musicList.Add(music.music);
                        }
                        person.music = musicList;
                    }
                    if (fields.Contains("phoneNumbers") || fields.Contains("@all"))
                    {
                        List <ListField> numList = new List <ListField>();
                        var numbers = db.personPhoneNumbers.Where(x => x.PartitionKey == personId);
                        foreach (var number in numbers)
                        {
                            numList.Add(new ListField(number.number_type, number.number));
                        }
                        person.phoneNumbers = numList;
                    }

                    /*
                     * if (_fields.Contains("ims") || _fields.Contains("@all"))
                     * {
                     *  var _ims = array();
                     *  _res2 = mysqli_query(this._db, "select value, value_type from person_ims where person_id = " + _person_id);
                     *  while (list(_value, _type) = @mysqli_fetch_row(_res2))
                     *  {
                     *  _ims[] = new Im(_value, _type);
                     *  }
                     *  _person.Ims = _ims;
                     * }
                     * if (_fields.Contains("accounts") || _fields.Contains("@all")) {
                     * _accounts = array();
                     * _res2 = mysqli_query(this._db, "select domain, userid, username from person_accounts where person_id = " + _person_id);
                     * while (list(_domain, _userid, _username) = @mysqli_fetch_row(_res2)) {
                     * _accounts[] = new Account(_domain, _userid, _username);
                     * }
                     * _person.Accounts = _accounts;
                     * }*/
                    /*
                     * if (fields.Contains("quotes") || fields.Contains("@all"))
                     * {
                     *  var _strings = db.person_quotes.Where(x => x.person_id == personId).Select(x => x.quote);
                     *  person.quotes = _strings.ToList();
                     * }
                     * if (fields.Contains("sports") || fields.Contains("@all"))
                     * {
                     *  var _strings = db.person_sports.Where(x => x.person_id == personId).Select(x => x.sport);
                     *  person.sports = _strings.ToList();
                     * }
                     *
                     * if (fields.Contains("tags") || fields.Contains("@all"))
                     * {
                     *  var _strings = db.person_tags.Where(x => x.person_id == personId).Select(x => x.tag);
                     *  person.tags = _strings.ToList();
                     * }
                     *
                     * if (fields.Contains("turnOns") || fields.Contains("@all"))
                     * {
                     *  var _strings = db.person_turn_ons.Where(x => x.person_id == personId).Select(x => x.turn_on);
                     *  person.turnOns = _strings.ToList();
                     * }
                     * if (fields.Contains("turnOffs") || fields.Contains("@all"))
                     * {
                     *  var _strings = db.person_turn_offs.Where(x => x.person_id == personId).Select(x => x.turn_off);
                     *  person.turnOffs = _strings.ToList();
                     * }
                     * */
                    if (fields.Contains("urls") || fields.Contains("@all"))
                    {
                        var urls = db.personUrls.Where(x => x.PartitionKey == personId);
                        List <ListField> urllist = new List <ListField>();
                        foreach (var u in urls)
                        {
                            var url = new Url(u.url, null, null);
                            urllist.Add(url);
                        }
                        //urllist.Add(new Url(urlPrefix + "/profile/" + personId, null, "profile"));
                        person.urls = urllist;
                    }

                    result.Add(personId, person);
                } // foreach
            }

            return(result);
        }
示例#54
0
        public Body(World world, Vector2 position = new Vector2(), float rotation = 0, BodyType bodyType = BodyType.Static, object userdata = null)
        {
            FixtureList = new List <Fixture>();
            BodyId      = _bodyIdCounter++;

            _world           = world;
            _enabled         = true;
            _awake           = true;
            _sleepingAllowed = true;

            UserData     = userdata;
            GravityScale = 1.0f;
            BodyType     = bodyType;

            _xf.q.Set(rotation);

            //FPE: optimization
            if (position != Vector2.Zero)
            {
                _xf.p     = position;
                _sweep.C0 = _xf.p;
                _sweep.C  = _xf.p;
            }

            //FPE: optimization
            if (rotation != 0)
            {
                _sweep.A0 = rotation;
                _sweep.A  = rotation;
            }

            world.AddBody(this); //FPE note: bodies can't live without a World
        }
示例#55
0
        public static Body CreateCapsule(World world, float height, float topRadius, int topEdges, float bottomRadius, int bottomEdges, float density, Vector2 position = new Vector2(), float rotation = 0, BodyType bodyType = BodyType.Static, object userData = null)
        {
            Vertices verts = PolygonUtils.CreateCapsule(height, topRadius, topEdges, bottomRadius, bottomEdges);

            //There are too many vertices in the capsule. We decompose it.
            if (verts.Count > Settings.MaxPolygonVertices)
            {
                List <Vertices> vertList = Triangulate.ConvexPartition(verts, TriangulationAlgorithm.Earclip);
                return(CreateCompoundPolygon(world, vertList, density, position, rotation, bodyType, userData));
            }

            return(CreatePolygon(world, verts, density, position, rotation, bodyType, userData));
        }
示例#56
0
 public HybridBuilder SetBodyType(BodyType bodyType)
 {
     _hybrid.BodyType = bodyType;
     return(this);
 }
示例#57
0
 void SetIconFor(SystemBodyInfoDB db)
 {
     BodyType type = db.BodyType;
     float    temp = db.BaseTemperature;
 }
示例#58
0
        public static Body CreateRectangle(World world, float width, float height, float density,
                                           Vector2 position = new Vector2(), float rotation = 0, BodyType bodyType = BodyType.Static,
                                           object userData  = null)
        {
            if (width <= 0)
            {
                throw new ArgumentOutOfRangeException(nameof(width), "Width must be more than 0 meters");
            }

            if (height <= 0)
            {
                throw new ArgumentOutOfRangeException(nameof(height), "Height must be more than 0 meters");
            }

            var body = CreateBody(world, position, rotation, bodyType, userData);

            var rectangleVertices = PolygonUtils.CreateRectangle(width / 2, height / 2);

            FixtureFactory.AttachPolygon(rectangleVertices, density, body);

            return(body);
        }
示例#59
0
        /// <summary>
        /// Duplicates the given Body along the given path for approximatly the given copies.
        /// </summary>
        /// <param name="world">The world.</param>
        /// <param name="path">The path.</param>
        /// <param name="shape">The shape.</param>
        /// <param name="type">The type.</param>
        /// <param name="copies">The copies.</param>
        /// <param name="userData">The user data.</param>
        /// <returns></returns>
        public static List <Body> EvenlyDistributeShapesAlongPath(World world, Path path, Shape shape, BodyType type,
                                                                  int copies, object userData)
        {
            List <Shape> shapes = new List <Shape>(1);

            shapes.Add(shape);

            return(EvenlyDistributeShapesAlongPath(world, path, shapes, type, copies, userData));
        }
示例#60
0
        public void Clone(Body body)
        {
            this._angularDamping  = body._angularDamping;
            this._bodyType        = body._bodyType;
            this._inertia         = body._inertia;
            this._linearDamping   = body._linearDamping;
            this._mass            = body._mass;
            this._sleepingAllowed = body._sleepingAllowed;
            this._awake           = body._awake;
            this._fixedRotation   = body._fixedRotation;
            this._enabled         = body._enabled;
            this._angularVelocity = body._angularVelocity;
            this._linearVelocity  = body._linearVelocity;
            this._force           = body._force;
            this._invI            = body._invI;
            this._invMass         = body._invMass;
            this._sleepTime       = body._sleepTime;

            this._sweep.A           = body._sweep.A;
            this._sweep.A0          = body._sweep.A0;
            this._sweep.Alpha0      = body._sweep.Alpha0;
            this._sweep.C           = body._sweep.C;
            this._sweep.C0          = body._sweep.C0;
            this._sweep.LocalCenter = body._sweep.LocalCenter;

            this._torque = body._torque;

            this._xf.p = body._xf.p;
            this._xf.q = body._xf.q;

            this._island  = body._island;
            this.disabled = body.disabled;

            this.GravityScale  = body.GravityScale;
            this.IsBullet      = body.IsBullet;
            this.IgnoreCCD     = body.IgnoreCCD;
            this.IgnoreGravity = body.IgnoreGravity;

            this.prevKinematicMass    = body.prevKinematicMass;
            this.prevKinematicInvMass = body.prevKinematicInvMass;
            this.prevKinematicInertia = body.prevKinematicInertia;
            this.prevKinematicInvI    = body.prevKinematicInvI;
            this.prevKinematicSweep   = body.prevKinematicSweep;

            for (int index = 0, length = shapesClone.Count; index < length; index++)
            {
                poolClone2D.GiveBack(shapesClone[index]);
            }

            this.shapesClone.Clear();

            List <Physics2D.Fixture> fixtureList = body.FixtureList;

            for (int index = 0, length = fixtureList.Count; index < length; index++)
            {
                GenericShapeClone2D shapeClone = poolClone2D.GetNew();
                shapeClone.Clone(body.FixtureList[index].Shape);

                this.shapesClone.Add(shapeClone);
            }

            if (body.ContactList == null)
            {
                this.contactEdgeClone = null;
            }
            else
            {
                this.contactEdgeClone = WorldClone2D.poolContactEdgeClone.GetNew();
                this.contactEdgeClone.Clone(body.ContactList);
            }
        }