перенос файлов клиента из папки White в _White

This commit is contained in:
Remuchi
2024-01-28 17:32:55 +07:00
parent c80b10a688
commit 21dbccfec9
139 changed files with 345 additions and 434 deletions

View File

@@ -0,0 +1,20 @@
using System.Numerics;
using Content.Shared.White.Spline;
using Content.Shared.White.Trail;
using Robust.Client.Graphics;
using Vector4 = Robust.Shared.Maths.Vector4;
namespace Content.Client._White.Trail.SplineRenderer;
public interface ITrailSplineRenderer
{
void Render(
DrawingHandleWorld handle,
Texture? texture,
ISpline<Vector2> splineIterator,
ISpline<Vector4> gradientIterator,
ITrailSettings settings,
Vector2[] paPositions,
float[] paLifetimes
);
}

View File

@@ -0,0 +1,17 @@
using Content.Shared.White.Trail;
namespace Content.Client._White.Trail.SplineRenderer;
public static class TrailSplineRenderer
{
public static ITrailSplineRenderer FromType(TrailSplineRendererType type)
{
return type switch
{
TrailSplineRendererType.Continuous => new TrailSplineRendererContinuous(),
TrailSplineRendererType.Point => new TrailSplineRendererPoint(),
TrailSplineRendererType.Debug => new TrailSplineRendererDebug(),
_ => throw new NotImplementedException()
};
}
}

View File

@@ -0,0 +1,90 @@
using System.Linq;
using System.Numerics;
using Content.Shared.White.Spline;
using Content.Shared.White.Trail;
using Robust.Client.Graphics;
using Vector4 = Robust.Shared.Maths.Vector4;
namespace Content.Client._White.Trail.SplineRenderer;
public sealed class TrailSplineRendererContinuous : ITrailSplineRenderer
{
public void Render(
DrawingHandleWorld handle,
Texture? texture,
ISpline<Vector2> splineIterator,
ISpline<Vector4> gradientIterator,
ITrailSettings settings,
Vector2[] paPositions,
float[] paLifetimes
)
{
float[] splinePointParams;
if (settings.LengthStep == 0f)
{
splinePointParams = Enumerable.Range(0, paPositions.Length - 1).Select(x => (float) x).ToArray();
}
else
{
splinePointParams = splineIterator
.IteratePointParamsByLength(paPositions, Math.Max(settings.LengthStep, 0.1f)).ToArray();
}
var gradientControlGroups = gradientIterator.GetControlGroupAmount(settings.Gradient.Length);
var colorToPointMul = 0f;
if (gradientControlGroups > 0)
colorToPointMul = gradientControlGroups / splineIterator.GetControlGroupAmount(paPositions.Length);
(Vector2, Vector2)? prevPoints = null;
foreach (var u in splinePointParams)
{
var (position, velocity) = splineIterator.SamplePositionVelocity(paPositions, u);
var offset = new Vector2(-velocity.Y, velocity.X).Normalized() *
settings.Scale.X; // 90-degree anticlockwise rotation
var curPoints = (position - offset, position + offset);
if (prevPoints.HasValue)
{
var colorVec = Vector4.One;
if (settings.Gradient != null && settings.Gradient.Length > 0)
{
if (gradientControlGroups > 0)
colorVec = gradientIterator.SamplePosition(settings.Gradient, u * colorToPointMul);
else
colorVec = settings.Gradient[0];
}
if (texture != null)
{
var verts = new DrawVertexUV2D[]
{
new(curPoints.Item1, Vector2.Zero),
new(curPoints.Item2, Vector2.UnitY),
new(prevPoints.Value.Item2, Vector2.One),
new(prevPoints.Value.Item1, Vector2.UnitX),
};
handle.DrawPrimitives(DrawPrimitiveTopology.TriangleFan, texture, verts,
new Color(colorVec.X, colorVec.Y, colorVec.Z, colorVec.W));
}
else
{
var verts = new[]
{
curPoints.Item1,
curPoints.Item2,
prevPoints.Value.Item2,
prevPoints.Value.Item1,
};
handle.DrawPrimitives(DrawPrimitiveTopology.TriangleFan, verts,
new Color(colorVec.X, colorVec.Y, colorVec.Z, colorVec.W));
}
}
prevPoints = curPoints;
}
}
}

View File

@@ -0,0 +1,54 @@
using System.Linq;
using System.Numerics;
using Content.Shared.White.Spline;
using Content.Shared.White.Trail;
using Robust.Client.Graphics;
using Vector4 = Robust.Shared.Maths.Vector4;
namespace Content.Client._White.Trail.SplineRenderer;
public sealed class TrailSplineRendererDebug : ITrailSplineRenderer
{
public void Render(
DrawingHandleWorld handle,
Texture? texture,
ISpline<Vector2> splineIterator,
ISpline<Vector4> gradientIterator,
ITrailSettings settings,
Vector2[] paPositions,
float[] paLifetimes
)
{
float[] splinePointParams;
if (settings.LengthStep == 0f)
{
splinePointParams = Enumerable.Range(0, paPositions.Length - 1).Select(x => (float) x).ToArray();
}
else
{
splinePointParams = splineIterator
.IteratePointParamsByLength(paPositions, Math.Max(settings.LengthStep, 0.1f)).ToArray();
}
Vector2? prevPosControlPoint = null;
foreach (var item in paPositions)
{
if (prevPosControlPoint.HasValue)
handle.DrawLine(item, prevPosControlPoint.Value, Color.Blue);
prevPosControlPoint = item;
}
Vector2? prevPosSplinePoint = null;
foreach (var u in splinePointParams)
{
var (position, velocity) = splineIterator.SamplePositionVelocity(paPositions, u);
if (prevPosSplinePoint.HasValue)
handle.DrawLine(position, prevPosSplinePoint.Value, Color.Red);
handle.DrawLine(position, position + velocity, Color.White);
handle.DrawCircle(position, 0.03f, new Color(0, 255, 0));
prevPosSplinePoint = position;
}
}
}

View File

@@ -0,0 +1,58 @@
using System.Linq;
using System.Numerics;
using Content.Shared.White.Spline;
using Content.Shared.White.Trail;
using Robust.Client.Graphics;
using Vector4 = Robust.Shared.Maths.Vector4;
namespace Content.Client._White.Trail.SplineRenderer;
public sealed class TrailSplineRendererPoint : ITrailSplineRenderer
{
public void Render(
DrawingHandleWorld handle,
Texture? texture,
ISpline<Vector2> splineIterator,
ISpline<Vector4> gradientIterator,
ITrailSettings settings,
Vector2[] paPositions,
float[] paLifetimes
)
{
if (texture == null)
return;
float[] splinePointParams;
if (settings.LengthStep == 0f)
{
splinePointParams = Enumerable.Range(0, paPositions.Length - 1).Select(x => (float) x).ToArray();
}
else
{
splinePointParams = splineIterator
.IteratePointParamsByLength(paPositions, Math.Max(settings.LengthStep, 0.1f)).ToArray();
}
var gradientControlGroups = gradientIterator.GetControlGroupAmount(settings.Gradient.Length);
var colorToPointMul = 0f;
if (gradientControlGroups > 0)
colorToPointMul = gradientControlGroups / gradientIterator.GetControlGroupAmount(paPositions.Length);
foreach (var u in splinePointParams)
{
var (position, velocity) = splineIterator.SamplePositionVelocity(paPositions, u);
var colorVec = Vector4.One;
if (settings.Gradient != null && settings.Gradient.Length > 0)
{
colorVec = gradientControlGroups > 0
? gradientIterator.SamplePosition(settings.Gradient, u * colorToPointMul)
: settings.Gradient[0];
}
var quad = Box2.FromDimensions(position, texture.Size * settings.Scale / EyeManager.PixelsPerMeter);
handle.DrawTextureRect(texture, new Box2Rotated(quad, velocity.ToAngle(), quad.Center),
new Color(colorVec.X, colorVec.Y, colorVec.Z, colorVec.W));
}
}
}