CreateComponent() публичный Метод

public CreateComponent ( Artemis.Entity entity, BodyDefinition definition, bool remoteSync = true ) : Physics2dComponent
entity Artemis.Entity
definition BodyDefinition
remoteSync bool
Результат Asgard.EntitySystems.Components.Physics2dComponent
Пример #1
0
        public void Setup(Midgard world,  long ballId = 0)
        {
            var manager = world.EntityManager;
            if (ballId > 0)
            {
                _entity = manager.GetEntityByUniqueId(ballId);
                if (_entity == null)
                    _entity = manager.Create(ballId);
            }
            else
            {
                _entity = manager.Create();
            }

            var phyComp = world.CreateComponent(_entity, BodyDef);
            var body = phyComp.Body;

            CircleShape shape = new CircleShape(1,1);
            var fix = body.CreateFixture(shape);
            fix.Restitution = 1;
        }
Пример #2
0
        private void CreatePhysics(Midgard midgard, Entity entity, bool usePos = true)
        {
            var comp = midgard.CreateComponent(entity,
                            new BodyDefinition()
                            {
                                Position = usePos ? new Farseer.Framework.Vector2(18f + (float)rnd.Next(0, 4), 17f + (float)rnd.Next(0, 3)) :
                                new Farseer.Framework.Vector2(0, 0)
                            });

            Vertices rectangleVertices = PolygonTools.CreateRectangle(0.5f, 0.2f,
                new Farseer.Framework.Vector2(0f, 0.4f), 0f);
            PolygonShape shape = new PolygonShape(rectangleVertices, 10000f);
            var fix = comp.Body.CreateFixture(shape);
            comp.Body.FixedRotation = true;
            comp.Body.Mass = 1000f;
            comp.Body.Restitution = 1f;
            comp.Body.CollisionCategories = FarseerPhysics.Dynamics.Category.Cat2;
            comp.Body.CollidesWith = FarseerPhysics.Dynamics.Category.Cat1;
        }