Skip to content

Commit

Permalink
Merge branch 'Rxup:master' into BackmenBoxMap
Browse files Browse the repository at this point in the history
  • Loading branch information
Agronomist-NN authored Feb 21, 2025
2 parents 4b8260d + 53b1c09 commit 45e3df0
Show file tree
Hide file tree
Showing 83 changed files with 1,287 additions and 412 deletions.
8 changes: 5 additions & 3 deletions Content.Client/Gameplay/GameplayStateBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -219,10 +219,12 @@ protected virtual void OnKeyBindStateChanged(ViewportBoundKeyEventArgs args)
{
entityToClick = GetClickedEntity(mousePosWorld);
}
var transformSystem = _entitySystemManager.GetEntitySystem<SharedTransformSystem>();
var mapSystem = _entitySystemManager.GetEntitySystem<MapSystem>();

coordinates = _mapManager.TryFindGridAt(mousePosWorld, out _, out var grid) ?
grid.MapToGrid(mousePosWorld) :
EntityCoordinates.FromMap(_mapManager, mousePosWorld);
coordinates = _mapManager.TryFindGridAt(mousePosWorld, out var uid, out _) ?
mapSystem.MapToGrid(uid, mousePosWorld) :
transformSystem.ToCoordinates(mousePosWorld);
}
else
{
Expand Down
3 changes: 2 additions & 1 deletion Content.Client/Lobby/UI/CharacterPickerButton.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
<SpriteView Scale="2 2"
Margin="0 4 4 4"
OverrideDirection="South"
Name="View"/>
Name="View"
SetSize="64 64"/>
<Label Name="DescriptionLabel"
ClipText="True"
HorizontalExpand="True"/>
Expand Down
8 changes: 0 additions & 8 deletions Content.Client/Storage/StorageBoundUserInterface.cs
Original file line number Diff line number Diff line change
Expand Up @@ -92,12 +92,4 @@ public void Show(Vector2 position)
Show();
LayoutContainer.SetPosition(_window, position);
}

public void ReOpen()
{
_window?.Orphan();
_window = null;
Open();
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -61,39 +61,11 @@ public override void Initialize()
{
base.Initialize();

UIManager.OnScreenChanged += OnScreenChange;

_configuration.OnValueChanged(CCVars.StaticStorageUI, OnStaticStorageChanged, true);
_configuration.OnValueChanged(CCVars.OpaqueStorageWindow, OnOpaqueWindowChanged, true);
_configuration.OnValueChanged(CCVars.StorageWindowTitle, OnStorageWindowTitle, true);
}

private void OnScreenChange((UIScreen? Old, UIScreen? New) obj)
{
// Handle reconnects with hotbargui.

// Essentially HotbarGui / the screen gets loaded AFTER gamestates at the moment (because clientgameticker manually changes it via event)
// and changing this may be a massive change.
// So instead we'll just manually reload it for now.
if (!StaticStorageUIEnabled ||
obj.New == null ||
!EntityManager.TryGetComponent(_player.LocalEntity, out UserInterfaceUserComponent? userComp))
{
return;
}

// UISystemDependency not injected at this point so do it the old fashion way, I love ordering issues.
var uiSystem = EntityManager.System<SharedUserInterfaceSystem>();

foreach (var bui in uiSystem.GetActorUis((_player.LocalEntity.Value, userComp)))
{
if (!uiSystem.TryGetOpenUi<StorageBoundUserInterface>(bui.Entity, StorageComponent.StorageUiKey.Key, out var storageBui))
continue;

storageBui.ReOpen();
}
}

private void OnStorageWindowTitle(bool obj)
{
WindowTitle = obj;
Expand Down
96 changes: 56 additions & 40 deletions Content.Client/Weapons/Melee/MeleeWeaponSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using Content.Shared.Mobs.Components;
using Content.Shared.StatusEffect;
using Content.Shared.Weapons.Melee;
using Content.Shared.Weapons.Melee.Components;
using Content.Shared.Weapons.Melee.Events;
using Content.Shared.Weapons.Ranged.Components;
using Robust.Client.GameObjects;
Expand Down Expand Up @@ -89,16 +90,6 @@ public override void Update(float frameTime)

// TODO using targeted actions while combat mode is enabled should NOT trigger attacks.

// TODO: Need to make alt-fire melee its own component I guess?
// Melee and guns share a lot in the middle but share virtually nothing at the start and end so
// it's kinda tricky.
// I think as long as we make secondaries their own component it's probably fine
// as long as guncomp has an alt-use key then it shouldn't be too much of a PITA to deal with.
if (TryComp<GunComponent>(weaponUid, out var gun) && gun.UseKey)
{
return;
}

var mousePos = _eyeManager.PixelToMap(_inputManager.MouseScreenPosition);

if (mousePos.MapId == MapId.Nullspace)
Expand All @@ -116,21 +107,38 @@ public override void Update(float frameTime)
{
coordinates = TransformSystem.ToCoordinates(_map.GetMap(mousePos.MapId), mousePos);
}

// If the gun has AltFireComponent, it can be used to attack.
if (TryComp<GunComponent>(weaponUid, out var gun) && gun.UseKey)
{
if (!TryComp<AltFireMeleeComponent>(weaponUid, out var altFireComponent) || altDown != BoundKeyState.Down)
return;

switch(altFireComponent.AttackType)
{
case AltFireAttackType.Light:
ClientLightAttack(entity, mousePos, coordinates, weaponUid, weapon);
break;

case AltFireAttackType.Heavy:
ClientHeavyAttack(entity, coordinates, weaponUid, weapon);
break;

case AltFireAttackType.Disarm:
ClientDisarm(entity, mousePos, coordinates);
break;
}

return;
}

// Heavy attack.
if (altDown == BoundKeyState.Down)
{
// If it's an unarmed attack then do a disarm
if (weapon.AltDisarm && weaponUid == entity)
{
EntityUid? target = null;

if (_stateManager.CurrentState is GameplayStateBase screen)
{
target = screen.GetClickedEntity(mousePos);
}

EntityManager.RaisePredictiveEvent(new DisarmAttackEvent(GetNetEntity(target), GetNetCoordinates(coordinates)));
ClientDisarm(entity, mousePos, coordinates);
return;
}

Expand All @@ -140,28 +148,7 @@ public override void Update(float frameTime)

// Light attack
if (useDown == BoundKeyState.Down)
{
var attackerPos = TransformSystem.GetMapCoordinates(entity);

if (mousePos.MapId != attackerPos.MapId ||
(attackerPos.Position - mousePos.Position).Length() > weapon.Range)
{
return;
}

EntityUid? target = null;

if (_stateManager.CurrentState is GameplayStateBase screen)
{
target = screen.GetClickedEntity(mousePos);
}

// Don't light-attack if interaction will be handling this instead
if (Interaction.CombatModeCanHandInteract(entity, target))
return;

RaisePredictiveEvent(new LightAttackEvent(GetNetEntity(target), GetNetEntity(weaponUid), GetNetCoordinates(coordinates)));
}
ClientLightAttack(entity, mousePos, coordinates, weaponUid, weapon);
}

protected override bool InRange(EntityUid user, EntityUid target, float range, ICommonSession? session)
Expand Down Expand Up @@ -235,6 +222,35 @@ private void ClientHeavyAttack(EntityUid user, EntityCoordinates coordinates, En
var entities = GetNetEntityList(ArcRayCast(userPos, direction.ToWorldAngle(), component.Angle, distance, userXform.MapID, user).ToList());
RaisePredictiveEvent(new HeavyAttackEvent(GetNetEntity(meleeUid), entities.GetRange(0, Math.Min(MaxTargets, entities.Count)), GetNetCoordinates(coordinates)));
}

private void ClientDisarm(EntityUid attacker, MapCoordinates mousePos, EntityCoordinates coordinates)
{
EntityUid? target = null;

if (_stateManager.CurrentState is GameplayStateBase screen)
target = screen.GetClickedEntity(mousePos);

RaisePredictiveEvent(new DisarmAttackEvent(GetNetEntity(target), GetNetCoordinates(coordinates)));
}

private void ClientLightAttack(EntityUid attacker, MapCoordinates mousePos, EntityCoordinates coordinates, EntityUid weaponUid, MeleeWeaponComponent meleeComponent)
{
var attackerPos = TransformSystem.GetMapCoordinates(attacker);

if (mousePos.MapId != attackerPos.MapId || (attackerPos.Position - mousePos.Position).Length() > meleeComponent.Range)
return;

EntityUid? target = null;

if (_stateManager.CurrentState is GameplayStateBase screen)
target = screen.GetClickedEntity(mousePos);

// Don't light-attack if interaction will be handling this instead
if (Interaction.CombatModeCanHandInteract(attacker, target))
return;

RaisePredictiveEvent(new LightAttackEvent(GetNetEntity(target), GetNetEntity(weaponUid), GetNetCoordinates(coordinates)));
}

private void OnMeleeLunge(MeleeLungeEvent ev)
{
Expand Down
5 changes: 3 additions & 2 deletions Content.Client/Weapons/Misc/TetherGunSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ public sealed class TetherGunSystem : SharedTetherGunSystem
[Dependency] private readonly IMapManager _mapManager = default!;
[Dependency] private readonly IOverlayManager _overlay = default!;
[Dependency] private readonly IPlayerManager _player = default!;
[Dependency] private readonly MapSystem _mapSystem = default!;

public override void Initialize()
{
Expand Down Expand Up @@ -73,11 +74,11 @@ public override void Update(float frameTime)

if (_mapManager.TryFindGridAt(mouseWorldPos, out var gridUid, out _))
{
coords = EntityCoordinates.FromMap(gridUid, mouseWorldPos, TransformSystem);
coords = TransformSystem.ToCoordinates(gridUid, mouseWorldPos);
}
else
{
coords = EntityCoordinates.FromMap(_mapManager.GetMapEntityId(mouseWorldPos.MapId), mouseWorldPos, TransformSystem);
coords = TransformSystem.ToCoordinates(_mapSystem.GetMap(mouseWorldPos.MapId), mouseWorldPos);
}

const float BufferDistance = 0.1f;
Expand Down
2 changes: 2 additions & 0 deletions Content.Server.Database/Model.cs
Original file line number Diff line number Diff line change
Expand Up @@ -988,6 +988,8 @@ public enum ConnectionDenyReason : byte
BabyJail = 4,
/// Results from rejected connections with external API checking tools
IPChecks = 5,
/// Results from rejected connections who are authenticated but have no modern hwid associated with them.
NoHwid = 6
}

public class ServerBanHit
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ private void AddSmiteVerbs(GetVerbsEvent<Verb> args)
Filter.PvsExcept(args.Target), true, PopupType.MediumCaution);
var board = Spawn("ChessBoard", xform.Coordinates);
var session = _tabletopSystem.EnsureSession(Comp<TabletopGameComponent>(board));
xform.Coordinates = EntityCoordinates.FromMap(_mapManager, session.Position);
xform.Coordinates = _transformSystem.ToCoordinates(session.Position);
_transformSystem.SetWorldRotationNoLerp((args.Target, xform), Angle.Zero);
},
Impact = LogImpact.Extreme,
Expand Down
2 changes: 1 addition & 1 deletion Content.Server/Backmen/EnergyDome/EnergyDomeSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ private void OnComponentRemove(Entity<EnergyDomeGeneratorComponent> generator, r
// Functional
public bool AttemptToggle(Entity<EnergyDomeGeneratorComponent> generator, bool status)
{
if (TryComp<UseDelayComponent>(generator, out var useDelay) && _useDelay.IsDelayed(new Entity<UseDelayComponent>(generator, useDelay)))
if (TryComp<UseDelayComponent>(generator, out var useDelay) && _useDelay.IsDelayed((generator, useDelay)))
{
_audio.PlayPvs(generator.Comp.TurnOffSound, generator);
_popup.PopupEntity(
Expand Down
5 changes: 5 additions & 0 deletions Content.Server/Connection/ConnectionManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,11 @@ session.Status is SessionStatus.Connected or SessionStatus.InGame

var modernHwid = e.UserData.ModernHWIds;

if (modernHwid.Length == 0 && e.AuthType == LoginType.LoggedIn && _cfg.GetCVar(CCVars.RequireModernHardwareId))
{
return (ConnectionDenyReason.NoHwid, Loc.GetString("hwid-required"), null);
}

var bans = await _db.GetServerBansAsync(addr, userId, hwId, modernHwid, includeUnbanned: false);
if (bans.Count > 0)
{
Expand Down
4 changes: 3 additions & 1 deletion Content.Server/Explosion/EntitySystems/ExplosionSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
using Content.Shared.Inventory;
using Content.Shared.Projectiles;
using Content.Shared.Throwing;
using Robust.Server.GameObjects;
using Robust.Server.GameStates;
using Robust.Server.Player;
using Robust.Shared.Audio.Systems;
Expand All @@ -38,6 +39,7 @@ public sealed partial class ExplosionSystem : SharedExplosionSystem
[Dependency] private readonly IConfigurationManager _cfg = default!;
[Dependency] private readonly IPlayerManager _playerManager = default!;

[Dependency] private readonly MapSystem _mapSystem = default!;
[Dependency] private readonly SharedAppearanceSystem _appearance = default!;
[Dependency] private readonly DamageableSystem _damageableSystem = default!;
[Dependency] private readonly NodeGroupSystem _nodeGroupSystem = default!;
Expand Down Expand Up @@ -356,7 +358,7 @@ public void QueueExplosion(MapCoordinates epicenter,
CameraShake(iterationIntensity.Count * 4f, pos, queued.TotalIntensity);

//For whatever bloody reason, sound system requires ENTITY coordinates.
var mapEntityCoords = EntityCoordinates.FromMap(_mapManager.GetMapEntityId(pos.MapId), pos, _transformSystem, EntityManager);
var mapEntityCoords = _transformSystem.ToCoordinates(_mapSystem.GetMap(pos.MapId), pos);

// play sound.
// for the normal audio, we want everyone in pvs range
Expand Down
6 changes: 3 additions & 3 deletions Content.Shared/Anomaly/SharedAnomalyCoreSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ private void OnAttemptMeleeThrowOnHit(Entity<CorePoweredThrowerComponent> ent, r
var (uid, comp) = ent;

// don't waste charges on non-anchorable non-anomalous static bodies.
if (!HasComp<AnomalyComponent>(args.Hit)
&& !HasComp<AnchorableComponent>(args.Hit)
&& TryComp<PhysicsComponent>(args.Hit, out var body)
if (!HasComp<AnomalyComponent>(args.Target)
&& !HasComp<AnchorableComponent>(args.Target)
&& TryComp<PhysicsComponent>(args.Target, out var body)
&& body.BodyType == BodyType.Static)
return;

Expand Down
10 changes: 7 additions & 3 deletions Content.Shared/Anomaly/SharedAnomalySystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using Content.Shared.Database;
using Content.Shared.Physics;
using Content.Shared.Popups;
using Content.Shared.Throwing;
using Content.Shared.Weapons.Melee.Components;
using Robust.Shared.Audio.Systems;
using Robust.Shared.Map;
Expand Down Expand Up @@ -41,19 +42,22 @@ public override void Initialize()
base.Initialize();

SubscribeLocalEvent<AnomalyComponent, MeleeThrowOnHitStartEvent>(OnAnomalyThrowStart);
SubscribeLocalEvent<AnomalyComponent, MeleeThrowOnHitEndEvent>(OnAnomalyThrowEnd);
SubscribeLocalEvent<AnomalyComponent, LandEvent>(OnLand);
}

private void OnAnomalyThrowStart(Entity<AnomalyComponent> ent, ref MeleeThrowOnHitStartEvent args)
{
if (!TryComp<CorePoweredThrowerComponent>(args.Used, out var corePowered) || !TryComp<PhysicsComponent>(ent, out var body))
if (!TryComp<CorePoweredThrowerComponent>(args.Weapon, out var corePowered) || !TryComp<PhysicsComponent>(ent, out var body))
return;

// anomalies are static by default, so we have set them to dynamic to be throwable
_physics.SetBodyType(ent, BodyType.Dynamic, body: body);
ChangeAnomalyStability(ent, Random.NextFloat(corePowered.StabilityPerThrow.X, corePowered.StabilityPerThrow.Y), ent.Comp);
}

private void OnAnomalyThrowEnd(Entity<AnomalyComponent> ent, ref MeleeThrowOnHitEndEvent args)
private void OnLand(Entity<AnomalyComponent> ent, ref LandEvent args)
{
// revert back to static
_physics.SetBodyType(ent, BodyType.Static);
}

Expand Down
6 changes: 6 additions & 0 deletions Content.Shared/CCVar/CCVars.Admin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,12 @@ public sealed partial class CCVars
public static readonly CVarDef<bool> BanHardwareIds =
CVarDef.Create("ban.hardware_ids", true, CVar.SERVERONLY);

/// <summary>
/// Determines if we'll reject connections from clients who don't have a modern hwid.
/// </summary>
public static readonly CVarDef<bool> RequireModernHardwareId =
CVarDef.Create("admin.require_modern_hwid", true, CVar.SERVERONLY);

/// <summary>
/// If true, players are allowed to connect to multiple game servers at once.
/// If false, they will be kicked from the first when connecting to another.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ public bool TryGetSolution(
[NotNullWhen(true)] out Solution? solution,
bool errorOnMissing = false)
{
if (!TryGetSolution(container, name, out entity))
if (!TryGetSolution(container, name, out entity, errorOnMissing: errorOnMissing))
{
solution = null;
return false;
Expand Down
4 changes: 2 additions & 2 deletions Content.Shared/Coordinates/Helpers/SnapgridHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ public static EntityCoordinates SnapToGrid(this EntityCoordinates coordinates, I
if (gridId == null)
{
var xformSys = entMan.System<SharedTransformSystem>();
var mapPos = coordinates.ToMap(entMan, xformSys);
var mapPos = xformSys.ToMapCoordinates(coordinates);
var mapX = (int)Math.Floor(mapPos.X) + 0.5f;
var mapY = (int)Math.Floor(mapPos.Y) + 0.5f;
mapPos = new MapCoordinates(new Vector2(mapX, mapY), mapPos.MapId);
return EntityCoordinates.FromMap(coordinates.EntityId, mapPos, xformSys);
return xformSys.ToCoordinates(coordinates.EntityId, mapPos);
}

var grid = entMan.GetComponent<MapGridComponent>(gridId.Value);
Expand Down
Loading

0 comments on commit 45e3df0

Please sign in to comment.