A bunch of AttachedEntity bullshit

This commit is contained in:
metalgearsloth
2021-12-06 15:39:46 +11:00
parent 215cae5655
commit 525297c5fe
58 changed files with 135 additions and 133 deletions

View File

@@ -75,7 +75,7 @@ namespace Content.IntegrationTests.Tests.GameObjects.Components.Mobs
await server.WaitAssertion(() => await server.WaitAssertion(() =>
{ {
var playerEnt = serverPlayerManager.Sessions.Single().AttachedEntity; var playerEnt = serverPlayerManager.Sessions.Single().AttachedEntity;
var actionsComponent = sEntities.GetComponent<ServerActionsComponent>(playerEnt!.Value); var actionsComponent = sEntities.GetComponent<ServerActionsComponent>(playerEnt);
// player should begin with their innate actions granted // player should begin with their innate actions granted
innateActions.AddRange(actionsComponent.InnateActions); innateActions.AddRange(actionsComponent.InnateActions);
@@ -157,7 +157,7 @@ namespace Content.IntegrationTests.Tests.GameObjects.Components.Mobs
await server.WaitAssertion(() => await server.WaitAssertion(() =>
{ {
var playerEnt = serverPlayerManager.Sessions.Single().AttachedEntity; var playerEnt = serverPlayerManager.Sessions.Single().AttachedEntity;
var actionsComponent = IoCManager.Resolve<IEntityManager>().GetComponent<ServerActionsComponent>(playerEnt!.Value); var actionsComponent = IoCManager.Resolve<IEntityManager>().GetComponent<ServerActionsComponent>(playerEnt);
actionsComponent.Revoke(ActionType.DebugInstant); actionsComponent.Revoke(ActionType.DebugInstant);
}); });
@@ -250,7 +250,7 @@ namespace Content.IntegrationTests.Tests.GameObjects.Components.Mobs
await server.WaitAssertion(() => await server.WaitAssertion(() =>
{ {
serverPlayerEnt = serverPlayerManager.Sessions.Single().AttachedEntity!.Value; serverPlayerEnt = serverPlayerManager.Sessions.Single().AttachedEntity;
serverActionsComponent = serverEntManager.GetComponent<ServerActionsComponent>(serverPlayerEnt); serverActionsComponent = serverEntManager.GetComponent<ServerActionsComponent>(serverPlayerEnt);
// spawn and give them an item that has actions // spawn and give them an item that has actions

View File

@@ -30,8 +30,8 @@ namespace Content.IntegrationTests.Tests.GameObjects.Components.Mobs
await server.WaitAssertion(() => await server.WaitAssertion(() =>
{ {
var playerEnt = serverPlayerManager.Sessions.Single().AttachedEntity; var playerEnt = serverPlayerManager.Sessions.Single().AttachedEntity;
Assert.NotNull(playerEnt); Assert.That(playerEnt != default);
var alertsComponent = IoCManager.Resolve<IEntityManager>().GetComponent<ServerAlertsComponent>(playerEnt!.Value); var alertsComponent = IoCManager.Resolve<IEntityManager>().GetComponent<ServerAlertsComponent>(playerEnt);
Assert.NotNull(alertsComponent); Assert.NotNull(alertsComponent);
// show 2 alerts // show 2 alerts
@@ -70,8 +70,8 @@ namespace Content.IntegrationTests.Tests.GameObjects.Components.Mobs
await server.WaitAssertion(() => await server.WaitAssertion(() =>
{ {
var playerEnt = serverPlayerManager.Sessions.Single().AttachedEntity; var playerEnt = serverPlayerManager.Sessions.Single().AttachedEntity;
Assert.NotNull(playerEnt); Assert.That(playerEnt != default);
var alertsComponent = IoCManager.Resolve<IEntityManager>().GetComponent<ServerAlertsComponent>(playerEnt!.Value); var alertsComponent = IoCManager.Resolve<IEntityManager>().GetComponent<ServerAlertsComponent>(playerEnt);
Assert.NotNull(alertsComponent); Assert.NotNull(alertsComponent);
alertsComponent.ClearAlert(AlertType.Debug1); alertsComponent.ClearAlert(AlertType.Debug1);

View File

@@ -59,9 +59,9 @@ namespace Content.IntegrationTests.Tests.PDA
await server.WaitAssertion(() => await server.WaitAssertion(() =>
{ {
var player = sPlayerManager.Sessions.Single().AttachedEntity!.Value; var player = sPlayerManager.Sessions.Single().AttachedEntity;
Assert.NotNull(player); Assert.That(player != default);
// The player spawns with an ID on by default // The player spawns with an ID on by default
Assert.NotNull(player.GetHeldId()); Assert.NotNull(player.GetHeldId());

View File

@@ -29,10 +29,10 @@ namespace Content.Server.Actions.Commands
if (!CommandUtils.TryGetAttachedEntityByUsernameOrId(shell, target, player, out attachedEntity)) return; if (!CommandUtils.TryGetAttachedEntityByUsernameOrId(shell, target, player, out attachedEntity)) return;
} }
if (attachedEntity == null) return; if (attachedEntity == default) return;
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(attachedEntity.Value, out ServerActionsComponent? actionsComponent)) if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(attachedEntity, out ServerActionsComponent? actionsComponent))
{ {
shell.WriteLine("user has no actions component"); shell.WriteError("user has no actions component");
return; return;
} }

View File

@@ -27,8 +27,8 @@ namespace Content.Server.Actions.Commands
if (!CommandUtils.TryGetAttachedEntityByUsernameOrId(shell, target, player, out attachedEntity)) return; if (!CommandUtils.TryGetAttachedEntityByUsernameOrId(shell, target, player, out attachedEntity)) return;
} }
if (attachedEntity == null) return; if (attachedEntity == default) return;
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(attachedEntity.Value, out ServerActionsComponent? actionsComponent)) if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(attachedEntity, out ServerActionsComponent? actionsComponent))
{ {
shell.WriteLine("user has no actions component"); shell.WriteLine("user has no actions component");
return; return;

View File

@@ -27,8 +27,8 @@ namespace Content.Server.Actions.Commands
var target = args[1]; var target = args[1];
if (!CommandUtils.TryGetAttachedEntityByUsernameOrId(shell, target, player, out attachedEntity)) return; if (!CommandUtils.TryGetAttachedEntityByUsernameOrId(shell, target, player, out attachedEntity)) return;
} }
if (attachedEntity == null) return; if (attachedEntity == default) return;
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(attachedEntity.Value, out ServerActionsComponent? actionsComponent)) if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(attachedEntity, out ServerActionsComponent? actionsComponent))
{ {
shell.WriteLine("user has no actions component"); shell.WriteLine("user has no actions component");
return; return;

View File

@@ -126,11 +126,11 @@ namespace Content.Server.Administration
var username = string.Empty; var username = string.Empty;
if (session.AttachedEntity != default) if (session.AttachedEntity != default)
username = EntityManager.GetComponent<MetaDataComponent>(session.AttachedEntity.Value).EntityName; username = EntityManager.GetComponent<MetaDataComponent>(session.AttachedEntity).EntityName;
var antag = session.ContentData()?.Mind?.AllRoles.Any(r => r.Antagonist) ?? false; var antag = session.ContentData()?.Mind?.AllRoles.Any(r => r.Antagonist) ?? false;
return new PlayerInfo(name, username, antag, session.AttachedEntity ?? default, session.UserId); return new PlayerInfo(name, username, antag, session.AttachedEntity, session.UserId);
} }
} }
} }

View File

@@ -43,8 +43,8 @@ namespace Content.Server.Administration.Commands
} }
var canReturn = mind.CurrentEntity != default; var canReturn = mind.CurrentEntity != default;
var coordinates = player.AttachedEntity.HasValue var coordinates = player.AttachedEntity != default
? _entities.GetComponent<TransformComponent>(player.AttachedEntity.Value).Coordinates ? _entities.GetComponent<TransformComponent>(player.AttachedEntity).Coordinates
: EntitySystem.Get<GameTicker>().GetObserverSpawnPoint(); : EntitySystem.Get<GameTicker>().GetObserverSpawnPoint();
var ghost = _entities.SpawnEntity("AdminObserver", coordinates); var ghost = _entities.SpawnEntity("AdminObserver", coordinates);

View File

@@ -35,7 +35,7 @@ namespace Content.Server.Administration.Commands
shell.WriteLine(Loc.GetString("rejuvenate-command-no-entity-attached-message")); shell.WriteLine(Loc.GetString("rejuvenate-command-no-entity-attached-message"));
return; return;
} }
PerformRejuvenate(player.AttachedEntity.Value); PerformRejuvenate(player.AttachedEntity);
} }
var entityManager = IoCManager.Resolve<IEntityManager>(); var entityManager = IoCManager.Resolve<IEntityManager>();

View File

@@ -34,7 +34,7 @@ namespace Content.Server.Alert.Commands
if (!CommandUtils.TryGetAttachedEntityByUsernameOrId(shell, target, player, out attachedEntity)) return; if (!CommandUtils.TryGetAttachedEntityByUsernameOrId(shell, target, player, out attachedEntity)) return;
} }
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(attachedEntity.Value, out ServerAlertsComponent? alertsComponent)) if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(attachedEntity, out ServerAlertsComponent? alertsComponent))
{ {
shell.WriteLine("user has no alerts component"); shell.WriteLine("user has no alerts component");
return; return;

View File

@@ -40,7 +40,7 @@ namespace Content.Server.Alert.Commands
if (!CommandUtils.TryGetAttachedEntityByUsernameOrId(shell, target, player, out attachedEntity)) return; if (!CommandUtils.TryGetAttachedEntityByUsernameOrId(shell, target, player, out attachedEntity)) return;
} }
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(attachedEntity.Value, out ServerAlertsComponent? alertsComponent)) if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(attachedEntity, out ServerAlertsComponent? alertsComponent))
{ {
shell.WriteLine("user has no alerts component"); shell.WriteLine("user has no alerts component");
return; return;

View File

@@ -67,7 +67,7 @@ namespace Content.Server.Alert
{ {
Logger.DebugS("alert", "user {0} attempted to" + Logger.DebugS("alert", "user {0} attempted to" +
" click alert {1} which is not currently showing for them", " click alert {1} which is not currently showing for them",
IoCManager.Resolve<IEntityManager>().GetComponent<MetaDataComponent>(player.Value).EntityName, msg.Type); IoCManager.Resolve<IEntityManager>().GetComponent<MetaDataComponent>(player).EntityName, msg.Type);
break; break;
} }
@@ -77,7 +77,7 @@ namespace Content.Server.Alert
break; break;
} }
alert.OnClick?.AlertClicked(new ClickAlertEventArgs(player.Value, alert)); alert.OnClick?.AlertClicked(new ClickAlertEventArgs(player, alert));
break; break;
} }
} }

View File

@@ -235,7 +235,7 @@ namespace Content.Server.Atmos.Components
if (handsComponent.GetActiveHand?.Owner is not {Valid: true} activeHandEntity || if (handsComponent.GetActiveHand?.Owner is not {Valid: true} activeHandEntity ||
!_entities.TryGetComponent(activeHandEntity, out GasAnalyzerComponent? gasAnalyzer)) !_entities.TryGetComponent(activeHandEntity, out GasAnalyzerComponent? gasAnalyzer))
{ {
serverMsg.Session.AttachedEntity?.PopupMessage(Loc.GetString("gas-analyzer-component-need-gas-analyzer-in-hand-message")); serverMsg.Session.AttachedEntity.PopupMessage(Loc.GetString("gas-analyzer-component-need-gas-analyzer-in-hand-message"));
return; return;
} }

View File

@@ -81,7 +81,7 @@ namespace Content.Server.Atmos.Piping.Unary.EntitySystems
private bool CheckInteract(ICommonSession session) private bool CheckInteract(ICommonSession session)
{ {
if (session.AttachedEntity is not {} uid if (session.AttachedEntity is not {Valid: true} uid
|| !_actionBlockerSystem.CanInteract(uid) || !_actionBlockerSystem.CanInteract(uid)
|| !_actionBlockerSystem.CanUse(uid)) || !_actionBlockerSystem.CanUse(uid))
return false; return false;

View File

@@ -44,13 +44,13 @@ namespace Content.Server.Body.Commands
return; return;
} }
if (player.AttachedEntity == null) if (player.AttachedEntity == default)
{ {
shell.WriteLine("You don't have an entity to add a hand to."); shell.WriteLine("You don't have an entity to add a hand to.");
return; return;
} }
entity = player.AttachedEntity.Value; entity = player.AttachedEntity;
hand = entityManager.SpawnEntity(DefaultHandPrototype, entityManager.GetComponent<TransformComponent>(entity).Coordinates); hand = entityManager.SpawnEntity(DefaultHandPrototype, entityManager.GetComponent<TransformComponent>(entity).Coordinates);
break; break;
} }
@@ -75,13 +75,13 @@ namespace Content.Server.Body.Commands
return; return;
} }
if (player.AttachedEntity == null) if (player.AttachedEntity == default)
{ {
shell.WriteLine("You don't have an entity to add a hand to."); shell.WriteLine("You don't have an entity to add a hand to.");
return; return;
} }
entity = player.AttachedEntity.Value; entity = player.AttachedEntity;
hand = entityManager.SpawnEntity(args[0], entityManager.GetComponent<TransformComponent>(entity).Coordinates); hand = entityManager.SpawnEntity(args[0], entityManager.GetComponent<TransformComponent>(entity).Coordinates);
} }

View File

@@ -44,7 +44,7 @@ namespace Content.Server.Body.Commands
return; return;
} }
entity = player.AttachedEntity.Value; entity = player.AttachedEntity;
break; break;
case 2: case 2:

View File

@@ -31,13 +31,13 @@ namespace Content.Server.Body.Commands
return; return;
} }
if (player.AttachedEntity == null) if (player.AttachedEntity == default)
{ {
shell.WriteLine("You have no entity."); shell.WriteLine("You have no entity.");
return; return;
} }
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(player.AttachedEntity.Value, out SharedBodyComponent? body)) if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(player.AttachedEntity, out SharedBodyComponent? body))
{ {
var random = IoCManager.Resolve<IRobustRandom>(); var random = IoCManager.Resolve<IRobustRandom>();
var text = $"You have no body{(random.Prob(0.2f) ? " and you must scream." : ".")}"; var text = $"You have no body{(random.Prob(0.2f) ? " and you must scream." : ".")}";

View File

@@ -33,7 +33,7 @@ namespace Content.Server.Body.Commands
return; return;
} }
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(player.AttachedEntity.Value, out SharedBodyComponent? body)) if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(player.AttachedEntity, out SharedBodyComponent? body))
{ {
var random = IoCManager.Resolve<IRobustRandom>(); var random = IoCManager.Resolve<IRobustRandom>();
var text = $"You have no body{(random.Prob(0.2f) ? " and you must scream." : ".")}"; var text = $"You have no body{(random.Prob(0.2f) ? " and you must scream." : ".")}";

View File

@@ -24,12 +24,12 @@ namespace Content.Server.Body.Components
var session = actor.PlayerSession; var session = actor.PlayerSession;
if (session.AttachedEntity == null) if (session.AttachedEntity == default)
{ {
return; return;
} }
if (IoCManager.Resolve<IEntityManager>().TryGetComponent(session.AttachedEntity.Value, out SharedBodyComponent? body)) if (IoCManager.Resolve<IEntityManager>().TryGetComponent(session.AttachedEntity, out SharedBodyComponent? body))
{ {
var state = InterfaceState(body); var state = InterfaceState(body);
UserInterface?.SetState(state); UserInterface?.SetState(state);

View File

@@ -24,7 +24,7 @@ namespace Content.Server.Chat.Commands
return; return;
} }
if (player.Status != SessionStatus.InGame || !player.AttachedEntity.HasValue) if (player.Status != SessionStatus.InGame || player.AttachedEntity == default)
return; return;
if (args.Length < 1) if (args.Length < 1)

View File

@@ -25,7 +25,7 @@ namespace Content.Server.Chat.Commands
return; return;
} }
if (player.Status != SessionStatus.InGame || !player.AttachedEntity.HasValue) if (player.Status != SessionStatus.InGame || player.AttachedEntity == default)
return; return;
if (args.Length < 1) if (args.Length < 1)

View File

@@ -306,7 +306,7 @@ namespace Content.Server.Chat.Managers
msg.MessageWrap = Loc.GetString("chat-manager-send-dead-chat-wrap-message", msg.MessageWrap = Loc.GetString("chat-manager-send-dead-chat-wrap-message",
("deadChannelName", Loc.GetString("chat-manager-dead-channel-name")), ("deadChannelName", Loc.GetString("chat-manager-dead-channel-name")),
("playerName", (playerName))); ("playerName", (playerName)));
msg.SenderEntity = player.AttachedEntity.GetValueOrDefault(); msg.SenderEntity = player.AttachedEntity;
_netManager.ServerSendToMany(msg, clients.ToList()); _netManager.ServerSendToMany(msg, clients.ToList());
} }

View File

@@ -143,7 +143,7 @@ namespace Content.Server.Chemistry.Components
_ => true, _ => true,
}; };
if (!PlayerCanUseDispenser(obj.Session.AttachedEntity.Value, needsPower)) if (!PlayerCanUseDispenser(obj.Session.AttachedEntity, needsPower))
return; return;
switch (msg.Button) switch (msg.Button)

View File

@@ -96,7 +96,7 @@ namespace Content.Server.Chemistry.Components
var amount = Math.Clamp(sval, MinimumTransferAmount.Float(), var amount = Math.Clamp(sval, MinimumTransferAmount.Float(),
MaximumTransferAmount.Float()); MaximumTransferAmount.Float());
serverMsg.Session.AttachedEntity?.PopupMessage(Loc.GetString("comp-solution-transfer-set-amount", serverMsg.Session.AttachedEntity.PopupMessage(Loc.GetString("comp-solution-transfer-set-amount",
("amount", amount))); ("amount", amount)));
SetTransferAmount(FixedPoint2.New(amount)); SetTransferAmount(FixedPoint2.New(amount));
break; break;

View File

@@ -87,13 +87,13 @@ namespace Content.Server.Cloning.Components
case UiButton.Clone: case UiButton.Clone:
if (BodyContainer.ContainedEntity != null) if (BodyContainer.ContainedEntity != null)
{ {
obj.Session.AttachedEntity?.PopupMessageCursor(Loc.GetString("cloning-pod-component-msg-occupied")); obj.Session.AttachedEntity.PopupMessageCursor(Loc.GetString("cloning-pod-component-msg-occupied"));
return; return;
} }
if (message.ScanId == null) if (message.ScanId == null)
{ {
obj.Session.AttachedEntity?.PopupMessageCursor(Loc.GetString("cloning-pod-component-msg-no-selection")); obj.Session.AttachedEntity.PopupMessageCursor(Loc.GetString("cloning-pod-component-msg-no-selection"));
return; return;
} }
@@ -101,7 +101,7 @@ namespace Content.Server.Cloning.Components
if (!cloningSystem.IdToDNA.TryGetValue(message.ScanId.Value, out var dna)) if (!cloningSystem.IdToDNA.TryGetValue(message.ScanId.Value, out var dna))
{ {
obj.Session.AttachedEntity?.PopupMessageCursor(Loc.GetString("cloning-pod-component-msg-bad-selection")); obj.Session.AttachedEntity.PopupMessageCursor(Loc.GetString("cloning-pod-component-msg-bad-selection"));
return; // ScanId is not in database return; // ScanId is not in database
} }
@@ -115,7 +115,7 @@ namespace Content.Server.Cloning.Components
_entities.TryGetComponent(clone, out MindComponent? cloneMindComp) && _entities.TryGetComponent(clone, out MindComponent? cloneMindComp) &&
(cloneMindComp.Mind == null || cloneMindComp.Mind == mind)) (cloneMindComp.Mind == null || cloneMindComp.Mind == mind))
{ {
obj.Session.AttachedEntity?.PopupMessageCursor(Loc.GetString("cloning-pod-component-msg-already-cloning")); obj.Session.AttachedEntity.PopupMessageCursor(Loc.GetString("cloning-pod-component-msg-already-cloning"));
return; // Mind already has clone return; // Mind already has clone
} }
@@ -126,14 +126,14 @@ namespace Content.Server.Cloning.Components
_entities.TryGetComponent<MobStateComponent?>(mind.OwnedEntity.Value, out var state) && _entities.TryGetComponent<MobStateComponent?>(mind.OwnedEntity.Value, out var state) &&
!state.IsDead()) !state.IsDead())
{ {
obj.Session.AttachedEntity?.PopupMessageCursor(Loc.GetString("cloning-pod-component-msg-already-alive")); obj.Session.AttachedEntity.PopupMessageCursor(Loc.GetString("cloning-pod-component-msg-already-alive"));
return; // Body controlled by mind is not dead return; // Body controlled by mind is not dead
} }
// Yes, we still need to track down the client because we need to open the Eui // Yes, we still need to track down the client because we need to open the Eui
if (mind.UserId == null || !_playerManager.TryGetSessionById(mind.UserId.Value, out var client)) if (mind.UserId == null || !_playerManager.TryGetSessionById(mind.UserId.Value, out var client))
{ {
obj.Session.AttachedEntity?.PopupMessageCursor(Loc.GetString("cloning-pod-component-msg-user-offline")); obj.Session.AttachedEntity.PopupMessageCursor(Loc.GetString("cloning-pod-component-msg-user-offline"));
return; // If we can't track down the client, we can't offer transfer. That'd be quite bad. return; // If we can't track down the client, we can't offer transfer. That'd be quite bad.
} }

View File

@@ -39,11 +39,11 @@ namespace Content.Server.Commands
/// sending a failure to the performer if unable to. /// sending a failure to the performer if unable to.
/// </summary> /// </summary>
public static bool TryGetAttachedEntityByUsernameOrId(IConsoleShell shell, public static bool TryGetAttachedEntityByUsernameOrId(IConsoleShell shell,
string usernameOrId, IPlayerSession performer, [NotNullWhen(true)] out EntityUid? attachedEntity) string usernameOrId, IPlayerSession performer, out EntityUid attachedEntity)
{ {
attachedEntity = null; attachedEntity = default;
if (!TryGetSessionByUsernameOrId(shell, usernameOrId, performer, out var session)) return false; if (!TryGetSessionByUsernameOrId(shell, usernameOrId, performer, out var session)) return false;
if (session.AttachedEntity == null) if (session.AttachedEntity == default)
{ {
shell.WriteLine("User has no attached entity."); shell.WriteLine("User has no attached entity.");
return false; return false;

View File

@@ -31,13 +31,13 @@ namespace Content.Server.Damage.Commands
return; return;
} }
if (player.AttachedEntity == null) if (player.AttachedEntity == default)
{ {
shell.WriteLine("An entity needs to be specified when you aren't attached to an entity."); shell.WriteLine("An entity needs to be specified when you aren't attached to an entity.");
return; return;
} }
entity = player.AttachedEntity.Value; entity = player.AttachedEntity;
break; break;
case 1: case 1:
if (!EntityUid.TryParse(args[0], out var id)) if (!EntityUid.TryParse(args[0], out var id))

View File

@@ -112,7 +112,7 @@ namespace Content.Server.Disposal.Tube.Components
var actionBlocker = EntitySystem.Get<ActionBlockerSystem>(); var actionBlocker = EntitySystem.Get<ActionBlockerSystem>();
var groupController = IoCManager.Resolve<IConGroupController>(); var groupController = IoCManager.Resolve<IConGroupController>();
//Check if player can interact in their current state //Check if player can interact in their current state
if (!groupController.CanAdminMenu(session) && (!actionBlocker.CanInteract(session.AttachedEntity!.Value) || !actionBlocker.CanUse(session.AttachedEntity!.Value))) if (!groupController.CanAdminMenu(session) && (!actionBlocker.CanInteract(session.AttachedEntity) || !actionBlocker.CanUse(session.AttachedEntity)))
return false; return false;
return true; return true;

View File

@@ -94,7 +94,7 @@ namespace Content.Server.Disposal.Tube.Components
var actionBlocker = EntitySystem.Get<ActionBlockerSystem>(); var actionBlocker = EntitySystem.Get<ActionBlockerSystem>();
var groupController = IoCManager.Resolve<IConGroupController>(); var groupController = IoCManager.Resolve<IConGroupController>();
//Check if player can interact in their current state //Check if player can interact in their current state
if (!groupController.CanAdminMenu(session) && (!actionBlocker.CanInteract(session.AttachedEntity!.Value) || !actionBlocker.CanUse(session.AttachedEntity!.Value))) if (!groupController.CanAdminMenu(session) && (!actionBlocker.CanInteract(session.AttachedEntity) || !actionBlocker.CanUse(session.AttachedEntity)))
return false; return false;
return true; return true;

View File

@@ -52,7 +52,7 @@ namespace Content.Server.Disposal
return; return;
} }
tube.PopupDirections(player.AttachedEntity.Value); tube.PopupDirections(player.AttachedEntity);
} }
} }
} }

View File

@@ -49,7 +49,7 @@ namespace Content.Server.EntityList
foreach (var entity in prototype.Entities(prototypeManager)) foreach (var entity in prototype.Entities(prototypeManager))
{ {
entityManager.SpawnEntity(entity.ID, entityManager.GetComponent<TransformComponent>(player.AttachedEntity.Value).Coordinates); entityManager.SpawnEntity(entity.ID, entityManager.GetComponent<TransformComponent>(player.AttachedEntity).Coordinates);
i++; i++;
} }

View File

@@ -72,7 +72,7 @@ namespace Content.Server.GameTicking.Presets
} }
prefList.Add(player); prefList.Add(player);
player.AttachedEntity?.EnsureComponent<SuspicionRoleComponent>(); player.AttachedEntity.EnsureComponent<SuspicionRoleComponent>();
} }
var numTraitors = MathHelper.Clamp(readyPlayers.Count / PlayersPerTraitor, var numTraitors = MathHelper.Clamp(readyPlayers.Count / PlayersPerTraitor,

View File

@@ -191,10 +191,10 @@ namespace Content.Server.Hands.Systems
var player = playerSession.AttachedEntity; var player = playerSession.AttachedEntity;
if (!player.HasValue || !player.Value.IsValid()) if (player is not {Valid: true})
return false; return false;
return EntityManager.TryGetComponent(player.Value, out hands); return EntityManager.TryGetComponent(player, out hands);
} }
private void HandleActivateItem(ICommonSession? session) private void HandleActivateItem(ICommonSession? session)

View File

@@ -108,11 +108,11 @@ public sealed partial class InstrumentSystem : SharedInstrumentSystem
{ {
if (instrument.LaggedBatches == (int) (MaxMidiLaggedBatches * (1 / 3d) + 1)) if (instrument.LaggedBatches == (int) (MaxMidiLaggedBatches * (1 / 3d) + 1))
{ {
instrument.InstrumentPlayer.AttachedEntity?.PopupMessage( instrument.InstrumentPlayer.AttachedEntity.PopupMessage(
Loc.GetString("instrument-component-finger-cramps-light-message")); Loc.GetString("instrument-component-finger-cramps-light-message"));
} else if (instrument.LaggedBatches == (int) (MaxMidiLaggedBatches * (2 / 3d) + 1)) } else if (instrument.LaggedBatches == (int) (MaxMidiLaggedBatches * (2 / 3d) + 1))
{ {
instrument.InstrumentPlayer.AttachedEntity?.PopupMessage( instrument.InstrumentPlayer.AttachedEntity.PopupMessage(
Loc.GetString("instrument-component-finger-cramps-serious-message")); Loc.GetString("instrument-component-finger-cramps-serious-message"));
} }
} }

View File

@@ -49,9 +49,9 @@ namespace Content.Server.Interaction
} }
var mapManager = IoCManager.Resolve<IMapManager>(); var mapManager = IoCManager.Resolve<IMapManager>();
var playerGrid = _entities.GetComponent<TransformComponent>(player.AttachedEntity.Value).GridID; var playerGrid = _entities.GetComponent<TransformComponent>(player.AttachedEntity).GridID;
var mapGrid = mapManager.GetGrid(playerGrid); var mapGrid = mapManager.GetGrid(playerGrid);
var playerPosition = _entities.GetComponent<TransformComponent>(player.AttachedEntity.Value).Coordinates; var playerPosition = _entities.GetComponent<TransformComponent>(player.AttachedEntity).Coordinates;
var tileDefinitionManager = IoCManager.Resolve<ITileDefinitionManager>(); var tileDefinitionManager = IoCManager.Resolve<ITileDefinitionManager>();
for (var i = -radius; i <= radius; i++) for (var i = -radius; i <= radius; i++)

View File

@@ -163,7 +163,7 @@ namespace Content.Server.Kitchen.EntitySystems
if (!EntityManager.TryGetComponent(component.Owner, out ApcPowerReceiverComponent? receiver) || if (!EntityManager.TryGetComponent(component.Owner, out ApcPowerReceiverComponent? receiver) ||
!receiver.Powered) break; !receiver.Powered) break;
ClickSound(component); ClickSound(component);
DoWork(component, message.Session.AttachedEntity!.Value, DoWork(component, message.Session.AttachedEntity,
SharedReagentGrinderComponent.GrinderProgram.Grind); SharedReagentGrinderComponent.GrinderProgram.Grind);
break; break;
@@ -171,7 +171,7 @@ namespace Content.Server.Kitchen.EntitySystems
if (!EntityManager.TryGetComponent(component.Owner, out ApcPowerReceiverComponent? receiver2) || if (!EntityManager.TryGetComponent(component.Owner, out ApcPowerReceiverComponent? receiver2) ||
!receiver2.Powered) break; !receiver2.Powered) break;
ClickSound(component); ClickSound(component);
DoWork(component, message.Session.AttachedEntity!.Value, DoWork(component, message.Session.AttachedEntity,
SharedReagentGrinderComponent.GrinderProgram.Juice); SharedReagentGrinderComponent.GrinderProgram.Juice);
break; break;

View File

@@ -81,7 +81,7 @@ namespace Content.Server.Labels
private bool CheckInteract(ICommonSession session) private bool CheckInteract(ICommonSession session)
{ {
if (session.AttachedEntity is not { } uid if (session.AttachedEntity is not {Valid: true } uid
|| !Get<ActionBlockerSystem>().CanInteract(uid) || !Get<ActionBlockerSystem>().CanInteract(uid)
|| !Get<ActionBlockerSystem>().CanUse(uid)) || !Get<ActionBlockerSystem>().CanUse(uid))
return false; return false;

View File

@@ -119,16 +119,16 @@ namespace Content.Server.MachineLinking.System
switch (msg.Message) switch (msg.Message)
{ {
case SignalPortSelected portSelected: case SignalPortSelected portSelected:
if (msg.Session.AttachedEntity == null || if (msg.Session.AttachedEntity == default ||
!EntityManager.TryGetComponent(msg.Session.AttachedEntity.Value, out HandsComponent? hands) || !EntityManager.TryGetComponent(msg.Session.AttachedEntity, out HandsComponent? hands) ||
!hands.TryGetActiveHeldEntity(out var heldEntity) || !hands.TryGetActiveHeldEntity(out var heldEntity) ||
!EntityManager.TryGetComponent(heldEntity, out SignalLinkerComponent? signalLinkerComponent) || !EntityManager.TryGetComponent(heldEntity, out SignalLinkerComponent? signalLinkerComponent) ||
!_interaction.InRangeUnobstructed(msg.Session.AttachedEntity.Value, component.Owner, ignoreInsideBlocker: true) || !_interaction.InRangeUnobstructed(msg.Session.AttachedEntity, component.Owner, ignoreInsideBlocker: true) ||
!signalLinkerComponent.Port.HasValue || !signalLinkerComponent.Port.HasValue ||
!signalLinkerComponent.Port.Value.transmitter.Outputs.ContainsPort(signalLinkerComponent.Port !signalLinkerComponent.Port.Value.transmitter.Outputs.ContainsPort(signalLinkerComponent.Port
.Value.port) || !component.Inputs.ContainsPort(portSelected.Port)) .Value.port) || !component.Inputs.ContainsPort(portSelected.Port))
return; return;
LinkerInteraction(msg.Session.AttachedEntity.Value, signalLinkerComponent.Port.Value.transmitter, LinkerInteraction(msg.Session.AttachedEntity, signalLinkerComponent.Port.Value.transmitter,
signalLinkerComponent.Port.Value.port, component, portSelected.Port); signalLinkerComponent.Port.Value.port, component, portSelected.Port);
break; break;
} }
@@ -159,13 +159,13 @@ namespace Content.Server.MachineLinking.System
switch (msg.Message) switch (msg.Message)
{ {
case SignalPortSelected portSelected: case SignalPortSelected portSelected:
if (msg.Session.AttachedEntity == null || if (msg.Session.AttachedEntity == default ||
!EntityManager.TryGetComponent(msg.Session.AttachedEntity.Value, out HandsComponent? hands) || !EntityManager.TryGetComponent(msg.Session.AttachedEntity, out HandsComponent? hands) ||
!hands.TryGetActiveHeldEntity(out var heldEntity) || !hands.TryGetActiveHeldEntity(out var heldEntity) ||
!EntityManager.TryGetComponent(heldEntity, out SignalLinkerComponent? signalLinkerComponent) || !EntityManager.TryGetComponent(heldEntity, out SignalLinkerComponent? signalLinkerComponent) ||
!_interaction.InRangeUnobstructed(msg.Session.AttachedEntity.Value, component.Owner, ignoreInsideBlocker: true)) !_interaction.InRangeUnobstructed(msg.Session.AttachedEntity, component.Owner, ignoreInsideBlocker: true))
return; return;
LinkerSaveInteraction(msg.Session.AttachedEntity.Value, signalLinkerComponent, component, LinkerSaveInteraction(msg.Session.AttachedEntity, signalLinkerComponent, component,
portSelected.Port); portSelected.Port);
break; break;
} }

View File

@@ -200,7 +200,7 @@ namespace Content.Server.Medical.Components
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(_bodyContainer.ContainedEntity.Value, out MindComponent? mindComp) || mindComp.Mind == null) if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(_bodyContainer.ContainedEntity.Value, out MindComponent? mindComp) || mindComp.Mind == null)
{ {
obj.Session.AttachedEntity?.PopupMessageCursor(Loc.GetString("medical-scanner-component-msg-no-soul")); obj.Session.AttachedEntity.PopupMessageCursor(Loc.GetString("medical-scanner-component-msg-no-soul"));
break; break;
} }
@@ -215,7 +215,7 @@ namespace Content.Server.Medical.Components
if (mindUser == null) if (mindUser == null)
{ {
// For now assume this means soul departed // For now assume this means soul departed
obj.Session.AttachedEntity?.PopupMessageCursor(Loc.GetString("medical-scanner-component-msg-soul-broken")); obj.Session.AttachedEntity.PopupMessageCursor(Loc.GetString("medical-scanner-component-msg-soul-broken"));
break; break;
} }

View File

@@ -145,7 +145,7 @@ namespace Content.Server.PDA
private void OnUIMessage(PDAComponent pda, ServerBoundUserInterfaceMessage msg) private void OnUIMessage(PDAComponent pda, ServerBoundUserInterfaceMessage msg)
{ {
// cast EntityUid? to EntityUid // cast EntityUid? to EntityUid
if (msg.Session.AttachedEntity is not { } playerUid) if (msg.Session.AttachedEntity is not {Valid: true} playerUid)
return; return;
switch (msg.Message) switch (msg.Message)

View File

@@ -93,7 +93,7 @@ namespace Content.Server.Power.Components
if (user == null) return; if (user == null) return;
var accessSystem = EntitySystem.Get<AccessReaderSystem>(); var accessSystem = EntitySystem.Get<AccessReaderSystem>();
if (_accessReader == null || accessSystem.IsAllowed(_accessReader, user.Value)) if (_accessReader == null || accessSystem.IsAllowed(_accessReader, user))
{ {
MainBreakerEnabled = !MainBreakerEnabled; MainBreakerEnabled = !MainBreakerEnabled;
IoCManager.Resolve<IEntityManager>().GetComponent<PowerNetworkBatteryComponent>(Owner).CanDischarge = MainBreakerEnabled; IoCManager.Resolve<IEntityManager>().GetComponent<PowerNetworkBatteryComponent>(Owner).CanDischarge = MainBreakerEnabled;
@@ -103,7 +103,7 @@ namespace Content.Server.Power.Components
} }
else else
{ {
user.Value.PopupMessageCursor(Loc.GetString("apc-component-insufficient-access")); user.PopupMessageCursor(Loc.GetString("apc-component-insufficient-access"));
} }
} }

View File

@@ -115,7 +115,7 @@ namespace Content.Server.Sandbox
} }
var player = _playerManager.GetSessionByChannel(message.MsgChannel); var player = _playerManager.GetSessionByChannel(message.MsgChannel);
if (player.AttachedEntity == null) if (player.AttachedEntity == default)
{ {
return; return;
} }
@@ -124,7 +124,7 @@ namespace Content.Server.Sandbox
.EnumeratePrototypes<AccessLevelPrototype>() .EnumeratePrototypes<AccessLevelPrototype>()
.Select(p => p.ID).ToArray(); .Select(p => p.ID).ToArray();
if (_entityManager.TryGetComponent(player.AttachedEntity.Value, out InventoryComponent? inv) if (_entityManager.TryGetComponent(player.AttachedEntity, out InventoryComponent? inv)
&& inv.TryGetSlotItem(Slots.IDCARD, out ItemComponent? wornItem)) && inv.TryGetSlotItem(Slots.IDCARD, out ItemComponent? wornItem))
{ {
if (_entityManager.HasComponent<AccessComponent>(wornItem.Owner)) if (_entityManager.HasComponent<AccessComponent>(wornItem.Owner))
@@ -148,10 +148,10 @@ namespace Content.Server.Sandbox
} }
} }
} }
else if (_entityManager.TryGetComponent<HandsComponent?>(player.AttachedEntity.Value, out var hands)) else if (_entityManager.TryGetComponent<HandsComponent?>(player.AttachedEntity, out var hands))
{ {
var card = CreateFreshId(); var card = CreateFreshId();
if (!_entityManager.TryGetComponent(player.AttachedEntity.Value, out inv) || !inv.Equip(Slots.IDCARD, card)) if (!_entityManager.TryGetComponent(player.AttachedEntity, out inv) || !inv.Equip(Slots.IDCARD, card))
{ {
hands.PutInHandOrDrop(_entityManager.GetComponent<ItemComponent>(card)); hands.PutInHandOrDrop(_entityManager.GetComponent<ItemComponent>(card));
} }
@@ -170,10 +170,10 @@ namespace Content.Server.Sandbox
EntityUid CreateFreshId() EntityUid CreateFreshId()
{ {
var card = _entityManager.SpawnEntity("CaptainIDCard", _entityManager.GetComponent<TransformComponent>(player.AttachedEntity.Value).Coordinates); var card = _entityManager.SpawnEntity("CaptainIDCard", _entityManager.GetComponent<TransformComponent>(player.AttachedEntity).Coordinates);
UpgradeId(card); UpgradeId(card);
_entityManager.GetComponent<IdCardComponent>(card).FullName = _entityManager.GetComponent<MetaDataComponent>(player.AttachedEntity.Value).EntityName; _entityManager.GetComponent<IdCardComponent>(card).FullName = _entityManager.GetComponent<MetaDataComponent>(player.AttachedEntity).EntityName;
return card; return card;
} }
} }

View File

@@ -2,6 +2,7 @@ using System.Collections.Generic;
using Content.Server.Hands.Components; using Content.Server.Hands.Components;
using Content.Server.Interaction; using Content.Server.Interaction;
using Content.Server.Storage.Components; using Content.Server.Storage.Components;
using Content.Shared.Interaction;
using Content.Shared.Movement; using Content.Shared.Movement;
using Content.Shared.Verbs; using Content.Shared.Verbs;
using JetBrains.Annotations; using JetBrains.Annotations;
@@ -151,14 +152,14 @@ namespace Content.Server.Storage.EntitySystems
var attachedEntity = session.AttachedEntity; var attachedEntity = session.AttachedEntity;
// The component manages the set of sessions, so this invalid session should be removed soon. // The component manages the set of sessions, so this invalid session should be removed soon.
if (attachedEntity == null || !IoCManager.Resolve<IEntityManager>().EntityExists(attachedEntity.Value)) if (attachedEntity == default || !IoCManager.Resolve<IEntityManager>().EntityExists(attachedEntity))
continue; continue;
if (storageMap != IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(attachedEntity.Value).MapID) if (storageMap != IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(attachedEntity).MapID)
continue; continue;
var distanceSquared = (storagePos - IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(attachedEntity.Value).WorldPosition).LengthSquared; var distanceSquared = (storagePos - IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(attachedEntity).WorldPosition).LengthSquared;
if (distanceSquared > InteractionSystem.InteractionRangeSquared) if (distanceSquared > SharedInteractionSystem.InteractionRangeSquared)
{ {
storageComp.UnsubscribeSession(session); storageComp.UnsubscribeSession(session);
} }

View File

@@ -73,7 +73,7 @@ namespace Content.Server.Tabletop
/// <param name="uid">The UID of the tabletop game entity.</param> /// <param name="uid">The UID of the tabletop game entity.</param>
public void OpenSessionFor(IPlayerSession player, EntityUid uid) public void OpenSessionFor(IPlayerSession player, EntityUid uid)
{ {
if (!EntityManager.TryGetComponent(uid, out TabletopGameComponent? tabletop) || player.AttachedEntity is not {} attachedEntity) if (!EntityManager.TryGetComponent(uid, out TabletopGameComponent? tabletop) || player.AttachedEntity is not {Valid: true} attachedEntity)
return; return;
// Make sure we have a session, and add the player to it if not added already. // Make sure we have a session, and add the player to it if not added already.

View File

@@ -74,7 +74,7 @@ namespace Content.Server.Traitor.Uplink.Commands
// Finally add uplink // Finally add uplink
if (!entityManager.EntitySysManager.GetEntitySystem<UplinkSystem>() if (!entityManager.EntitySysManager.GetEntitySystem<UplinkSystem>()
.AddUplink(user.Value, uplinkAccount, uplinkEntity)) .AddUplink(user, uplinkAccount, uplinkEntity))
{ {
shell.WriteLine(Loc.GetString("Failed to add uplink to the player")); shell.WriteLine(Loc.GetString("Failed to add uplink to the player"));
return; return;

View File

@@ -26,7 +26,7 @@ namespace Content.Server.Traitor.Uplink.Telecrystal
if (args.Handled) if (args.Handled)
return; return;
if (args.Target == null || !EntityManager.TryGetComponent(args.Target, out UplinkComponent? uplink)) if (args.Target == null || !EntityManager.TryGetComponent(args.Target.Value, out UplinkComponent? uplink))
return; return;
// TODO: when uplink will have some auth logic (like PDA ringtone code) // TODO: when uplink will have some auth logic (like PDA ringtone code)

View File

@@ -116,7 +116,7 @@ namespace Content.Server.UserInterface
// Must ToList in order to close things safely. // Must ToList in order to close things safely.
foreach (var session in ui.SubscribedSessions.ToArray()) foreach (var session in ui.SubscribedSessions.ToArray())
{ {
if (session.AttachedEntity == null || !_actionBlockerSystem.CanInteract(session.AttachedEntity.Value)) if (session.AttachedEntity == null || !_actionBlockerSystem.CanInteract(session.AttachedEntity))
{ {
ui.Close(session); ui.Close(session);
} }

View File

@@ -32,9 +32,9 @@ namespace Content.Server.Verbs.Commands
EntityUid playerEntity = default; EntityUid playerEntity = default;
if (!int.TryParse(args[0], out var intPlayerUid)) if (!int.TryParse(args[0], out var intPlayerUid))
{ {
if (args[0] == "self" && shell.Player?.AttachedEntity != null) if (args[0] == "self" && shell.Player?.AttachedEntity != default)
{ {
playerEntity = shell.Player.AttachedEntity.Value; playerEntity = shell.Player.AttachedEntity;
} }
else else
{ {

View File

@@ -36,7 +36,7 @@ namespace Content.Server.Verbs
// Get the list of verbs. This effectively also checks that the requested verb is in fact a valid verb that // Get the list of verbs. This effectively also checks that the requested verb is in fact a valid verb that
// the user can perform. // the user can perform.
var verbs = GetLocalVerbs(args.Target, userEntity.Value, args.Type)[args.Type]; var verbs = GetLocalVerbs(args.Target, userEntity, args.Type)[args.Type];
// Note that GetLocalVerbs might waste time checking & preparing unrelated verbs even though we know // Note that GetLocalVerbs might waste time checking & preparing unrelated verbs even though we know
// precisely which one we want to run. However, MOST entities will only have 1 or 2 verbs of a given type. // precisely which one we want to run. However, MOST entities will only have 1 or 2 verbs of a given type.
@@ -44,7 +44,7 @@ namespace Content.Server.Verbs
// Find the requested verb. // Find the requested verb.
if (verbs.TryGetValue(args.RequestedVerb, out var verb)) if (verbs.TryGetValue(args.RequestedVerb, out var verb))
ExecuteVerb(verb, userEntity.Value, args.Target); ExecuteVerb(verb, userEntity, args.Target);
else else
// 404 Verb not found. Note that this could happen due to something as simple as opening the verb menu, walking away, then trying // 404 Verb not found. Note that this could happen due to something as simple as opening the verb menu, walking away, then trying
// to run the pickup-item verb. So maybe this shouldn't even be logged? // to run the pickup-item verb. So maybe this shouldn't even be logged?
@@ -61,7 +61,7 @@ namespace Content.Server.Verbs
return; return;
} }
if (player.AttachedEntity == null) if (player.AttachedEntity == default)
{ {
Logger.Warning($"{nameof(HandleVerbRequest)} called by player {player} with no attached entity."); Logger.Warning($"{nameof(HandleVerbRequest)} called by player {player} with no attached entity.");
return; return;
@@ -71,7 +71,7 @@ namespace Content.Server.Verbs
// this, and some verbs (e.g. view variables) won't even care about whether an entity is accessible through // this, and some verbs (e.g. view variables) won't even care about whether an entity is accessible through
// the entity menu or not. // the entity menu or not.
var response = new VerbsResponseEvent(args.EntityUid, GetLocalVerbs(args.EntityUid, player.AttachedEntity.Value, args.Type)); var response = new VerbsResponseEvent(args.EntityUid, GetLocalVerbs(args.EntityUid, player.AttachedEntity, args.Type));
RaiseNetworkEvent(response, player.ConnectedClient); RaiseNetworkEvent(response, player.ConnectedClient);
} }
} }

View File

@@ -202,10 +202,10 @@ namespace Content.Server.Weapon.Ranged.Barrels.Components
{ {
return default; return default;
} }
var entity = _chamberContainer.ContainedEntity; var entity = _chamberContainer.ContainedEntity ?? default;
Cycle(); Cycle();
return (entity != null ? IoCManager.Resolve<IEntityManager>().GetComponent<AmmoComponent>(entity) : null).TakeBullet(spawnAt); return entity != default ? IoCManager.Resolve<IEntityManager>().GetComponent<AmmoComponent>(entity).TakeBullet(spawnAt) : null;
} }
private void Cycle(bool manual = false) private void Cycle(bool manual = false)
@@ -275,14 +275,14 @@ namespace Content.Server.Weapon.Ranged.Barrels.Components
var chamberEntity = _chamberContainer.ContainedEntity; var chamberEntity = _chamberContainer.ContainedEntity;
if (chamberEntity != null) if (chamberEntity != null)
{ {
if (!_chamberContainer.Remove(chamberEntity)) if (!_chamberContainer.Remove(chamberEntity.Value))
{ {
return false; return false;
} }
var ammoComponent = IoCManager.Resolve<IEntityManager>().GetComponent<AmmoComponent>(chamberEntity); var ammoComponent = IoCManager.Resolve<IEntityManager>().GetComponent<AmmoComponent>(chamberEntity.Value);
if (!ammoComponent.Caseless) if (!ammoComponent.Caseless)
{ {
EjectCasing(chamberEntity); EjectCasing(chamberEntity.Value);
} }
return true; return true;
} }
@@ -297,10 +297,10 @@ namespace Content.Server.Weapon.Ranged.Barrels.Components
} }
// Try and pull a round from the magazine to replace the chamber if possible // Try and pull a round from the magazine to replace the chamber if possible
var magazine = MagazineContainer.ContainedEntity; var magazine = MagazineContainer.ContainedEntity ?? default;
var nextRound = (magazine != null ? IoCManager.Resolve<IEntityManager>().GetComponent<RangedMagazineComponent>(magazine) : null).TakeAmmo(); var nextRound = magazine != default ? IoCManager.Resolve<IEntityManager>().GetComponent<RangedMagazineComponent>(magazine).TakeAmmo() : default;
if (nextRound == null) if (nextRound == default)
{ {
return false; return false;
} }
@@ -334,12 +334,12 @@ namespace Content.Server.Weapon.Ranged.Barrels.Components
return; return;
} }
MagazineContainer.Remove(mag); MagazineContainer.Remove(mag.Value);
SoundSystem.Play(Filter.Pvs(Owner), _soundMagEject.GetSound(), Owner, AudioParams.Default.WithVolume(-2)); SoundSystem.Play(Filter.Pvs(Owner), _soundMagEject.GetSound(), Owner, AudioParams.Default.WithVolume(-2));
if (IoCManager.Resolve<IEntityManager>().TryGetComponent(user, out HandsComponent? handsComponent)) if (IoCManager.Resolve<IEntityManager>().TryGetComponent(user, out HandsComponent? handsComponent))
{ {
handsComponent.PutInHandOrDrop(IoCManager.Resolve<IEntityManager>().GetComponent<ItemComponent>(mag)); handsComponent.PutInHandOrDrop(IoCManager.Resolve<IEntityManager>().GetComponent<ItemComponent>(mag.Value));
} }
Dirty(); Dirty();

View File

@@ -9,6 +9,8 @@ using Content.Server.UserInterface;
using Content.Server.VendingMachines; using Content.Server.VendingMachines;
using Content.Shared.Examine; using Content.Shared.Examine;
using Content.Shared.Interaction; using Content.Shared.Interaction;
using Content.Shared.Interaction.Helpers;
using Content.Shared.Popups;
using Content.Shared.Sound; using Content.Shared.Sound;
using Content.Shared.Tools; using Content.Shared.Tools;
using Content.Shared.Wires; using Content.Shared.Wires;

View File

@@ -16,7 +16,7 @@ namespace Content.Shared.CombatMode
{ {
var entity = eventArgs.SenderSession.AttachedEntity; var entity = eventArgs.SenderSession.AttachedEntity;
if (entity == null || !EntityManager.TryGetComponent(entity.Value, out SharedCombatModeComponent? combatModeComponent)) if (entity == null || !EntityManager.TryGetComponent(entity, out SharedCombatModeComponent? combatModeComponent))
{ {
return; return;
} }

View File

@@ -244,14 +244,14 @@ namespace Content.Shared.Containers.ItemSlots
if (!hands.TryGetActiveHeldEntity(out var item)) if (!hands.TryGetActiveHeldEntity(out var item))
return false; return false;
if (!CanInsert(uid, item.Value, slot)) if (!CanInsert(uid, item, slot))
return false; return false;
// hands.Drop(item) checks CanDrop action blocker // hands.Drop(item) checks CanDrop action blocker
if (!_actionBlockerSystem.CanInteract(user) && hands.Drop(item.Value)) if (!_actionBlockerSystem.CanInteract(user) && hands.Drop(item))
return false; return false;
Insert(uid, slot, item.Value); Insert(uid, slot, item);
return true; return true;
} }
#endregion #endregion

View File

@@ -35,9 +35,9 @@ namespace Content.Shared.Cuffs
private void HandleStopPull(EntityUid uid, SharedCuffableComponent component, StopPullingEvent args) private void HandleStopPull(EntityUid uid, SharedCuffableComponent component, StopPullingEvent args)
{ {
if (args.User == null || !EntityManager.EntityExists(args.User.Value) return; if (args.User == null || !EntityManager.EntityExists(args.User.Value)) return;
if (user == component.Owner && !component.CanStillInteract) if (args.User.Value == component.Owner && !component.CanStillInteract)
{ {
args.Cancel(); args.Cancel();
} }

View File

@@ -12,8 +12,7 @@ namespace Content.Shared.Gravity
private void HandleGridInitialize(GridInitializeEvent ev) private void HandleGridInitialize(GridInitializeEvent ev)
{ {
var gridev.EntityUid EntityManager.EnsureComponent<GravityComponent>(ev.EntityUid);
gridEnt.EnsureComponent<GravityComponent>();
} }
} }
} }

View File

@@ -112,7 +112,7 @@ namespace Content.Shared.Hands.Components
if (hand.HeldEntity == null) if (hand.HeldEntity == null)
continue; continue;
if (!entMan.TryGetComponent(hand.HeldEntity.Value, out SharedItemComponent? item) || item.RsiPath == null) if (!entMan.TryGetComponent(hand.HeldEntity, out SharedItemComponent? item) || item.RsiPath == null)
continue; continue;
var handState = new HandVisualState(item.RsiPath, item.EquippedPrefix, hand.Location, item.Color); var handState = new HandVisualState(item.RsiPath, item.EquippedPrefix, hand.Location, item.Color);
@@ -250,7 +250,7 @@ namespace Content.Shared.Hands.Components
foreach (var hand in Hands) foreach (var hand in Hands)
{ {
if (hand.HeldEntity != default) if (hand.HeldEntity != default)
yield return hand.HeldEntity.Value; yield return hand.HeldEntity;
} }
} }
@@ -416,7 +416,7 @@ namespace Content.Shared.Hands.Components
if (hand.HeldEntity == null) if (hand.HeldEntity == null)
return false; return false;
var heldEntity = hand.HeldEntity.Value; var heldEntity = hand.HeldEntity;
var handContainer = hand.Container; var handContainer = hand.Container;
if (handContainer == null) if (handContainer == null)
@@ -447,7 +447,7 @@ namespace Content.Shared.Hands.Components
if (hand.HeldEntity == null) if (hand.HeldEntity == null)
return; return;
var heldEntity = hand.HeldEntity.Value; var heldEntity = hand.HeldEntity;
var handContainer = hand.Container; var handContainer = hand.Container;
if (handContainer == null) if (handContainer == null)
@@ -475,7 +475,7 @@ namespace Content.Shared.Hands.Components
if (hand.HeldEntity == null) if (hand.HeldEntity == null)
return; return;
var heldEntity = hand.HeldEntity.Value; var heldEntity = hand.HeldEntity;
RemoveHeldEntityFromHand(hand); RemoveHeldEntityFromHand(hand);
@@ -538,7 +538,7 @@ namespace Content.Shared.Hands.Components
if (hand.HeldEntity == null) if (hand.HeldEntity == null)
return false; return false;
var heldEntity = hand.HeldEntity.Value; var heldEntity = hand.HeldEntity;
if (checkActionBlocker && !PlayerCanDrop()) if (checkActionBlocker && !PlayerCanDrop())
return false; return false;
@@ -557,7 +557,7 @@ namespace Content.Shared.Hands.Components
if (hand.HeldEntity == null) if (hand.HeldEntity == null)
return; return;
var heldEntity = hand.HeldEntity.Value; var heldEntity = hand.HeldEntity;
RemoveHeldEntityFromHand(hand); RemoveHeldEntityFromHand(hand);
@@ -713,7 +713,7 @@ namespace Content.Shared.Hands.Components
return; return;
await EntitySystem.Get<SharedInteractionSystem>() await EntitySystem.Get<SharedInteractionSystem>()
.InteractUsing(Owner, activeHeldEntity.Value, heldEntity.Value, EntityCoordinates.Invalid); .InteractUsing(Owner, activeHeldEntity, heldEntity, EntityCoordinates.Invalid);
} }
public void ActivateItem(bool altInteract = false) public void ActivateItem(bool altInteract = false)
@@ -722,7 +722,7 @@ namespace Content.Shared.Hands.Components
return; return;
EntitySystem.Get<SharedInteractionSystem>() EntitySystem.Get<SharedInteractionSystem>()
.TryUseInteraction(Owner, heldEntity.Value, altInteract); .TryUseInteraction(Owner, heldEntity, altInteract);
} }
public void ActivateHeldEntity(string handName) public void ActivateHeldEntity(string handName)
@@ -745,14 +745,14 @@ namespace Content.Shared.Hands.Components
if (!TryGetHeldEntity(handName, out var heldEntity)) if (!TryGetHeldEntity(handName, out var heldEntity))
return false; return false;
if (!CanInsertEntityIntoHand(activeHand, heldEntity.Value) || !CanRemoveHeldEntityFromHand(hand)) if (!CanInsertEntityIntoHand(activeHand, heldEntity) || !CanRemoveHeldEntityFromHand(hand))
return false; return false;
if (checkActionBlocker && (!PlayerCanDrop() || !PlayerCanPickup())) if (checkActionBlocker && (!PlayerCanDrop() || !PlayerCanPickup()))
return false; return false;
RemoveHeldEntityFromHand(hand); RemoveHeldEntityFromHand(hand);
PutEntityIntoHand(activeHand, heldEntity.Value); PutEntityIntoHand(activeHand, heldEntity);
return true; return true;
} }
@@ -761,13 +761,13 @@ namespace Content.Shared.Hands.Components
private void DeselectActiveHeldEntity() private void DeselectActiveHeldEntity()
{ {
if (TryGetActiveHeldEntity(out var entity)) if (TryGetActiveHeldEntity(out var entity))
EntitySystem.Get<SharedInteractionSystem>().HandDeselectedInteraction(Owner, entity.Value); EntitySystem.Get<SharedInteractionSystem>().HandDeselectedInteraction(Owner, entity);
} }
private void SelectActiveHeldEntity() private void SelectActiveHeldEntity()
{ {
if (TryGetActiveHeldEntity(out var entity)) if (TryGetActiveHeldEntity(out var entity))
EntitySystem.Get<SharedInteractionSystem>().HandSelectedInteraction(Owner, entity.Value); EntitySystem.Get<SharedInteractionSystem>().HandSelectedInteraction(Owner, entity);
} }
private void HandCountChanged() private void HandCountChanged()

View File

@@ -22,7 +22,7 @@ namespace Content.Shared.Hands
{ {
var entity = eventArgs.SenderSession.AttachedEntity; var entity = eventArgs.SenderSession.AttachedEntity;
if (entity == default || !EntityManager.TryGetComponent(entity, out SharedHandsComponent? hands)) if (entity == null || !EntityManager.TryGetComponent(entity, out SharedHandsComponent? hands))
return; return;
hands.ActiveHand = msg.HandName; hands.ActiveHand = msg.HandName;

View File

@@ -20,7 +20,7 @@ namespace Content.Shared.Pulling.Systems
private void OnRelayMoveInput(EntityUid uid, SharedPullableComponent component, RelayMoveInputEvent args) private void OnRelayMoveInput(EntityUid uid, SharedPullableComponent component, RelayMoveInputEvent args)
{ {
var entity = args.Session.AttachedEntity; var entity = args.Session.AttachedEntity;
if (!entity.HasValue || !_blocker.CanMove(entity.Value)) return; if (entity == default || !_blocker.CanMove(entity)) return;
_pullSystem.TryStopPull(component); _pullSystem.TryStopPull(component);
} }
} }