Skip to content

Commit

Permalink
Update content vectors to numerics (#17759)
Browse files Browse the repository at this point in the history
  • Loading branch information
metalgearsloth authored Jul 8, 2023
1 parent 1577247 commit 68480af
Show file tree
Hide file tree
Showing 383 changed files with 978 additions and 575 deletions.
1 change: 1 addition & 0 deletions Content.Client/Administration/AdminNameOverlay.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System.Numerics;
using Content.Client.Administration.Systems;
using Robust.Client.Graphics;
using Robust.Client.ResourceManagement;
Expand Down
3 changes: 2 additions & 1 deletion Content.Client/Administration/Systems/KillSignSystem.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Content.Client.Administration.Components;
using System.Numerics;
using Content.Client.Administration.Components;
using Robust.Client.GameObjects;
using Robust.Shared.Utility;

Expand Down
3 changes: 2 additions & 1 deletion Content.Client/Administration/UI/AdminMenuWindow.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System.Numerics;
using Robust.Client.AutoGenerated;
using Robust.Client.UserInterface.CustomControls;
using Robust.Client.UserInterface.XAML;
Expand All @@ -11,7 +12,7 @@ public sealed partial class AdminMenuWindow : DefaultWindow

public AdminMenuWindow()
{
MinSize = (500, 250);
MinSize = new Vector2(500, 250);
Title = Loc.GetString("admin-menu-title");
RobustXamlLoader.Load(this);
MasterTabContainer.SetTabTitle(0, Loc.GetString("admin-menu-admin-tab"));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Linq;
using System.Numerics;
using Content.Client.Administration.UI.CustomControls;
using Content.Shared.Administration.BanList;
using Robust.Client.AutoGenerated;
Expand Down Expand Up @@ -57,7 +58,7 @@ private bool LineIdsClicked(BanListLine line)

_popup = new BanListIdsPopup(id, ip, hwid, guid);

var box = UIBox2.FromDimensions(UserInterfaceManager.MousePositionScaled.Position, (1, 1));
var box = UIBox2.FromDimensions(UserInterfaceManager.MousePositionScaled.Position, new Vector2(1, 1));
_popup.Open(box);

return true;
Expand Down
5 changes: 3 additions & 2 deletions Content.Client/Administration/UI/CustomControls/VSeparator.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Robust.Client.Graphics;
using System.Numerics;
using Robust.Client.Graphics;
using Robust.Client.UserInterface.Controls;
using Robust.Shared.Maths;

Expand All @@ -10,7 +11,7 @@ public sealed class VSeparator : PanelContainer

public VSeparator(Color color)
{
MinSize = (2, 5);
MinSize = new Vector2(2, 5);

AddChild(new PanelContainer
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Linq;
using System.Numerics;
using Content.Shared.Administration.Notes;
using Robust.Client.AutoGenerated;
using Robust.Client.UserInterface;
Expand Down Expand Up @@ -67,7 +68,7 @@ private bool NoteClicked(AdminNotesLine line)
};
_popup.OnDeletePressed += noteId => OnNoteDeleted?.Invoke(noteId);

var box = UIBox2.FromDimensions(UserInterfaceManager.MousePositionScaled.Position, (1, 1));
var box = UIBox2.FromDimensions(UserInterfaceManager.MousePositionScaled.Position, Vector2.One);
_popup.Open(box);

return true;
Expand Down
7 changes: 4 additions & 3 deletions Content.Client/Administration/UI/PermissionsEui.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System.Collections.Generic;
using System.Linq;
using System.Numerics;
using Content.Client.Administration.Managers;
using Content.Client.Eui;
using Content.Client.Stylesheets;
Expand Down Expand Up @@ -339,7 +340,7 @@ public Menu(PermissionsEui ui)
Contents.AddChild(tab);
}

protected override Vector2 ContentsMinimumSize => (600, 400);
protected override Vector2 ContentsMinimumSize => new Vector2(600, 400);
}

private sealed class EditAdminWindow : DefaultWindow
Expand All @@ -356,7 +357,7 @@ private sealed class EditAdminWindow : DefaultWindow

public EditAdminWindow(PermissionsEui ui, PermissionsEuiState.AdminData? data)
{
MinSize = (600, 400);
MinSize = new Vector2(600, 400);
SourceData = data;

Control nameControl;
Expand Down Expand Up @@ -534,7 +535,7 @@ private sealed class EditAdminRankWindow : DefaultWindow
public EditAdminRankWindow(PermissionsEui ui, KeyValuePair<int, PermissionsEuiState.AdminRankData>? data)
{
Title = Loc.GetString("permissions-eui-edit-admin-rank-window-title");
MinSize = (600, 400);
MinSize = new Vector2(600, 400);
SourceId = data?.Key;

NameEdit = new LineEdit
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System.Numerics;
using Content.Shared.Roles;
using Robust.Client.AutoGenerated;
using Robust.Client.Console;
Expand All @@ -22,7 +23,7 @@ public sealed partial class SetOutfitMenu : DefaultWindow

public SetOutfitMenu()
{
MinSize = SetSize = (250, 320);
MinSize = SetSize = new Vector2(250, 320);
IoCManager.InjectDependencies(this);
RobustXamlLoader.Load(this);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using Robust.Shared.Enums;
using Robust.Shared.Map;
using System.Linq;
using System.Numerics;

namespace Content.Client.Administration.UI.SpawnExplosion;

Expand Down Expand Up @@ -94,7 +95,7 @@ private void DrawText(

foreach (var tile in tiles)
{
var centre = ((Vector2) tile + 0.5f) * tileSize;
var centre = (tile + Vector2Helpers.Half) * tileSize;

// is the center of this tile visible to the user?
if (!gridBounds.Contains(centre))
Expand All @@ -105,9 +106,9 @@ private void DrawText(
var screenCenter = _eyeManager.WorldToScreen(worldCenter);

if (Intensity[i] > 9)
screenCenter += (-12, -8);
screenCenter += new Vector2(-12, -8);
else
screenCenter += (-8, -8);
screenCenter += new Vector2(-8, -8);

handle.DrawString(_font, screenCenter, Intensity[i].ToString("F2"));
}
Expand All @@ -116,8 +117,8 @@ private void DrawText(
if (tileSets.ContainsKey(0))
{
var epicenter = tileSets[0].First();
var worldCenter = transform.Transform(((Vector2) epicenter + 0.5f) * tileSize);
var screenCenter = _eyeManager.WorldToScreen(worldCenter) + (-24, -24);
var worldCenter = transform.Transform((epicenter + Vector2Helpers.Half) * tileSize);
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 @@ -168,7 +169,7 @@ private void DrawTiles(

foreach (var tile in tiles)
{
var centre = ((Vector2) tile + 0.5f) * tileSize;
var centre = (tile + Vector2Helpers.Half) * tileSize;

// is the center of this tile visible to the user?
if (!gridBounds.Contains(centre))
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System.Numerics;
using Content.Shared.Explosion;
using JetBrains.Annotations;
using Robust.Client.AutoGenerated;
Expand Down Expand Up @@ -120,7 +121,7 @@ private void UpdatePreview()
return;
}

MapCoordinates coords = new((MapX.Value, MapY.Value), _mapData[MapOptions.SelectedId]);
MapCoordinates coords = new(new Vector2(MapX.Value, MapY.Value), _mapData[MapOptions.SelectedId]);
var explosionType = _explosionTypes[ExplosionOption.SelectedId];
_eui.RequestPreviewData(coords, explosionType, Intensity.Value, Slope.Value, MaxIntensity.Value);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System.Numerics;
using JetBrains.Annotations;
using Robust.Client.AutoGenerated;
using Robust.Client.Console;
Expand Down
1 change: 1 addition & 0 deletions Content.Client/Animations/ReusableAnimations.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using System.Numerics;
using Robust.Client.Animations;
using Robust.Client.GameObjects;
using Robust.Shared.Animations;
Expand Down
3 changes: 2 additions & 1 deletion Content.Client/Anomaly/AnomalySystem.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Content.Client.Gravity;
using System.Numerics;
using Content.Client.Gravity;
using Content.Shared.Anomaly;
using Content.Shared.Anomaly.Components;
using Robust.Client.GameObjects;
Expand Down
3 changes: 2 additions & 1 deletion Content.Client/Arcade/BlockGameMenu.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;
using System.Text;
using Content.Client.Arcade.UI;
using Content.Client.Resources;
Expand Down Expand Up @@ -61,7 +62,7 @@ public BlockGameMenu(BlockGameBoundUserInterface owner)
Title = Loc.GetString("blockgame-menu-title");
_owner = owner;

MinSize = SetSize = (410, 490);
MinSize = SetSize = new Vector2(410, 490);

var resourceCache = IoCManager.Resolve<IResourceCache>();
var backgroundTexture = resourceCache.GetTexture("/Textures/Interface/Nano/button.svg.96dpi.png");
Expand Down
7 changes: 3 additions & 4 deletions Content.Client/Arcade/SpaceVillainArcadeMenu.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
using Content.Client.Arcade.UI;
using System.Numerics;
using Content.Client.Arcade.UI;
using Content.Shared.Arcade;
using Robust.Client.UserInterface.Controls;
using Robust.Client.UserInterface.CustomControls;
using Robust.Shared.Localization;
using Vector2 = Robust.Shared.Maths.Vector2;

namespace Content.Client.Arcade
{
Expand All @@ -20,7 +19,7 @@ public sealed class SpaceVillainArcadeMenu : DefaultWindow
private readonly Button[] _gameButtons = new Button[3]; //used to disable/enable all game buttons
public SpaceVillainArcadeMenu(SpaceVillainArcadeBoundUserInterface owner)
{
MinSize = SetSize = (300, 225);
MinSize = SetSize = new Vector2(300, 225);
Title = Loc.GetString("spacevillain-menu-title");
Owner = owner;

Expand Down
1 change: 1 addition & 0 deletions Content.Client/Atmos/Overlays/AtmosDebugOverlay.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System.Numerics;
using Content.Client.Atmos.EntitySystems;
using Content.Shared.Atmos;
using Content.Shared.Atmos.EntitySystems;
Expand Down
1 change: 1 addition & 0 deletions Content.Client/Atmos/Overlays/GasTileOverlay.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System.Numerics;
using Content.Client.Atmos.Components;
using Content.Client.Atmos.EntitySystems;
using Content.Shared.Atmos;
Expand Down
1 change: 1 addition & 0 deletions Content.Client/Atmos/UI/GasAnalyzerWindow.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System.Numerics;
using Content.Client.UserInterface.Controls;
using Content.Shared.Atmos;
using Content.Shared.Temperature;
Expand Down
9 changes: 6 additions & 3 deletions Content.Client/Audio/AmbientSoundSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
using Robust.Shared.Timing;
using Robust.Shared.Utility;
using System.Linq;
using System.Numerics;
using Robust.Client.GameObjects;

namespace Content.Client.Audio;
Expand All @@ -36,6 +37,8 @@ protected override void QueueUpdate(EntityUid uid, AmbientSoundComponent ambienc
private int _maxAmbientCount;
private bool _overlayEnabled;
private float _maxAmbientRange;
private Vector2 MaxAmbientVector => new(_maxAmbientRange, _maxAmbientRange);

private float _cooldown;
private TimeSpan _targetTime = TimeSpan.Zero;
private float _ambienceVolume = 0.0f;
Expand Down Expand Up @@ -210,7 +213,7 @@ private static bool Callback(
? xform.LocalPosition - state.Player.LocalPosition
: xform.WorldPosition - state.MapPos;

var range = delta.Length;
var range = delta.Length();
if (range >= ambientComp.Range)
return true;

Expand Down Expand Up @@ -250,7 +253,7 @@ private void ProcessNearbyAmbience(TransformComponent playerXform)
? xform.LocalPosition - playerXform.LocalPosition
: xform.WorldPosition - mapPos.Position;

if (distance.LengthSquared < comp.Range * comp.Range)
if (distance.LengthSquared() < comp.Range * comp.Range)
continue;
}

Expand All @@ -266,7 +269,7 @@ private void ProcessNearbyAmbience(TransformComponent playerXform)

var pos = mapPos.Position;
var state = new QueryState(pos, playerXform, query);
var worldAabb = new Box2(pos - _maxAmbientRange, pos + _maxAmbientRange);
var worldAabb = new Box2(pos - MaxAmbientVector, pos + MaxAmbientVector);
_treeSys.QueryAabb(ref state, Callback, mapPos.MapId, worldAabb);

// Add in range ambiences
Expand Down
3 changes: 2 additions & 1 deletion Content.Client/Audio/AmbientSoundTreeSystem.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System.Numerics;
using Content.Shared.Audio;
using Robust.Shared.ComponentTrees;
using Robust.Shared.Physics;
Expand All @@ -13,7 +14,7 @@ public sealed class AmbientSoundTreeSystem : ComponentTreeSystem<AmbientSoundTre
protected override bool Recursive => true;

protected override Box2 ExtractAabb(in ComponentTreeEntry<AmbientSoundComponent> entry, Vector2 pos, Angle rot)
=> new Box2(pos - entry.Component.Range, pos + entry.Component.Range);
=> new Box2(pos - entry.Component.RangeVector, pos + entry.Component.RangeVector);

protected override Box2 ExtractAabb(in ComponentTreeEntry<AmbientSoundComponent> entry)
{
Expand Down
1 change: 1 addition & 0 deletions Content.Client/Botany/PotencyVisualsSystem.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System.Numerics;
using Content.Shared.Botany;
using Content.Client.Botany.Components;
using Robust.Client.GameObjects;
Expand Down
5 changes: 3 additions & 2 deletions Content.Client/Bql/BqlResultsWindow.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Robust.Client.AutoGenerated;
using System.Numerics;
using Robust.Client.AutoGenerated;
using Robust.Client.Console;
using Robust.Client.UserInterface.Controls;
using Robust.Client.UserInterface.CustomControls;
Expand All @@ -20,7 +21,7 @@ public BqlResultsWindow(IClientConsoleHost console, ILocalizationManager loc)
RobustXamlLoader.Load(this);
}

protected override Vector2 ContentsMinimumSize => (500, 700);
protected override Vector2 ContentsMinimumSize => new(500, 700);

public void Update((string name, EntityUid entity)[] entities)
{
Expand Down
10 changes: 6 additions & 4 deletions Content.Client/Camera/CameraRecoilSystem.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System.Numerics;
using Content.Shared.Camera;

namespace Content.Client.Camera;
Expand All @@ -17,15 +18,16 @@ private void OnCameraKick(CameraKickEvent ev)

public override void KickCamera(EntityUid uid, Vector2 recoil, CameraRecoilComponent? component = null)
{
if (!Resolve(uid, ref component, false)) return;
if (!Resolve(uid, ref component, false))
return;

// Use really bad math to "dampen" kicks when we're already kicked.
var existing = component.CurrentKick.Length;
var existing = component.CurrentKick.Length();
var dampen = existing / KickMagnitudeMax;
component.CurrentKick += recoil * (1 - dampen);

if (component.CurrentKick.Length > KickMagnitudeMax)
component.CurrentKick = component.CurrentKick.Normalized * KickMagnitudeMax;
if (component.CurrentKick.Length() > KickMagnitudeMax)
component.CurrentKick = component.CurrentKick.Normalized() * KickMagnitudeMax;

component.LastKickTime = 0;
}
Expand Down
3 changes: 2 additions & 1 deletion Content.Client/CardboardBox/CardboardBoxSystem.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Content.Shared.CardboardBox;
using System.Numerics;
using Content.Shared.CardboardBox;
using Content.Shared.CardboardBox.Components;
using Content.Shared.Examine;
using Content.Shared.Movement.Components;
Expand Down
7 changes: 4 additions & 3 deletions Content.Client/Changelog/ChangelogWindow.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Linq;
using System.Numerics;
using Content.Client.Resources;
using Content.Client.Stylesheets;
using Content.Client.UserInterface.Systems.EscapeMenu;
Expand Down Expand Up @@ -108,7 +109,7 @@ private async void PopulateChangelog()
{
Texture = upArrow,
ModulateSelfOverride = Color.FromHex("#888"),
TextureScale = (0.5f, 0.5f),
TextureScale = new Vector2(0.5f, 0.5f),
Margin = new Thickness(4, 3),
VerticalAlignment = VAlignment.Bottom
},
Expand All @@ -122,7 +123,7 @@ private async void PopulateChangelog()
{
Texture = upArrow,
ModulateSelfOverride = Color.FromHex("#888"),
TextureScale = (0.5f, 0.5f),
TextureScale = new Vector2(0.5f, 0.5f),
Margin = new Thickness(4, 3),
VerticalAlignment = VAlignment.Bottom
}
Expand Down Expand Up @@ -184,7 +185,7 @@ private TextureRect GetIcon(ChangelogLineType type)
{
Texture = _resourceCache.GetTexture(new ResPath($"/Textures/Interface/Changelog/{file}")),
VerticalAlignment = VAlignment.Top,
TextureScale = (0.5f, 0.5f),
TextureScale = new Vector2(0.5f, 0.5f),
Margin = new Thickness(2, 4, 6, 2),
ModulateSelfOverride = Color.FromHex(color)
};
Expand Down
Loading

0 comments on commit 68480af

Please sign in to comment.