Пример #1
0
        static void VoxelMeteorCraterSuccess(MySyncVoxel sync, ref MeteorCraterMsg msg, MyNetworkClient sender)
        {
            var voxel = sync.Entity as MyVoxelBase;

            if (voxel != null)
            {
                MyVoxelGenerator.MakeCrater(voxel, new BoundingSphere(msg.Center, msg.Radius), msg.Normal, MyDefinitionManager.Static.GetVoxelMaterialDefinition(msg.Material));
            }
        }
Пример #2
0
        void IMyVoxelBase.CreateMeteorCrater(Vector3D center, float radius, Vector3 normal, byte materialIdx)
        {
            Debug.Assert(Sync.IsServer);
            var material = MyDefinitionManager.Static.GetVoxelMaterialDefinition(materialIdx);

            if (Sync.IsServer)
            {
                CreateVoxelMeteorCrater(center, radius, normal, material);
                MyVoxelGenerator.MakeCrater(this, new BoundingSphere(center, radius), normal, material);
            }
        }
Пример #3
0
 private void CreateCrater(MyPhysics.MyContactPointEvent value, MyVoxelBase voxel)
 {
     if (Math.Abs(Vector3.Normalize(-Entity.WorldMatrix.Forward).Dot(value.ContactPointEvent.ContactPoint.Normal)) < 0.1)
     {
         MyParticleEffect impactParticle1;
         if (InParticleVisibleRange && MyParticlesManager.TryCreateParticleEffect("Meteorit_Smoke1AfterHit", out impactParticle1))
         {
             impactParticle1.WorldMatrix = Entity.WorldMatrix;
             impactParticle1.UserScale   = (float)Entity.PositionComp.WorldVolume.Radius * 2;
         }
         m_particleVectorUp     = Vector3.Zero;
         m_closeAfterSimulation = Sync.IsServer;
         return;
     }
     if (Sync.IsServer)
     {
         float           craterRadius = Entity.PositionComp.Scale.Value * 5;
         BoundingSphereD sphere       = new BoundingSphere(value.Position, craterRadius);
         Vector3         direction;
         // if contact was send after reflection we need to get former direction
         if (value.ContactPointEvent.SeparatingVelocity < 0)
         {
             direction = Vector3.Normalize(Entity.Physics.LinearVelocity);
         }
         else
         {
             direction = Vector3.Normalize(Vector3.Reflect(Entity.Physics.LinearVelocity, value.ContactPointEvent.ContactPoint.Normal));
         }
         var material = VoxelMaterial;
         int tries    = MyDefinitionManager.Static.GetVoxelMaterialDefinitions().Count() * 2; // max amount of tries
         while (!material.IsRare || !material.SpawnsFromMeteorites || material.MinVersion > MySession.Static.Settings.VoxelGeneratorVersion)
         {
             if (--tries < 0) // to prevent infinite loops in case all materials are disabled just use the meteorites' initial material
             {
                 material = VoxelMaterial;
                 break;
             }
             material = MyDefinitionManager.Static.GetVoxelMaterialDefinitions().ElementAt(MyUtils.GetRandomInt(MyDefinitionManager.Static.GetVoxelMaterialDefinitions().Count() - 1));
         }
         voxel.CreateVoxelMeteorCrater(sphere.Center, (float)sphere.Radius, -direction, material);
         MyVoxelGenerator.MakeCrater(voxel, sphere, -direction, material);
     }
     m_soundEmitter.Entity = voxel as MyEntity;
     m_soundEmitter.SetPosition(Entity.PositionComp.GetPosition());
     m_closeAfterSimulation = Sync.IsServer;
 }
Пример #4
0
 private void CreateCrater(MyPhysics.MyContactPointEvent value, MyVoxelMap voxel)
 {
     if (Math.Abs(Vector3.Normalize(-Entity.WorldMatrix.Forward).Dot(value.ContactPointEvent.ContactPoint.Normal)) < 0.1)
     {
         MyParticleEffect impactParticle1;
         if (InParticleVisibleRange && MyParticlesManager.TryCreateParticleEffect((int)MyParticleEffectsIDEnum.MeteorAsteroidCollision, out impactParticle1))
         {
             impactParticle1.WorldMatrix = Entity.WorldMatrix;
             impactParticle1.UserScale   = (float)Entity.PositionComp.WorldVolume.Radius * 2;
         }
         m_particleVectorUp = Vector3.Zero;
         return;
     }
     if (Sync.IsServer)
     {
         BoundingSphereD sphere = new BoundingSphere(value.Position, Entity.PositionComp.Scale.Value / 3);
         Vector3         direction;
         // if contact was send after reflection we need to get former direction
         if (value.ContactPointEvent.SeparatingVelocity < 0)
         {
             direction = Vector3.Normalize(Entity.Physics.LinearVelocity);
         }
         else
         {
             direction = Vector3.Normalize(Vector3.Reflect(Entity.Physics.LinearVelocity, value.ContactPointEvent.ContactPoint.Normal));
         }
         var material = VoxelMaterial;
         while (!material.IsRare)
         {
             material = MyDefinitionManager.Static.GetVoxelMaterialDefinitions().ElementAt(MyUtils.GetRandomInt(MyDefinitionManager.Static.GetVoxelMaterialDefinitions().Count() - 1));
         }
         voxel.SyncObject.CreateVoxelMeteorCrater(sphere.Center, (float)sphere.Radius, -direction, material);
         MyVoxelGenerator.MakeCrater(voxel, sphere, -direction, material);
     }
     m_closeAfterSimulation = true;
 }
Пример #5
0
 private void CreateVoxelMeteorCrater_Implementation(Vector3D center, float radius, Vector3 normal, byte material)
 {
     MyVoxelGenerator.MakeCrater(this, new BoundingSphere(center, radius), normal, MyDefinitionManager.Static.GetVoxelMaterialDefinition(material));
 }
Пример #6
0
        void IMyVoxelMaps.MakeCrater(IMyVoxelBase voxelMap, BoundingSphereD sphere, Vector3 normal, byte materialIdx)
        {
            var material = MyDefinitionManager.Static.GetVoxelMaterialDefinition(materialIdx);

            MyVoxelGenerator.MakeCrater((MyVoxelBase)voxelMap, sphere, normal, material);
        }