1using System.Globalization;
14 public string[]
Lines = [
string.Empty,
string.Empty,
string.Empty,
string.Empty];
18 public string Url =
string.Empty;
85 return new SignData { Lines = value.Lines.ToArray(), Colors = value.Colors.ToArray(), Url = value.Url };
92 for (
int i = 0; i < 4; i++) {
93 textData.
Lines[i] = lines[i];
94 textData.
Colors[i] = colors[i];
97 textData.MovingBlock = movingBlock;
114 int x2 = x - point.
X;
115 int y2 = y - point.
Y;
116 int z2 = z - point.
Z;
155 && !
string.IsNullOrEmpty(signData.
Url)) {
166 Point3 key =
new(x, y, z);
171 textData.MovingBlock = movingBlock;
181 textData.Point =
new Point3(x, y, z);
182 textData.MovingBlock =
null;
187 public override void OnBlockRemoved(
int value,
int newValue,
int x,
int y,
int z) {
188 Point3 key =
new(x, y, z);
202 base.Load(valuesDictionary);
210 string value2 = value11.GetValue(
"Line1",
string.Empty);
211 string value3 = value11.GetValue(
"Line2",
string.Empty);
212 string value4 = value11.GetValue(
"Line3",
string.Empty);
213 string value5 = value11.GetValue(
"Line4",
string.Empty);
218 string value10 = value11.GetValue(
"Url",
string.Empty);
219 SetSignData(value, [value2, value3, value4, value5], [value6, value7, value8, value9], value10, movingBlock);
225 valuesDictionary.SetValue(
"Point", textData.
Point);
227 if (!
string.IsNullOrEmpty(textData.
Lines[0])) {
228 valuesDictionary.SetValue(
"Line1", textData.
Lines[0]);
230 if (!
string.IsNullOrEmpty(textData.
Lines[1])) {
231 valuesDictionary.SetValue(
"Line2", textData.
Lines[1]);
233 if (!
string.IsNullOrEmpty(textData.
Lines[2])) {
234 valuesDictionary.SetValue(
"Line3", textData.
Lines[2]);
236 if (!
string.IsNullOrEmpty(textData.
Lines[3])) {
237 valuesDictionary.SetValue(
"Line4", textData.
Lines[3]);
240 valuesDictionary.SetValue(
"Color1", textData.
Colors[0]);
243 valuesDictionary.SetValue(
"Color2", textData.
Colors[1]);
246 valuesDictionary.SetValue(
"Color3", textData.
Colors[2]);
249 valuesDictionary.SetValue(
"Color4", textData.
Colors[3]);
251 if (!
string.IsNullOrEmpty(textData.
Url)) {
252 valuesDictionary.SetValue(
"Url", textData.
Url);
259 valuesDictionary.SetValue(
"Texts", valuesDictionary2);
266 valuesDictionary2.SetValue(num++.ToString(CultureInfo.InvariantCulture), valuesDictionary3);
271 valuesDictionary2.SetValue(num++.ToString(CultureInfo.InvariantCulture), valuesDictionary3);
287 m_maxTexts = Display.MaxTextureSize / eachSignHeight;
304 value.TextureLocation =
null;
312 List<string> list = [];
313 List<Color> list2 = [];
314 for (
int i = 0; i < textData.
Lines.Length; i++) {
315 if (!
string.IsNullOrEmpty(textData.
Lines[i])) {
316 list.Add(textData.
Lines[i].Replace(
"\\",
"").ToUpper());
317 list2.Add(textData.
Colors[i]);
320 if (list.Count > 0) {
321 float num = list.Max(l => l.Length) * m_font.GlyphHeight *
m_fontScale;
322 float num2 = list.Count * m_font.GlyphHeight *
m_fontScale;
326 if (num / num2 < num3) {
334 bool flag = !
string.IsNullOrEmpty(textData.
Url);
335 for (
int j = 0; j < list.Count; j++) {
345 color: flag ?
new Color(0, 0, 64) : list2[j],
351 textData.UsedTextureWidth = num4;
352 textData.UsedTextureHeight = num5;
381 value.Distance = num;
388 float num =
m_subsystemViews.CalculateSquaredDistanceFromNearestView(position);
390 value.Distance = num;
394 m_nearTexts.Sort((d1, d2) => Comparer<float>.
Default.Compare(d1.Distance, d2.Distance));
414 if (textData2 !=
null) {
415 textData2.TextureLocation =
null;
419 textData.TextureLocation = num2;
441 if (textData3 !=
null) {
448 Display.RenderTarget = renderTarget;
478 BlockMesh signSurfaceBlockMesh = signBlock.GetSignSurfaceBlockMesh(data);
479 if (signSurfaceBlockMesh !=
null) {
481 if (chunkAtCell !=
null
486 Color color =
new(num2, num2, num2);
488 float x2 = nearText.UsedTextureWidth / (m_font.GlyphHeight * 16f *
m_fontScale);
490 float x4 = (nearText.TextureLocation.Value + nearText.UsedTextureHeight / (m_font.GlyphHeight * 4f *
m_fontScale)) /
m_maxTexts;
491 Vector3 signSurfaceNormal = signBlock.GetSignSurfaceNormal(data);
496 float num3 =
Vector3.
Dot(camera.ViewPosition - (vector +
new Vector3(0.5f)), signSurfaceNormal);
498 for (
int i = 0; i < signSurfaceBlockMesh.Indices.Count / 3; i++) {
502 Vector3 p = blockMeshVertex.Position + vector + vector2;
503 Vector3 p2 = blockMeshVertex2.Position + vector + vector2;
504 Vector3 p3 = blockMeshVertex3.Position + vector + vector2;
508 textureCoordinates.X =
MathUtils.
Lerp(x, x2, textureCoordinates.
X);
509 textureCoordinates2.X =
MathUtils.
Lerp(x, x2, textureCoordinates2.
X);
510 textureCoordinates3.X =
MathUtils.
Lerp(x, x2, textureCoordinates3.
X);
511 textureCoordinates.Y =
MathUtils.
Lerp(x3, x4, textureCoordinates.
Y);
512 textureCoordinates2.Y =
MathUtils.
Lerp(x3, x4, textureCoordinates2.
Y);
513 textureCoordinates3.Y =
MathUtils.
Lerp(x3, x4, textureCoordinates3.
Y);
514 texturedBatch3D.QueueTriangle(
static readonly BlendState Opaque
static readonly DepthStencilState None
static readonly DepthStencilState DepthRead
static int MaxTextureSize
static void Clear(Vector4? color, float? depth=null, int? stencil=null)
static RenderTarget2D RenderTarget
void QueueText(string text, Vector2 position, float depth, Color color, TextAnchor anchor=TextAnchor.Default)
static readonly RasterizerState CullCounterClockwiseScissor
static SamplerState PointClamp
static int Min(int x1, int x2)
static int Max(int x1, int x2)
static float Lerp(float x1, float x2, float f)
static int GetFace(int data)
static void PlaySound(string name, float volume, float pitch, float pan)
virtual bool IsCollidable_(int value)
DynamicArray< BlockMeshVertex > Vertices
DynamicArray< int > Indices
ComponentPlayer ComponentPlayer
ContainerWidget GuiWidget
static void ShowDialog(ContainerWidget parentWidget, Dialog dialog)
static readonly float[] LightIntensityByLightValue
static bool IsNullOrStopped(MovingBlock movingBlock)
void SetValuesDicionary(ValuesDictionary valuesDictionary, bool saveWhenStopped=false)
static MovingBlock LoadFromValuesDictionary(Project project, ValuesDictionary valuesDictionary, bool throwOnError=true, bool throwIfNotFound=false)
static bool GetHanging(int data)
SubsystemTerrain SubsystemTerrain
List< Vector3 > m_lastUpdatePositions
override void OnBlockStopMoving(int value, int oldValue, int x, int y, int z, MovingBlock movingBlock)
void SetSignData(Point3 point, string[] lines, Color[] colors, string url, MovingBlock movingBlock=null)
SubsystemGameWidgets m_subsystemViews
static int[] m_drawOrders
override void Load(ValuesDictionary valuesDictionary)
virtual void DrawSigns(Camera camera)
TextData[] m_textureLocations
override int[] HandledBlocks
void CreateRenderTarget()
void Display_DeviceReset()
PrimitivesRenderer2D m_primitivesRenderer2D
virtual void Draw(Camera camera, int drawOrder)
virtual void SaveTextData(TextData textData, ValuesDictionary valuesDictionary)
virtual void Update(float dt)
RenderTarget2D m_renderTarget
PrimitivesRenderer3D m_primitivesRenderer3D
virtual void UpdateRenderTarget()
void RenderText(FontBatch2D fontBatch, FlatBatch2D flatBatch, TextData textData)
SubsystemTerrain m_subsystemTerrain
SubsystemGameInfo m_subsystemGameInfo
Dictionary< MovingBlock, TextData > m_textsByMovingBlock
List< RenderTarget2D > m_texturesByPoint
void InvalidateRenderTarget()
override void OnBlockRemoved(int value, int newValue, int x, int y, int z)
override void OnBlockStartMoving(int value, int newValue, int x, int y, int z, MovingBlock movingBlock)
override void OnNeighborBlockChanged(int x, int y, int z, int neighborX, int neighborY, int neighborZ)
override bool OnInteract(TerrainRaycastResult raycastResult, ComponentMiner componentMiner)
const float m_minUpdateDistance
override void Save(ValuesDictionary valuesDictionary)
Dictionary< Point3, TextData > m_textsByPoint
SignData GetSignData(Point3 point)
List< TextData > m_nearTexts
const float m_maxVisibilityDistanceSqr
static int ExtractContents(int value)
static int ExtractLight(int value)
static int ExtractData(int value)
static void LaunchBrowser(string url)
ValuesDictionary ValuesDictionary
static readonly Vector2 Zero
static float DistanceSquared(Vector3 v1, Vector3 v2)
static float Dot(Vector3 v1, Vector3 v2)
Vector2 TextureCoordinates
static Point3 FaceToPoint3(int face)