public void RemoveTrail(Projectile projectile) { if (projectile.TrailParticleSystem != null) { if (m_subsystemParticles.ContainsParticleSystem((ParticleSystemBase)projectile.TrailParticleSystem)) { m_subsystemParticles.RemoveParticleSystem((ParticleSystemBase)projectile.TrailParticleSystem); } projectile.TrailParticleSystem = null; } }
public override void Load(ValuesDictionary valuesDictionary, IdToEntityMap idToEntityMap) { m_subsystemParticles = base.Project.FindSubsystem <SubsystemParticles>(throwOnError: true); m_subsystemAudio = base.Project.FindSubsystem <SubsystemAudio>(throwOnError: true); m_subsystemTerrain = base.Project.FindSubsystem <SubsystemTerrain>(throwOnError: true); m_componentCreature = base.Entity.FindComponent <ComponentCreature>(throwOnError: true); m_componentPathfinding = base.Entity.FindComponent <ComponentPathfinding>(throwOnError: true); m_stateMachine.AddState("Inactive", null, delegate { m_importanceLevel = MathUtils.Lerp(0f, 400f, MathUtils.Saturate((0.75f - m_componentCreature.ComponentHealth.Air) / 0.75f)); if (IsActive) { m_stateMachine.TransitionTo("Surface"); } }, null); m_stateMachine.AddState("Surface", delegate { m_componentPathfinding.Stop(); }, delegate { _ = m_componentCreature.ComponentBody.Position; if (!m_componentPathfinding.Destination.HasValue) { Vector3?destination = FindSurfaceDestination(); if (destination.HasValue) { float speed = (m_componentCreature.ComponentHealth.Air < 0.25f) ? 1f : m_random.Float(0.4f, 0.6f); m_componentPathfinding.SetDestination(destination, speed, 1f, 0, useRandomMovements: false, ignoreHeightDifference: false, raycastDestination: false, null); } } else if (m_componentPathfinding.IsStuck) { m_importanceLevel = 0f; } if (m_componentCreature.ComponentHealth.Air > 0.9f) { m_stateMachine.TransitionTo("Breathe"); } }, null); m_stateMachine.AddState("Breathe", delegate { Vector3 forward = m_componentCreature.ComponentBody.Matrix.Forward; Vector3 value = m_componentCreature.ComponentBody.Matrix.Translation + 10f * forward + new Vector3(0f, 2f, 0f); m_componentPathfinding.SetDestination(value, 0.6f, 1f, 0, useRandomMovements: false, ignoreHeightDifference: false, raycastDestination: false, null); m_particleSystem = new WhalePlumeParticleSystem(m_subsystemTerrain, m_random.Float(0.8f, 1.1f), m_random.Float(1f, 1.3f)); m_subsystemParticles.AddParticleSystem(m_particleSystem); m_subsystemAudio.PlayRandomSound("Audio/Creatures/WhaleBlow", 1f, m_random.Float(-0.2f, 0.2f), m_componentCreature.ComponentBody.Position, 10f, autoDelay: true); }, delegate { m_particleSystem.Position = m_componentCreature.ComponentBody.Position + new Vector3(0f, 0.8f * m_componentCreature.ComponentBody.BoxSize.Y, 0f); if (!m_subsystemParticles.ContainsParticleSystem(m_particleSystem)) { m_importanceLevel = 0f; } }, delegate { m_particleSystem.IsStopped = true; m_particleSystem = null; }); }
public void Draw(Camera camera, int drawOrder) { int num = (SettingsManager.VisibilityRange > 128) ? 9 : ((SettingsManager.VisibilityRange <= 64) ? 7 : 8); int num2 = num * num; Dictionary <Point2, PrecipitationShaftParticleSystem> activeShafts = GetActiveShafts(camera.GameWidget); byte b = (byte)(255f * MathUtils.Lerp(0.15f, 1f, SubsystemSky.SkyLightIntensity)); RainColor = new Color(b, b, b); byte b2 = (byte)(255f * MathUtils.Lerp(0.15f, 1f, SubsystemSky.SkyLightIntensity)); SnowColor = new Color(b2, b2, b2); Vector2 vector = new Vector2(camera.ViewPosition.X, camera.ViewPosition.Z); Point2 point = Terrain.ToCell(vector); Vector2?value = null; m_lastShaftsUpdatePositions.TryGetValue(camera.GameWidget, out value); if (value.HasValue && !(Vector2.DistanceSquared(value.Value, vector) > 1f)) { return; } m_lastShaftsUpdatePositions[camera.GameWidget] = vector; m_toRemove.Clear(); foreach (PrecipitationShaftParticleSystem value2 in activeShafts.Values) { if (MathUtils.Sqr((float)value2.Point.X + 0.5f - vector.X) + MathUtils.Sqr((float)value2.Point.Y + 0.5f - vector.Y) > (float)num2 + 1f) { m_toRemove.Add(value2); } } foreach (PrecipitationShaftParticleSystem item in m_toRemove) { if (m_subsystemParticles.ContainsParticleSystem(item)) { m_subsystemParticles.RemoveParticleSystem(item); } activeShafts.Remove(item.Point); } for (int i = point.X - num; i <= point.X + num; i++) { for (int j = point.Y - num; j <= point.Y + num; j++) { if (MathUtils.Sqr((float)i + 0.5f - vector.X) + MathUtils.Sqr((float)j + 0.5f - vector.Y) <= (float)num2) { Point2 point2 = new Point2(i, j); if (!activeShafts.ContainsKey(point2)) { PrecipitationShaftParticleSystem precipitationShaftParticleSystem = new PrecipitationShaftParticleSystem(camera.GameWidget, this, m_random, point2, GetPrecipitationShaftInfo(point2.X, point2.Y).Type); m_subsystemParticles.AddParticleSystem(precipitationShaftParticleSystem); activeShafts.Add(point2, precipitationShaftParticleSystem); } } } } }