Esempio n. 1
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);
                             }
                         }
                     }
                 }
             }
         }
     }
 }
Esempio n. 2
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);
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
 }