Survivalcraft API 1.8.2.3 v1.8.2.3
Survivalcraft 2.4
载入中...
搜索中...
未找到
WhalePlumeParticleSystem.cs
浏览该文件的文档.
1using Engine;
3
4namespace Game {
5 public class WhalePlumeParticleSystem : ParticleSystem<WhalePlumeParticleSystem.Particle> {
6 public class Particle : Game.Particle {
8
9 public float Time;
10
11 public float Duration;
12 }
13
14 public Random m_random = new();
15
16 public float m_time;
17
18 public float m_duration;
19
20 public float m_size;
21
22 public float m_toGenerate;
23
24 public bool IsStopped { get; set; }
25
26 public Vector3 Position { get; set; }
27
28 // ReSharper disable UnusedParameter.Local
29 public WhalePlumeParticleSystem(SubsystemTerrain terrain, float size, float duration)
30 // ReSharper restore UnusedParameter.Local
31 : base(100) {
32 Texture = ContentManager.Get<Texture2D>("Textures/WaterSplashParticle");
34 m_size = size;
35 m_duration = duration;
36 }
37
38 public override bool Simulate(float dt) {
39 m_time += dt;
40 if (m_time < m_duration
41 && !IsStopped) {
42 m_toGenerate += 60f * dt;
43 }
44 else {
45 m_toGenerate = 0f;
46 }
47 float num = MathF.Pow(0.001f, dt);
48 float num2 = MathUtils.Lerp(4f, 10f, MathUtils.Saturate(2f * m_time / m_duration));
49 Vector3 v = new(0f, 1f, 2f);
50 bool flag = false;
51 for (int i = 0; i < Particles.Length; i++) {
52 Particle particle = Particles[i];
53 if (particle.IsActive) {
54 flag = true;
55 particle.Time += dt;
56 if (particle.Time <= particle.Duration) {
57 particle.Position += particle.Velocity * dt;
58 particle.Velocity *= num;
59 particle.Velocity += v * dt;
60 particle.TextureSlot = (int)MathUtils.Min(4f * particle.Time / particle.Duration * 1.2f, 3f);
61 particle.Size = new Vector2(m_size) * MathUtils.Lerp(0.1f, 0.2f, particle.Time / particle.Duration);
62 }
63 else {
64 particle.IsActive = false;
65 }
66 }
67 else if (m_toGenerate >= 1f) {
68 particle.IsActive = true;
69 Vector3 v2 = 0.1f * m_size * new Vector3(m_random.Float(-1f, 1f), m_random.Float(0f, 2f), m_random.Float(-1f, 1f));
70 particle.Position = Position + v2;
71 particle.Color = new Color(200, 220, 210);
72 particle.Velocity = 1f * m_size * new Vector3(m_random.Float(-1f, 1f), num2 * m_random.Float(0.3f, 1f), m_random.Float(-1f, 1f));
73 particle.Size = Vector2.Zero;
74 particle.Time = 0f;
75 particle.Duration = m_random.Float(1f, 3f);
76 particle.FlipX = m_random.Bool();
77 particle.FlipY = m_random.Bool();
78 m_toGenerate -= 1f;
79 }
80 }
82 if (!flag
83 && (m_time >= m_duration || IsStopped)) {
84 return true;
85 }
86 return false;
87 }
88 }
89}
Engine.Color Color
Engine.Vector3 Vector3
static float Remainder(float x, float y)
static int Min(int x1, int x2)
static float Saturate(float x)
static float Lerp(float x1, float x2, float f)
static object Get(Type type, string name)
ParticleSystem(int particlesCount)
WhalePlumeParticleSystem(SubsystemTerrain terrain, float size, float duration)
static readonly Vector2 Zero