public MyParticleEffect Duplicate() { MyParticleEffect effect = MyParticlesManager.EffectsPool.Allocate(); effect.Start(0); effect.Name = Name; effect.m_length = m_length; effect.DurationMin = m_durationMin; effect.DurationMax = m_durationMax; effect.Loop = m_loop; foreach (IMyParticleGeneration generation in m_generations) { IMyParticleGeneration duplicatedGeneration = generation.Duplicate(effect); effect.AddGeneration(duplicatedGeneration); } foreach (var particleLight in m_particleLights) { var newParticleLight = (MyParticleLight)particleLight.Duplicate(effect); effect.AddParticleLight(newParticleLight); } foreach (var particleSound in m_particleSounds) { var newParticleSound = (MyParticleSound)particleSound.Duplicate(effect); effect.AddParticleSound(newParticleSound); } return(effect); }
public WeaponEffect(MyModelDummy dummy, int effectId, MyWeaponDefinition.WeaponEffectAction action, MyParticleEffect effect) { this.Dummy = dummy; this.EffectId = effectId; this.Effect = effect; this.Action = action; }
public static bool TryCreateParticleEffect(string effectName, out MyParticleEffect effect, bool userDraw = false) { int id; MyParticlesLibrary.GetParticleEffectsID(effectName, out id); return TryCreateParticleEffect(id, out effect, userDraw); }
static MyParticleEffect CreateParticleEffect(int id, bool userDraw = false) { MyParticleEffect effect = MyParticlesLibrary.CreateParticleEffect(id); //Not in parallel userDraw = false; if (effect != null) { if (!userDraw) { lock (m_particleEffectsForUpdate) { m_particleEffectsForUpdate.Add(effect); } } else { effect.AutoDelete = false; } effect.UserDraw = userDraw; m_particleEffectsAll.Add(effect); } return(effect); }
void m_entity_OnClose(MyEntity obj) { if (m_shotSmoke != null) { MyParticlesManager.RemoveParticleEffect(m_shotSmoke); m_shotSmoke = null; } }
public void Start(MyParticleEffect effect) { System.Diagnostics.Debug.Assert(m_effect == null); m_effect = effect; m_name = "ParticleSound"; m_particleSoundId = m_particleSoundIdGlobal++; }
public void Start(MyParticleEffect effect) { System.Diagnostics.Debug.Assert(m_effect == null); System.Diagnostics.Debug.Assert(Position == null); m_effect = effect; m_name = "ParticleLight"; }
public static bool TryCreateParticleEffect(string effectName, out MyParticleEffect effect, bool userDraw = false) { int id; MyParticlesLibrary.GetParticleEffectsID(effectName, out id); return(TryCreateParticleEffect(id, out effect, userDraw)); }
public WeaponEffect(string name, Matrix localMatrix, int effectId, MyWeaponDefinition.WeaponEffectAction action, MyParticleEffect effect) { this.Name = name; this.EffectId = effectId; this.Effect = effect; this.Action = action; this.LocalMatrix = localMatrix; }
public void Start(MyParticleEffect effect) { System.Diagnostics.Debug.Assert(m_effect == null); System.Diagnostics.Debug.Assert(Life == null); m_effect = effect; m_name = "ParticleGeneration GPU"; m_dirty = true; }
public void Start(MyParticleEffect effect) { System.Diagnostics.Debug.Assert(m_effect == null); System.Diagnostics.Debug.Assert(Life == null); m_effect = effect; m_name = "ParticleGeneration GPU"; m_dirty = true; m_renderId = MyRenderProxy.CreateGPUEmitter(); }
public static void AddParticleEffect(MyParticleEffect effect) { MyParticleEffect oldEffect; if (m_libraryEffectsString.TryGetValue(effect.Name, out oldEffect) || m_libraryEffects.TryGetValue(effect.ID, out oldEffect)) return; //We dont want replace effects if they may be shown in editor //RemoveParticleEffect(oldEffect.ID); m_libraryEffects.Add(effect.GetID(), effect); m_libraryEffectsString[effect.Name] = effect; }
public void RemoveInstance(MyParticleEffect effect) { if (m_instances != null) { if (m_instances.Contains(effect)) { m_instances.Remove(effect); } } }
public MyParticleEffect CreateInstance() { MyParticleEffect effect = MyParticlesManager.EffectsPool.Allocate(true); if (effect != null) { effect.Start(m_particleID); effect.Name = Name; effect.Enabled = Enabled; effect.Length = Length; effect.m_globalScale = m_globalScale; effect.LowRes = LowRes; effect.Loop = m_loop; effect.DurationMin = m_durationMin; effect.DurationMax = m_durationMax; effect.SetRandomDuration(); foreach (IMyParticleGeneration generation in m_generations) { IMyParticleGeneration gen = generation.CreateInstance(effect); if (gen != null) { effect.AddGeneration(gen); } } foreach (MyParticleLight particleLight in m_particleLights) { MyParticleLight pl = particleLight.CreateInstance(effect); if (pl != null) { effect.AddParticleLight(pl); } } foreach (MyParticleSound particleSound in m_particleSounds) { MyParticleSound ps = particleSound.CreateInstance(effect); if (ps != null) { effect.AddParticleSound(ps); } } if (m_instances == null) { m_instances = new List <MyParticleEffect>(); } m_instances.Add(effect); } return(effect); }
public static bool TryCreateParticleEffect(int id, out MyParticleEffect effect, bool userDraw = false) { if (id == -1 || !Enabled || !MyParticlesLibrary.EffectExists(id)) { effect = null; return false; } effect = CreateParticleEffect(id, userDraw); return effect != null; }
public static bool TryCreateParticleEffect(int id, out MyParticleEffect effect, bool userDraw = false) { if (id == -1 || !Enabled || !MyParticlesLibrary.EffectExists(id)) { effect = null; return(false); } effect = CreateParticleEffect(id, userDraw); return(effect != null); }
public void Close() { for (int i = 0; i < m_properties.Length; i++) { m_properties[i] = null; } m_effect = null; CloseSound(); }
public override void OnBeforeRemovedFromContainer() { base.OnBeforeRemovedFromContainer(); if(m_landingEffect != null) { m_landingEffect.Stop(); m_landingEffect = null; --m_landingEffectCount; } }
public static void AddParticleEffect(MyParticleEffect effect) { MyParticleEffect oldEffect; if (m_libraryEffectsString.TryGetValue(effect.Name, out oldEffect) || m_libraryEffects.TryGetValue(effect.ID, out oldEffect)) { return; //We dont want replace effects if they may be shown in editor } //RemoveParticleEffect(oldEffect.ID); m_libraryEffects.Add(effect.GetID(), effect); m_libraryEffectsString[effect.Name] = effect; }
public void Close() { Clear(); for (int i = 0; i < m_properties.Length; i++) { m_properties[i] = null; } m_emitter.Close(); m_effect = null; }
public MyParticleEffect CreateInstance() { MyParticleEffect effect = MyParticlesManager.EffectsPool.Allocate(true); if (effect != null) { effect.Start(m_particleID); effect.Name = Name; effect.Enabled = Enabled; effect.SetLength(GetLength()); effect.SetPreload(GetPreload()); effect.LowRes = LowRes; foreach (IMyParticleGeneration generation in m_generations) { IMyParticleGeneration gen = generation.CreateInstance(effect); if (gen != null) { effect.AddGeneration(gen); } } foreach (MyParticleLight particleLight in m_particleLights) { MyParticleLight pl = particleLight.CreateInstance(effect); if (pl != null) { effect.AddParticleLight(pl); } } foreach (MyParticleSound particleSound in m_particleSounds) { MyParticleSound ps = particleSound.CreateInstance(effect); if (ps != null) { effect.AddParticleSound(ps); } } if (m_instances == null) { m_instances = new List <MyParticleEffect>(); } m_instances.Add(effect); } return(effect); }
public MyParticleSound Duplicate(MyParticleEffect effect) { MyParticleSound particleSound = MyParticlesManager.SoundsPool.Allocate(); particleSound.Start(effect); particleSound.Name = Name; for (int i = 0; i < m_properties.Length; i++) { particleSound.m_properties[i] = m_properties[i].Duplicate(); } return(particleSound); }
public MyParticleLight Duplicate(MyParticleEffect effect) { MyParticleLight particleLight = MyParticlesManager.LightsPool.Allocate(); particleLight.Start(effect); particleLight.Name = Name; for (int i = 0; i < m_properties.Length; i++) { particleLight.m_properties[i] = m_properties[i].Duplicate(); } return(particleLight); }
public IMyParticleGeneration Duplicate(MyParticleEffect effect) { MyParticleGPUGeneration generation = MyParticlesManager.GPUGenerationsPool.Allocate(); generation.Start(effect); generation.Name = Name; for (int i = 0; i < m_properties.Length; i++) { generation.m_properties[i] = m_properties[i].Duplicate(); } return(generation); }
public MyParticleSound CreateInstance(MyParticleEffect effect) { MyParticleSound particleSound; MyParticlesManager.SoundsPool.AllocateOrCreate(out particleSound); particleSound.Start(effect); particleSound.Name = Name; for (int i = 0; i < m_properties.Length; i++) { particleSound.m_properties[i] = m_properties[i]; } return(particleSound); }
public MyParticleLight CreateInstance(MyParticleEffect effect) { MyParticleLight particleLight; MyParticlesManager.LightsPool.AllocateOrCreate(out particleLight); particleLight.Start(effect); particleLight.Name = Name; for (int i = 0; i < m_properties.Length; i++) { particleLight.m_properties[i] = m_properties[i]; } return(particleLight); }
public IMyParticleGeneration CreateInstance(MyParticleEffect effect) { MyParticleGPUGeneration generation; MyParticlesManager.GPUGenerationsPool.AllocateOrCreate(out generation); generation.Start(effect); generation.Name = Name; for (int i = 0; i < m_properties.Length; i++) { generation.m_properties[i] = m_properties[i]; } return(generation); }
public static VRageRender.MyBillboard AddBillboardEffect(MyParticleEffect effect) { //VRageRender.MyBillboard billboard = m_preallocatedParticleBillboards.Allocate(); //VRageRender.MyBillboard billboard = new VRageRender.MyBillboard(); VRageRender.MyBillboard billboard = VRageRender.MyRenderProxy.BillboardsPoolWrite.Allocate(); if (billboard != null) { MyTransparentGeometry.StartParticleProfilingBlock("AddBillboardEffect"); billboard.DistanceSquared = (float)Vector3D.DistanceSquared(MyTransparentGeometry.Camera.Translation, effect.WorldMatrix.Translation); billboard.CustomViewProjection = -1; MyTransparentGeometry.EndParticleProfilingBlock(); } return(billboard); }
public void Close() { Clear(); for (int i = 0; i < m_properties.Length; i++) { m_properties[i] = null; } m_effect = null; if (m_renderId != MyRenderProxy.RENDER_ID_UNASSIGNED) { MyRenderProxy.RemoveRenderObject(m_renderId); m_renderId = MyRenderProxy.RENDER_ID_UNASSIGNED; } }
public void Start(MyParticleEffect effect) { System.Diagnostics.Debug.Assert(m_effect == null); System.Diagnostics.Debug.Assert(m_particles.Count == 0); System.Diagnostics.Debug.Assert(Birth == null); m_effect = effect; m_name = "ParticleGeneration"; m_emitter.Start(); m_lastEffectPosition = null; IsInherited = false; m_birthRate = 0.0f; m_particlesToCreate = 0.0f; m_AABB = BoundingBoxD.CreateInvalid(); }
private void Stop(bool instant) { Clear(); for (int i = 0; i < m_properties.Length; i++) { m_properties[i] = null; } m_effect = null; if (m_renderId != MyRenderProxy.RENDER_ID_UNASSIGNED) { MyRenderProxy.RemoveGPUEmitter(m_renderId, instant); m_renderId = MyRenderProxy.RENDER_ID_UNASSIGNED; } }
public MyParticleEffect Duplicate() { MyParticleEffect effect = MyParticlesManager.EffectsPool.Allocate(); effect.Start(0); effect.Name = Name; effect.m_preload = m_preload; effect.m_length = m_length; foreach (IMyParticleGeneration generation in m_generations) { IMyParticleGeneration duplicatedGeneration = generation.Duplicate(effect); effect.AddGeneration(duplicatedGeneration); } return(effect); }
public static void RemoveParticleEffect(MyParticleEffect effect, bool fromBackground = false) { bool remove = true; if (!effect.UserDraw) { lock (m_particleEffectsForUpdate) { remove = m_particleEffectsForUpdate.Contains(effect); if (remove) { m_particleEffectsForUpdate.Remove(effect); } } } m_particleEffectsAll.Remove(effect); MyParticlesLibrary.RemoveParticleEffectInstance(effect); }
static public void RemoveParticleEffectInstance(MyParticleEffect effect) { effect.Close(false); //if (effect.Enabled) if (m_libraryEffects.ContainsKey(effect.GetID())) { var instances = m_libraryEffects[effect.GetID()].GetInstances(); if (instances != null) { if (instances.Contains(effect)) { MyParticlesManager.EffectsPool.Deallocate(effect); m_libraryEffects[effect.GetID()].RemoveInstance(effect); } else { System.Diagnostics.Debug.Assert(false, "Effect deleted twice!"); } } } }
static public void Deserialize(XmlReader reader) { Close(); RedundancyDetected = 0; reader.ReadStartElement(); //VRageParticleLibrary int version = reader.ReadElementContentAsInt(); reader.ReadStartElement(); //ParticleEffects while (reader.NodeType != XmlNodeType.EndElement) { MyParticleEffect effect = MyParticlesManager.EffectsPool.Allocate(); effect.Deserialize(reader); AddParticleEffect(effect); } reader.ReadEndElement(); //ParticleEffects reader.ReadEndElement(); //root }
public MyParticleGeneration CreateInstance(MyParticleEffect effect) { MyParticleGeneration generation = MyParticlesManager.GenerationsPool.Allocate(true); if (generation == null) { return(null); } generation.Start(effect); generation.Name = Name; for (int i = 0; i < m_properties.Length; i++) { generation.m_properties[i] = m_properties[i]; } generation.m_emitter.CreateInstance(m_emitter); return(generation); }
public override void UpdateAfterSimulation100() { base.UpdateAfterSimulation100(); if (Sync.IsServer && IsWorking) UpdateActions(); if (m_playVentEffect == false) { if (m_effect != null) { m_effect.Stop(); m_effect = null; } } m_isProducing = m_producedSinceLastUpdate; m_producedSinceLastUpdate = false; m_playVentEffect = false; var block = GetOxygenBlock(); int sourceUpdateFrames = (MySession.Static.GameplayFrameCounter - m_lastOutputUpdateTime); int sinkUpdateFrames = (MySession.Static.GameplayFrameCounter - m_lastInputUpdateTime); m_lastOutputUpdateTime = MySession.Static.GameplayFrameCounter; m_lastInputUpdateTime = MySession.Static.GameplayFrameCounter; float gasInput = GasInputPerUpdate * sinkUpdateFrames; float gasOutput = GasOutputPerUpdate * sourceUpdateFrames; float totalTransfer = gasInput - gasOutput + m_nextGasTransfer; if (totalTransfer != 0f) Transfer(totalTransfer); SourceComp.SetRemainingCapacityByType(m_oxygenGasId, (float)(block.Room != null && block.Room.IsPressurized ? block.Room.OxygenAmount : (MyOxygenProviderSystem.GetOxygenInPoint(WorldMatrix.Translation) != 0 ? BlockDefinition.VentilationCapacityPerSecond * 100 : 0f))); ResourceSink.Update(); UdpateTexts(); UpdateEmissivity(); if (MyFakes.ENABLE_OXYGEN_SOUNDS) UpdateSound(); }
private void StopSparks() { if (m_particleEffect1 != null) { m_particleEffect1.Stop(); m_particleEffect1 = null; } if (m_particleEffect2 != null) { m_particleEffect2.Stop(); m_particleEffect2 = null; } }
private void DrawAtmosphericEntryEffect() { var naturalGravity = MyGravityProviderSystem.CalculateNaturalGravityInPoint(m_grid.PositionComp.GetPosition()); var naturalGravityMagnitude = naturalGravity.Length(); bool noPhysics = m_grid.Physics == null; bool recentlyHitVoxel = MySandboxGame.TotalGamePlayTimeInMilliseconds - m_lastVoxelContactTime < m_atmosphericEffectVoxelContactDelay; bool notNearPlanet = naturalGravityMagnitude <= 0; bool tooLowSpeed = !noPhysics && (m_grid.Physics.LinearVelocity.Length() < m_atmosphericEffectMinSpeed); if (noPhysics || recentlyHitVoxel || notNearPlanet || tooLowSpeed) { if (m_atmosphericEffect != null) { MyParticlesManager.RemoveParticleEffect(m_atmosphericEffect); m_atmosphericEffect = null; } return; } var currentVelocity = m_grid.Physics.LinearVelocity; var currentVelocityDirection = Vector3.Normalize(currentVelocity); var currentSpeed = currentVelocity.Length(); if (m_atmosphericEffect == null) { if (!MyParticlesManager.TryCreateParticleEffect(52, out m_atmosphericEffect)) return; } BoundingBox worldAABB = (BoundingBox)m_grid.PositionComp.WorldAABB; var aabbCenter = worldAABB.Center; var directionFaceCenter = new Vector3(); Debug.Assert(m_tmpCornerList.Count == 0); foreach (var corner in worldAABB.GetCorners()) { var centerToCorner = corner - aabbCenter; if (centerToCorner.Dot(currentVelocityDirection) > 0.01f) { m_tmpCornerList.Add(corner); directionFaceCenter += corner; if (m_tmpCornerList.Count == 4) break; } } if (m_tmpCornerList.Count > 0) directionFaceCenter /= m_tmpCornerList.Count; Plane plane = new Plane(directionFaceCenter, -currentVelocityDirection); m_tmpCornerList.Clear(); var startPosition = m_grid.Physics.CenterOfMassWorld; float? intersectDistance = new Ray(startPosition, currentVelocityDirection).Intersects(plane); m_lastWorkingIntersectDistance = intersectDistance ?? m_lastWorkingIntersectDistance; var intersectPoint = startPosition + 0.875f * currentVelocityDirection * m_lastWorkingIntersectDistance; Matrix worldMatrix = Matrix.Identity; worldMatrix.Translation = intersectPoint; worldMatrix.Forward = currentVelocityDirection; var forwardPerpendicular = Vector3.Transform(currentVelocityDirection, Quaternion.CreateFromAxisAngle(m_grid.PositionComp.WorldMatrix.Left, (float)Math.PI / 2.0f)); worldMatrix.Up = Vector3.Normalize(Vector3.Reject(m_grid.PositionComp.WorldMatrix.Left, forwardPerpendicular)); worldMatrix.Left = worldMatrix.Up.Cross(worldMatrix.Forward); var atmosphericDensityMultiplier = MyGravityProviderSystem.CalculateHighestNaturalGravityMultiplierInPoint(m_grid.PositionComp.GetPosition()); m_atmosphericEffect.UserScale = (float)worldAABB.ProjectedArea(currentVelocityDirection) / (float)Math.Pow(38.0 * m_grid.GridSize, 2.0); m_atmosphericEffect.UserAxisScale = Vector3.Normalize(new Vector3(1.0f, 1.0f, 1.0f + 1.5f * (m_grid.Physics.LinearVelocity.Length() - m_atmosphericEffectMinSpeed) / (MyGridPhysics.ShipMaxLinearVelocity() - m_atmosphericEffectMinSpeed))); m_atmosphericEffect.WorldMatrix = worldMatrix; m_atmosphericEffect.UserColorMultiplier = new Vector4(MathHelper.Clamp((currentSpeed - m_atmosphericEffectMinSpeed) / (m_atmosphericEffectMinSpeed * 0.5f) * (float)Math.Pow(atmosphericDensityMultiplier, 1.5), 0.0f, m_atmosphericEffectMinFade)); }
public static void CustomDraw(MyParticleEffect effect) { System.Diagnostics.Debug.Assert(effect != null); m_effectsForCustomDraw.Add(effect); }
protected override void StopEffects() { if (m_particleEffect != null) { m_particleEffect.Stop(); m_particleEffect = null; } if (m_effectLight != null) { MyLights.RemoveLight(m_effectLight); m_effectLight = null; } }
public static VRageRender.MyBillboard AddBillboardEffect(MyParticleEffect effect) { //VRageRender.MyBillboard billboard = m_preallocatedParticleBillboards.Allocate(); //VRageRender.MyBillboard billboard = new VRageRender.MyBillboard(); VRageRender.MyBillboard billboard = VRageRender.MyRenderProxy.BillboardsPoolWrite.Allocate(); if (billboard != null) { billboard.ContainedBillboards.Clear(); MyTransparentGeometry.StartParticleProfilingBlock("AddBillboardEffect"); billboard.DistanceSquared = (float)Vector3D.DistanceSquared(MyTransparentGeometry.Camera.Translation, effect.WorldMatrix.Translation); billboard.Lowres = VRageRender.MyRenderConstants.RenderQualityProfile.LowResParticles; billboard.Near = effect.Near; billboard.CustomViewProjection = -1; MyTransparentGeometry.EndParticleProfilingBlock(); } return billboard; }
public static void RemoveParticleEffect(MyParticleEffect effect) { RemoveParticleEffect(effect.GetID()); }
public static void RemoveParticleEffect(MyParticleEffect effect, bool fromBackground = false) { bool remove = true; if (!effect.UserDraw) { lock (m_particleEffectsForUpdate) { remove = m_particleEffectsForUpdate.Contains(effect); if (remove) m_particleEffectsForUpdate.Remove(effect); } } m_particleEffectsAll.Remove(effect); MyParticlesLibrary.RemoveParticleEffectInstance(effect); }
private void StopDustParticles() { if (DustParticles != null) { DustParticles.Stop(); DustParticles = null; } }
public override void Draw() { base.Draw(); //var worldToLocal = MatrixD.Normalize(MatrixD.Invert(Container.Entity.PositionComp.WorldMatrix)); if (m_thrust.CanDraw()) { m_thrust.UpdateThrustFlame(); m_thrust.UpdateThrustColor(); foreach (var flame in m_thrust.Flames) { if (m_thrust.CubeGrid.Physics == null) continue; MyCubeBlock cubeBlock = Container.Entity as MyCubeBlock; float scale = cubeBlock != null ? cubeBlock.CubeGrid.GridScale : 1.0f; var flameDirection = Vector3D.TransformNormal(flame.Direction, Container.Entity.PositionComp.WorldMatrix); var flamePosition = Vector3D.Transform(flame.Position, Container.Entity.PositionComp.WorldMatrix); float radius = m_thrust.ThrustRadiusRand * flame.Radius * scale; float length = m_thrust.ThrustLengthRand * flame.Radius * scale; float thickness = m_thrust.ThrustThicknessRand * flame.Radius * scale; //Vector3D velocityAtNewCOM = Vector3D.Cross(m_thrust.CubeGrid.Physics.AngularVelocity, flamePosition - m_thrust.CubeGrid.Physics.CenterOfMassWorld); //var velocity = m_thrust.CubeGrid.Physics.LinearVelocity + velocityAtNewCOM; if (m_thrust.CurrentStrength > 0 && length > 0) { float angle = 1 - Math.Abs(Vector3.Dot(MyUtils.Normalize(MySector.MainCamera.Position - flamePosition), flameDirection)); float alphaCone = (1 - (float)Math.Pow(1 - angle, 30)) * 0.5f; // We move polyline particle backward, because we are stretching ball texture and it doesn't look good if stretched. This will hide it. MyTransparentGeometry.AddLineBillboard(m_thrust.FlameLengthMaterial, m_thrust.ThrustColor * alphaCone, flamePosition - (Vector3D)flameDirection * length * 0.25f, -1, ref MatrixD.Identity, flameDirection, length, thickness); } if (radius > 0) MyTransparentGeometry.AddPointBillboard(m_thrust.FlamePointMaterial, m_thrust.ThrustColor, flamePosition, -1, ref MatrixD.Identity, radius, 0); if (m_thrust.ThrustLengthRand > MyMathConstants.EPSILON && m_landingEffectUpdateCounter-- <= 0) { m_landingEffectUpdateCounter = (int)Math.Round(m_landingEffectUpdateInterval * (0.8f + MyRandom.Instance.NextFloat() * 0.4f)); m_lastHitInfo = MyPhysics.CastRay(flamePosition, flamePosition + flameDirection * m_thrust.ThrustLengthRand * (m_thrust.CubeGrid.GridSizeEnum == MyCubeSize.Large ? 5.0f : 3.0f) * flame.Radius, MyPhysics.CollisionLayers.DefaultCollisionLayer); } var voxelBase = m_lastHitInfo.HasValue ? m_lastHitInfo.Value.HkHitInfo.GetHitEntity() as MyVoxelPhysics : null; if (voxelBase == null) { if (m_landingEffect != null) { m_landingEffect.Stop(); m_landingEffect = null; --m_landingEffectCount; } continue; } if (m_landingEffect == null && m_landingEffectCount < m_maxNumberLandingEffects && MyParticlesManager.TryCreateParticleEffect(54, out m_landingEffect)) { ++m_landingEffectCount; } if (m_landingEffect == null) continue; m_landingEffect.UserScale = m_thrust.CubeGrid.GridSize; m_landingEffect.WorldMatrix = MatrixD.CreateFromTransformScale(Quaternion.CreateFromForwardUp(-m_lastHitInfo.Value.HkHitInfo.Normal, Vector3.CalculatePerpendicularVector(m_lastHitInfo.Value.HkHitInfo.Normal)), m_lastHitInfo.Value.Position, Vector3D.One); MatrixD.Rescale(m_landingEffect.WorldMatrix, scale); } } else if(m_landingEffect != null) { m_landingEffect.Stop(); m_landingEffect = null; --m_landingEffectCount; } if (m_thrust.Light != null) { m_thrust.UpdateLight(); } }
public void AddParticleToLibrary(MyParticleEffect effect) { MyParticlesLibrary.AddParticleEffect(effect); }
static public void RemoveParticleEffectInstance(MyParticleEffect effect) { effect.Close(false); //if (effect.Enabled) if (m_libraryEffects.ContainsKey(effect.GetID())) { var instances = m_libraryEffects[effect.GetID()].GetInstances(); if (instances != null) { if (instances.Contains(effect)) { MyParticlesManager.EffectsPool.Deallocate(effect); m_libraryEffects[effect.GetID()].RemoveInstance(effect); } else { System.Diagnostics.Debug.Assert(false, "Effect deleted twice!"); } } } }
private void CreateEffect() { if (m_effect != null) { m_effect.Stop(); m_effect = null; } if (MyParticlesManager.TryCreateParticleEffect(48, out m_effect)) { Matrix mat; Orientation.GetMatrix(out mat); var orientation = mat; if (IsDepressurizing) { orientation.Left = mat.Right; orientation.Up = mat.Down; orientation.Forward = mat.Backward; } orientation = Matrix.Multiply(orientation, CubeGrid.PositionComp.WorldMatrix.GetOrientation()); orientation.Translation = CubeGrid.GridIntegerToWorld(Position + mat.Forward / 4f); m_effect.WorldMatrix = orientation; m_effect.AutoDelete = false; m_effect.UserScale = 3f; } }
public void StopSparkParticles() { if (SparkEffect != null) { SparkEffect.Stop(); SparkEffect = null; } }
public void RemoveParticle(MyParticleEffect effect) { MyParticlesLibrary.RemoveParticleEffectInstance(effect); }
public static void AddParticleEffect(MyParticleEffect effect) { m_libraryEffects.Add(effect.GetID(), effect); m_libraryEffectsString[effect.Name] = effect; }
public override void Close() { if (m_dustEffect != null) { m_dustEffect.Stop(); m_dustEffect = null; } base.Close(); }
public static void CustomDraw(MyParticleEffect effect) { System.Diagnostics.Debug.Assert(effect != null); m_effectsForCustomDraw.Add(effect); }
public override void OnBeforeRemovedFromContainer() { base.OnBeforeRemovedFromContainer(); if (m_atmosphericEffect != null) { MyParticlesManager.RemoveParticleEffect(m_atmosphericEffect); m_atmosphericEffect = null; } }
private void DestroyMeteor() { MyParticleEffect impactParticle; if (InParticleVisibleRange && MyParticlesManager.TryCreateParticleEffect("Meteorit_Smoke1AfterHit", out impactParticle)) { impactParticle.WorldMatrix = Entity.WorldMatrix; impactParticle.UserScale = MyUtils.GetRandomFloat(1.5f, 2); } if (m_dustEffect != null) { m_dustEffect.Stop(); m_dustEffect = null; } PlayExplosionSound(); }
public override void UpdateBeforeSimulation100() { base.UpdateBeforeSimulation100(); if (m_particleVectorUp == Vector3.Zero) { if (Entity.Physics.LinearVelocity != Vector3.Zero) m_particleVectorUp = -Vector3.Normalize(Entity.Physics.LinearVelocity); else m_particleVectorUp = Vector3.Up; m_particleVectorUp.CalculatePerpendicularVector(out m_particleVectorForward); } if (m_dustEffect != null && !InParticleVisibleRange) { m_dustEffect.Stop(); m_dustEffect = null; } if (m_dustEffect == null && Entity.PositionComp.Scale > 1.5 && InParticleVisibleRange) { if (MyParticlesManager.TryCreateParticleEffect(m_particleEffectId, out m_dustEffect)) { UpdateParticlePosition(); m_dustEffect.UserScale = Entity.PositionComp.Scale.Value / 5; } } m_soundEmitter.Update(); if (Sync.IsServer && MySandboxGame.TotalGamePlayTimeInMilliseconds - m_timeCreated > Math.Min(MAX_TRAJECTORY_LENGTH / MIN_SPEED, MAX_TRAJECTORY_LENGTH / Entity.Physics.LinearVelocity.Length()) * 1000) { CloseMeteorInternal(); } }
public override void UpdateBeforeSimulation100() { base.UpdateBeforeSimulation100(); if (m_particleVectorUp == Vector3.Zero) { if (Entity.Physics.LinearVelocity != Vector3.Zero) m_particleVectorUp = -Vector3.Normalize(Entity.Physics.LinearVelocity); else m_particleVectorUp = Vector3.Up; m_particleVectorUp.CalculatePerpendicularVector(out m_particleVectorForward); } Vector3D pos = Entity.PositionComp.GetPosition(); var planet = MyGamePruningStructure.GetClosestPlanet(pos); MeteorStatus orig = m_meteorStatus; if (planet != null && planet.HasAtmosphere && planet.GetAirDensity(pos) > 0.5f) m_meteorStatus = MeteorStatus.InAtmosphere; else m_meteorStatus = MeteorStatus.InSpace; if (orig != m_meteorStatus && m_dustEffect != null) { m_dustEffect.Stop(); m_dustEffect = null; } if (m_dustEffect != null && !InParticleVisibleRange) { m_dustEffect.Stop(); m_dustEffect = null; } if (m_dustEffect == null && InParticleVisibleRange) { if (MyParticlesManager.TryCreateParticleEffect(m_particleEffectNames[(int)m_meteorStatus], out m_dustEffect)) { UpdateParticlePosition(); m_dustEffect.UserScale = Entity.PositionComp.Scale.Value; } } m_soundEmitter.Update(); if (Sync.IsServer && MySandboxGame.TotalGamePlayTimeInMilliseconds - m_timeCreated > Math.Min(MAX_TRAJECTORY_LENGTH / SPEED, MAX_TRAJECTORY_LENGTH / Entity.Physics.LinearVelocity.Length()) * 1000) { CloseMeteorInternal(); } }
private void DestroyMeteor() { MyParticleEffect impactParticle; if (InParticleVisibleRange && MyParticlesManager.TryCreateParticleEffect((int)MyParticleEffectsIDEnum.MeteorAsteroidCollision, out impactParticle)) { impactParticle.WorldMatrix = Entity.WorldMatrix; impactParticle.UserScale = MyUtils.GetRandomFloat(1.5f, 2); } if (m_dustEffect != null) { m_dustEffect.Stop(); if (m_particleEffectId == (int)MyParticleEffectsIDEnum.MeteorParticle) { m_dustEffect.Close(false); if (InParticleVisibleRange && m_particleVectorUp != Vector3.Zero && MyParticlesManager.TryCreateParticleEffect((int)MyParticleEffectsIDEnum.MeteorParticleAfterHit, out m_dustEffect)) { MatrixD m = MatrixD.CreateWorld(Entity.WorldMatrix.Translation, m_particleVectorForward, m_particleVectorUp); m_dustEffect.WorldMatrix = m; } } m_dustEffect = null; } PlayExplosionSound(); }
private void DestroyMeteor() { MyParticleEffect impactParticle; if (InParticleVisibleRange && MyParticlesManager.TryCreateParticleEffect("Meteorit_Smoke1AfterHit", out impactParticle)) { impactParticle.WorldMatrix = Entity.WorldMatrix; impactParticle.UserScale = 5 * MyUtils.GetRandomFloat(0.8f, 1.2f); } if (m_dustEffect != null) { m_dustEffect.Stop(); if (MySession.Static.EnvironmentHostility != MyEnvironmentHostilityEnum.CATACLYSM_UNREAL) { m_dustEffect.Close(false); if (InParticleVisibleRange && m_particleVectorUp != Vector3.Zero && MyParticlesManager.TryCreateParticleEffect("Meteorit_Smoke1AfterHit", out m_dustEffect)) { MatrixD m = MatrixD.CreateWorld(Entity.WorldMatrix.Translation, m_particleVectorForward, m_particleVectorUp); m_dustEffect.WorldMatrix = m; } } m_dustEffect = null; } if (m_dustEffect != null) { m_dustEffect.Stop(); m_dustEffect = null; } PlayExplosionSound(); }