Ejemplo n.º 1
0
 protected override void OnRemoved(ComponentStateEventArgs registrationArgs)
 {
     physics.Body.BroadphaseTag &= ~(int)BodyTags.Projectile;
     physics.Synchronized -= syncHandler;
     physics.World.Events.BodiesBeginCollide -= collideHandler;
     base.OnRemoved(registrationArgs);
 }
Ejemplo n.º 2
0
 /// <summary>
 /// Occurs when the component is dettached from an entity.
 /// </summary>
 protected virtual void OnRemoved(ComponentStateEventArgs registrationArgs)
 {
     if (Removed != null)
     {
         Removed(this, registrationArgs);
     }
 }
Ejemplo n.º 3
0
 protected override void OnAdded(ComponentStateEventArgs registrationArgs)
 {
     base.OnAdded(registrationArgs);
     physics.Body.Material.Restitution = 0f;
     physics.Body.Material.KineticFriction = 0.5f;
     physics.Body.Material.StaticFriction = 0.5f;
     physics.Body.SetMassProperties(JMatrix.Zero, 1.0f, true);
 }
Ejemplo n.º 4
0
 protected override void OnAdded(ComponentStateEventArgs registrationArgs)
 {
     base.OnAdded(registrationArgs);
     if (physics.Body.Shape is Multishape) throw new NotSupportedException("Multishapes not supported!");
     physics.Body.BroadphaseTag |= (int)BodyTags.Projectile;
     physics.Body.SetMassProperties(JMatrix.Identity, 0.1f, false);
     physics.Synchronized += syncHandler;
 }
Ejemplo n.º 5
0
		protected override void OnAdded(ComponentStateEventArgs registrationArgs)
		{
			base.OnAdded(registrationArgs);
			if (physics.Body.Shape is Multishape) throw new NotSupportedException("Multishapes not supported!");
			physics.Body.IsStatic = true;
			physics.Body.BroadphaseTag |= (int)BodyTags.Ghost;
			physics.Synchronized += syncHandler;
		}
Ejemplo n.º 6
0
 protected override void OnAdded(ComponentStateEventArgs registrationArgs) {
     base.OnAdded(registrationArgs);
     /*
     Layer =
         _sprite.Layer - 1;
     */
     Size = new Size(
         _sprite.Size.Width + TextureSourceRectangle.Width,
         _sprite.Size.Height + TextureSourceRectangle.Height);
 }
Ejemplo n.º 7
0
		private void Synchronized(object sender, ComponentStateEventArgs componentStateEventArgs)
		{
			if (IsOutOfSync)
			{
				physics.World.Events.PostStep -= postStepHandler;
			}
			else
			{
				physics.World.Events.PostStep += postStepHandler;
			}
		}
Ejemplo n.º 8
0
	    protected override void OnAdded(ComponentStateEventArgs registrationArgs)
        {
            base.OnAdded(registrationArgs);
			Body.Tag = Record.Name;
            var offset = Body.Position;
            var rot = JMatrix.CreateFromQuaternion(transform.Rotation.ToQuaternion());
            JVector.Transform(ref offset, ref rot, out offset);
            Offset = offset.ToVector3();
            Body.Orientation = Body.Orientation * rot;
            Body.Position = offset + transform.Translation.ToJVector();
			baseTransform = new Transform(JQuaternion.CreateFromMatrix(Body.Orientation).ToQuaternion(),
										 Body.Position.ToVector3()).Invert() * new Transform(transform.Rotation, transform.Translation);
            storedScale = transform.Scale;
            transform.Bind(GetTransform, SetTransform);
        }
Ejemplo n.º 9
0
 protected override void OnAdded(ComponentStateEventArgs registrationArgs)
 {
     base.OnAdded(registrationArgs);
     physics.Body.Material.Restitution = 0f;
     physics.Body.Material.KineticFriction = 0.5f;
     physics.Body.Material.StaticFriction = 0.5f;
     physics.Body.Mass = 1000f;
     physics.Body.SetMassProperties(JMatrix.Zero, 1/physics.Body.Mass, true);
     constraint = new TargetConstraint(physics.Body) {Velocity = 3.0f};
     Activate();
     physics.Synchronized += (sender, args) =>
                                 {
                                     if (!IsOutOfSync)
                                         physics.World.AddConstraint(constraint);
                                     else
                                         physics.World.RemoveConstraint(constraint);
                                 };
 }
Ejemplo n.º 10
0
        protected override void OnRemoved(ComponentStateEventArgs registrationArgs) {
            base.OnRemoved(registrationArgs);

            for (int i = 0; i < _sprites.Length; i++) {
                Sprite sprite = _sprites[i];

                if (sprite == null) {
                    continue;
                }

                if (sprite.Record != null) {
                    sprite.Record.Drop();
                }

                if (SpriteBatch != null) {
                    SpriteBatch.Remove(sprite);
                }

                _sprites[i] = null;
            }
        }
Ejemplo n.º 11
0
 protected override void OnAdded(ComponentStateEventArgs e)
 {
     base.OnAdded(e);
 }
Ejemplo n.º 12
0
        /// <summary>
        /// Occurs when the component is dettached from an entity. All managed dependencies are null'ed.
        /// </summary>
        /// <remarks>
        /// If you don't want the dependencies to get lost, then override this method and don't call base.
        /// </remarks>
        protected override void OnRemoved(ComponentStateEventArgs registrationArgs)
        {
            base.OnRemoved(registrationArgs);

            ClearDependencies();
        }
Ejemplo n.º 13
0
        /// <summary>
        /// Occurs when the component is attached to an entity. All dependencies are injected.
        /// </summary>
        protected override void OnAdded(ComponentStateEventArgs registrationArgs)
        {
            base.OnAdded(registrationArgs);

            InjectDependencies();
        }
Ejemplo n.º 14
0
 protected override void OnAdded(ComponentStateEventArgs e)
 {
     base.OnAdded(e);
     phys.Body.Material.KineticFriction = 0f;
     phys.Body.Material.StaticFriction = 0f;
     phys.Body.Material.Restitution = 0f;
     var invInertia = phys.Body.InverseInertia;
     invInertia.M11 = 0;
     invInertia.M22 = 0;
     invInertia.M33 = 0;
     phys.Body.SetMassProperties(invInertia, 1f, true);
     phys.Synchronized += OnSynchronized;
 }
Ejemplo n.º 15
0
 void OnSpriteRemoved(object sender, ComponentStateEventArgs e) {
     Remove(sender as Sprite);
 }
Ejemplo n.º 16
0
 private void Synchronized(object sender, ComponentStateEventArgs componentStateEventArgs)
 {
     if (IsOutOfSync) return;
     physics.World.Events.BodiesBeginCollide += collideHandler;
 }
Ejemplo n.º 17
0
 protected override void OnRemoved(ComponentStateEventArgs e)
 {
     if (controller != null) phys.World.RemoveConstraint(controller);
     base.OnRemoved(e);
 }
Ejemplo n.º 18
0
 private void OnSynchronized(object sender, ComponentStateEventArgs e)
 {
     if (!IsOutOfSync)
     {
         controller = new CharacterController(phys.World, phys.Body);
         controller.StateChanged += OnStateChanged;
         phys.World.AddConstraint(controller);
         var ground = Entity.FindAllWithComponent<TerrainComponent>().FirstOrDefault();
         terrain = ground.GetComponent<TerrainComponent>();
         terrainPhys = ground.GetComponent<PhysicsComponent>();
     }
 }
Ejemplo n.º 19
0
 protected override void OnRemoved(ComponentStateEventArgs e)
 {
     base.OnRemoved(e);
     localParent.RemoveChild(localRoot);
 }
Ejemplo n.º 20
0
        protected override void OnAdded(ComponentStateEventArgs registrationArgs) {
            base.OnAdded(registrationArgs);

            Reset();
        }
Ejemplo n.º 21
0
        protected override void OnAdded(ComponentStateEventArgs registrationArgs) {
            base.OnAdded(registrationArgs);

            _walls.Left += OnLeftBoundaries;
        }
Ejemplo n.º 22
0
		protected override void OnRemoved(ComponentStateEventArgs registrationArgs)
		{
			base.OnRemoved(registrationArgs);
			physics.Body.BroadphaseTag ^= (int)BodyTags.Ghost;
			physics.Synchronized -= syncHandler;
		}
Ejemplo n.º 23
0
        /// <summary>
        /// Occurs when the component is attached to an entity. All dependencies are injected.
        /// </summary>
        protected override void OnAdded(ComponentStateEventArgs registrationArgs)
        {
            base.OnAdded(registrationArgs);

            InjectDependencies();
        }
Ejemplo n.º 24
0
        /// <summary>
        /// Occurs when the component is dettached from an entity. All managed dependencies are null'ed.
        /// </summary>
        /// <remarks>
        /// > If you don't want the dependencies to get lost, then override this method and don't base.
        /// </remarks>
        protected override void OnRemoved(ComponentStateEventArgs registrationArgs)
        {
            base.OnRemoved(registrationArgs);

            ClearDependencies();
        }