protected override void Init(MyObjectBuilder_DefinitionBase ob) { base.Init(ob); var builder = ob as MyObjectBuilder_VoxelMaterialDefinition; MyDebug.AssertDebug(builder != null); MaterialTypeName = builder.MaterialTypeName; MinedOre = builder.MinedOre; MinedOreRatio = builder.MinedOreRatio; CanBeHarvested = builder.CanBeHarvested; IsRare = builder.IsRare; SpawnsInAsteroids = builder.SpawnsInAsteroids; SpawnsFromMeteorites = builder.SpawnsFromMeteorites; DamageRatio = builder.DamageRatio; DiffuseXZ = builder.DiffuseXZ; DiffuseY = builder.DiffuseY; NormalXZ = builder.NormalXZ; NormalY = builder.NormalY; SpecularPower = builder.SpecularPower; SpecularShininess = builder.SpecularShininess; MinVersion = builder.MinVersion; if (!string.IsNullOrEmpty(builder.ParticleEffect)) { ParticleEffect = (MyParticleEffectsIDEnum)Enum.Parse(typeof(MyParticleEffectsIDEnum), builder.ParticleEffect); } else { ParticleEffect = MyParticleEffectsIDEnum.None; } DamageThreshold = (int)(builder.DamageThreashold * 255); DamagedMaterial = MyStringHash.GetOrCompute(builder.DamagedMaterial); }
/// <param name="drillEntity">Entity to which this drill is attached.</param> /// <param name="inventoryCollectionRatio">Ratio (0 to 1) of mined material that will be stored in inventory (if one is assigned), rest will be thrown out in space.</param> public MyDrillBase( MyEntity drillEntity, MyParticleEffectsIDEnum dustEffectId, MyParticleEffectsIDEnum dustEffectStonesId, MyParticleEffectsIDEnum sparksEffectId, MyDrillSensorBase sensor, MyDrillCutOut cutOut, float animationSlowdownTimeInSeconds, float floatingObjectSpawnOffset, float floatingObjectSpawnRadius, float inventoryCollectionRatio = 0f) { m_drillEntity = drillEntity; m_sensor = sensor; m_cutOut = cutOut; m_dustEffectId = dustEffectId; m_dustEffectStonesId = dustEffectStonesId; m_sparksEffectId = sparksEffectId; m_animationSlowdownTimeInSeconds = animationSlowdownTimeInSeconds; m_floatingObjectSpawnOffset = floatingObjectSpawnOffset; m_floatingObjectSpawnRadius = floatingObjectSpawnRadius; Debug.Assert(inventoryCollectionRatio >= 0f && inventoryCollectionRatio <= 1f, "Inventory collection ratio must be in range <0;1>"); m_inventoryCollectionRatio = (MyFixedPoint)inventoryCollectionRatio; m_drilledMaterialBuffer = new Dictionary <MyVoxelMaterialDefinition, int>(); m_soundEmitter = new MyEntity3DSoundEmitter(m_drillEntity); }
protected static void CreateImpactEffect(Vector3 position, Vector3 normal, MyParticleEffectsIDEnum effectID) { var effect = MyParticlesManager.CreateParticleEffect((int)effectID); Vector3 tangent; MyUtils.GetPerpendicularVector(ref normal, out tangent); effect.WorldMatrix = Matrix.CreateWorld(position, normal, tangent); }
public static void AddDestructionEffect(MyParticleEffectsIDEnum effectId, Vector3D position, Vector3 direction, float scale) { AddDestructionEffectMsg msg = new AddDestructionEffectMsg(); msg.EffectId = effectId; msg.Position = position; msg.Direction = direction; msg.Scale = scale; MySession.Static.SyncLayer.SendMessageToServerAndSelf(ref msg); }
public static MyDummyEffectHelper Get(MyParticleEffectsIDEnum particleEffectType) { MyDummyEffectHelper ret; if (m_dummyEffectHelpers.TryGetValue(particleEffectType, out ret)) { return ret; } return null; }
public static MyDummyEffectHelper Get(MyParticleEffectsIDEnum particleEffectType) { MyDummyEffectHelper ret; if (m_dummyEffectHelpers.TryGetValue(particleEffectType, out ret)) { return(ret); } return(null); }
public MiningHammerEffect(MyCubeBlock block) { m_block = block; CreateMiningHammer(m_block); m_soundPair = new MySoundPair("NaniteHammer"); m_soundEmitter = new MyEntity3DSoundEmitter(m_block, true); m_dustEffectId = MyParticleEffectsIDEnum.Smoke_DrillDust; m_dustEffectStonesId = MyParticleEffectsIDEnum.Smoke_DrillDust; m_sparksEffectId = MyParticleEffectsIDEnum.Collision_Sparks; m_smokeStarted = DateTime.MinValue; }
public void AddExplosion(MyEntity entity, MyExplosionTypeEnum explosionType, float damage, float radius, bool forceDebris, bool createDecals, MyParticleEffectsIDEnum? particleIDOverride = null) { Debug.Assert(entity != null && entity.EntityId.HasValue); var msg = new MyEventAddExplosion(); msg.Damage = damage; msg.EntityId = entity.EntityId.Value.NumericValue; msg.ExplosionType = (byte)explosionType; msg.Radius = radius; msg.ParticleIDOverride = (int?)particleIDOverride; msg.CreateDecals = createDecals; msg.ForceDebris = forceDebris; Peers.SendToAll(ref msg, NetDeliveryMethod.ReliableOrdered); }
public bool TrySpawnParticle(Vector3D worldPosition, MyParticleEffectsIDEnum particleEffect = MyParticleEffectsIDEnum.Collision_Meteor) { if (!MyFakes.ENABLE_DRIVING_PARTICLES) { return(false); } MyWheel wheel = Entity as MyWheel; if (wheel == null) { return(false); } var speedMultiplier = wheel.GetTopMostParent().Physics.LinearVelocity.Length() / MyGridPhysics.ShipMaxLinearVelocity(); var currentTime = MySandboxGame.TotalGamePlayTimeInMilliseconds; if (currentTime - m_lastGlobalEffectCreationTime < 5 || currentTime - m_lastEffectCreationTime < m_effectCreationInterval * MyUtils.GetRandomFloat(0.9f * (1.5f - speedMultiplier), 1.1f / (0.25f + speedMultiplier))) { return(false); } MyParticleEffect drivingEffect = null; if (!MyParticlesManager.TryCreateParticleEffect((int)particleEffect, out drivingEffect)) { return(false); } m_lastEffectCreationTime = currentTime; m_lastGlobalEffectCreationTime = m_lastEffectCreationTime; drivingEffect.WorldMatrix = MatrixD.CreateTranslation(worldPosition); drivingEffect.Preload = 1.0f; var speedScaleMultiplier = 1.0f + speedMultiplier * 6.0f; drivingEffect.UserScale = 0.25f * speedScaleMultiplier; return(true); }
public override void ContactPointCallback(ref MyGridContactInfo value) { //return; var prop = value.Event.ContactProperties; prop.Friction = Friction; prop.Restitution = 0.5f; value.EnableParticles = false; value.RubberDeformation = true; if (value.CollidingEntity is MyVoxelBase) { MyVoxelBase voxel = value.CollidingEntity as MyVoxelBase; Vector3D contactPosition = value.ContactPosition; MyParticleEffectsIDEnum particleEffect = voxel.GetMaterialAt(ref contactPosition).ParticleEffect; if (Render != null && particleEffect != MyParticleEffectsIDEnum.None) { Render.TrySpawnParticle(value.ContactPosition, particleEffect); } } }
// Generate explosion particles. These will be smoke, explosion and some polyline particles. void GenerateExplosionParticles(MyParticleEffectsIDEnum newParticlesType, BoundingSphere explosionSphere, float particleScale) { Vector3 dirToCamera = MyCamera.Position - explosionSphere.Center; if (MyMwcUtils.IsZero(dirToCamera)) { dirToCamera = MyCamera.ForwardVector; } else { dirToCamera = MyMwcUtils.Normalize(dirToCamera); } // Move explosion particles in the direction of camera, so we won't see billboards intersecting the large ship BoundingSphere tempExplosionSphere = m_explosionSphere; tempExplosionSphere.Center = m_explosionSphere.Center + dirToCamera * 0.9f; MyParticleEffect explosionEffect = MyParticlesManager.CreateParticleEffect((int)newParticlesType); explosionEffect.WorldMatrix = Matrix.CreateTranslation(tempExplosionSphere.Center); explosionEffect.UserRadiusMultiplier = tempExplosionSphere.Radius; explosionEffect.UserScale = particleScale; }
// Generate explosion particles. These will be smoke, explosion and some polyline particles. void GenerateExplosionParticles(MyParticleEffectsIDEnum newParticlesType, BoundingSphere explosionSphere, float particleScale) { Vector3 dirToCamera = MyCamera.Position - explosionSphere.Center; if (MyMwcUtils.IsZero(dirToCamera)) dirToCamera = MyCamera.ForwardVector; else dirToCamera = MyMwcUtils.Normalize(dirToCamera); // Move explosion particles in the direction of camera, so we won't see billboards intersecting the large ship BoundingSphere tempExplosionSphere = m_explosionSphere; tempExplosionSphere.Center = m_explosionSphere.Center + dirToCamera * 0.9f; MyParticleEffect explosionEffect = MyParticlesManager.CreateParticleEffect((int)newParticlesType); explosionEffect.WorldMatrix = Matrix.CreateTranslation(tempExplosionSphere.Center); explosionEffect.UserRadiusMultiplier = tempExplosionSphere.Radius; explosionEffect.UserScale = particleScale; }
protected override void Init(MyObjectBuilder_DefinitionBase ob) { base.Init(ob); var builder = ob as MyObjectBuilder_VoxelMaterialDefinition; MyDebug.AssertDebug(builder != null); MaterialTypeName = builder.MaterialTypeName; MinedOre = builder.MinedOre; MinedOreRatio = builder.MinedOreRatio; CanBeHarvested = builder.CanBeHarvested; IsRare = builder.IsRare; SpawnsInAsteroids = builder.SpawnsInAsteroids; SpawnsFromMeteorites = builder.SpawnsFromMeteorites; DamageRatio = builder.DamageRatio; DiffuseXZ = builder.DiffuseXZ; DiffuseY = builder.DiffuseY; NormalXZ = builder.NormalXZ; NormalY = builder.NormalY; SpecularPower = builder.SpecularPower; SpecularShininess = builder.SpecularShininess; MinVersion = builder.MinVersion; if (!string.IsNullOrEmpty(builder.ParticleEffect)) { ParticleEffect = (MyParticleEffectsIDEnum)Enum.Parse(typeof(MyParticleEffectsIDEnum), builder.ParticleEffect); } else { ParticleEffect = MyParticleEffectsIDEnum.None; } DamageThreshold = (int) (builder.DamageThreashold*255); DamagedMaterial = MyStringHash.GetOrCompute(builder.DamagedMaterial); }
public MyPrefabConfigurationParticles(MyModelsEnum modelLod0Enum, MyModelsEnum?modelLod1Enum, BuildTypesEnum buildType, CategoryTypesEnum categoryType, SubCategoryTypesEnum?subCategoryType, MyMaterialType materialType, MyParticleEffectsIDEnum effectID) : this(modelLod0Enum, modelLod1Enum, buildType, categoryType, subCategoryType, materialType, effectID, PrefabTypesFlagEnum.Default) { }
static void OnAddDestructionEffectMessage(MyParticleEffectsIDEnum effectId, Vector3D position, Vector3 direction, float scale) { MyGridPhysics.CreateDestructionEffect(effectId, position, direction, scale); }
public static void CreateDestructionEffect(MyParticleEffectsIDEnum effectId, Vector3D position, Vector3 direction, float scale) { MatrixD dirMatrix = MatrixD.CreateFromDir(direction); MyParticleEffect effect; if (MyParticlesManager.TryCreateParticleEffect((int)effectId, out effect)) { effect.UserScale = scale; effect.WorldMatrix = MatrixD.CreateWorld(position, dirMatrix.Forward, dirMatrix.Up); } }
public MyPrefabConfigurationParticles(MyModelsEnum modelLod0Enum, MyModelsEnum? modelLod1Enum, BuildTypesEnum buildType, CategoryTypesEnum categoryType, SubCategoryTypesEnum? subCategoryType, MyMaterialType materialType, MyParticleEffectsIDEnum effectID) : this(modelLod0Enum, modelLod1Enum, buildType, categoryType, subCategoryType, materialType, effectID, PrefabTypesFlagEnum.Default) { }
public MyPrefabConfigurationParticles(MyModelsEnum modelLod0Enum, MyModelsEnum? modelLod1Enum, BuildTypesEnum buildType, CategoryTypesEnum categoryType, SubCategoryTypesEnum? subCategoryType, MyMaterialType materialType, MyParticleEffectsIDEnum effectID, PrefabTypesFlagEnum prefabTypeFlag) : base(modelLod0Enum, modelLod1Enum, buildType, categoryType, subCategoryType, materialType, prefabTypeFlag) { EffectID = effectID; }
/// <param name="drillEntity">Entity to which this drill is attached.</param> /// <param name="inventoryCollectionRatio">Ratio (0 to 1) of mined material that will be stored in inventory (if one is assigned), rest will be thrown out in space.</param> public MyDrillBase( MyEntity drillEntity, MyParticleEffectsIDEnum dustEffectId, MyParticleEffectsIDEnum dustEffectStonesId, MyParticleEffectsIDEnum sparksEffectId, MyDrillSensorBase sensor, MyDrillCutOut cutOut, float animationSlowdownTimeInSeconds, float floatingObjectSpawnOffset, float floatingObjectSpawnRadius, Sounds sounds, float inventoryCollectionRatio = 0f) { m_drillEntity = drillEntity; m_sensor = sensor; m_cutOut = cutOut; m_dustEffectId = dustEffectId; m_dustEffectStonesId = dustEffectStonesId; m_sparksEffectId = sparksEffectId; m_animationSlowdownTimeInSeconds = animationSlowdownTimeInSeconds; m_floatingObjectSpawnOffset = floatingObjectSpawnOffset; m_floatingObjectSpawnRadius = floatingObjectSpawnRadius; Debug.Assert(inventoryCollectionRatio >= 0f && inventoryCollectionRatio <= 1f, "Inventory collection ratio must be in range <0;1>"); m_inventoryCollectionRatio = (MyFixedPoint)inventoryCollectionRatio; m_drilledMaterialBuffer = new Dictionary<MyVoxelMaterialDefinition, int>(); m_sounds = sounds; m_soundEmitter = new MyEntity3DSoundEmitter(m_drillEntity); }
// Generate explosion particles. These will be smoke, explosion and some polyline particles. void GenerateExplosionParticles(MyParticleEffectsIDEnum newParticlesType, BoundingSphere explosionSphere, float particleScale) { if (MyParticlesManager.TryCreateParticleEffect((int)newParticlesType, out m_explosionEffect)) { m_explosionEffect.OnDelete += delegate { m_explosionInfo.LifespanMiliseconds = 0; m_explosionEffect = null; }; m_explosionEffect.WorldMatrix = CalculateEffectMatrix(explosionSphere); //explosionEffect.UserRadiusMultiplier = tempExplosionSphere.Radius; m_explosionEffect.UserScale = particleScale; } // m_lifespanInMiliseconds = Math.Max(m_lifespanInMiliseconds, (int)(m_explosionEffect.GetLength() * 1000)); }
public static void AddDestructionEffect(MyParticleEffectsIDEnum effectId, Vector3D position, Vector3 direction, float scale) { MyMultiplayer.RaiseStaticEvent(s => MySyncDestructions.OnAddDestructionEffectMessage, effectId, position, direction, scale); }
public MyPrefabConfigurationParticles(MyModelsEnum modelLod0Enum, MyModelsEnum?modelLod1Enum, BuildTypesEnum buildType, CategoryTypesEnum categoryType, SubCategoryTypesEnum?subCategoryType, MyMaterialType materialType, MyParticleEffectsIDEnum effectID, PrefabTypesFlagEnum prefabTypeFlag) : base(modelLod0Enum, modelLod1Enum, buildType, categoryType, subCategoryType, materialType, prefabTypeFlag) { EffectID = effectID; }