Beispiel #1
0
            public virtual void Init(MyDebrisBaseDescription desc)
            {
                HkShape shape;

                base.Init(null, desc.Model, null, 1f, null);
                this.LifespanInMiliseconds = MyUtils.GetRandomInt(desc.LifespanMinInMiliseconds, desc.LifespanMaxInMiliseconds);
                MyDebrisBase.MyDebrisPhysics physics = (MyDebrisBase.MyDebrisPhysics) this.GetPhysics(RigidBodyFlag.RBF_DEBRIS);
                base.Container.Entity.Physics = physics;
                float mass = this.CalculateMass(((MyEntity)base.Entity).Render.GetModel().BoundingSphere.Radius);

                physics.CreatePhysicsShape(out shape, out this.m_massProperties, mass);
                physics.CreateFromCollisionObject(shape, Vector3.Zero, MatrixD.Identity, new HkMassProperties?(this.m_massProperties), 20);
                HkMassChangerUtil.Create(physics.RigidBody, -21, 1f, 0f);
                new HkEasePenetrationAction(physics.RigidBody, 3f)
                {
                    InitialAllowedPenetrationDepthMultiplier = 10f
                }.RemoveReference();
                base.Container.Entity.Physics.Enabled = false;
                shape.RemoveReference();
                base.m_entity.Save = false;
                base.Container.Entity.Physics.PlayCollisionCueEnabled = true;
                base.NeedsUpdate = MyEntityUpdateEnum.EACH_FRAME;
                base.Container.Entity.NeedsUpdate = MyEntityUpdateEnum.EACH_FRAME;
                this.m_onCloseCallback            = desc.OnCloseAction;
            }
Beispiel #2
0
            public override void Init(MyDebrisBaseDescription desc)
            {
                base.Init(desc);
                HkRigidBody rigidBody = base.Entity.Physics.RigidBody;

                rigidBody.EnableDeactivation = false;
                rigidBody.MaxAngularVelocity = 2f;
            }
            /// <summary>
            /// One time initialization for debris entity. These are settings that do not change
            /// when this debris entity is pulled from the pool.
            /// Also note that this is the only way Debris should be initialized. It calls other Init methods with
            /// correct arguments.
            /// </summary>
            public virtual void Init(MyDebrisBaseDescription desc)
            {
                base.Init(null, desc.Model, null, 1.0f);
                RandomScale = MyUtils.GetRandomFloat(desc.ScaleMin, desc.ScaleMax);
                Container.Entity.PositionComp.Scale = RandomScale;
                LifespanInMiliseconds = MyUtils.GetRandomInt(desc.LifespanMinInMiliseconds, desc.LifespanMaxInMiliseconds);

                HkShape shape;

                m_massProperties         = new HkMassProperties();
                m_massProperties.Mass    = 50;
                Container.Entity.Physics = GetPhysics(RigidBodyFlag.RBF_DEBRIS);
                (Container.Entity.Physics as MyDebrisPhysics).CreatePhysicsShape(out shape, ref m_massProperties);
                (Container.Entity.Physics as MyDebrisPhysics).CreateFromCollisionObject(shape, Vector3.Zero, MatrixD.Identity, m_massProperties, MyPhysics.CollisionLayers.DebrisCollisionLayer);
                Container.Entity.Physics.Enabled = false;
                shape.RemoveReference();

                m_entity.Save = false;
                Container.Entity.Physics.PlayCollisionCueEnabled = true;
                NeedsUpdate       = MyEntityUpdateEnum.EACH_FRAME;
                m_onCloseCallback = desc.OnCloseAction;
            }
Beispiel #4
0
            /// <summary>
            /// One time initialization for debris entity. These are settings that do not change 
            /// when this debris entity is pulled from the pool.
            /// Also note that this is the only way Debris should be initialized. It calls other Init methods with 
            /// correct arguments.
            /// </summary>
            public virtual void Init(MyDebrisBaseDescription desc)
            {
                base.Init(null, desc.Model, null, 1.0f);
                m_randomScale = MyUtils.GetRandomFloat(desc.ScaleMin, desc.ScaleMax);
                Container.Entity.PositionComp.Scale = m_randomScale;
                m_lifespanInMiliseconds = MyUtils.GetRandomInt(desc.LifespanMinInMiliseconds, desc.LifespanMaxInMiliseconds);

                HkShape shape;
                m_massProperties = new HkMassProperties();
                m_massProperties.Mass = 50;
                Container.Entity.Physics = GetPhysics(RigidBodyFlag.RBF_DEBRIS);
                (Container.Entity.Physics as MyDebrisPhysics).CreatePhysicsShape(out shape, ref m_massProperties);
                (Container.Entity.Physics as MyDebrisPhysics).CreateFromCollisionObject(shape, Vector3.Zero, MatrixD.Identity, m_massProperties, MyPhysics.DebrisCollisionLayer);
                Container.Entity.Physics.Enabled = false;
                shape.RemoveReference();

                m_entity.Save = false;
                Container.Entity.Physics.PlayCollisionCueEnabled = true;
                NeedsUpdate = MyEntityUpdateEnum.EACH_FRAME;
                m_onCloseCallback = desc.OnCloseAction;
            }