36 public virtual void Update(
float dt) {
44 if (terrainRaycastResult.Distance < 3f) {
50 terrainRaycastResult.Distance =
MathUtils.
Max(terrainRaycastResult.Distance, 0.1f);
61 PerformanceManager.
AddExtraStat($
"Block Value: {cellValue}, CellFace: ({cellFace.X},{cellFace.Y},{cellFace.Z},{cellFace.Face}), Distance: {terrainRaycastResult.Distance:F1}");
85 ModsManager.GetInPakOrStorageFile<
string>(
"Shaders/Highlight",
"vsh"),
86 ModsManager.GetInPakOrStorageFile<
string>(
"Shaders/Highlight",
"psh"),
92 if (!camera.
Eye.HasValue) {
98 ray = terrainRaycastResult.Ray;
102 ray = bodyRaycastResult.Ray;
106 ray = movingBlocksRaycastResult.Ray;
107 num =
MathUtils.
Min(movingBlocksRaycastResult.Distance, 2f);
116 Color color = Color.White * 0.5f;
124 if (camera.
Eye !=
null) {
128 Vector3 vector = result.HitPoint();
131 vector2 = -result.Ray.Direction;
137 float num2 = 0.03f +
MathUtils.
Min(0.008f * num, 0.04f);
138 float num3 = 0.01f * num;
152 Vector3 vector6 = vector + num2 * (-vector4 + vector5) + num3 * vector2;
153 Vector3 vector7 = vector + num2 * (vector4 + vector5) + num3 * vector2;
154 Vector3 vector8 = vector + num2 * (vector4 - vector5) + num3 * vector2;
155 Vector3 vector9 = vector + num2 * (-vector4 - vector5) + num3 * vector2;
160 texturedBatch3D.QueueQuad(
176 if (camera.
Eye !=
null
198 DynamicArray<TerrainVertex> vertices =
m_geometry.SubsetOpaque.Vertices;
199 DynamicArray<int> indices =
m_geometry.SubsetOpaque.Indices;
206 m_shader.GetParameter(
"u_origin").SetValue(vector.
XZ);
207 m_shader.GetParameter(
"u_viewProjectionMatrix").SetValue(matrix);
208 m_shader.GetParameter(
"u_viewPosition").SetValue(translation);
213 m_shader.GetParameter(
"u_fogBottomTopDensity")
244 cellFaceBoundingBox.
Min,
245 cellFaceBoundingBox.
Max,
260 cellFaceBoundingBox2.
Min,
261 cellFaceBoundingBox2.
Max,
320 Vector3 vector =
new(point.
X, point.
Y, point.
Z);
321 if (customCollisionBoxes.Length != 0) {
323 for (
int i = 0; i < customCollisionBoxes.Length; i++) {
324 if (customCollisionBoxes[i] !=
default) {
325 boundingBox = boundingBox.HasValue ?
BoundingBox.
Union(boundingBox.Value, customCollisionBoxes[i]) : customCollisionBoxes[i];
329 return new BoundingBox(boundingBox.Value.
Min + vector, boundingBox.Value.
Max + vector);
336 for (
int l = 0; l <
Subsets.Length; l++) {
341 terrainGeometrySubset,
342 terrainGeometrySubset,
343 terrainGeometrySubset,
344 terrainGeometrySubset,
345 terrainGeometrySubset,
346 terrainGeometrySubset
354 for (
int i = 0; i < 7; i++) {
355 Subsets[i] = terrainGeometrySubset;
void Flush(Matrix matrix, bool clearAfterFlush=true)
static readonly BlendState NonPremultiplied
static readonly DepthStencilState Default
static readonly DepthStencilState None
static readonly DepthStencilState DepthRead
void QueueLine(Vector3 p1, Vector3 p2, Color color)
static readonly RasterizerState CullCounterClockwiseScissor
static SamplerState PointWrap
static SamplerState LinearClamp
static int Min(int x1, int x2)
static float Saturate(float x)
static int Max(int x1, int x2)
static float Floor(float x)
void GenerateTerrainVertices(BlockGeometryGenerator generator, TerrainGeometry geometry, int value, int x, int y, int z)
生成地形顶点(用于绘制放置的方块)
virtual bool IsEditable_(int value)
virtual BoundingBox[] GetCustomCollisionBoxes(SubsystemTerrain terrain, int value)
bool UsesMovementControls
Matrix InvertedViewMatrix
Matrix ViewProjectionMatrix
Geometry(Texture2D texture2D)
SubsystemTerrain m_subsystemTerrain
virtual void DrawRayHighlight(Camera camera)
virtual void Update(float dt)
virtual void DrawFillHighlight(Camera camera)
SubsystemAnimatedTextures m_subsystemAnimatedTextures
virtual void DrawReticleHighlight(Camera camera)
SubsystemSky m_subsystemSky
override void Load(ValuesDictionary valuesDictionary, IdToEntityMap idToEntityMap)
virtual void DrawOutlineHighlight(Camera camera)
object m_highlightRaycastResult
virtual void Draw(Camera camera, int drawOrder)
static int[] m_drawOrders
static void DrawBoundingBoxFace(FlatBatch3D batch, int face, Vector3 c1, Vector3 c2, Color color)
Point3? NearbyEditableCell
BoundingBox GetCellFaceBoundingBox(Point3 point)
ComponentPlayer m_componentPlayer
PrimitivesRenderer3D m_primitivesRenderer3D
static object Get(Type type, string name)
static LookControlMode LookControlMode
Texture2D AnimatedBlocksTexture
readonly Texture2D Texture
readonly Vector2 BottomRight
TerrainGeometrySubset[] Subsets
TerrainGeometrySubset[] TransparentSubsetsByFace
TerrainGeometrySubset SubsetTransparent
TerrainGeometrySubset SubsetAlphaTest
TerrainGeometrySubset SubsetOpaque
TerrainGeometrySubset[] AlphaTestSubsetsByFace
TerrainGeometrySubset[] OpaqueSubsetsByFace
static int ExtractContents(int value)
ValuesDictionary ValuesDictionary
static BoundingBox Union(BoundingBox b1, BoundingBox b2)
static Color Lerp(Color c1, Color c2, float f)
static Color MultiplyNotSaturated(Color c, float s)
static Matrix CreateTranslation(float x, float y, float z)
static readonly Vector3 One
static Vector3 Cross(Vector3 v1, Vector3 v2)
static Vector3 Normalize(Vector3 v)
static readonly Vector3 Zero
static float Distance(Vector3 v1, Vector3 v2)
static readonly Vector3 UnitX
static readonly Vector3 UnitY
static float Dot(Vector3 v1, Vector3 v2)
CellFace(int x, int y, int z, int face)
static Vector3 FaceToVector3(int face)
static readonly VertexDeclaration VertexDeclaration