Survivalcraft API 1.8.2.3
v1.8.2.3
Survivalcraft 2.4
载入中...
搜索中...
未找到
PaintParticleSystem.cs
浏览该文件的文档.
1
using
Engine
;
2
3
namespace
Game
{
4
public
class
PaintParticleSystem
:
ParticleSystem
<PaintParticleSystem.Particle> {
5
public
class
Particle
:
Game
.
Particle
{
6
public
Vector3
Velocity
;
7
8
public
float
TimeToLive
;
9
10
public
float
HighDampingFactor
;
11
12
public
bool
NoGravity
;
13
14
public
float
Alpha
;
15
}
16
17
public
Random
m_random
=
new
();
18
19
public
SubsystemTerrain
m_subsystemTerrain
;
20
21
public
Color
m_color
;
22
23
public
PaintParticleSystem
(
SubsystemTerrain
terrain,
Vector3
position,
Vector3
normal,
Color
color) : base(20) {
24
m_subsystemTerrain
= terrain;
25
Texture
= terrain.
Project
.
FindSubsystem
<
SubsystemBlocksTexture
>(
true
).
BlocksTexture
;
26
int
num =
Terrain
.
ToCell
(position.
X
);
27
int
num2 =
Terrain
.
ToCell
(position.
Y
);
28
int
num3 =
Terrain
.
ToCell
(position.
Z
);
29
int
x = 0;
30
x =
MathUtils
.
Max
(x, terrain.
Terrain
.
GetCellLight
(num + 1, num2, num3));
31
x =
MathUtils
.
Max
(x, terrain.
Terrain
.
GetCellLight
(num - 1, num2, num3));
32
x =
MathUtils
.
Max
(x, terrain.
Terrain
.
GetCellLight
(num, num2 + 1, num3));
33
x =
MathUtils
.
Max
(x, terrain.
Terrain
.
GetCellLight
(num, num2 - 1, num3));
34
x =
MathUtils
.
Max
(x, terrain.
Terrain
.
GetCellLight
(num, num2, num3 + 1));
35
x =
MathUtils
.
Max
(x, terrain.
Terrain
.
GetCellLight
(num, num2, num3 - 1));
36
TextureSlotsCount
= 16;
37
float
s =
LightingManager
.
LightIntensityByLightValue
[x];
38
m_color
= color * s;
39
m_color
.A = color.
A
;
40
Vector3
vector =
Vector3
.
Normalize
(
Vector3
.
Cross
(normal,
new
Vector3
(0.37f, 0.15f, 0.17f)));
41
Vector3
v =
Vector3
.
Normalize
(
Vector3
.
Cross
(normal, vector));
42
for (
int
i = 0; i <
Particles
.Length; i++) {
43
Particle
obj =
Particles
[i];
44
obj.IsActive =
true
;
45
Vector2
vector2 =
new
(
m_random
.Float(-1f, 1f),
m_random
.Float(-1f, 1f));
46
obj.Position = position + 0.4f * (vector2.X * vector + vector2.Y * v) + 0.03f * normal;
47
obj.Color =
m_color
;
48
obj.Size =
new
Vector2
(
m_random
.Float(0.025f, 0.035f));
49
obj.TimeToLive =
m_random
.Float(0.5f, 1.5f);
50
obj.Velocity = 1f * (vector2.X * vector + vector2.Y * v) +
m_random
.Float(-3f, 0.5f) * normal;
51
obj.TextureSlot = 15;
52
obj.Alpha =
m_random
.Float(0.3f, 0.6f);
53
}
54
}
55
56
public
override
bool
Simulate
(
float
dt) {
57
dt = Math.Clamp(dt, 0f, 0.1f);
58
float
num = MathF.Pow(0.2f, dt);
59
float
num2 = MathF.Pow(1E-07f, dt);
60
bool
flag =
false
;
61
for
(
int
i = 0; i <
Particles
.Length; i++) {
62
Particle
particle =
Particles
[i];
63
if
(!particle.
IsActive
) {
64
continue
;
65
}
66
flag =
true
;
67
particle.TimeToLive -= dt;
68
if
(particle.
TimeToLive
> 0f) {
69
Vector3
position = particle.
Position
;
70
Vector3
vector = position + particle.Velocity * dt;
71
TerrainRaycastResult
? terrainRaycastResult =
m_subsystemTerrain
.Raycast(
72
position,
73
vector,
74
false
,
75
true
,
76
(value, _) =>
BlocksManager
.
Blocks
[
Terrain
.
ExtractContents
(value)].
IsCollidable_
(value)
77
);
78
if
(terrainRaycastResult.HasValue) {
79
particle.Velocity =
Vector3
.
Zero
;
80
particle.Position = terrainRaycastResult.
Value
.HitPoint(0.03f);
81
particle.HighDampingFactor =
m_random
.Float(0.5f, 1f);
82
if
(terrainRaycastResult.
Value
.CellFace.Face >= 4) {
83
particle.NoGravity =
true
;
84
}
85
}
86
else
{
87
particle.Position = vector;
88
}
89
if
(!particle.
NoGravity
) {
90
particle.Velocity.Y += -9.81f * dt;
91
}
92
particle.Velocity *= particle.HighDampingFactor > 0f ? num2 * particle.HighDampingFactor : num;
93
particle.Color =
m_color
*
MathUtils
.
Saturate
(1.5f * particle.
TimeToLive
* particle.
Alpha
);
94
}
95
else
{
96
particle.IsActive =
false
;
97
}
98
}
99
return
!flag;
100
}
101
}
102
}
Engine.MathUtils
定义
MathUtils.cs:2
Engine.MathUtils.Saturate
static float Saturate(float x)
定义
MathUtils.cs:163
Engine.MathUtils.Max
static int Max(int x1, int x2)
定义
MathUtils.cs:18
Game.Block.IsCollidable_
virtual bool IsCollidable_(int value)
定义
Block.cs:260
Game.BlocksManager
定义
BlocksManager.cs:10
Game.BlocksManager.Blocks
static Block[] Blocks
定义
BlocksManager.cs:41
Game.LightingManager
定义
LightingManager.cs:4
Game.LightingManager.LightIntensityByLightValue
static readonly float[] LightIntensityByLightValue
定义
LightingManager.cs:11
Game.PaintParticleSystem.Particle
定义
PaintParticleSystem.cs:5
Game.PaintParticleSystem.Particle.Velocity
Vector3 Velocity
定义
PaintParticleSystem.cs:6
Game.PaintParticleSystem.Particle.TimeToLive
float TimeToLive
定义
PaintParticleSystem.cs:8
Game.PaintParticleSystem.Particle.NoGravity
bool NoGravity
定义
PaintParticleSystem.cs:12
Game.PaintParticleSystem.Particle.HighDampingFactor
float HighDampingFactor
定义
PaintParticleSystem.cs:10
Game.PaintParticleSystem.Particle.Alpha
float Alpha
定义
PaintParticleSystem.cs:14
Game.PaintParticleSystem.PaintParticleSystem
PaintParticleSystem(SubsystemTerrain terrain, Vector3 position, Vector3 normal, Color color)
定义
PaintParticleSystem.cs:23
Game.PaintParticleSystem.m_random
Random m_random
定义
PaintParticleSystem.cs:17
Game.PaintParticleSystem.m_color
Color m_color
定义
PaintParticleSystem.cs:21
Game.PaintParticleSystem.m_subsystemTerrain
SubsystemTerrain m_subsystemTerrain
定义
PaintParticleSystem.cs:19
Game.PaintParticleSystem.Simulate
override bool Simulate(float dt)
定义
PaintParticleSystem.cs:56
Game.Particle.IsActive
bool IsActive
定义
Particle.cs:5
Game.Particle.Position
Vector3 Position
定义
Particle.cs:7
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.SubsystemBlocksTexture
定义
SubsystemBlocksTexture.cs:6
Game.SubsystemBlocksTexture.BlocksTexture
Texture2D BlocksTexture
定义
SubsystemBlocksTexture.cs:7
Game.SubsystemTerrain
定义
SubsystemTerrain.cs:6
Game.SubsystemTerrain.Terrain
virtual Terrain Terrain
定义
SubsystemTerrain.cs:50
Game.Terrain
定义
Terrain.cs:5
Game.Terrain.ExtractContents
static int ExtractContents(int value)
定义
Terrain.cs:303
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
GameEntitySystem.Project.FindSubsystem
virtual Subsystem FindSubsystem(Type type, string name, bool throwOnError)
定义
Project.cs:110
GameEntitySystem.Subsystem.Project
Project Project
定义
Subsystem.cs:10
Engine
定义
BaseSound.cs:10
Game
定义
ContentFileBridge.cs:4
Engine.Color
定义
Color.cs:2
Engine.Color.A
byte A
定义
Color.cs:92
Engine.Vector2
定义
Vector2.cs:2
Engine.Vector3
定义
Vector3.cs:2
Engine.Vector3.Y
float Y
定义
Vector3.cs:5
Engine.Vector3.Cross
static Vector3 Cross(Vector3 v1, Vector3 v2)
定义
Vector3.cs:114
Engine.Vector3.Normalize
static Vector3 Normalize(Vector3 v)
定义
Vector3.cs:154
Engine.Vector3.Zero
static readonly Vector3 Zero
定义
Vector3.cs:9
Engine.Vector3.Z
float Z
定义
Vector3.cs:7
Engine.Vector3.X
float X
定义
Vector3.cs:3
Game.TerrainRaycastResult
定义
TerrainRaycastResult.cs:5
Game.TerrainRaycastResult.Value
int Value
定义
TerrainRaycastResult.cs:10
SurvivalcraftApi 1.8.2.3
Survivalcraft.Windows
Game
PaintParticleSystem.cs
制作者
1.16.1