Exemplo n.º 1
0
        protected override void InitVoxelMap(MatrixD worldMatrix, Vector3I size, bool useOffset = true)
        {
            base.InitVoxelMap(worldMatrix, size, useOffset);

            ProfilerShort.Begin("new MyVoxelPhysicsBody");
            Physics         = new MyVoxelPhysicsBody(this, 3.0f, lazyPhysics: DelayRigidBodyCreation);
            Physics.Enabled = true;
            ProfilerShort.End();
        }
Exemplo n.º 2
0
        protected override void InitVoxelMap(MatrixD worldMatrix, Vector3I size, bool useOffset = true)
        {
            base.InitVoxelMap(worldMatrix, size, useOffset);

            ((MyStorageBase)Storage).InitWriteCache(8);

            ProfilerShort.Begin("new MyVoxelPhysicsBody");
            Physics         = new MyVoxelPhysicsBody(this, 3.0f, lazyPhysics: DelayRigidBodyCreation);
            Physics.Enabled = !MyFakes.DISABLE_VOXEL_PHYSICS;
            ProfilerShort.End();
        }
Exemplo n.º 3
0
        public void CreatePhysics()
        {
            Profiler.Begin("MyVoxelMap::CreatePhysics()");
            if (Physics != null)
            {
                Physics.Close();
            }

            Physics = new MyVoxelPhysicsBody(this);
            if (Physics.IsEmpty)
            {
                Physics.Close();
                Physics = null;
            }
            else
            {
                Physics.Enabled = true;
            }

            Profiler.End();
        }
Exemplo n.º 4
0
 protected override void InitVoxelMap(Vector3D positionMinCorner, Vector3I size, bool useOffset = true)
 {
     base.InitVoxelMap(positionMinCorner, size, useOffset);
     Physics         = new MyVoxelPhysicsBody(this, 3.0f);
     Physics.Enabled = true;
 }
Exemplo n.º 5
0
 internal void TrySpawnWalkingParticles(ref HkContactPointEvent value)
 {
     if (MyFakes.ENABLE_WALKING_PARTICLES)
     {
         int lastWalkParticleCheckTime = this.m_lastWalkParticleCheckTime;
         this.m_lastWalkParticleCheckTime   = MySandboxGame.TotalGamePlayTimeInMilliseconds;
         this.m_walkParticleSpawnCounterMs -= this.m_lastWalkParticleCheckTime - lastWalkParticleCheckTime;
         if (this.m_walkParticleSpawnCounterMs <= 0)
         {
             if (MyGravityProviderSystem.CalculateHighestNaturalGravityMultiplierInPoint(base.Entity.PositionComp.WorldMatrix.Translation) <= 0f)
             {
                 this.m_walkParticleSpawnCounterMs = 0x2710;
             }
             else
             {
                 MyCharacter entity = base.Entity as MyCharacter;
                 if (entity.JetpackRunning)
                 {
                     this.m_walkParticleSpawnCounterMs = 0x7d0;
                 }
                 else
                 {
                     MyCharacterMovementEnum currentMovementState = entity.GetCurrentMovementState();
                     if ((currentMovementState.GetDirection() == 0) || (currentMovementState == MyCharacterMovementEnum.Falling))
                     {
                         this.m_walkParticleSpawnCounterMs = 0x3e8;
                     }
                     else
                     {
                         MyVoxelPhysicsBody physics = value.GetOtherEntity(entity).Physics as MyVoxelPhysicsBody;
                         if (physics != null)
                         {
                             MyStringId walk;
                             ushort     speed = currentMovementState.GetSpeed();
                             if (speed == 0)
                             {
                                 walk = MyMaterialPropertiesHelper.CollisionType.Walk;
                                 this.m_walkParticleSpawnCounterMs = 500;
                             }
                             else if (speed == 0x400)
                             {
                                 walk = MyMaterialPropertiesHelper.CollisionType.Run;
                                 this.m_walkParticleSpawnCounterMs = 0x113;
                             }
                             else if (speed != 0x800)
                             {
                                 walk = MyMaterialPropertiesHelper.CollisionType.Walk;
                                 this.m_walkParticleSpawnCounterMs = 0x3e8;
                             }
                             else
                             {
                                 walk = MyMaterialPropertiesHelper.CollisionType.Sprint;
                                 this.m_walkParticleSpawnCounterMs = 250;
                             }
                             Vector3D worldPosition = physics.ClusterToWorld(value.ContactPoint.Position);
                             MyVoxelMaterialDefinition materialAt = physics.m_voxelMap.GetMaterialAt(ref worldPosition);
                             if (materialAt != null)
                             {
                                 MyMaterialPropertiesHelper.Static.TryCreateCollisionEffect(walk, worldPosition, value.ContactPoint.Normal, ID_CHARACTER, materialAt.MaterialTypeNameHash, null);
                             }
                         }
                     }
                 }
             }
         }
     }
 }
Exemplo n.º 6
0
 internal void TrySpawnWalkingParticles()
 {
     if (MyFakes.ENABLE_WALKING_PARTICLES)
     {
         int lastWalkParticleCheckTime = this.m_lastWalkParticleCheckTime;
         this.m_lastWalkParticleCheckTime   = MySandboxGame.TotalGamePlayTimeInMilliseconds;
         this.m_walkParticleSpawnCounterMs -= this.m_lastWalkParticleCheckTime - lastWalkParticleCheckTime;
         if (this.m_walkParticleSpawnCounterMs <= 0)
         {
             if (MyGravityProviderSystem.CalculateHighestNaturalGravityMultiplierInPoint(base.Entity.PositionComp.WorldMatrix.Translation) <= 0f)
             {
                 this.m_walkParticleSpawnCounterMs = 0x2710;
             }
             else
             {
                 MyCharacter entity = base.Entity as MyCharacter;
                 if (entity.JetpackRunning)
                 {
                     this.m_walkParticleSpawnCounterMs = 0x7d0;
                 }
                 else
                 {
                     MyCharacterMovementEnum currentMovementState = entity.GetCurrentMovementState();
                     if ((currentMovementState.GetDirection() == 0) || (currentMovementState == MyCharacterMovementEnum.Falling))
                     {
                         this.m_walkParticleSpawnCounterMs = 0x3e8;
                     }
                     else
                     {
                         Vector3D          up       = base.Entity.PositionComp.WorldMatrix.Up;
                         Vector3D          from     = base.Entity.PositionComp.WorldMatrix.Translation + (0.2 * up);
                         MyPhysics.HitInfo?nullable = MyPhysics.CastRay(from, (base.Entity.PositionComp.WorldMatrix.Translation + (0.2 * up)) - (0.5 * up), 0x1c);
                         if (nullable != null)
                         {
                             MyVoxelPhysicsBody physics = nullable.Value.HkHitInfo.GetHitEntity().Physics as MyVoxelPhysicsBody;
                             if (physics != null)
                             {
                                 MyStringId walk;
                                 ushort     speed = currentMovementState.GetSpeed();
                                 if (speed == 0)
                                 {
                                     walk = MyMaterialPropertiesHelper.CollisionType.Walk;
                                     this.m_walkParticleSpawnCounterMs = 500;
                                 }
                                 else if (speed == 0x400)
                                 {
                                     walk = MyMaterialPropertiesHelper.CollisionType.Run;
                                     this.m_walkParticleSpawnCounterMs = 0x113;
                                 }
                                 else if (speed != 0x800)
                                 {
                                     walk = MyMaterialPropertiesHelper.CollisionType.Walk;
                                     this.m_walkParticleSpawnCounterMs = 0x3e8;
                                 }
                                 else
                                 {
                                     walk = MyMaterialPropertiesHelper.CollisionType.Sprint;
                                     this.m_walkParticleSpawnCounterMs = 250;
                                 }
                                 Vector3D position = nullable.Value.Position;
                                 MyVoxelMaterialDefinition materialAt = physics.m_voxelMap.GetMaterialAt(ref position);
                                 if (materialAt != null)
                                 {
                                     MyMaterialPropertiesHelper.Static.TryCreateCollisionEffect(walk, position, (Vector3)up, ID_CHARACTER, materialAt.MaterialTypeNameHash, null);
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
 }
Exemplo n.º 7
0
 protected override void InitVoxelMap(MatrixD worldMatrix, Vector3I size, bool useOffset = true)
 {
     base.InitVoxelMap(worldMatrix, size, useOffset);
     Physics         = new MyVoxelPhysicsBody(this, 1.5f, 7.0f);
     Physics.Enabled = true;
 }