Survivalcraft API 1.8.2.3
v1.8.2.3
Survivalcraft 2.4
载入中...
搜索中...
未找到
GunSmokeParticleSystem.cs
浏览该文件的文档.
1
using
Engine
;
2
using
Engine.Graphics
;
3
4
namespace
Game
{
5
public
class
GunSmokeParticleSystem
:
ParticleSystem
<GunSmokeParticleSystem.Particle> {
6
public
class
Particle
:
Game
.
Particle
{
7
public
Vector3
Velocity
;
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_toGenerate
;
19
20
public
Vector3
m_position
;
21
22
public
Vector3
m_direction
;
23
24
public
Color
m_color
;
25
26
public
GunSmokeParticleSystem
(
SubsystemTerrain
terrain,
Vector3
position,
Vector3
direction) : base(50) {
27
Texture
=
ContentManager
.
Get
<
Texture2D
>(
"Textures/GunSmokeParticle"
);
28
TextureSlotsCount
= 3;
29
m_position
= position;
30
m_direction
=
Vector3
.
Normalize
(direction);
31
int
num =
Terrain
.
ToCell
(position.
X
);
32
int
num2 =
Terrain
.
ToCell
(position.
Y
);
33
int
num3 =
Terrain
.
ToCell
(position.
Z
);
34
int
x = 0;
35
x =
MathUtils
.
Max
(x, terrain.
Terrain
.
GetCellLight
(num + 1, num2, num3));
36
x =
MathUtils
.
Max
(x, terrain.
Terrain
.
GetCellLight
(num - 1, num2, num3));
37
x =
MathUtils
.
Max
(x, terrain.
Terrain
.
GetCellLight
(num, num2 + 1, num3));
38
x =
MathUtils
.
Max
(x, terrain.
Terrain
.
GetCellLight
(num, num2 - 1, num3));
39
x =
MathUtils
.
Max
(x, terrain.
Terrain
.
GetCellLight
(num, num2, num3 + 1));
40
x =
MathUtils
.
Max
(x, terrain.
Terrain
.
GetCellLight
(num, num2, num3 - 1));
41
float
num4 =
LightingManager
.
LightIntensityByLightValue
[x];
42
m_color
=
new
Color
(num4, num4, num4);
43
}
44
45
public
override
bool
Simulate
(
float
dt) {
46
m_time
+= dt;
47
float
num =
MathUtils
.
Lerp
(150f, 20f,
MathUtils
.
Saturate
(2f *
m_time
/ 0.5f));
48
float
num2 = MathF.Pow(0.01f, dt);
49
float
s =
MathUtils
.
Lerp
(20f, 0f,
MathUtils
.
Saturate
(2f *
m_time
/ 0.5f));
50
Vector3
v =
new
(2f, 2f, 1f);
51
if
(
m_time
< 0.5f) {
52
m_toGenerate
+= num * dt;
53
}
54
else
{
55
m_toGenerate
= 0f;
56
}
57
bool
flag =
false
;
58
for
(
int
i = 0; i <
Particles
.Length; i++) {
59
Particle
particle =
Particles
[i];
60
if
(particle.
IsActive
) {
61
flag =
true
;
62
particle.Time += dt;
63
if
(particle.
Time
<= particle.
Duration
) {
64
particle.Position += particle.Velocity * dt;
65
particle.Velocity *= num2;
66
particle.Velocity += v * dt;
67
particle.TextureSlot = (int)
MathUtils
.
Min
(9f * particle.
Time
/ particle.
Duration
, 8f);
68
particle.Size =
new
Vector2
(0.3f);
69
}
70
else
{
71
particle.IsActive =
false
;
72
}
73
}
74
else
if
(
m_toGenerate
>= 1f) {
75
particle.IsActive =
true
;
76
Vector3
v2 =
m_random
.Vector3(0f, 1f);
77
particle.Position =
m_position
+ 0.3f * v2;
78
particle.Color =
m_color
;
79
particle.Velocity = s * (
m_direction
+
m_random
.Vector3(0f, 0.1f)) + 2.5f * v2;
80
particle.Size =
Vector2
.
Zero
;
81
particle.Time = 0f;
82
particle.Duration =
m_random
.Float(0.5f, 2f);
83
particle.FlipX =
m_random
.Bool();
84
particle.FlipY =
m_random
.Bool();
85
m_toGenerate
-= 1f;
86
}
87
}
88
m_toGenerate
=
MathUtils
.
Remainder
(
m_toGenerate
, 1f);
89
if
(!flag
90
&&
m_time
>= 0.5f) {
91
return
true
;
92
}
93
return
false
;
94
}
95
}
96
}
Engine.Graphics.Texture2D
定义
Texture2D.cs:15
Engine.MathUtils
定义
MathUtils.cs:2
Engine.MathUtils.Remainder
static float Remainder(float x, float y)
定义
MathUtils.cs:183
Engine.MathUtils.Min
static int Min(int x1, int x2)
定义
MathUtils.cs:7
Engine.MathUtils.Saturate
static float Saturate(float x)
定义
MathUtils.cs:163
Engine.MathUtils.Max
static int Max(int x1, int x2)
定义
MathUtils.cs:18
Engine.MathUtils.Lerp
static float Lerp(float x1, float x2, float f)
定义
MathUtils.cs:213
Game.ContentManager
定义
ContentManager.cs:50
Game.ContentManager.Get
static object Get(Type type, string name)
定义
ContentManager.cs:70
Game.GunSmokeParticleSystem.Particle
定义
GunSmokeParticleSystem.cs:6
Game.GunSmokeParticleSystem.Particle.Velocity
Vector3 Velocity
定义
GunSmokeParticleSystem.cs:7
Game.GunSmokeParticleSystem.Particle.Duration
float Duration
定义
GunSmokeParticleSystem.cs:11
Game.GunSmokeParticleSystem.Particle.Time
float Time
定义
GunSmokeParticleSystem.cs:9
Game.GunSmokeParticleSystem.m_toGenerate
float m_toGenerate
定义
GunSmokeParticleSystem.cs:18
Game.GunSmokeParticleSystem.GunSmokeParticleSystem
GunSmokeParticleSystem(SubsystemTerrain terrain, Vector3 position, Vector3 direction)
定义
GunSmokeParticleSystem.cs:26
Game.GunSmokeParticleSystem.m_color
Color m_color
定义
GunSmokeParticleSystem.cs:24
Game.GunSmokeParticleSystem.m_direction
Vector3 m_direction
定义
GunSmokeParticleSystem.cs:22
Game.GunSmokeParticleSystem.m_position
Vector3 m_position
定义
GunSmokeParticleSystem.cs:20
Game.GunSmokeParticleSystem.m_random
Random m_random
定义
GunSmokeParticleSystem.cs:14
Game.GunSmokeParticleSystem.Simulate
override bool Simulate(float dt)
定义
GunSmokeParticleSystem.cs:45
Game.GunSmokeParticleSystem.m_time
float m_time
定义
GunSmokeParticleSystem.cs:16
Game.LightingManager
定义
LightingManager.cs:4
Game.LightingManager.LightIntensityByLightValue
static readonly float[] LightIntensityByLightValue
定义
LightingManager.cs:11
Game.Particle.IsActive
bool IsActive
定义
Particle.cs:5
Game.ParticleSystem-1-g.TextureSlotsCount
int TextureSlotsCount
定义
ParticleSystem.cs:33
Game.ParticleSystem-1-g.Texture
Texture2D Texture
定义
ParticleSystem.cs:22
Game.ParticleSystem-1-g.ParticleSystem
ParticleSystem(int particlesCount)
定义
ParticleSystem.cs:35
Game.ParticleSystem-1-g.Particles
T[] Particles
定义
ParticleSystem.cs:20
Game.Random
定义
Random.cs:5
Game.SubsystemTerrain
定义
SubsystemTerrain.cs:6
Game.SubsystemTerrain.Terrain
virtual Terrain Terrain
定义
SubsystemTerrain.cs:50
Game.Terrain
定义
Terrain.cs:5
Game.Terrain.GetCellLight
virtual int GetCellLight(int x, int y, int z)
定义
Terrain.cs:232
Game.Terrain.ToCell
static int ToCell(float x)
定义
Terrain.cs:210
Engine.Graphics
定义
BaseBatch.cs:1
Engine.Graphics.ShaderParameterType.Vector2
@ Vector2
定义
ShaderParameterType.cs:4
Engine
定义
BaseSound.cs:10
Game
定义
ContentFileBridge.cs:4
Engine.Color
定义
Color.cs:2
Engine.Vector2
定义
Vector2.cs:2
Engine.Vector2.Zero
static readonly Vector2 Zero
定义
Vector2.cs:7
Engine.Vector3
定义
Vector3.cs:2
Engine.Vector3.Y
float Y
定义
Vector3.cs:5
Engine.Vector3.Normalize
static Vector3 Normalize(Vector3 v)
定义
Vector3.cs:154
Engine.Vector3.Z
float Z
定义
Vector3.cs:7
Engine.Vector3.X
float X
定义
Vector3.cs:3
SurvivalcraftApi 1.8.2.3
Survivalcraft.Windows
Game
GunSmokeParticleSystem.cs
制作者
1.16.1