Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

More General Fixes #1547

Merged
merged 20 commits into from
Jan 14, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 46 additions & 0 deletions Content.Client/Movement/Systems/ClientSpriteMovementSystem.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
using Content.Shared.Movement.Components;
using Content.Shared.Movement.Systems;
using Robust.Client.GameObjects;
using Robust.Shared.Timing;

namespace Content.Client.Movement.Systems;

/// <summary>
/// Controls the switching of motion and standing still animation
/// </summary>
public sealed class ClientSpriteMovementSystem : SharedSpriteMovementSystem
{
[Dependency] private readonly IGameTiming _timing = default!;

private EntityQuery<SpriteComponent> _spriteQuery;

public override void Initialize()
{
base.Initialize();

_spriteQuery = GetEntityQuery<SpriteComponent>();

SubscribeLocalEvent<SpriteMovementComponent, AfterAutoHandleStateEvent>(OnAfterAutoHandleState);
}

private void OnAfterAutoHandleState(Entity<SpriteMovementComponent> ent, ref AfterAutoHandleStateEvent args)
{
if (!_spriteQuery.TryGetComponent(ent, out var sprite))
return;

if (ent.Comp.IsMoving)
{
foreach (var (layer, state) in ent.Comp.MovementLayers)
{
sprite.LayerSetData(layer, state);
}
}
else
{
foreach (var (layer, state) in ent.Comp.NoMovementLayers)
{
sprite.LayerSetData(layer, state);
}
}
}
}
51 changes: 0 additions & 51 deletions Content.Client/Movement/Systems/SpriteMovementSystem.cs

This file was deleted.

42 changes: 21 additions & 21 deletions Content.Client/Physics/Controllers/MoverController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,57 +34,57 @@ public override void Initialize()
Subs.CVar(_config, CCVars.DefaultWalk, _ => RaiseNetworkEvent(new UpdateInputCVarsMessage()));
}

private void OnUpdatePredicted(EntityUid uid, InputMoverComponent component, ref UpdateIsPredictedEvent args)
private void OnUpdatePredicted(Entity<InputMoverComponent> entity, ref UpdateIsPredictedEvent args)
{
// Enable prediction if an entity is controlled by the player
if (uid == _playerManager.LocalEntity)
if (entity.Owner == _playerManager.LocalEntity)
args.IsPredicted = true;
}

private void OnUpdateRelayTargetPredicted(EntityUid uid, MovementRelayTargetComponent component, ref UpdateIsPredictedEvent args)
private void OnUpdateRelayTargetPredicted(Entity<MovementRelayTargetComponent> entity, ref UpdateIsPredictedEvent args)
{
if (component.Source == _playerManager.LocalEntity)
if (entity.Comp.Source == _playerManager.LocalEntity)
args.IsPredicted = true;
}

private void OnUpdatePullablePredicted(EntityUid uid, PullableComponent component, ref UpdateIsPredictedEvent args)
private void OnUpdatePullablePredicted(Entity<PullableComponent> entity, ref UpdateIsPredictedEvent args)
{
// Enable prediction if an entity is being pulled by the player.
// Disable prediction if an entity is being pulled by some non-player entity.

if (component.Puller == _playerManager.LocalEntity)
if (entity.Comp.Puller == _playerManager.LocalEntity)
args.IsPredicted = true;
else if (component.Puller != null)
else if (entity.Comp.Puller != null)
args.BlockPrediction = true;

// TODO recursive pulling checks?
// What if the entity is being pulled by a vehicle controlled by the player?
}

private void OnRelayPlayerAttached(EntityUid uid, RelayInputMoverComponent component, LocalPlayerAttachedEvent args)
private void OnRelayPlayerAttached(Entity<RelayInputMoverComponent> entity, ref LocalPlayerAttachedEvent args)
{
Physics.UpdateIsPredicted(uid);
Physics.UpdateIsPredicted(component.RelayEntity);
if (MoverQuery.TryGetComponent(component.RelayEntity, out var inputMover))
SetMoveInput(inputMover, MoveButtons.None);
Physics.UpdateIsPredicted(entity.Owner);
Physics.UpdateIsPredicted(entity.Comp.RelayEntity);
if (MoverQuery.TryGetComponent(entity.Comp.RelayEntity, out var inputMover))
SetMoveInput((entity.Owner, inputMover), MoveButtons.None);
}

private void OnRelayPlayerDetached(EntityUid uid, RelayInputMoverComponent component, LocalPlayerDetachedEvent args)
private void OnRelayPlayerDetached(Entity<RelayInputMoverComponent> entity, ref LocalPlayerDetachedEvent args)
{
Physics.UpdateIsPredicted(uid);
Physics.UpdateIsPredicted(component.RelayEntity);
if (MoverQuery.TryGetComponent(component.RelayEntity, out var inputMover))
SetMoveInput(inputMover, MoveButtons.None);
Physics.UpdateIsPredicted(entity.Owner);
Physics.UpdateIsPredicted(entity.Comp.RelayEntity);
if (MoverQuery.TryGetComponent(entity.Comp.RelayEntity, out var inputMover))
SetMoveInput((entity.Owner, inputMover), MoveButtons.None);
}

private void OnPlayerAttached(EntityUid uid, InputMoverComponent component, LocalPlayerAttachedEvent args)
private void OnPlayerAttached(Entity<InputMoverComponent> entity, ref LocalPlayerAttachedEvent args)
{
SetMoveInput(component, MoveButtons.None);
SetMoveInput(entity, MoveButtons.None);
}

private void OnPlayerDetached(EntityUid uid, InputMoverComponent component, LocalPlayerDetachedEvent args)
private void OnPlayerDetached(Entity<InputMoverComponent> entity, ref LocalPlayerDetachedEvent args)
{
SetMoveInput(component, MoveButtons.None);
SetMoveInput(entity, MoveButtons.None);
}

public override void UpdateBeforeSolve(bool prediction, float frameTime)
Expand Down
8 changes: 5 additions & 3 deletions Content.Client/Wires/UI/WiresMenu.cs
Original file line number Diff line number Diff line change
Expand Up @@ -206,8 +206,7 @@ public WiresMenu()
(_statusContainer = new GridContainer
{
Margin = new Thickness(8, 4),
// TODO: automatically change columns count.
Columns = 3
Rows = 2
})
}
}
Expand All @@ -227,7 +226,8 @@ public WiresMenu()
PanelOverride = new StyleBoxFlat {BackgroundColor = Color.FromHex("#525252ff")}
});
CloseButton.OnPressed += _ => Close();
SetSize = new Vector2(320, 200);
SetHeight = 200;
MinWidth = 320;
}


Expand Down Expand Up @@ -503,6 +503,8 @@ private sealed class StatusLight : Control

public StatusLight(StatusLightData data, IResourceCache resourceCache)
{
HorizontalAlignment = HAlignment.Right;

var hsv = Color.ToHsv(data.Color);
hsv.Z /= 2;
var dimColor = Color.FromHsv(hsv);
Expand Down
2 changes: 1 addition & 1 deletion Content.Server/Body/Systems/BodySystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public override void Initialize()
private void OnRelayMoveInput(Entity<BodyComponent> ent, ref MoveInputEvent args)
{
// If they haven't actually moved then ignore it.
if ((args.Component.HeldMoveButtons &
if ((args.Entity.Comp.HeldMoveButtons &
(MoveButtons.Down | MoveButtons.Left | MoveButtons.Up | MoveButtons.Right)) == 0x0)
{
return;
Expand Down
5 changes: 2 additions & 3 deletions Content.Server/Cargo/Systems/CargoSystem.Orders.cs
Original file line number Diff line number Diff line change
Expand Up @@ -191,9 +191,7 @@ private void OnApproveOrderMessage(EntityUid uid, CargoOrderConsoleComponent com
}
}

_idCardSystem.TryFindIdCard(player, out var idCard);
// ReSharper disable once ConditionalAccessQualifierIsNonNullableAccordingToAPIContract
order.SetApproverData(idCard.Comp?.FullName, idCard.Comp?.JobTitle);
order.Approved = true;
_audio.PlayPvs(component.ConfirmSound, uid);

if (!HasComp<EmaggedComponent>(uid))
Expand Down Expand Up @@ -430,6 +428,7 @@ Entity<StationDataComponent> stationData

// Approve it now
order.SetApproverData(dest, sender);
order.Approved = true;

// Log order addition
_adminLogger.Add(LogType.Action, LogImpact.Low,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,13 @@ public enum DeviceNetIdDefaults
[DataField("sendBroadcastAttemptEvent")]
public bool SendBroadcastAttemptEvent = false;

/// <summary>
/// Whether this device's address can be saved to device-lists
/// </summary>
[ViewVariables(VVAccess.ReadWrite)]
[DataField("savableAddress")]
public bool SavableAddress = true;

/// <summary>
/// A list of device-lists that this device is on.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,13 @@ private void TryAddNetworkDevice(EntityUid configuratorUid, EntityUid? targetUid
if (!targetUid.HasValue || !Resolve(targetUid.Value, ref device, false))
return;

//This checks if the device is marked as having a savable address,
//to avoid adding pdas and whatnot to air alarms. This flag is true
//by default, so this will only prevent devices from being added to
//network configurator lists if manually set to false in the prototype
if (!device.SavableAddress)
return;

var address = device.Address;
if (string.IsNullOrEmpty(address))
{
Expand Down
2 changes: 1 addition & 1 deletion Content.Server/Ghost/GhostSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ private void OnActionPerform(EntityUid uid, GhostComponent component, BooActionE
private void OnRelayMoveInput(EntityUid uid, GhostOnMoveComponent component, ref MoveInputEvent args)
{
// If they haven't actually moved then ignore it.
if ((args.Component.HeldMoveButtons &
if ((args.Entity.Comp.HeldMoveButtons &
(MoveButtons.Down | MoveButtons.Left | MoveButtons.Up | MoveButtons.Right)) == 0x0)
{
return;
Expand Down
7 changes: 7 additions & 0 deletions Content.Server/Movement/Systems/SpriteMovementSystem.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
using Content.Shared.Movement.Systems;

namespace Content.Server.Movement.Systems;

public sealed class SpriteMovementSystem : SharedSpriteMovementSystem
{
}
26 changes: 26 additions & 0 deletions Content.Server/NPC/HTN/Preconditions/HandcuffedPrecondition.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
using Content.Server.Cuffs;
using Content.Shared.Cuffs.Components;

namespace Content.Server.NPC.HTN.Preconditions;

public sealed partial class HandcuffedPrecondition : HTNPrecondition
{
[Dependency] private readonly IEntityManager _entManager = default!;

[DataField]
public bool ReactOnlyWhenFullyCuffed = true;

public override bool IsMet(NPCBlackboard blackboard)
{
var cuffable = _entManager.System<CuffableSystem>();
var owner = blackboard.GetValue<EntityUid>(NPCBlackboard.Owner);

if (!_entManager.TryGetComponent<CuffableComponent>(owner, out var cuffComp))
return false;

var target = (owner, cuffComp);

return cuffable.IsCuffed(target, ReactOnlyWhenFullyCuffed);
}

}
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Content.Shared.Movement.Pulling.Components;
using Content.Shared.ActionBlocker;
using Content.Shared.Movement.Pulling.Components;
using Content.Shared.Movement.Pulling.Systems;

namespace Content.Server.NPC.HTN.PrimitiveTasks.Operators.Combat;
Expand All @@ -7,6 +8,7 @@ public sealed partial class UnPullOperator : HTNOperator
{
[Dependency] private readonly IEntityManager _entManager = default!;
private PullingSystem _pulling = default!;
private ActionBlockerSystem _actionBlocker = default!;

private EntityQuery<PullableComponent> _pullableQuery;

Expand All @@ -16,6 +18,7 @@ public sealed partial class UnPullOperator : HTNOperator
public override void Initialize(IEntitySystemManager sysManager)
{
base.Initialize(sysManager);
_actionBlocker = sysManager.GetEntitySystem<ActionBlockerSystem>();
_pulling = sysManager.GetEntitySystem<PullingSystem>();
_pullableQuery = _entManager.GetEntityQuery<PullableComponent>();
}
Expand All @@ -25,7 +28,8 @@ public override void Startup(NPCBlackboard blackboard)
base.Startup(blackboard);
var owner = blackboard.GetValue<EntityUid>(NPCBlackboard.Owner);

_pulling.TryStopPull(owner, _pullableQuery.GetComponent(owner), owner);
if (_actionBlocker.CanInteract(owner, owner)) //prevents handcuffed monkeys from pulling etc.
_pulling.TryStopPull(owner, _pullableQuery.GetComponent(owner), owner);
}

public override HTNOperatorStatus Update(NPCBlackboard blackboard, float frameTime)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Content.Server.Buckle.Systems;
using Content.Server.Buckle.Systems;

namespace Content.Server.NPC.HTN.PrimitiveTasks.Operators.Combat;

Expand All @@ -19,7 +19,7 @@ public override void Startup(NPCBlackboard blackboard)
{
base.Startup(blackboard);
var owner = blackboard.GetValue<EntityUid>(NPCBlackboard.Owner);
_buckle.Unbuckle(owner, null);
_buckle.TryUnbuckle(owner, owner, false);
}

public override HTNOperatorStatus Update(NPCBlackboard blackboard, float frameTime)
Expand Down
12 changes: 10 additions & 2 deletions Content.Server/NPC/Systems/NPCSteeringSystem.Context.cs
Original file line number Diff line number Diff line change
Expand Up @@ -243,12 +243,20 @@ private bool TrySeek(
// Alright just adjust slightly and grab the next node so we don't stop moving for a tick.
// TODO: If it's the last node just grab the target instead.
targetCoordinates = GetTargetCoordinates(steering);
targetMap = targetCoordinates.ToMap(EntityManager, _transform);

if (!targetCoordinates.IsValid(EntityManager))
{
SetDirection(uid, mover, steering, Vector2.Zero);
steering.Status = SteeringStatus.NoPath;
return false;
}

targetMap = _transform.ToMapCoordinates(targetCoordinates);

// Can't make it again.
if (ourMap.MapId != targetMap.MapId)
{
SetDirection(mover, steering, Vector2.Zero);
SetDirection(uid, mover, steering, Vector2.Zero);
steering.Status = SteeringStatus.NoPath;
return false;
}
Expand Down
Loading
Loading