Skip to content

Commit

Permalink
Merge pull request #753 from Roudenn/upstream-sync
Browse files Browse the repository at this point in the history
[Feature] Upstream Sync 17.09.24
  • Loading branch information
Rxup authored Sep 17, 2024
2 parents 83817f4 + d957daf commit 0679a59
Show file tree
Hide file tree
Showing 254 changed files with 6,049 additions and 2,832 deletions.
50 changes: 50 additions & 0 deletions Content.Client/Anomaly/Effects/ClientInnerBodySystem.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
using Content.Shared.Anomaly.Components;
using Content.Shared.Anomaly.Effects;
using Content.Shared.Body.Components;
using Robust.Client.GameObjects;

namespace Content.Client.Anomaly.Effects;

public sealed class ClientInnerBodyAnomalySystem : SharedInnerBodyAnomalySystem
{
public override void Initialize()
{
SubscribeLocalEvent<InnerBodyAnomalyComponent, AfterAutoHandleStateEvent>(OnAfterHandleState);
SubscribeLocalEvent<InnerBodyAnomalyComponent, ComponentShutdown>(OnCompShutdown);
}

private void OnAfterHandleState(Entity<InnerBodyAnomalyComponent> ent, ref AfterAutoHandleStateEvent args)
{
if (!TryComp<SpriteComponent>(ent, out var sprite))
return;

if (ent.Comp.FallbackSprite is null)
return;

if (!sprite.LayerMapTryGet(ent.Comp.LayerMap, out var index))
index = sprite.LayerMapReserveBlank(ent.Comp.LayerMap);

if (TryComp<BodyComponent>(ent, out var body) &&
body.Prototype is not null &&
ent.Comp.SpeciesSprites.TryGetValue(body.Prototype.Value, out var speciesSprite))
{
sprite.LayerSetSprite(index, speciesSprite);
}
else
{
sprite.LayerSetSprite(index, ent.Comp.FallbackSprite);
}

sprite.LayerSetVisible(index, true);
sprite.LayerSetShader(index, "unshaded");
}

private void OnCompShutdown(Entity<InnerBodyAnomalyComponent> ent, ref ComponentShutdown args)
{
if (!TryComp<SpriteComponent>(ent, out var sprite))
return;

var index = sprite.LayerMapGet(ent.Comp.LayerMap);
sprite.LayerSetVisible(index, false);
}
}
20 changes: 9 additions & 11 deletions Content.Client/Examine/ExamineSystem.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
using System.Linq;
using System.Numerics;
using System.Threading;
using Content.Client.Verbs;
using Content.Shared.Examine;
using Content.Shared.IdentityManagement;
using Content.Shared.Input;
using Content.Shared.Interaction.Events;
using Content.Shared.Item;
using Content.Shared.Verbs;
using JetBrains.Annotations;
using Robust.Client.GameObjects;
Expand All @@ -12,13 +17,8 @@
using Robust.Shared.Input.Binding;
using Robust.Shared.Map;
using Robust.Shared.Utility;
using System.Linq;
using System.Numerics;
using System.Threading;
using static Content.Shared.Interaction.SharedInteractionSystem;
using static Robust.Client.UserInterface.Controls.BoxContainer;
using Content.Shared.Interaction.Events;
using Content.Shared.Item;
using Direction = Robust.Shared.Maths.Direction;

namespace Content.Client.Examine
Expand All @@ -35,7 +35,6 @@ public sealed class ExamineSystem : ExamineSystemShared

private EntityUid _examinedEntity;
private EntityUid _lastExaminedEntity;
private EntityUid _playerEntity;
private Popup? _examineTooltipOpen;
private ScreenCoordinates _popupPos;
private CancellationTokenSource? _requestCancelTokenSource;
Expand Down Expand Up @@ -74,9 +73,9 @@ private void OnExaminedItemDropped(EntityUid item, ItemComponent comp, DroppedEv
public override void Update(float frameTime)
{
if (_examineTooltipOpen is not {Visible: true}) return;
if (!_examinedEntity.Valid || !_playerEntity.Valid) return;
if (!_examinedEntity.Valid || _playerManager.LocalEntity is not { } player) return;

if (!CanExamine(_playerEntity, _examinedEntity))
if (!CanExamine(player, _examinedEntity))
CloseTooltip();
}

Expand Down Expand Up @@ -114,9 +113,8 @@ private bool HandleExamine(in PointerInputCmdHandler.PointerInputCmdArgs args)
return false;
}

_playerEntity = _playerManager.LocalEntity ?? default;

if (_playerEntity == default || !CanExamine(_playerEntity, entity))
if (_playerManager.LocalEntity is not { } player ||
!CanExamine(player, entity))
{
return false;
}
Expand Down
12 changes: 10 additions & 2 deletions Content.Client/PDA/PdaBoundUserInterface.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,20 @@
using Content.Shared.PDA;
using JetBrains.Annotations;
using Robust.Client.UserInterface;
using Robust.Shared.Configuration;

namespace Content.Client.PDA
{
[UsedImplicitly]
public sealed class PdaBoundUserInterface : CartridgeLoaderBoundUserInterface
{
private readonly PdaSystem _pdaSystem;

[ViewVariables]
private PdaMenu? _menu;

public PdaBoundUserInterface(EntityUid owner, Enum uiKey) : base(owner, uiKey)
{
_pdaSystem = EntMan.System<PdaSystem>();
}

protected override void Open()
Expand Down Expand Up @@ -92,7 +94,13 @@ protected override void UpdateState(BoundUserInterfaceState state)
if (state is not PdaUpdateState updateState)
return;

_menu?.UpdateState(updateState);
if (_menu == null)
{
_pdaSystem.Log.Error("PDA state received before menu was created.");
return;
}

_menu.UpdateState(updateState);
}

protected override void AttachCartridgeUI(Control cartridgeUIFragment, string? title)
Expand Down
3 changes: 3 additions & 0 deletions Content.Client/PDA/PdaMenu.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -67,14 +67,17 @@
Description="{Loc 'comp-pda-ui-ringtone-button-description'}"/>
<pda:PdaSettingsButton Name="ActivateMusicButton"
Access="Public"
Visible="False"
Text="{Loc 'pda-bound-user-interface-music-button'}"
Description="{Loc 'pda-bound-user-interface-music-button-description'}"/>
<pda:PdaSettingsButton Name="ShowUplinkButton"
Access="Public"
Visible="False"
Text="{Loc 'pda-bound-user-interface-show-uplink-title'}"
Description="{Loc 'pda-bound-user-interface-show-uplink-description'}"/>
<pda:PdaSettingsButton Name="LockUplinkButton"
Access="Public"
Visible="False"
Text="{Loc 'pda-bound-user-interface-lock-uplink-title'}"
Description="{Loc 'pda-bound-user-interface-lock-uplink-description'}"/>
</BoxContainer>
Expand Down
201 changes: 100 additions & 101 deletions Content.Client/Physics/Controllers/MoverController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,132 +8,131 @@
using Robust.Shared.Player;
using Robust.Shared.Timing;

namespace Content.Client.Physics.Controllers
namespace Content.Client.Physics.Controllers;

public sealed class MoverController : SharedMoverController
{
public sealed class MoverController : SharedMoverController
{
[Dependency] private readonly IGameTiming _timing = default!;
[Dependency] private readonly IPlayerManager _playerManager = default!;
[Dependency] private readonly IGameTiming _timing = default!;
[Dependency] private readonly IPlayerManager _playerManager = default!;

public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<RelayInputMoverComponent, LocalPlayerAttachedEvent>(OnRelayPlayerAttached);
SubscribeLocalEvent<RelayInputMoverComponent, LocalPlayerDetachedEvent>(OnRelayPlayerDetached);
SubscribeLocalEvent<InputMoverComponent, LocalPlayerAttachedEvent>(OnPlayerAttached);
SubscribeLocalEvent<InputMoverComponent, LocalPlayerDetachedEvent>(OnPlayerDetached);

SubscribeLocalEvent<InputMoverComponent, UpdateIsPredictedEvent>(OnUpdatePredicted);
SubscribeLocalEvent<MovementRelayTargetComponent, UpdateIsPredictedEvent>(OnUpdateRelayTargetPredicted);
SubscribeLocalEvent<PullableComponent, UpdateIsPredictedEvent>(OnUpdatePullablePredicted);
}
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<RelayInputMoverComponent, LocalPlayerAttachedEvent>(OnRelayPlayerAttached);
SubscribeLocalEvent<RelayInputMoverComponent, LocalPlayerDetachedEvent>(OnRelayPlayerDetached);
SubscribeLocalEvent<InputMoverComponent, LocalPlayerAttachedEvent>(OnPlayerAttached);
SubscribeLocalEvent<InputMoverComponent, LocalPlayerDetachedEvent>(OnPlayerDetached);

SubscribeLocalEvent<InputMoverComponent, UpdateIsPredictedEvent>(OnUpdatePredicted);
SubscribeLocalEvent<MovementRelayTargetComponent, UpdateIsPredictedEvent>(OnUpdateRelayTargetPredicted);
SubscribeLocalEvent<PullableComponent, UpdateIsPredictedEvent>(OnUpdatePullablePredicted);
}

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

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

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.
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 (entity.Comp.Puller == _playerManager.LocalEntity)
args.IsPredicted = true;
else if (entity.Comp.Puller != null)
args.BlockPrediction = true;
if (entity.Comp.Puller == _playerManager.LocalEntity)
args.IsPredicted = true;
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?
}
// TODO recursive pulling checks?
// What if the entity is being pulled by a vehicle controlled by the player?
}

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

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

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

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

public override void UpdateBeforeSolve(bool prediction, float frameTime)
{
base.UpdateBeforeSolve(prediction, frameTime);
public override void UpdateBeforeSolve(bool prediction, float frameTime)
{
base.UpdateBeforeSolve(prediction, frameTime);

if (_playerManager.LocalEntity is not {Valid: true} player)
return;
if (_playerManager.LocalEntity is not {Valid: true} player)
return;

if (RelayQuery.TryGetComponent(player, out var relayMover))
HandleClientsideMovement(relayMover.RelayEntity, frameTime);
if (RelayQuery.TryGetComponent(player, out var relayMover))
HandleClientsideMovement(relayMover.RelayEntity, frameTime);

HandleClientsideMovement(player, frameTime);
}
HandleClientsideMovement(player, frameTime);
}

private void HandleClientsideMovement(EntityUid player, float frameTime)
private void HandleClientsideMovement(EntityUid player, float frameTime)
{
if (!MoverQuery.TryGetComponent(player, out var mover) ||
!XformQuery.TryGetComponent(player, out var xform))
{
if (!MoverQuery.TryGetComponent(player, out var mover) ||
!XformQuery.TryGetComponent(player, out var xform))
{
return;
}

var physicsUid = player;
PhysicsComponent? body;
var xformMover = xform;
return;
}

if (mover.ToParent && RelayQuery.HasComponent(xform.ParentUid))
{
if (!PhysicsQuery.TryGetComponent(xform.ParentUid, out body) ||
!XformQuery.TryGetComponent(xform.ParentUid, out xformMover))
{
return;
}
var physicsUid = player;
PhysicsComponent? body;
var xformMover = xform;

physicsUid = xform.ParentUid;
}
else if (!PhysicsQuery.TryGetComponent(player, out body))
if (mover.ToParent && RelayQuery.HasComponent(xform.ParentUid))
{
if (!PhysicsQuery.TryGetComponent(xform.ParentUid, out body) ||
!XformQuery.TryGetComponent(xform.ParentUid, out xformMover))
{
return;
}

// Server-side should just be handled on its own so we'll just do this shizznit
HandleMobMovement(
player,
mover,
physicsUid,
body,
xformMover,
frameTime);
physicsUid = xform.ParentUid;
}

protected override bool CanSound()
else if (!PhysicsQuery.TryGetComponent(player, out body))
{
return _timing is { IsFirstTimePredicted: true, InSimulation: true };
return;
}

// Server-side should just be handled on its own so we'll just do this shizznit
HandleMobMovement(
player,
mover,
physicsUid,
body,
xformMover,
frameTime);
}

protected override bool CanSound()
{
return _timing is { IsFirstTimePredicted: true, InSimulation: true };
}
}
Loading

0 comments on commit 0679a59

Please sign in to comment.