Survivalcraft API 1.8.2.3 v1.8.2.3
Survivalcraft 2.4
载入中...
搜索中...
未找到
FireworksTrailParticleSystem.cs
浏览该文件的文档.
1using Engine;
3
4namespace Game {
5 public class FireworksTrailParticleSystem : ParticleSystem<FireworksTrailParticleSystem.Particle>, ITrailParticleSystem {
6 public class Particle : Game.Particle {
7 public float Time;
8
9 public float Duration;
10 }
11
12 public Random m_random = new();
13
14 public float m_toGenerate;
15
17
18 public Vector3 Position { get; set; }
19
20 public bool IsStopped { get; set; }
21
22 public FireworksTrailParticleSystem() : base(60) {
23 Texture = ContentManager.Get<Texture2D>("Textures/FireParticle");
25 }
26
27 public override bool Simulate(float dt) {
28 float num = 120f;
29 m_toGenerate += num * dt;
30 if (!m_lastPosition.HasValue) {
32 }
33 bool flag = false;
34 for (int i = 0; i < Particles.Length; i++) {
35 Particle particle = Particles[i];
36 if (particle.IsActive) {
37 flag = true;
38 particle.Time += dt;
39 if (particle.Time <= particle.Duration) {
40 particle.TextureSlot = (int)MathUtils.Min(9f * particle.Time / particle.Duration, 8f);
41 }
42 else {
43 particle.IsActive = false;
44 }
45 }
46 else if (!IsStopped
47 && m_toGenerate >= 1f) {
48 particle.IsActive = true;
49 particle.Position = Vector3.Lerp(m_lastPosition.Value, Position, m_random.Float(0f, 1f));
50 particle.Color = Color.White;
51 particle.Time = m_random.Float(0f, 0.75f);
52 particle.Size = new Vector2(m_random.Float(0.12f, 0.16f));
53 particle.Duration = 1f;
54 particle.FlipX = m_random.Bool();
55 particle.FlipY = m_random.Bool();
56 m_toGenerate -= 1f;
57 }
58 }
61 if (IsStopped) {
62 return !flag;
63 }
64 return false;
65 }
66 }
67}
static float Remainder(float x, float y)
static int Min(int x1, int x2)
static object Get(Type type, string name)
ParticleSystem(int particlesCount)
static Color White
static Vector3 Lerp(Vector3 v1, Vector3 v2, float f)