Skip to content

Commit

Permalink
Merge pull request #96 from SS14-Classic/Update-11/8/2024
Browse files Browse the repository at this point in the history
Update 11/8/2024
  • Loading branch information
VMSolidus authored Nov 9, 2024
2 parents cdb7acd + 6416c50 commit 14acf0b
Show file tree
Hide file tree
Showing 235 changed files with 4,425 additions and 2,136 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public sealed class ExplosionDebugOverlay : Overlay

public override OverlaySpace Space => OverlaySpace.WorldSpace | OverlaySpace.ScreenSpace;

public Matrix3 SpaceMatrix;
public Matrix3x2 SpaceMatrix;
public MapId Map;

private readonly Font _font;
Expand Down Expand Up @@ -78,15 +78,16 @@ private void DrawScreen(OverlayDrawArgs args)
if (SpaceTiles == null)
return;

gridBounds = Matrix3.Invert(SpaceMatrix).TransformBox(args.WorldBounds);
Matrix3x2.Invert(SpaceMatrix, out var invSpace);
gridBounds = invSpace.TransformBox(args.WorldBounds);

DrawText(handle, gridBounds, SpaceMatrix, SpaceTiles, SpaceTileSize);
}

private void DrawText(
DrawingHandleScreen handle,
Box2 gridBounds,
Matrix3 transform,
Matrix3x2 transform,
Dictionary<int, List<Vector2i>> tileSets,
ushort tileSize)
{
Expand All @@ -103,7 +104,7 @@ private void DrawText(
if (!gridBounds.Contains(centre))
continue;

var worldCenter = transform.Transform(centre);
var worldCenter = Vector2.Transform(centre, transform);

var screenCenter = _eyeManager.WorldToScreen(worldCenter);

Expand All @@ -119,7 +120,7 @@ private void DrawText(
if (tileSets.TryGetValue(0, out var set))
{
var epicenter = set.First();
var worldCenter = transform.Transform((epicenter + Vector2Helpers.Half) * tileSize);
var worldCenter = Vector2.Transform((epicenter + Vector2Helpers.Half) * tileSize, transform);
var screenCenter = _eyeManager.WorldToScreen(worldCenter) + new Vector2(-24, -24);
var text = $"{Intensity[0]:F2}\nΣ={TotalIntensity:F1}\nΔ={Slope:F1}";
handle.DrawString(_font, screenCenter, text);
Expand Down Expand Up @@ -148,11 +149,12 @@ private void DrawWorld(in OverlayDrawArgs args)
if (SpaceTiles == null)
return;

gridBounds = Matrix3.Invert(SpaceMatrix).TransformBox(args.WorldBounds).Enlarged(2);
Matrix3x2.Invert(SpaceMatrix, out var invSpace);
gridBounds = invSpace.TransformBox(args.WorldBounds).Enlarged(2);
handle.SetTransform(SpaceMatrix);

DrawTiles(handle, gridBounds, SpaceTiles, SpaceTileSize);
handle.SetTransform(Matrix3.Identity);
handle.SetTransform(Matrix3x2.Identity);
}

private void DrawTiles(
Expand Down
39 changes: 25 additions & 14 deletions Content.Client/Atmos/EntitySystems/GasTileOverlaySystem.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Content.Client.Atmos.Overlays;
using Content.Shared.Atmos;
using Content.Shared.Atmos.Components;
using Content.Shared.Atmos.EntitySystems;
using JetBrains.Annotations;
Expand Down Expand Up @@ -36,28 +37,38 @@ public override void Shutdown()

private void OnHandleState(EntityUid gridUid, GasTileOverlayComponent comp, ref ComponentHandleState args)
{
if (args.Current is not GasTileOverlayState state)
return;
Dictionary<Vector2i, GasOverlayChunk> modifiedChunks;

// is this a delta or full state?
if (!state.FullState)
switch (args.Current)
{
foreach (var index in comp.Chunks.Keys)
// is this a delta or full state?
case GasTileOverlayDeltaState delta:
{
if (!state.AllChunks!.Contains(index))
comp.Chunks.Remove(index);
modifiedChunks = delta.ModifiedChunks;
foreach (var index in comp.Chunks.Keys)
{
if (!delta.AllChunks.Contains(index))
comp.Chunks.Remove(index);
}

break;
}
}
else
{
foreach (var index in comp.Chunks.Keys)
case GasTileOverlayState state:
{
if (!state.Chunks.ContainsKey(index))
comp.Chunks.Remove(index);
modifiedChunks = state.Chunks;
foreach (var index in comp.Chunks.Keys)
{
if (!state.Chunks.ContainsKey(index))
comp.Chunks.Remove(index);
}

break;
}
default:
return;
}

foreach (var (index, data) in state.Chunks)
foreach (var (index, data) in modifiedChunks)
{
comp.Chunks[index] = data;
}
Expand Down
2 changes: 1 addition & 1 deletion Content.Client/Atmos/Overlays/AtmosDebugOverlay.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ protected override void Draw(in OverlayDrawArgs args)
DrawData(msg, handle);
}

handle.SetTransform(Matrix3.Identity);
handle.SetTransform(Matrix3x2.Identity);
}

private void DrawData(DebugMessage msg,
Expand Down
4 changes: 2 additions & 2 deletions Content.Client/Atmos/Overlays/GasTileOverlay.cs
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ protected override void Draw(in OverlayDrawArgs args)

var (_, _, worldMatrix, invMatrix) = gridXform.GetWorldPositionRotationMatrixWithInv();
state.drawHandle.SetTransform(worldMatrix);
var floatBounds = invMatrix.TransformBox(in state.WorldBounds).Enlarged(grid.TileSize);
var floatBounds = invMatrix.TransformBox(state.WorldBounds).Enlarged(grid.TileSize);
var localBounds = new Box2i(
(int) MathF.Floor(floatBounds.Left),
(int) MathF.Floor(floatBounds.Bottom),
Expand Down Expand Up @@ -249,7 +249,7 @@ protected override void Draw(in OverlayDrawArgs args)
});

drawHandle.UseShader(null);
drawHandle.SetTransform(Matrix3.Identity);
drawHandle.SetTransform(Matrix3x2.Identity);
}

private void DrawMapOverlay(
Expand Down
12 changes: 6 additions & 6 deletions Content.Client/Clickable/ClickableComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,18 +38,18 @@ public bool CheckClick(SpriteComponent sprite, TransformComponent transform, Ent
renderOrder = sprite.RenderOrder;
var (spritePos, spriteRot) = transform.GetWorldPositionRotation(xformQuery);
var spriteBB = sprite.CalculateRotatedBoundingBox(spritePos, spriteRot, eye.Rotation);
bottom = Matrix3.CreateRotation(eye.Rotation).TransformBox(spriteBB).Bottom;
bottom = Matrix3Helpers.CreateRotation(eye.Rotation).TransformBox(spriteBB).Bottom;

var invSpriteMatrix = Matrix3.Invert(sprite.GetLocalMatrix());
Matrix3x2.Invert(sprite.GetLocalMatrix(), out var invSpriteMatrix);

// This should have been the rotation of the sprite relative to the screen, but this is not the case with no-rot or directional sprites.
var relativeRotation = (spriteRot + eye.Rotation).Reduced().FlipPositive();

Angle cardinalSnapping = sprite.SnapCardinals ? relativeRotation.GetCardinalDir().ToAngle() : Angle.Zero;

// First we get `localPos`, the clicked location in the sprite-coordinate frame.
var entityXform = Matrix3.CreateInverseTransform(transform.WorldPosition, sprite.NoRotation ? -eye.Rotation : spriteRot - cardinalSnapping);
var localPos = invSpriteMatrix.Transform(entityXform.Transform(worldPos));
var entityXform = Matrix3Helpers.CreateInverseTransform(transform.WorldPosition, sprite.NoRotation ? -eye.Rotation : spriteRot - cardinalSnapping);
var localPos = Vector2.Transform(Vector2.Transform(worldPos, entityXform), invSpriteMatrix);

// Check explicitly defined click-able bounds
if (CheckDirBound(sprite, relativeRotation, localPos))
Expand Down Expand Up @@ -79,8 +79,8 @@ public bool CheckClick(SpriteComponent sprite, TransformComponent transform, Ent

// convert to layer-local coordinates
layer.GetLayerDrawMatrix(dir, out var matrix);
var inverseMatrix = Matrix3.Invert(matrix);
var layerLocal = inverseMatrix.Transform(localPos);
Matrix3x2.Invert(matrix, out var inverseMatrix);
var layerLocal = Vector2.Transform(localPos, inverseMatrix);

// Convert to image coordinates
var layerImagePos = (Vector2i) (layerLocal * EyeManager.PixelsPerMeter * new Vector2(1, -1) + rsiState.Size / 2f);
Expand Down
39 changes: 24 additions & 15 deletions Content.Client/Decals/DecalSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,34 +56,43 @@ protected override void OnDecalRemoved(EntityUid gridId, uint decalId, DecalGrid

private void OnHandleState(EntityUid gridUid, DecalGridComponent gridComp, ref ComponentHandleState args)
{
if (args.Current is not DecalGridState state)
return;

// is this a delta or full state?
_removedChunks.Clear();
Dictionary<Vector2i, DecalChunk> modifiedChunks;

if (!state.FullState)
switch (args.Current)
{
foreach (var key in gridComp.ChunkCollection.ChunkCollection.Keys)
case DecalGridDeltaState delta:
{
if (!state.AllChunks!.Contains(key))
_removedChunks.Add(key);
modifiedChunks = delta.ModifiedChunks;
foreach (var key in gridComp.ChunkCollection.ChunkCollection.Keys)
{
if (!delta.AllChunks.Contains(key))
_removedChunks.Add(key);
}

break;
}
}
else
{
foreach (var key in gridComp.ChunkCollection.ChunkCollection.Keys)
case DecalGridState state:
{
if (!state.Chunks.ContainsKey(key))
_removedChunks.Add(key);
modifiedChunks = state.Chunks;
foreach (var key in gridComp.ChunkCollection.ChunkCollection.Keys)
{
if (!state.Chunks.ContainsKey(key))
_removedChunks.Add(key);
}

break;
}
default:
return;
}

if (_removedChunks.Count > 0)
RemoveChunks(gridUid, gridComp, _removedChunks);

if (state.Chunks.Count > 0)
UpdateChunks(gridUid, gridComp, state.Chunks);
if (modifiedChunks.Count > 0)
UpdateChunks(gridUid, gridComp, modifiedChunks);
}

private void OnChunkUpdate(DecalChunkUpdateEvent ev)
Expand Down
3 changes: 2 additions & 1 deletion Content.Client/Decals/Overlays/DecalOverlay.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System.Numerics;
using Content.Shared.Decals;
using Robust.Client.GameObjects;
using Robust.Client.Graphics;
Expand Down Expand Up @@ -113,7 +114,7 @@ protected override void Draw(in OverlayDrawArgs args)
handle.DrawTexture(cache.Texture, decal.Coordinates, angle, decal.Color);
}

handle.SetTransform(Matrix3.Identity);
handle.SetTransform(Matrix3x2.Identity);
}
}
}
4 changes: 2 additions & 2 deletions Content.Client/Decals/Overlays/DecalPlacementOverlay.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ protected override void Draw(in OverlayDrawArgs args)
var handle = args.WorldHandle;
handle.SetTransform(worldMatrix);

var localPos = invMatrix.Transform(mousePos.Position);
var localPos = Vector2.Transform(mousePos.Position, invMatrix);

if (snap)
{
Expand All @@ -63,6 +63,6 @@ protected override void Draw(in OverlayDrawArgs args)
var box = new Box2Rotated(aabb, rotation, localPos);

handle.DrawTextureRect(_sprite.Frame0(decal.Sprite), box, color);
handle.SetTransform(Matrix3.Identity);
handle.SetTransform(Matrix3x2.Identity);
}
}
12 changes: 6 additions & 6 deletions Content.Client/DoAfter/DoAfterOverlay.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ protected override void Draw(in OverlayDrawArgs args)

// If you use the display UI scale then need to set max(1f, displayscale) because 0 is valid.
const float scale = 1f;
var scaleMatrix = Matrix3.CreateScale(new Vector2(scale, scale));
var rotationMatrix = Matrix3.CreateRotation(-rotation);
var scaleMatrix = Matrix3Helpers.CreateScale(new Vector2(scale, scale));
var rotationMatrix = Matrix3Helpers.CreateRotation(-rotation);

var curTime = _timing.CurTime;

Expand Down Expand Up @@ -91,9 +91,9 @@ protected override void Draw(in OverlayDrawArgs args)
? curTime - _meta.GetPauseTime(uid, meta)
: curTime;

var worldMatrix = Matrix3.CreateTranslation(worldPosition);
Matrix3.Multiply(scaleMatrix, worldMatrix, out var scaledWorld);
Matrix3.Multiply(rotationMatrix, scaledWorld, out var matty);
var worldMatrix = Matrix3Helpers.CreateTranslation(worldPosition);
var scaledWorld = Matrix3x2.Multiply(scaleMatrix, worldMatrix);
var matty = Matrix3x2.Multiply(rotationMatrix, scaledWorld);
handle.SetTransform(matty);

var offset = 0f;
Expand Down Expand Up @@ -151,7 +151,7 @@ protected override void Draw(in OverlayDrawArgs args)
}

handle.UseShader(null);
handle.SetTransform(Matrix3.Identity);
handle.SetTransform(Matrix3x2.Identity);
}

public Color GetProgressColor(float progress, float alpha = 1f)
Expand Down
5 changes: 3 additions & 2 deletions Content.Client/Explosion/ExplosionOverlay.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ protected override void Draw(in OverlayDrawArgs args)
DrawExplosion(drawHandle, args.WorldBounds, visuals, index, xforms, textures);
}

drawHandle.SetTransform(Matrix3.Identity);
drawHandle.SetTransform(Matrix3x2.Identity);
drawHandle.UseShader(null);
}

Expand Down Expand Up @@ -78,7 +78,8 @@ private void DrawExplosion(
if (visuals.SpaceTiles == null)
return;

gridBounds = Matrix3.Invert(visuals.SpaceMatrix).TransformBox(worldBounds).Enlarged(2);
Matrix3x2.Invert(visuals.SpaceMatrix, out var invSpace);
gridBounds = invSpace.TransformBox(worldBounds).Enlarged(2);
drawHandle.SetTransform(visuals.SpaceMatrix);

DrawTiles(drawHandle, gridBounds, index, visuals.SpaceTiles, visuals, visuals.SpaceTileSize, textures);
Expand Down
7 changes: 4 additions & 3 deletions Content.Client/Fluids/PuddleOverlay.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Content.Shared.FixedPoint;
using System.Numerics;
using Content.Shared.FixedPoint;
using Robust.Client.Graphics;
using Robust.Client.ResourceManagement;
using Robust.Shared.Enums;
Expand Down Expand Up @@ -73,7 +74,7 @@ private void DrawWorld(in OverlayDrawArgs args)
}
}

drawHandle.SetTransform(Matrix3.Identity);
drawHandle.SetTransform(Matrix3x2.Identity);
}

private void DrawScreen(in OverlayDrawArgs args)
Expand All @@ -99,7 +100,7 @@ private void DrawScreen(in OverlayDrawArgs args)
if (!gridBounds.Contains(centre))
continue;

var screenCenter = _eyeManager.WorldToScreen(matrix.Transform(centre));
var screenCenter = _eyeManager.WorldToScreen(Vector2.Transform(centre, matrix));

drawHandle.DrawString(_font, screenCenter, debugOverlayData.CurrentVolume.ToString(), Color.White);
}
Expand Down
Loading

0 comments on commit 14acf0b

Please sign in to comment.