protected override void OnRemoved(ComponentStateEventArgs registrationArgs) { physics.Body.BroadphaseTag &= ~(int)BodyTags.Projectile; physics.Synchronized -= syncHandler; physics.World.Events.BodiesBeginCollide -= collideHandler; base.OnRemoved(registrationArgs); }
/// <summary> /// Occurs when the component is dettached from an entity. /// </summary> protected virtual void OnRemoved(ComponentStateEventArgs registrationArgs) { if (Removed != null) { Removed(this, registrationArgs); } }
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); }
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; }
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; }
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); }
private void Synchronized(object sender, ComponentStateEventArgs componentStateEventArgs) { if (IsOutOfSync) { physics.World.Events.PostStep -= postStepHandler; } else { physics.World.Events.PostStep += postStepHandler; } }
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); }
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); }; }
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; } }
protected override void OnAdded(ComponentStateEventArgs e) { base.OnAdded(e); }
/// <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(); }
/// <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(); }
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; }
void OnSpriteRemoved(object sender, ComponentStateEventArgs e) { Remove(sender as Sprite); }
private void Synchronized(object sender, ComponentStateEventArgs componentStateEventArgs) { if (IsOutOfSync) return; physics.World.Events.BodiesBeginCollide += collideHandler; }
protected override void OnRemoved(ComponentStateEventArgs e) { if (controller != null) phys.World.RemoveConstraint(controller); base.OnRemoved(e); }
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>(); } }
protected override void OnRemoved(ComponentStateEventArgs e) { base.OnRemoved(e); localParent.RemoveChild(localRoot); }
protected override void OnAdded(ComponentStateEventArgs registrationArgs) { base.OnAdded(registrationArgs); Reset(); }
protected override void OnAdded(ComponentStateEventArgs registrationArgs) { base.OnAdded(registrationArgs); _walls.Left += OnLeftBoundaries; }
protected override void OnRemoved(ComponentStateEventArgs registrationArgs) { base.OnRemoved(registrationArgs); physics.Body.BroadphaseTag ^= (int)BodyTags.Ghost; physics.Synchronized -= syncHandler; }
/// <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(); }