removes componentdependencies (#6160)

This commit is contained in:
Paul Ritter
2022-01-15 03:26:37 +01:00
committed by GitHub
parent 46405ec165
commit 9e1607722d
33 changed files with 257 additions and 274 deletions

View File

@@ -3,6 +3,7 @@ using Content.Shared.Cuffs.Components;
using Robust.Client.GameObjects; using Robust.Client.GameObjects;
using Robust.Client.Graphics; using Robust.Client.Graphics;
using Robust.Shared.GameObjects; using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.Utility; using Robust.Shared.Utility;
using Robust.Shared.ViewVariables; using Robust.Shared.ViewVariables;
@@ -15,7 +16,7 @@ namespace Content.Client.Cuffs.Components
[ViewVariables] [ViewVariables]
private string? _currentRSI; private string? _currentRSI;
[ViewVariables] [ComponentDependency] private readonly SpriteComponent? _spriteComponent = null; [Dependency] private readonly IEntityManager _entityManager = default!;
public override void HandleComponentState(ComponentState? curState, ComponentState? nextState) public override void HandleComponentState(ComponentState? curState, ComponentState? nextState)
{ {
@@ -26,10 +27,10 @@ namespace Content.Client.Cuffs.Components
CanStillInteract = cuffState.CanStillInteract; CanStillInteract = cuffState.CanStillInteract;
if (_spriteComponent != null) if (_entityManager.TryGetComponent<SpriteComponent>(Owner, out var spriteComponent))
{ {
_spriteComponent.LayerSetVisible(HumanoidVisualLayers.Handcuffs, cuffState.NumHandsCuffed > 0); spriteComponent.LayerSetVisible(HumanoidVisualLayers.Handcuffs, cuffState.NumHandsCuffed > 0);
_spriteComponent.LayerSetColor(HumanoidVisualLayers.Handcuffs, cuffState.Color); spriteComponent.LayerSetColor(HumanoidVisualLayers.Handcuffs, cuffState.Color);
if (cuffState.NumHandsCuffed > 0) if (cuffState.NumHandsCuffed > 0)
{ {
@@ -39,12 +40,12 @@ namespace Content.Client.Cuffs.Components
if (_currentRSI != null) if (_currentRSI != null)
{ {
_spriteComponent.LayerSetState(HumanoidVisualLayers.Handcuffs, new RSI.StateId(cuffState.IconState), new ResourcePath(_currentRSI)); spriteComponent.LayerSetState(HumanoidVisualLayers.Handcuffs, new RSI.StateId(cuffState.IconState), new ResourcePath(_currentRSI));
} }
} }
else else
{ {
_spriteComponent.LayerSetState(HumanoidVisualLayers.Handcuffs, new RSI.StateId(cuffState.IconState)); // TODO: safety check to see if RSI contains the state? spriteComponent.LayerSetState(HumanoidVisualLayers.Handcuffs, new RSI.StateId(cuffState.IconState)); // TODO: safety check to see if RSI contains the state?
} }
} }
} }
@@ -53,8 +54,8 @@ namespace Content.Client.Cuffs.Components
protected override void OnRemove() protected override void OnRemove()
{ {
base.OnRemove(); base.OnRemove();
if (_entityManager.TryGetComponent<SpriteComponent>(Owner, out var spriteComponent))
_spriteComponent?.LayerSetVisible(HumanoidVisualLayers.Handcuffs, false); spriteComponent.LayerSetVisible(HumanoidVisualLayers.Handcuffs, false);
} }
} }
} }

View File

@@ -23,9 +23,9 @@ namespace Content.Server.Arcade.Components
public override string Name => "BlockGameArcade"; public override string Name => "BlockGameArcade";
[ComponentDependency] private readonly ApcPowerReceiverComponent? _powerReceiverComponent = default!; [Dependency] private readonly IEntityManager _entityManager = default!;
private bool Powered => _powerReceiverComponent?.Powered ?? false; private bool Powered => _entityManager.TryGetComponent<ApcPowerReceiverComponent>(Owner, out var powerReceiverComponent) && powerReceiverComponent.Powered;
private BoundUserInterface? UserInterface => Owner.GetUIOrNull(BlockGameUiKey.Key); private BoundUserInterface? UserInterface => Owner.GetUIOrNull(BlockGameUiKey.Key);
private BlockGame? _game; private BlockGame? _game;

View File

@@ -30,10 +30,8 @@ namespace Content.Server.Arcade.Components
{ {
[Dependency] private readonly IRobustRandom _random = null!; [Dependency] private readonly IRobustRandom _random = null!;
[ComponentDependency] private readonly ApcPowerReceiverComponent? _powerReceiverComponent = default!; [Dependency] private readonly IEntityManager _entityManager = default!;
[ComponentDependency] private readonly WiresComponent? _wiresComponent = default!; private bool Powered => _entityManager.TryGetComponent<ApcPowerReceiverComponent>(Owner, out var powerReceiverComponent) && powerReceiverComponent.Powered;
private bool Powered => _powerReceiverComponent != null && _powerReceiverComponent.Powered;
[ViewVariables] private BoundUserInterface? UserInterface => Owner.GetUIOrNull(SpaceVillainArcadeUiKey.Key); [ViewVariables] private BoundUserInterface? UserInterface => Owner.GetUIOrNull(SpaceVillainArcadeUiKey.Key);
[ViewVariables] private bool _overflowFlag; [ViewVariables] private bool _overflowFlag;
@@ -84,9 +82,9 @@ namespace Content.Server.Arcade.Components
_game ??= new SpaceVillainGame(this); _game ??= new SpaceVillainGame(this);
if (_wiresComponent?.IsPanelOpen == true) if (_entityManager.TryGetComponent<WiresComponent>(Owner, out var wiresComponent) && wiresComponent.IsPanelOpen)
{ {
_wiresComponent.OpenInterface(actor.PlayerSession); wiresComponent.OpenInterface(actor.PlayerSession);
} }
else else
{ {
@@ -205,13 +203,15 @@ namespace Content.Server.Arcade.Components
public void IndicatorUpdate() public void IndicatorUpdate()
{ {
_wiresComponent?.SetStatus(Indicators.HealthManager, if (!_entityManager.TryGetComponent<WiresComponent>(Owner, out var wiresComponent)) return;
wiresComponent.SetStatus(Indicators.HealthManager,
new SharedWiresComponent.StatusLightData(Color.Purple, new SharedWiresComponent.StatusLightData(Color.Purple,
_playerInvincibilityFlag || _enemyInvincibilityFlag _playerInvincibilityFlag || _enemyInvincibilityFlag
? SharedWiresComponent.StatusLightState.BlinkingSlow ? SharedWiresComponent.StatusLightState.BlinkingSlow
: SharedWiresComponent.StatusLightState.On, : SharedWiresComponent.StatusLightState.On,
"MNGR")); "MNGR"));
_wiresComponent?.SetStatus(Indicators.HealthLimiter, wiresComponent.SetStatus(Indicators.HealthLimiter,
new SharedWiresComponent.StatusLightData(Color.Red, new SharedWiresComponent.StatusLightData(Color.Red,
_overflowFlag _overflowFlag
? SharedWiresComponent.StatusLightState.BlinkingSlow ? SharedWiresComponent.StatusLightState.BlinkingSlow

View File

@@ -43,7 +43,7 @@ namespace Content.Server.Atmos.Components
private int _integrity = 3; private int _integrity = 3;
[ComponentDependency] private readonly ItemActionsComponent? _itemActions = null; [Dependency] private readonly IEntityManager _entityManager = default!;
[ViewVariables] private BoundUserInterface? _userInterface; [ViewVariables] private BoundUserInterface? _userInterface;
@@ -190,8 +190,8 @@ namespace Content.Server.Atmos.Components
CanConnectInternals = IsFunctional && internals != null CanConnectInternals = IsFunctional && internals != null
}); });
if (internals == null) return; if (internals == null || !_entityManager.TryGetComponent<ItemActionsComponent>(Owner, out var itemActions)) return;
_itemActions?.GrantOrUpdate(ItemActionType.ToggleInternals, IsFunctional, IsConnected); itemActions.GrantOrUpdate(ItemActionType.ToggleInternals, IsFunctional, IsConnected);
} }
private void UserInterfaceOnOnReceiveMessage(ServerBoundUserInterfaceMessage message) private void UserInterfaceOnOnReceiveMessage(ServerBoundUserInterfaceMessage message)

View File

@@ -8,6 +8,7 @@ using Content.Server.VendingMachines; // TODO: Move this out of vending machines
using Content.Server.WireHacking; using Content.Server.WireHacking;
using Content.Shared.Atmos.Monitor.Components; using Content.Shared.Atmos.Monitor.Components;
using Robust.Shared.GameObjects; using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.Maths; using Robust.Shared.Maths;
using Robust.Shared.Network; using Robust.Shared.Network;
using Robust.Shared.ViewVariables; using Robust.Shared.ViewVariables;
@@ -19,10 +20,7 @@ namespace Content.Server.Atmos.Monitor.Components
[RegisterComponent] [RegisterComponent]
public class AirAlarmComponent : Component, IWires public class AirAlarmComponent : Component, IWires
{ {
[ComponentDependency] public readonly ApcPowerReceiverComponent? DeviceRecvComponent = default!; [Dependency] private readonly IEntityManager _entMan = default!;
[ComponentDependency] public readonly AtmosMonitorComponent? AtmosMonitorComponent = default!;
[ComponentDependency] public readonly DeviceNetworkComponent? DeviceNetComponent = default!;
[ComponentDependency] public readonly WiresComponent? WiresComponent = null;
private AirAlarmSystem? _airAlarmSystem; private AirAlarmSystem? _airAlarmSystem;
@@ -79,7 +77,7 @@ namespace Content.Server.Atmos.Monitor.Components
if (_airAlarmSystem == null) if (_airAlarmSystem == null)
_airAlarmSystem = EntitySystem.Get<AirAlarmSystem>(); _airAlarmSystem = EntitySystem.Get<AirAlarmSystem>();
if (WiresComponent == null) return; if (!_entMan.TryGetComponent<WiresComponent>(Owner, out var wires)) return;
var pwrLightState = (PowerPulsed, PowerCut) switch { var pwrLightState = (PowerPulsed, PowerCut) switch {
(true, false) => StatusLightState.BlinkingFast, (true, false) => StatusLightState.BlinkingFast,
@@ -91,7 +89,7 @@ namespace Content.Server.Atmos.Monitor.Components
var accessLight = new StatusLightData( var accessLight = new StatusLightData(
Color.Green, Color.Green,
WiresComponent.IsWireCut(Wires.Access) ? StatusLightState.Off : StatusLightState.On, wires.IsWireCut(Wires.Access) ? StatusLightState.Off : StatusLightState.On,
"ACC" "ACC"
); );
@@ -103,17 +101,17 @@ namespace Content.Server.Atmos.Monitor.Components
var syncLightState = StatusLightState.BlinkingSlow; var syncLightState = StatusLightState.BlinkingSlow;
if (AtmosMonitorComponent != null && !AtmosMonitorComponent.NetEnabled) if (_entMan.TryGetComponent<AtmosMonitorComponent>(Owner, out var atmosMonitorComponent) && !atmosMonitorComponent.NetEnabled)
syncLightState = StatusLightState.Off; syncLightState = StatusLightState.Off;
else if (DeviceData.Count != 0) else if (DeviceData.Count != 0)
syncLightState = StatusLightState.On; syncLightState = StatusLightState.On;
var syncLight = new StatusLightData(Color.Orange, syncLightState, "NET"); var syncLight = new StatusLightData(Color.Orange, syncLightState, "NET");
WiresComponent.SetStatus(AirAlarmWireStatus.Power, powerLight); wires.SetStatus(AirAlarmWireStatus.Power, powerLight);
WiresComponent.SetStatus(AirAlarmWireStatus.Access, accessLight); wires.SetStatus(AirAlarmWireStatus.Access, accessLight);
WiresComponent.SetStatus(AirAlarmWireStatus.Panic, panicLight); wires.SetStatus(AirAlarmWireStatus.Panic, panicLight);
WiresComponent.SetStatus(AirAlarmWireStatus.DeviceSync, syncLight); wires.SetStatus(AirAlarmWireStatus.DeviceSync, syncLight);
} }
private bool _powerCut; private bool _powerCut;
@@ -140,14 +138,14 @@ namespace Content.Server.Atmos.Monitor.Components
private void SetPower() private void SetPower()
{ {
if (DeviceRecvComponent != null if (_entMan.TryGetComponent<ApcPowerReceiverComponent>(Owner, out var receiverComponent)
&& WiresComponent != null) && _entMan.HasComponent<WiresComponent>(Owner))
DeviceRecvComponent.PowerDisabled = PowerPulsed || PowerCut; receiverComponent.PowerDisabled = PowerPulsed || PowerCut;
} }
public void WiresUpdate(WiresUpdateEventArgs args) public void WiresUpdate(WiresUpdateEventArgs args)
{ {
if (DeviceNetComponent == null) return; if (!_entMan.TryGetComponent<DeviceNetworkComponent>(Owner, out var deviceNetworkComponent)) return;
if (_airAlarmSystem == null) if (_airAlarmSystem == null)
_airAlarmSystem = EntitySystem.Get<AirAlarmSystem>(); _airAlarmSystem = EntitySystem.Get<AirAlarmSystem>();
@@ -167,7 +165,7 @@ namespace Content.Server.Atmos.Monitor.Components
break; break;
case Wires.Panic: case Wires.Panic:
if (CurrentMode != AirAlarmMode.Panic) if (CurrentMode != AirAlarmMode.Panic)
_airAlarmSystem.SetMode(Owner, DeviceNetComponent.Address, AirAlarmMode.Panic, true, false); _airAlarmSystem.SetMode(Owner, deviceNetworkComponent.Address, AirAlarmMode.Panic, true, false);
break; break;
case Wires.DeviceSync: case Wires.DeviceSync:
_airAlarmSystem.SyncAllDevices(Owner); _airAlarmSystem.SyncAllDevices(Owner);
@@ -184,14 +182,14 @@ namespace Content.Server.Atmos.Monitor.Components
break; break;
case Wires.Panic: case Wires.Panic:
if (CurrentMode == AirAlarmMode.Panic) if (CurrentMode == AirAlarmMode.Panic)
_airAlarmSystem.SetMode(Owner, DeviceNetComponent.Address, AirAlarmMode.Filtering, true, false); _airAlarmSystem.SetMode(Owner, deviceNetworkComponent.Address, AirAlarmMode.Filtering, true, false);
break; break;
case Wires.Access: case Wires.Access:
FullAccess = false; FullAccess = false;
break; break;
case Wires.DeviceSync: case Wires.DeviceSync:
if (AtmosMonitorComponent != null) if (_entMan.TryGetComponent<AtmosMonitorComponent>(Owner, out var atmosMonitorComponent))
AtmosMonitorComponent.NetEnabled = true; atmosMonitorComponent.NetEnabled = true;
break; break;
} }
@@ -201,10 +199,10 @@ namespace Content.Server.Atmos.Monitor.Components
{ {
case Wires.DeviceSync: case Wires.DeviceSync:
DeviceData.Clear(); DeviceData.Clear();
if (AtmosMonitorComponent != null) if (_entMan.TryGetComponent<AtmosMonitorComponent>(Owner, out var atmosMonitorComponent))
{ {
AtmosMonitorComponent.NetworkAlarmStates.Clear(); atmosMonitorComponent.NetworkAlarmStates.Clear();
AtmosMonitorComponent.NetEnabled = false; atmosMonitorComponent.NetEnabled = false;
} }
break; break;

View File

@@ -16,12 +16,6 @@ namespace Content.Server.Atmos.Monitor.Components
{ {
public override string Name => "AtmosMonitor"; public override string Name => "AtmosMonitor";
// Requires power. No logic related to this will be performed here, however,
// save for ensuring that the data is valid upon set.
// This is how the system discovers entities that are alarmable.
[ComponentDependency] public readonly ApcPowerReceiverComponent? PowerRecvComponent = default!;
[ComponentDependency] public readonly AtmosDeviceComponent? AtmosDeviceComponent = default!;
// Whether this monitor can send alarms, // Whether this monitor can send alarms,
// or recieve atmos command events. // or recieve atmos command events.
// //

View File

@@ -9,6 +9,7 @@ using Content.Shared.Atmos.Monitor;
using Content.Shared.Atmos.Monitor.Components; using Content.Shared.Atmos.Monitor.Components;
using Robust.Server.GameObjects; using Robust.Server.GameObjects;
using Robust.Shared.GameObjects; using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.Log; using Robust.Shared.Log;
using Robust.Shared.Maths; using Robust.Shared.Maths;
using static Content.Shared.Wires.SharedWiresComponent; using static Content.Shared.Wires.SharedWiresComponent;
@@ -20,9 +21,7 @@ namespace Content.Server.Atmos.Monitor.Components
[RegisterComponent] [RegisterComponent]
public class FireAlarmComponent : Component, IWires public class FireAlarmComponent : Component, IWires
{ {
[ComponentDependency] public readonly ApcPowerReceiverComponent? DeviceRecvComponent = default!; [Dependency] private readonly IEntityManager _entMan = default!;
[ComponentDependency] public readonly AtmosMonitorComponent? AtmosMonitorComponent = default!;
[ComponentDependency] public readonly WiresComponent? WiresComponent = null;
private AtmosMonitorSystem? _atmosMonitorSystem; private AtmosMonitorSystem? _atmosMonitorSystem;
@@ -69,9 +68,8 @@ namespace Content.Server.Atmos.Monitor.Components
private void SetPower() private void SetPower()
{ {
if (DeviceRecvComponent != null if (_entMan.TryGetComponent<ApcPowerReceiverComponent>(Owner, out var receiverComponent) && _entMan.HasComponent<WiresComponent>(Owner))
&& WiresComponent != null) receiverComponent.PowerDisabled = PowerPulsed || PowerCut;
DeviceRecvComponent.PowerDisabled = PowerPulsed || PowerCut;
} }
@@ -87,7 +85,7 @@ namespace Content.Server.Atmos.Monitor.Components
public void UpdateWires() public void UpdateWires()
{ {
if (WiresComponent == null) return; if (!_entMan.TryGetComponent<WiresComponent>(Owner, out var wiresComponent)) return;
var powerLight = new StatusLightData(Color.Yellow, StatusLightState.On, "POWR"); var powerLight = new StatusLightData(Color.Yellow, StatusLightState.On, "POWR");
@@ -98,14 +96,14 @@ namespace Content.Server.Atmos.Monitor.Components
var syncLight = new StatusLightData(Color.Orange, StatusLightState.On, "NET"); var syncLight = new StatusLightData(Color.Orange, StatusLightState.On, "NET");
if (AtmosMonitorComponent != null) if (_entMan.TryGetComponent<AtmosMonitorComponent>(Owner, out var atmosMonitorComponent))
if (!AtmosMonitorComponent.NetEnabled) if (!atmosMonitorComponent.NetEnabled)
syncLight = new StatusLightData(Color.Orange, StatusLightState.Off, "NET"); syncLight = new StatusLightData(Color.Orange, StatusLightState.Off, "NET");
else if (AtmosMonitorComponent.HighestAlarmInNetwork == AtmosMonitorAlarmType.Danger) else if (atmosMonitorComponent.HighestAlarmInNetwork == AtmosMonitorAlarmType.Danger)
syncLight = new StatusLightData(Color.Orange, StatusLightState.BlinkingFast, "NET"); syncLight = new StatusLightData(Color.Orange, StatusLightState.BlinkingFast, "NET");
WiresComponent.SetStatus(FireAlarmWireStatus.Power, powerLight); wiresComponent.SetStatus(FireAlarmWireStatus.Power, powerLight);
WiresComponent.SetStatus(FireAlarmWireStatus.Alarm, syncLight); wiresComponent.SetStatus(FireAlarmWireStatus.Alarm, syncLight);
} }
public void WiresUpdate(WiresUpdateEventArgs args) public void WiresUpdate(WiresUpdateEventArgs args)
@@ -127,8 +125,8 @@ namespace Content.Server.Atmos.Monitor.Components
_powerPulsedCancel.Token); _powerPulsedCancel.Token);
break; break;
case Wires.Alarm: case Wires.Alarm:
if (AtmosMonitorComponent != null) if (_entMan.TryGetComponent<AtmosMonitorComponent>(Owner, out var atmosMonitorComponent))
_atmosMonitorSystem.Alert(Owner, AtmosMonitorAlarmType.Danger); _atmosMonitorSystem.Alert(Owner, AtmosMonitorAlarmType.Danger, monitor: atmosMonitorComponent);
break; break;
} }
@@ -142,8 +140,8 @@ namespace Content.Server.Atmos.Monitor.Components
PowerCut = false; PowerCut = false;
break; break;
case Wires.Alarm: case Wires.Alarm:
if (AtmosMonitorComponent != null) if (_entMan.TryGetComponent<AtmosMonitorComponent>(Owner, out var atmosMonitorComponent))
AtmosMonitorComponent.NetEnabled = true; atmosMonitorComponent.NetEnabled = true;
break; break;
} }
@@ -155,8 +153,8 @@ namespace Content.Server.Atmos.Monitor.Components
PowerCut = true; PowerCut = true;
break; break;
case Wires.Alarm: case Wires.Alarm:
if (AtmosMonitorComponent != null) if (_entMan.TryGetComponent<AtmosMonitorComponent>(Owner, out var atmosMonitorComponent))
AtmosMonitorComponent.NetEnabled = false; atmosMonitorComponent.NetEnabled = false;
break; break;
} }

View File

@@ -392,7 +392,7 @@ namespace Content.Server.Atmos.Monitor.Systems
// _airAlarmDataSystem.UpdateDeviceData(uid, args.SenderAddress, data); // _airAlarmDataSystem.UpdateDeviceData(uid, args.SenderAddress, data);
// //
_uiSystem.TrySendUiMessage(uid, SharedAirAlarmInterfaceKey.Key, new AirAlarmUpdateDeviceDataMessage(args.SenderAddress, data)); _uiSystem.TrySendUiMessage(uid, SharedAirAlarmInterfaceKey.Key, new AirAlarmUpdateDeviceDataMessage(args.SenderAddress, data));
if (controller.WiresComponent != null) controller.UpdateWires(); if (HasComp<WiresComponent>(uid)) controller.UpdateWires();
if (!controller.DeviceData.TryAdd(args.SenderAddress, data)) if (!controller.DeviceData.TryAdd(args.SenderAddress, data))
controller.DeviceData[args.SenderAddress] = data; controller.DeviceData[args.SenderAddress] = data;

View File

@@ -98,10 +98,10 @@ namespace Content.Server.Atmos.Monitor.Systems
private void OnAtmosMonitorStartup(EntityUid uid, AtmosMonitorComponent component, ComponentStartup args) private void OnAtmosMonitorStartup(EntityUid uid, AtmosMonitorComponent component, ComponentStartup args)
{ {
if (component.PowerRecvComponent == null if (!HasComp<ApcPowerReceiverComponent>(uid)
&& component.AtmosDeviceComponent != null) && TryComp<AtmosDeviceComponent>(uid, out var atmosDeviceComponent))
{ {
_atmosDeviceSystem.LeaveAtmosphere(component.AtmosDeviceComponent); _atmosDeviceSystem.LeaveAtmosphere(atmosDeviceComponent);
return; return;
} }
@@ -204,28 +204,29 @@ namespace Content.Server.Atmos.Monitor.Systems
private void OnPowerChangedEvent(EntityUid uid, AtmosMonitorComponent component, PowerChangedEvent args) private void OnPowerChangedEvent(EntityUid uid, AtmosMonitorComponent component, PowerChangedEvent args)
{ {
if (!args.Powered) if (TryComp<AtmosDeviceComponent>(uid, out var atmosDeviceComponent))
{ {
if (component.AtmosDeviceComponent != null if (!args.Powered)
&& component.AtmosDeviceComponent.JoinedGrid != null)
{ {
_atmosDeviceSystem.LeaveAtmosphere(component.AtmosDeviceComponent); if (atmosDeviceComponent.JoinedGrid != null)
component.TileGas = null; {
} _atmosDeviceSystem.LeaveAtmosphere(atmosDeviceComponent);
component.TileGas = null;
}
// clear memory when power cycled // clear memory when power cycled
component.LastAlarmState = AtmosMonitorAlarmType.Normal; component.LastAlarmState = AtmosMonitorAlarmType.Normal;
component.NetworkAlarmStates.Clear(); component.NetworkAlarmStates.Clear();
} }
else if (args.Powered) else if (args.Powered)
{
if (component.AtmosDeviceComponent != null
&& component.AtmosDeviceComponent.JoinedGrid == null)
{ {
_atmosDeviceSystem.JoinAtmosphere(component.AtmosDeviceComponent); if (atmosDeviceComponent.JoinedGrid == null)
var coords = Transform(component.Owner).Coordinates; {
var air = _atmosphereSystem.GetTileMixture(coords); _atmosDeviceSystem.JoinAtmosphere(atmosDeviceComponent);
component.TileGas = air; var coords = Transform(component.Owner).Coordinates;
var air = _atmosphereSystem.GetTileMixture(coords);
component.TileGas = air;
}
} }
} }
@@ -238,8 +239,8 @@ namespace Content.Server.Atmos.Monitor.Systems
private void OnFireEvent(EntityUid uid, AtmosMonitorComponent component, TileFireEvent args) private void OnFireEvent(EntityUid uid, AtmosMonitorComponent component, TileFireEvent args)
{ {
if (component.PowerRecvComponent == null if (!TryComp<ApcPowerReceiverComponent>(uid, out var powerReceiverComponent)
|| !component.PowerRecvComponent.Powered) || !powerReceiverComponent.Powered)
return; return;
// if we're monitoring for atmos fire, then we make it similar to a smoke detector // if we're monitoring for atmos fire, then we make it similar to a smoke detector
@@ -261,15 +262,15 @@ namespace Content.Server.Atmos.Monitor.Systems
private void OnAtmosUpdate(EntityUid uid, AtmosMonitorComponent component, AtmosDeviceUpdateEvent args) private void OnAtmosUpdate(EntityUid uid, AtmosMonitorComponent component, AtmosDeviceUpdateEvent args)
{ {
if (component.PowerRecvComponent == null if (!TryComp<ApcPowerReceiverComponent>(uid, out var powerReceiverComponent)
|| !component.PowerRecvComponent.Powered) || !powerReceiverComponent.Powered)
return; return;
// can't hurt // can't hurt
// (in case something is making AtmosDeviceUpdateEvents // (in case something is making AtmosDeviceUpdateEvents
// outside the typical device loop) // outside the typical device loop)
if (component.AtmosDeviceComponent == null if (!TryComp<AtmosDeviceComponent>(uid, out var atmosDeviceComponent)
|| component.AtmosDeviceComponent.JoinedGrid == null) || atmosDeviceComponent.JoinedGrid == null)
return; return;
// if we're not monitoring atmos, don't bother // if we're not monitoring atmos, don't bother

View File

@@ -46,7 +46,6 @@ namespace Content.Server.Botany.Components
[Dependency] private readonly IPrototypeManager _prototypeManager = default!; [Dependency] private readonly IPrototypeManager _prototypeManager = default!;
[Dependency] private readonly IGameTiming _gameTiming = default!; [Dependency] private readonly IGameTiming _gameTiming = default!;
[Dependency] private readonly IEntityManager _entMan = default!; [Dependency] private readonly IEntityManager _entMan = default!;
[ComponentDependency] private readonly AppearanceComponent? _appearanceComponent = default!;
public override string Name => "PlantHolder"; public override string Name => "PlantHolder";
@@ -583,50 +582,50 @@ namespace Content.Server.Botany.Components
{ {
_updateSpriteAfterUpdate = false; _updateSpriteAfterUpdate = false;
if (_appearanceComponent == null) if (!_entMan.TryGetComponent<AppearanceComponent>(Owner, out var appearanceComponent))
return; return;
if (Seed != null) if (Seed != null)
{ {
if (DrawWarnings) if (DrawWarnings)
_appearanceComponent.SetData(PlantHolderVisuals.HealthLight, Health <= (Seed.Endurance / 2f)); appearanceComponent.SetData(PlantHolderVisuals.HealthLight, Health <= (Seed.Endurance / 2f));
if (Dead) if (Dead)
{ {
_appearanceComponent.SetData(PlantHolderVisuals.Plant, appearanceComponent.SetData(PlantHolderVisuals.Plant,
new SpriteSpecifier.Rsi(Seed.PlantRsi, "dead")); new SpriteSpecifier.Rsi(Seed.PlantRsi, "dead"));
} }
else if (Harvest) else if (Harvest)
{ {
_appearanceComponent.SetData(PlantHolderVisuals.Plant, appearanceComponent.SetData(PlantHolderVisuals.Plant,
new SpriteSpecifier.Rsi(Seed.PlantRsi, "harvest")); new SpriteSpecifier.Rsi(Seed.PlantRsi, "harvest"));
} }
else if (Age < Seed.Maturation) else if (Age < Seed.Maturation)
{ {
var growthStage = Math.Max(1, (int) ((Age * Seed.GrowthStages) / Seed.Maturation)); var growthStage = Math.Max(1, (int) ((Age * Seed.GrowthStages) / Seed.Maturation));
_appearanceComponent.SetData(PlantHolderVisuals.Plant, appearanceComponent.SetData(PlantHolderVisuals.Plant,
new SpriteSpecifier.Rsi(Seed.PlantRsi, $"stage-{growthStage}")); new SpriteSpecifier.Rsi(Seed.PlantRsi, $"stage-{growthStage}"));
_lastProduce = Age; _lastProduce = Age;
} }
else else
{ {
_appearanceComponent.SetData(PlantHolderVisuals.Plant, appearanceComponent.SetData(PlantHolderVisuals.Plant,
new SpriteSpecifier.Rsi(Seed.PlantRsi, $"stage-{Seed.GrowthStages}")); new SpriteSpecifier.Rsi(Seed.PlantRsi, $"stage-{Seed.GrowthStages}"));
} }
} }
else else
{ {
_appearanceComponent.SetData(PlantHolderVisuals.Plant, SpriteSpecifier.Invalid); appearanceComponent.SetData(PlantHolderVisuals.Plant, SpriteSpecifier.Invalid);
_appearanceComponent.SetData(PlantHolderVisuals.HealthLight, false); appearanceComponent.SetData(PlantHolderVisuals.HealthLight, false);
} }
if (!DrawWarnings) return; if (!DrawWarnings) return;
_appearanceComponent.SetData(PlantHolderVisuals.WaterLight, WaterLevel <= 10); appearanceComponent.SetData(PlantHolderVisuals.WaterLight, WaterLevel <= 10);
_appearanceComponent.SetData(PlantHolderVisuals.NutritionLight, NutritionLevel <= 2); appearanceComponent.SetData(PlantHolderVisuals.NutritionLight, NutritionLevel <= 2);
_appearanceComponent.SetData(PlantHolderVisuals.AlertLight, appearanceComponent.SetData(PlantHolderVisuals.AlertLight,
WeedLevel >= 5 || PestLevel >= 5 || Toxins >= 40 || ImproperHeat || ImproperLight || ImproperPressure || WeedLevel >= 5 || PestLevel >= 5 || Toxins >= 40 || ImproperHeat || ImproperLight || ImproperPressure ||
_missingGas > 0); _missingGas > 0);
_appearanceComponent.SetData(PlantHolderVisuals.HarvestLight, Harvest); appearanceComponent.SetData(PlantHolderVisuals.HarvestLight, Harvest);
} }
public void CheckForDivergence(bool modified) public void CheckForDivergence(bool modified)
@@ -735,10 +734,10 @@ namespace Content.Server.Botany.Components
var targetEntity = Owner; var targetEntity = Owner;
var solutionEntity = usingItem; var solutionEntity = usingItem;
SoundSystem.Play(Filter.Pvs(usingItem), spray.SpraySound.GetSound(), usingItem, SoundSystem.Play(Filter.Pvs(usingItem), spray.SpraySound.GetSound(), usingItem,
AudioHelpers.WithVariation(0.125f)); AudioHelpers.WithVariation(0.125f));
var split = solutionSystem.Drain(solutionEntity, solution, amount); var split = solutionSystem.Drain(solutionEntity, solution, amount);

View File

@@ -12,8 +12,6 @@ namespace Content.Server.Botany.Components
[RegisterComponent] [RegisterComponent]
public class SeedExtractorComponent : Component, IInteractUsing public class SeedExtractorComponent : Component, IInteractUsing
{ {
[ComponentDependency] private readonly ApcPowerReceiverComponent? _powerReceiver = default!;
[Dependency] private readonly IEntityManager _entMan = default!; [Dependency] private readonly IEntityManager _entMan = default!;
[Dependency] private readonly IRobustRandom _random = default!; [Dependency] private readonly IRobustRandom _random = default!;
@@ -25,7 +23,7 @@ namespace Content.Server.Botany.Components
async Task<bool> IInteractUsing.InteractUsing(InteractUsingEventArgs eventArgs) async Task<bool> IInteractUsing.InteractUsing(InteractUsingEventArgs eventArgs)
{ {
if (!_powerReceiver?.Powered ?? false) if (!_entMan.TryGetComponent<ApcPowerReceiverComponent>(Owner, out var powerReceiverComponent) || !powerReceiverComponent.Powered)
return false; return false;
if (_entMan.TryGetComponent(eventArgs.Using, out ProduceComponent? produce) && produce.Seed != null) if (_entMan.TryGetComponent(eventArgs.Using, out ProduceComponent? produce) && produce.Seed != null)

View File

@@ -11,6 +11,7 @@ using Content.Shared.Popups;
using Content.Shared.Pulling.Components; using Content.Shared.Pulling.Components;
using Content.Shared.Standing; using Content.Shared.Standing;
using Content.Shared.Stunnable; using Content.Shared.Stunnable;
using Robust.Server.GameObjects;
using Robust.Shared.Audio; using Robust.Shared.Audio;
using Robust.Shared.Containers; using Robust.Shared.Containers;
using Robust.Shared.GameObjects; using Robust.Shared.GameObjects;
@@ -34,9 +35,6 @@ namespace Content.Server.Buckle.Components
[Dependency] private readonly IEntityManager _entMan = default!; [Dependency] private readonly IEntityManager _entMan = default!;
[Dependency] private readonly IGameTiming _gameTiming = default!; [Dependency] private readonly IGameTiming _gameTiming = default!;
[ComponentDependency] public readonly AppearanceComponent? Appearance = null;
[ComponentDependency] private readonly MobStateComponent? _mobState = null;
[DataField("size")] [DataField("size")]
private int _size = 100; private int _size = 100;
@@ -234,7 +232,8 @@ namespace Content.Server.Buckle.Components
return false; return false;
} }
Appearance?.SetData(BuckleVisuals.Buckled, true); if(_entMan.TryGetComponent<AppearanceComponent>(Owner, out var appearance))
appearance.SetData(BuckleVisuals.Buckled, true);
ReAttach(strap); ReAttach(strap);
@@ -324,10 +323,11 @@ namespace Content.Server.Buckle.Components
xform.Coordinates = oldBuckledXform.Coordinates.Offset(oldBuckledTo.UnbuckleOffset); xform.Coordinates = oldBuckledXform.Coordinates.Offset(oldBuckledTo.UnbuckleOffset);
} }
Appearance?.SetData(BuckleVisuals.Buckled, false); if(_entMan.TryGetComponent<AppearanceComponent>(Owner, out var appearance))
appearance.SetData(BuckleVisuals.Buckled, false);
if (_entMan.HasComponent<KnockedDownComponent>(Owner) if (_entMan.HasComponent<KnockedDownComponent>(Owner)
|| (_mobState?.IsIncapacitated() ?? false)) | _entMan.TryGetComponent<MobStateComponent>(Owner, out var mobState) && mobState.IsIncapacitated())
{ {
EntitySystem.Get<StandingStateSystem>().Down(Owner); EntitySystem.Get<StandingStateSystem>().Down(Owner);
} }
@@ -336,7 +336,7 @@ namespace Content.Server.Buckle.Components
EntitySystem.Get<StandingStateSystem>().Stand(Owner); EntitySystem.Get<StandingStateSystem>().Stand(Owner);
} }
_mobState?.CurrentState?.EnterState(Owner, _entMan); mobState?.CurrentState?.EnterState(Owner, _entMan);
UpdateBuckleStatus(); UpdateBuckleStatus();
@@ -397,9 +397,9 @@ namespace Content.Server.Buckle.Components
if (BuckledTo != null && if (BuckledTo != null &&
_entMan.GetComponent<TransformComponent>(BuckledTo.Owner).LocalRotation.GetCardinalDir() == Direction.North && _entMan.GetComponent<TransformComponent>(BuckledTo.Owner).LocalRotation.GetCardinalDir() == Direction.North &&
BuckledTo.SpriteComponent != null) _entMan.TryGetComponent<SpriteComponent>(BuckledTo.Owner, out var spriteComponent))
{ {
drawDepth = BuckledTo.SpriteComponent.DrawDepth - 1; drawDepth = spriteComponent.DrawDepth - 1;
} }
return new BuckleComponentState(Buckled, drawDepth, LastEntityBuckledTo, DontCollide); return new BuckleComponentState(Buckled, drawDepth, LastEntityBuckledTo, DontCollide);

View File

@@ -20,7 +20,7 @@ namespace Content.Server.Buckle.Components
[ComponentReference(typeof(SharedStrapComponent))] [ComponentReference(typeof(SharedStrapComponent))]
public class StrapComponent : SharedStrapComponent, IInteractHand, ISerializationHooks, IDestroyAct public class StrapComponent : SharedStrapComponent, IInteractHand, ISerializationHooks, IDestroyAct
{ {
[ComponentDependency] public readonly SpriteComponent? SpriteComponent = null; [Dependency] private readonly IEntityManager _entityManager = default!;
private readonly HashSet<EntityUid> _buckledEntities = new(); private readonly HashSet<EntityUid> _buckledEntities = new();
@@ -153,7 +153,8 @@ namespace Content.Server.Buckle.Components
_occupiedSize += buckle.Size; _occupiedSize += buckle.Size;
buckle.Appearance?.SetData(StrapVisuals.RotationAngle, _rotation); if(_entityManager.TryGetComponent<AppearanceComponent>(buckle.Owner, out var appearanceComponent))
appearanceComponent.SetData(StrapVisuals.RotationAngle, _rotation);
// Update the visuals of the strap object // Update the visuals of the strap object
if (IoCManager.Resolve<IEntityManager>().TryGetComponent<AppearanceComponent>(Owner, out var appearance)) if (IoCManager.Resolve<IEntityManager>().TryGetComponent<AppearanceComponent>(Owner, out var appearance))

View File

@@ -14,6 +14,7 @@ namespace Content.Server.Climbing.Components
public class ClimbingComponent : SharedClimbingComponent public class ClimbingComponent : SharedClimbingComponent
{ {
[Dependency] private readonly IGameTiming _gameTiming = default!; [Dependency] private readonly IGameTiming _gameTiming = default!;
[Dependency] private readonly IEntityManager _entityManager = default!;
public override bool IsClimbing public override bool IsClimbing
{ {
@@ -73,7 +74,7 @@ namespace Content.Server.Climbing.Components
/// </summary> /// </summary>
public void TryMoveTo(Vector2 from, Vector2 to) public void TryMoveTo(Vector2 from, Vector2 to)
{ {
if (Body == null) return; if (!_entityManager.TryGetComponent<PhysicsComponent>(Owner, out var physicsComponent)) return;
var velocity = (to - from).Length; var velocity = (to - from).Length;
@@ -82,7 +83,7 @@ namespace Content.Server.Climbing.Components
// Since there are bodies with different masses: // Since there are bodies with different masses:
// mass * 5 seems enough to move entity // mass * 5 seems enough to move entity
// instead of launching cats like rockets against the walls with constant impulse value. // instead of launching cats like rockets against the walls with constant impulse value.
Body.ApplyLinearImpulse((to - from).Normalized * velocity * Body.Mass * 5); physicsComponent.ApplyLinearImpulse((to - from).Normalized * velocity * physicsComponent.Mass * 5);
OwnerIsTransitioning = true; OwnerIsTransitioning = true;
EntitySystem.Get<ClimbSystem>().UnsetTransitionBoolAfterBufferTime(Owner, this); EntitySystem.Get<ClimbSystem>().UnsetTransitionBoolAfterBufferTime(Owner, this);

View File

@@ -20,9 +20,7 @@ namespace Content.Server.Clothing.Components
[ComponentReference(typeof(SharedMagbootsComponent))] [ComponentReference(typeof(SharedMagbootsComponent))]
public sealed class MagbootsComponent : SharedMagbootsComponent, IActivate public sealed class MagbootsComponent : SharedMagbootsComponent, IActivate
{ {
[ComponentDependency] private SharedItemComponent? _item = null; [Dependency] private readonly IEntityManager _entMan = default!;
[ComponentDependency] private ItemActionsComponent? _itemActions = null;
[ComponentDependency] private SpriteComponent? _sprite = null;
private bool _on; private bool _on;
@@ -40,10 +38,12 @@ namespace Content.Server.Clothing.Components
EntitySystem.Get<MagbootsSystem>().UpdateMagbootEffects(container.Owner, Owner, true, this); EntitySystem.Get<MagbootsSystem>().UpdateMagbootEffects(container.Owner, Owner, true, this);
} }
_itemActions?.Toggle(ItemActionType.ToggleMagboots, On); if(_entMan.TryGetComponent<ItemActionsComponent>(Owner, out var itemActions))
if (_item != null) itemActions.Toggle(ItemActionType.ToggleMagboots, On);
_item.EquippedPrefix = On ? "on" : null; if (_entMan.TryGetComponent<SharedItemComponent>(Owner, out var item))
_sprite?.LayerSetState(0, On ? "icon-on" : "icon"); item.EquippedPrefix = On ? "on" : null;
if(_entMan.TryGetComponent<SpriteComponent>(Owner, out var sprite))
sprite.LayerSetState(0, On ? "icon-on" : "icon");
OnChanged(); OnChanged();
Dirty(); Dirty();
} }

View File

@@ -23,20 +23,10 @@ namespace Content.Server.Doors.Components
[RegisterComponent] [RegisterComponent]
public class AirlockComponent : Component, IWires public class AirlockComponent : Component, IWires
{ {
[Dependency] private readonly IEntityManager _entityManager = default!;
public override string Name => "Airlock"; public override string Name => "Airlock";
[ComponentDependency]
public readonly ServerDoorComponent? DoorComponent = null;
[ComponentDependency]
public readonly AppearanceComponent? AppearanceComponent = null;
[ComponentDependency]
public readonly ApcPowerReceiverComponent? ReceiverComponent = null;
[ComponentDependency]
public readonly WiresComponent? WiresComponent = null;
/// <summary> /// <summary>
/// Sound to play when the bolts on the airlock go up. /// Sound to play when the bolts on the airlock go up.
/// </summary> /// </summary>
@@ -98,7 +88,7 @@ namespace Content.Server.Doors.Components
private bool BoltLightsVisible private bool BoltLightsVisible
{ {
get => _boltLightsWirePulsed && BoltsDown && IsPowered() get => _boltLightsWirePulsed && BoltsDown && IsPowered()
&& DoorComponent != null && DoorComponent.State == SharedDoorComponent.DoorState.Closed; && _entityManager.TryGetComponent<ServerDoorComponent>(Owner, out var doorComponent) && doorComponent.State == SharedDoorComponent.DoorState.Closed;
set set
{ {
_boltLightsWirePulsed = value; _boltLightsWirePulsed = value;
@@ -122,9 +112,10 @@ namespace Content.Server.Doors.Components
{ {
base.Initialize(); base.Initialize();
if (ReceiverComponent != null && AppearanceComponent != null) if (_entityManager.TryGetComponent<ApcPowerReceiverComponent>(Owner, out var receiverComponent) &&
_entityManager.TryGetComponent<AppearanceComponent>(Owner, out var appearanceComponent))
{ {
AppearanceComponent.SetData(DoorVisuals.Powered, ReceiverComponent.Powered); appearanceComponent.SetData(DoorVisuals.Powered, receiverComponent.Powered);
} }
} }
@@ -140,23 +131,23 @@ namespace Content.Server.Doors.Components
public bool IsPowered() public bool IsPowered()
{ {
return ReceiverComponent == null || ReceiverComponent.Powered; return _entityManager.TryGetComponent<ApcPowerReceiverComponent>(Owner, out var receiverComponent) && receiverComponent.Powered;
} }
public void UpdateBoltLightStatus() public void UpdateBoltLightStatus()
{ {
if (AppearanceComponent != null) if (_entityManager.TryGetComponent<AppearanceComponent>(Owner, out var appearanceComponent))
{ {
AppearanceComponent.SetData(DoorVisuals.BoltLights, BoltLightsVisible); appearanceComponent.SetData(DoorVisuals.BoltLights, BoltLightsVisible);
} }
} }
public void UpdateWiresStatus() public void UpdateWiresStatus()
{ {
if (WiresComponent == null) return; if (_entityManager.TryGetComponent<WiresComponent>(Owner, out var wiresComponent)) return;
var mainPowerCut = WiresComponent.IsWireCut(Wires.MainPower); var mainPowerCut = wiresComponent.IsWireCut(Wires.MainPower);
var backupPowerCut = WiresComponent.IsWireCut(Wires.BackupPower); var backupPowerCut = wiresComponent.IsWireCut(Wires.BackupPower);
var statusLightState = PowerWiresPulsed ? StatusLightState.BlinkingFast : StatusLightState.On; var statusLightState = PowerWiresPulsed ? StatusLightState.BlinkingFast : StatusLightState.On;
StatusLightData powerLight; StatusLightData powerLight;
if (mainPowerCut && backupPowerCut) if (mainPowerCut && backupPowerCut)
@@ -190,42 +181,42 @@ namespace Content.Server.Doors.Components
new StatusLightData(Color.Red, Safety ? StatusLightState.On : StatusLightState.Off, "SAFETY"); new StatusLightData(Color.Red, Safety ? StatusLightState.On : StatusLightState.Off, "SAFETY");
WiresComponent.SetStatus(AirlockWireStatus.PowerIndicator, powerLight); wiresComponent.SetStatus(AirlockWireStatus.PowerIndicator, powerLight);
WiresComponent.SetStatus(AirlockWireStatus.BoltIndicator, boltStatus); wiresComponent.SetStatus(AirlockWireStatus.BoltIndicator, boltStatus);
WiresComponent.SetStatus(AirlockWireStatus.BoltLightIndicator, boltLightsStatus); wiresComponent.SetStatus(AirlockWireStatus.BoltLightIndicator, boltLightsStatus);
WiresComponent.SetStatus(AirlockWireStatus.AIControlIndicator, new StatusLightData(Color.Purple, StatusLightState.BlinkingSlow, "AI CTRL")); wiresComponent.SetStatus(AirlockWireStatus.AIControlIndicator, new StatusLightData(Color.Purple, StatusLightState.BlinkingSlow, "AI CTRL"));
WiresComponent.SetStatus(AirlockWireStatus.TimingIndicator, timingStatus); wiresComponent.SetStatus(AirlockWireStatus.TimingIndicator, timingStatus);
WiresComponent.SetStatus(AirlockWireStatus.SafetyIndicator, safetyStatus); wiresComponent.SetStatus(AirlockWireStatus.SafetyIndicator, safetyStatus);
} }
private void UpdatePowerCutStatus() private void UpdatePowerCutStatus()
{ {
if (ReceiverComponent == null) if (!_entityManager.TryGetComponent<ApcPowerReceiverComponent>(Owner, out var receiverComponent))
{ {
return; return;
} }
if (PowerWiresPulsed) if (PowerWiresPulsed)
{ {
ReceiverComponent.PowerDisabled = true; receiverComponent.PowerDisabled = true;
return; return;
} }
if (WiresComponent == null) if (!_entityManager.TryGetComponent<WiresComponent>(Owner, out var wiresComponent))
{ {
return; return;
} }
ReceiverComponent.PowerDisabled = receiverComponent.PowerDisabled =
WiresComponent.IsWireCut(Wires.MainPower) && wiresComponent.IsWireCut(Wires.MainPower) &&
WiresComponent.IsWireCut(Wires.BackupPower); wiresComponent.IsWireCut(Wires.BackupPower);
} }
private void PowerDeviceOnOnPowerStateChanged(PowerChangedMessage e) private void PowerDeviceOnOnPowerStateChanged(PowerChangedMessage e)
{ {
if (AppearanceComponent != null) if (_entityManager.TryGetComponent<AppearanceComponent>(Owner, out var appearanceComponent))
{ {
AppearanceComponent.SetData(DoorVisuals.Powered, e.Powered); appearanceComponent.SetData(DoorVisuals.Powered, e.Powered);
} }
// BoltLights also got out // BoltLights also got out
@@ -290,7 +281,7 @@ namespace Content.Server.Doors.Components
public void WiresUpdate(WiresUpdateEventArgs args) public void WiresUpdate(WiresUpdateEventArgs args)
{ {
if (DoorComponent == null) if (!_entityManager.TryGetComponent<ServerDoorComponent>(Owner, out var doorComponent))
{ {
return; return;
} }
@@ -328,7 +319,7 @@ namespace Content.Server.Doors.Components
break; break;
case Wires.Timing: case Wires.Timing:
AutoCloseDelayModifier = 0.5f; AutoCloseDelayModifier = 0.5f;
DoorComponent.RefreshAutoClose(); doorComponent.RefreshAutoClose();
break; break;
case Wires.Safety: case Wires.Safety:
Safety = !Safety; Safety = !Safety;
@@ -351,7 +342,7 @@ namespace Content.Server.Doors.Components
break; break;
case Wires.Timing: case Wires.Timing:
AutoClose = true; AutoClose = true;
DoorComponent.RefreshAutoClose(); doorComponent.RefreshAutoClose();
break; break;
case Wires.Safety: case Wires.Safety:
Safety = true; Safety = true;
@@ -371,7 +362,7 @@ namespace Content.Server.Doors.Components
break; break;
case Wires.Timing: case Wires.Timing:
AutoClose = false; AutoClose = false;
DoorComponent.RefreshAutoClose(); doorComponent.RefreshAutoClose();
break; break;
case Wires.Safety: case Wires.Safety:
Safety = false; Safety = false;

View File

@@ -18,9 +18,6 @@ namespace Content.Server.Doors.Components
public override string Name => "Firelock"; public override string Name => "Firelock";
[ComponentDependency]
public readonly ServerDoorComponent? DoorComponent = null;
/// <summary> /// <summary>
/// Pry time modifier to be used when the firelock is currently closed due to fire or pressure. /// Pry time modifier to be used when the firelock is currently closed due to fire or pressure.
/// </summary> /// </summary>
@@ -30,9 +27,9 @@ namespace Content.Server.Doors.Components
public bool EmergencyPressureStop() public bool EmergencyPressureStop()
{ {
if (DoorComponent != null && DoorComponent.State == SharedDoorComponent.DoorState.Open && DoorComponent.CanCloseGeneric()) if (_entMan.TryGetComponent<ServerDoorComponent>(Owner, out var doorComp) && doorComp.State == SharedDoorComponent.DoorState.Open && doorComp.CanCloseGeneric())
{ {
DoorComponent.Close(); doorComp.Close();
if (_entMan.TryGetComponent(Owner, out AirtightComponent? airtight)) if (_entMan.TryGetComponent(Owner, out AirtightComponent? airtight))
{ {
EntitySystem.Get<AirtightSystem>().SetAirblocked(airtight, true); EntitySystem.Get<AirtightSystem>().SetAirblocked(airtight, true);

View File

@@ -24,6 +24,7 @@ using Robust.Shared.GameObjects;
using Robust.Shared.IoC; using Robust.Shared.IoC;
using Robust.Shared.Log; using Robust.Shared.Log;
using Robust.Shared.Maths; using Robust.Shared.Maths;
using Robust.Shared.Physics;
using Robust.Shared.Player; using Robust.Shared.Player;
using Robust.Shared.Prototypes; using Robust.Shared.Prototypes;
using Robust.Shared.Serialization.Manager.Attributes; using Robust.Shared.Serialization.Manager.Attributes;
@@ -557,19 +558,19 @@ namespace Content.Server.Doors.Components
/// <returns>True if we crushed somebody, false if we did not.</returns> /// <returns>True if we crushed somebody, false if we did not.</returns>
private bool TryCrush() private bool TryCrush()
{ {
if (PhysicsComponent == null) if (!_entMan.TryGetComponent(Owner, out PhysicsComponent physicsComponent) || physicsComponent is not IPhysBody body)
{ {
return false; return false;
} }
var collidingentities = PhysicsComponent.GetCollidingEntities(Vector2.Zero, false); var collidingentities = body.GetCollidingEntities(Vector2.Zero, false);
if (!collidingentities.Any()) if (!collidingentities.Any())
{ {
return false; return false;
} }
var doorAABB = PhysicsComponent.GetWorldAABB(); var doorAABB = body.GetWorldAABB();
var hitsomebody = false; var hitsomebody = false;
// Crush // Crush
@@ -718,7 +719,7 @@ namespace Content.Server.Doors.Components
// no interaction occurred // no interaction occurred
return false; return false;
} }
_beingWelded = true; _beingWelded = true;
// perform a do-after delay // perform a do-after delay

View File

@@ -1,5 +1,6 @@
using Content.Server.Doors.Components; using Content.Server.Doors.Components;
using Content.Server.Power.Components; using Content.Server.Power.Components;
using Content.Server.WireHacking;
using Content.Shared.Doors; using Content.Shared.Doors;
using Content.Shared.Popups; using Content.Shared.Popups;
using Robust.Server.GameObjects; using Robust.Server.GameObjects;
@@ -29,9 +30,9 @@ namespace Content.Server.Doors.Systems
private void OnPowerChanged(EntityUid uid, AirlockComponent component, PowerChangedEvent args) private void OnPowerChanged(EntityUid uid, AirlockComponent component, PowerChangedEvent args)
{ {
if (component.AppearanceComponent != null) if (TryComp<AppearanceComponent>(uid, out var appearanceComponent))
{ {
component.AppearanceComponent.SetData(DoorVisuals.Powered, args.Powered); appearanceComponent.SetData(DoorVisuals.Powered, args.Powered);
} }
// BoltLights also got out // BoltLights also got out
@@ -41,9 +42,9 @@ namespace Content.Server.Doors.Systems
private void OnStateChanged(EntityUid uid, AirlockComponent component, DoorStateChangedEvent args) private void OnStateChanged(EntityUid uid, AirlockComponent component, DoorStateChangedEvent args)
{ {
// Only show the maintenance panel if the airlock is closed // Only show the maintenance panel if the airlock is closed
if (component.WiresComponent != null) if (TryComp<WiresComponent>(uid, out var wiresComponent))
{ {
component.WiresComponent.IsPanelVisible = wiresComponent.IsPanelVisible =
component.OpenPanelVisible component.OpenPanelVisible
|| args.State != SharedDoorComponent.DoorState.Open; || args.State != SharedDoorComponent.DoorState.Open;
} }
@@ -87,10 +88,10 @@ namespace Content.Server.Doors.Systems
private void OnDoorClickShouldActivate(EntityUid uid, AirlockComponent component, DoorClickShouldActivateEvent args) private void OnDoorClickShouldActivate(EntityUid uid, AirlockComponent component, DoorClickShouldActivateEvent args)
{ {
if (component.WiresComponent != null && component.WiresComponent.IsPanelOpen && if (TryComp<WiresComponent>(uid, out var wiresComponent) && wiresComponent.IsPanelOpen &&
EntityManager.TryGetComponent(args.Args.User, out ActorComponent? actor)) EntityManager.TryGetComponent(args.Args.User, out ActorComponent? actor))
{ {
component.WiresComponent.OpenInterface(actor.PlayerSession); wiresComponent.OpenInterface(actor.PlayerSession);
args.Handled = true; args.Handled = true;
} }
} }

View File

@@ -50,7 +50,7 @@ namespace Content.Server.Doors.Systems
private void OnBeforeDoorPry(EntityUid uid, FirelockComponent component, BeforeDoorPryEvent args) private void OnBeforeDoorPry(EntityUid uid, FirelockComponent component, BeforeDoorPryEvent args)
{ {
if (component.DoorComponent == null || component.DoorComponent.State != SharedDoorComponent.DoorState.Closed) if (!TryComp<ServerDoorComponent>(uid, out var doorComponent) || doorComponent.State != SharedDoorComponent.DoorState.Closed)
{ {
return; return;
} }
@@ -81,12 +81,12 @@ namespace Content.Server.Doors.Systems
private void OnAtmosAlarm(EntityUid uid, FirelockComponent component, AtmosMonitorAlarmEvent args) private void OnAtmosAlarm(EntityUid uid, FirelockComponent component, AtmosMonitorAlarmEvent args)
{ {
if (component.DoorComponent == null) return; if (!TryComp<ServerDoorComponent>(uid, out var doorComponent)) return;
if (args.HighestNetworkType == AtmosMonitorAlarmType.Normal) if (args.HighestNetworkType == AtmosMonitorAlarmType.Normal)
{ {
if (component.DoorComponent.State == SharedDoorComponent.DoorState.Closed) if (doorComponent.State == SharedDoorComponent.DoorState.Closed)
component.DoorComponent.Open(); doorComponent.Open();
} }
else if (args.HighestNetworkType == AtmosMonitorAlarmType.Danger) else if (args.HighestNetworkType == AtmosMonitorAlarmType.Danger)
{ {

View File

@@ -32,11 +32,5 @@ namespace Content.Server.Light.Components
/// Sound played when you ignite the matchstick. /// Sound played when you ignite the matchstick.
/// </summary> /// </summary>
[DataField("igniteSound", required: true)] public SoundSpecifier IgniteSound = default!; [DataField("igniteSound", required: true)] public SoundSpecifier IgniteSound = default!;
/// <summary>
/// Point light component. Gives matches a glow in dark effect.
/// </summary>
[ComponentDependency]
public readonly PointLightComponent? PointLightComponent = default!;
} }
} }

View File

@@ -6,6 +6,7 @@ using Content.Shared.Interaction;
using Content.Shared.Item; using Content.Shared.Item;
using Content.Shared.Smoking; using Content.Shared.Smoking;
using Content.Shared.Temperature; using Content.Shared.Temperature;
using Robust.Server.GameObjects;
using Robust.Shared.Audio; using Robust.Shared.Audio;
using Robust.Shared.GameObjects; using Robust.Shared.GameObjects;
using Robust.Shared.IoC; using Robust.Shared.IoC;
@@ -85,9 +86,9 @@ namespace Content.Server.Light.EntitySystems
{ {
component.CurrentState = value; component.CurrentState = value;
if (component.PointLightComponent != null) if (TryComp<PointLightComponent>(component.Owner, out var pointLightComponent))
{ {
component.PointLightComponent.Enabled = component.CurrentState == SmokableState.Lit; pointLightComponent.Enabled = component.CurrentState == SmokableState.Lit;
} }
if (EntityManager.TryGetComponent(component.Owner, out SharedItemComponent? item)) if (EntityManager.TryGetComponent(component.Owner, out SharedItemComponent? item))

View File

@@ -50,16 +50,16 @@ namespace Content.Server.Morgue.Components
void IExamine.Examine(FormattedMessage message, bool inDetailsRange) void IExamine.Examine(FormattedMessage message, bool inDetailsRange)
{ {
if (Appearance == null) return; if (_entities.TryGetComponent<AppearanceComponent>(Owner, out var appearance)) return;
if (inDetailsRange) if (inDetailsRange)
{ {
if (Appearance.TryGetData(CrematoriumVisuals.Burning, out bool isBurning) && isBurning) if (appearance.TryGetData(CrematoriumVisuals.Burning, out bool isBurning) && isBurning)
{ {
message.AddMarkup(Loc.GetString("crematorium-entity-storage-component-on-examine-details-is-burning", ("owner", Owner)) + "\n"); message.AddMarkup(Loc.GetString("crematorium-entity-storage-component-on-examine-details-is-burning", ("owner", Owner)) + "\n");
} }
if (Appearance.TryGetData(MorgueVisuals.HasContents, out bool hasContents) && hasContents) if (appearance.TryGetData(MorgueVisuals.HasContents, out bool hasContents) && hasContents)
{ {
message.AddMarkup(Loc.GetString("crematorium-entity-storage-component-on-examine-details-has-contents")); message.AddMarkup(Loc.GetString("crematorium-entity-storage-component-on-examine-details-has-contents"));
} }
@@ -96,7 +96,8 @@ namespace Content.Server.Morgue.Components
if (Open) if (Open)
CloseStorage(); CloseStorage();
Appearance?.SetData(CrematoriumVisuals.Burning, true); if(_entities.TryGetComponent(Owner, out AppearanceComponent appearanceComponent))
appearanceComponent.SetData(CrematoriumVisuals.Burning, true);
Cooking = true; Cooking = true;
SoundSystem.Play(Filter.Pvs(Owner), _crematingSound.GetSound(), Owner); SoundSystem.Play(Filter.Pvs(Owner), _crematingSound.GetSound(), Owner);
@@ -108,8 +109,8 @@ namespace Content.Server.Morgue.Components
{ {
if (_entities.Deleted(Owner)) if (_entities.Deleted(Owner))
return; return;
if(_entities.TryGetComponent(Owner, out appearanceComponent))
Appearance?.SetData(CrematoriumVisuals.Burning, false); appearanceComponent.SetData(CrematoriumVisuals.Burning, false);
Cooking = false; Cooking = false;
if (Contents.ContainedEntities.Count > 0) if (Contents.ContainedEntities.Count > 0)

View File

@@ -56,13 +56,11 @@ namespace Content.Server.Morgue.Components
[DataField("occupantHasSoulAlarmSound")] [DataField("occupantHasSoulAlarmSound")]
private SoundSpecifier _occupantHasSoulAlarmSound = new SoundPathSpecifier("/Audio/Weapons/Guns/EmptyAlarm/smg_empty_alarm.ogg"); private SoundSpecifier _occupantHasSoulAlarmSound = new SoundPathSpecifier("/Audio/Weapons/Guns/EmptyAlarm/smg_empty_alarm.ogg");
[ViewVariables]
[ComponentDependency] protected readonly AppearanceComponent? Appearance = null;
protected override void Initialize() protected override void Initialize()
{ {
base.Initialize(); base.Initialize();
Appearance?.SetData(MorgueVisuals.Open, false); if(_entMan.TryGetComponent<AppearanceComponent>(Owner, out var appearance))
appearance.SetData(MorgueVisuals.Open, false);
TrayContainer = Owner.EnsureContainer<ContainerSlot>("morgue_tray", out _); TrayContainer = Owner.EnsureContainer<ContainerSlot>("morgue_tray", out _);
} }
@@ -97,10 +95,13 @@ namespace Content.Server.Morgue.Components
protected override void OpenStorage() protected override void OpenStorage()
{ {
Appearance?.SetData(MorgueVisuals.Open, true); if (_entMan.TryGetComponent<AppearanceComponent>(Owner, out var appearance))
Appearance?.SetData(MorgueVisuals.HasContents, false); {
Appearance?.SetData(MorgueVisuals.HasMob, false); appearance.SetData(MorgueVisuals.Open, true);
Appearance?.SetData(MorgueVisuals.HasSoul, false); appearance.SetData(MorgueVisuals.HasContents, false);
appearance.SetData(MorgueVisuals.HasMob, false);
appearance.SetData(MorgueVisuals.HasSoul, false);
}
if (_tray == null) if (_tray == null)
{ {
@@ -131,16 +132,21 @@ namespace Content.Server.Morgue.Components
if (!hasSoul && _entMan.TryGetComponent<ActorComponent?>(entity, out var actor) && actor.PlayerSession != null) if (!hasSoul && _entMan.TryGetComponent<ActorComponent?>(entity, out var actor) && actor.PlayerSession != null)
hasSoul = true; hasSoul = true;
} }
Appearance?.SetData(MorgueVisuals.HasContents, count > 0);
Appearance?.SetData(MorgueVisuals.HasMob, hasMob); if (_entMan.TryGetComponent<AppearanceComponent>(Owner, out var appearance))
Appearance?.SetData(MorgueVisuals.HasSoul, hasSoul); {
appearance.SetData(MorgueVisuals.HasContents, count > 0);
appearance.SetData(MorgueVisuals.HasMob, hasMob);
appearance.SetData(MorgueVisuals.HasSoul, hasSoul);
}
} }
protected override void CloseStorage() protected override void CloseStorage()
{ {
base.CloseStorage(); base.CloseStorage();
Appearance?.SetData(MorgueVisuals.Open, false); if (_entMan.TryGetComponent<AppearanceComponent>(Owner, out var appearance))
appearance.SetData(MorgueVisuals.Open, false);
CheckContents(); CheckContents();
if (_tray != null) if (_tray != null)
@@ -168,7 +174,8 @@ namespace Content.Server.Morgue.Components
{ {
CheckContents(); CheckContents();
if (DoSoulBeep && Appearance != null && Appearance.TryGetData(MorgueVisuals.HasSoul, out bool hasSoul) && hasSoul) if (DoSoulBeep && _entMan.TryGetComponent<AppearanceComponent>(Owner, out var appearance) &&
appearance.TryGetData(MorgueVisuals.HasSoul, out bool hasSoul) && hasSoul)
{ {
SoundSystem.Play(Filter.Pvs(Owner), _occupantHasSoulAlarmSound.GetSound(), Owner); SoundSystem.Play(Filter.Pvs(Owner), _occupantHasSoulAlarmSound.GetSound(), Owner);
} }
@@ -176,19 +183,19 @@ namespace Content.Server.Morgue.Components
void IExamine.Examine(FormattedMessage message, bool inDetailsRange) void IExamine.Examine(FormattedMessage message, bool inDetailsRange)
{ {
if (Appearance == null) return; if (!_entMan.TryGetComponent<AppearanceComponent>(Owner, out var appearance)) return;
if (inDetailsRange) if (inDetailsRange)
{ {
if (Appearance.TryGetData(MorgueVisuals.HasSoul, out bool hasSoul) && hasSoul) if (appearance.TryGetData(MorgueVisuals.HasSoul, out bool hasSoul) && hasSoul)
{ {
message.AddMarkup(Loc.GetString("morgue-entity-storage-component-on-examine-details-body-has-soul")); message.AddMarkup(Loc.GetString("morgue-entity-storage-component-on-examine-details-body-has-soul"));
} }
else if (Appearance.TryGetData(MorgueVisuals.HasMob, out bool hasMob) && hasMob) else if (appearance.TryGetData(MorgueVisuals.HasMob, out bool hasMob) && hasMob)
{ {
message.AddMarkup(Loc.GetString("morgue-entity-storage-component-on-examine-details-body-has-no-soul")); message.AddMarkup(Loc.GetString("morgue-entity-storage-component-on-examine-details-body-has-no-soul"));
} }
else if (Appearance.TryGetData(MorgueVisuals.HasContents, out bool hasContents) && hasContents) else if (appearance.TryGetData(MorgueVisuals.HasContents, out bool hasContents) && hasContents)
{ {
message.AddMarkup(Loc.GetString("morgue-entity-storage-component-on-examine-details-has-contents")); message.AddMarkup(Loc.GetString("morgue-entity-storage-component-on-examine-details-has-contents"));
} }

View File

@@ -59,8 +59,6 @@ namespace Content.Server.Power.Components
public BatteryComponent? Battery => _entMan.TryGetComponent(Owner, out BatteryComponent? batteryComponent) ? batteryComponent : null; public BatteryComponent? Battery => _entMan.TryGetComponent(Owner, out BatteryComponent? batteryComponent) ? batteryComponent : null;
[ComponentDependency] private AccessReaderComponent? _accessReader = null;
protected override void Initialize() protected override void Initialize()
{ {
base.Initialize(); base.Initialize();
@@ -92,7 +90,7 @@ namespace Content.Server.Power.Components
return; return;
var accessSystem = EntitySystem.Get<AccessReaderSystem>(); var accessSystem = EntitySystem.Get<AccessReaderSystem>();
if (_accessReader == null || accessSystem.IsAllowed(_accessReader, attached)) if (_entMan.TryGetComponent<AccessReaderComponent>(Owner, out var accessReaderComponent) || accessSystem.IsAllowed(accessReaderComponent, attached))
{ {
MainBreakerEnabled = !MainBreakerEnabled; MainBreakerEnabled = !MainBreakerEnabled;
_entMan.GetComponent<PowerNetworkBatteryComponent>(Owner).CanDischarge = MainBreakerEnabled; _entMan.GetComponent<PowerNetworkBatteryComponent>(Owner).CanDischarge = MainBreakerEnabled;

View File

@@ -1,5 +1,6 @@
using Content.Shared.Examine; using Content.Shared.Examine;
using Robust.Shared.GameObjects; using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.Localization; using Robust.Shared.Localization;
using Robust.Shared.Utility; using Robust.Shared.Utility;
using Robust.Shared.ViewVariables; using Robust.Shared.ViewVariables;
@@ -13,19 +14,18 @@ namespace Content.Server.Power.Components
{ {
public override string Name => "ExaminableBattery"; public override string Name => "ExaminableBattery";
[ViewVariables] [Dependency] private readonly IEntityManager _entityManager = default!;
[ComponentDependency] private BatteryComponent? _battery = default!;
void IExamine.Examine(FormattedMessage message, bool inDetailsRange) void IExamine.Examine(FormattedMessage message, bool inDetailsRange)
{ {
if (_battery == null) if (_entityManager.TryGetComponent<BatteryComponent>(Owner, out var batteryComponent))
return; return;
if (inDetailsRange) if (inDetailsRange)
{ {
var effectiveMax = _battery.MaxCharge; var effectiveMax = batteryComponent.MaxCharge;
if (effectiveMax == 0) if (effectiveMax == 0)
effectiveMax = 1; effectiveMax = 1;
var chargeFraction = _battery.CurrentCharge / effectiveMax; var chargeFraction = batteryComponent.CurrentCharge / effectiveMax;
var chargePercentRounded = (int) (chargeFraction * 100); var chargePercentRounded = (int) (chargeFraction * 100);
message.AddMarkup( message.AddMarkup(
Loc.GetString( Loc.GetString(

View File

@@ -58,9 +58,6 @@ namespace Content.Server.Singularity.Components
} }
} }
[ComponentDependency] private readonly PhysicsComponent? _collidableComponent = default;
[ComponentDependency] private readonly PointLightComponent? _pointLightComponent = default;
private Tuple<Direction, ContainmentFieldConnection>? _connection1; private Tuple<Direction, ContainmentFieldConnection>? _connection1;
private Tuple<Direction, ContainmentFieldConnection>? _connection2; private Tuple<Direction, ContainmentFieldConnection>? _connection2;
@@ -69,7 +66,7 @@ namespace Content.Server.Singularity.Components
public void OnAnchoredChanged() public void OnAnchoredChanged()
{ {
if(_collidableComponent?.BodyType != BodyType.Static) if(_entMan.TryGetComponent<PhysicsComponent>(Owner, out var physicsComponent) && physicsComponent.BodyType != BodyType.Static)
{ {
_connection1?.Item2.Dispose(); _connection1?.Item2.Dispose();
_connection2?.Item2.Dispose(); _connection2?.Item2.Dispose();
@@ -91,7 +88,7 @@ namespace Content.Server.Singularity.Components
private bool TryGenerateFieldConnection([NotNullWhen(true)] ref Tuple<Direction, ContainmentFieldConnection>? propertyFieldTuple) private bool TryGenerateFieldConnection([NotNullWhen(true)] ref Tuple<Direction, ContainmentFieldConnection>? propertyFieldTuple)
{ {
if (propertyFieldTuple != null) return false; if (propertyFieldTuple != null) return false;
if(_collidableComponent?.BodyType != BodyType.Static) return false; if(_entMan.TryGetComponent<PhysicsComponent>(Owner, out var physicsComponent) && physicsComponent.BodyType != BodyType.Static) return false;
foreach (var direction in new[] {Direction.North, Direction.East, Direction.South, Direction.West}) foreach (var direction in new[] {Direction.North, Direction.East, Direction.South, Direction.West})
{ {
@@ -166,10 +163,10 @@ namespace Content.Server.Singularity.Components
public void UpdateConnectionLights() public void UpdateConnectionLights()
{ {
if (_pointLightComponent != null) if (_entMan.TryGetComponent<PointLightComponent>(Owner, out var pointLightComponent))
{ {
bool hasAnyConnection = (_connection1 != null) || (_connection2 != null); bool hasAnyConnection = (_connection1 != null) || (_connection2 != null);
_pointLightComponent.Enabled = hasAnyConnection; pointLightComponent.Enabled = hasAnyConnection;
} }
} }

View File

@@ -13,10 +13,6 @@ namespace Content.Server.Singularity.Components
[RegisterComponent] [RegisterComponent]
public class EmitterComponent : Component public class EmitterComponent : Component
{ {
[ComponentDependency] public readonly AppearanceComponent? Appearance = default;
[ComponentDependency] public readonly AccessReaderComponent? AccessReader = default;
[ComponentDependency] public readonly PowerConsumerComponent? PowerConsumer = default;
public override string Name => "Emitter"; public override string Name => "Emitter";
public CancellationTokenSource? TimerCancel; public CancellationTokenSource? TimerCancel;

View File

@@ -16,6 +16,7 @@ namespace Content.Server.Singularity.Components
public class RadiationCollectorComponent : Component, IInteractHand, IRadiationAct public class RadiationCollectorComponent : Component, IInteractHand, IRadiationAct
{ {
[Dependency] private readonly IGameTiming _gameTiming = default!; [Dependency] private readonly IGameTiming _gameTiming = default!;
[Dependency] private readonly IEntityManager _entMan = default!;
public override string Name => "RadiationCollector"; public override string Name => "RadiationCollector";
private bool _enabled; private bool _enabled;
@@ -32,8 +33,6 @@ namespace Content.Server.Singularity.Components
} }
} }
[ComponentDependency] private readonly BatteryComponent? _batteryComponent = default!;
bool IInteractHand.InteractHand(InteractHandEventArgs eventArgs) bool IInteractHand.InteractHand(InteractHandEventArgs eventArgs)
{ {
var curTime = _gameTiming.CurTime; var curTime = _gameTiming.CurTime;
@@ -66,9 +65,9 @@ namespace Content.Server.Singularity.Components
// But the previous logic would also make the radiation collectors never ever stop providing energy. // But the previous logic would also make the radiation collectors never ever stop providing energy.
// And since frameTime was used there, I'm assuming that this is what the intent was. // And since frameTime was used there, I'm assuming that this is what the intent was.
// This still won't stop things being potentially hilarously unbalanced though. // This still won't stop things being potentially hilarously unbalanced though.
if (_batteryComponent != null) if (_entMan.TryGetComponent<BatteryComponent>(Owner, out var batteryComponent))
{ {
_batteryComponent!.CurrentCharge += frameTime * radiation.RadsPerSecond * 3000f; batteryComponent.CurrentCharge += frameTime * radiation.RadsPerSecond * 3000f;
} }
} }

View File

@@ -1,6 +1,7 @@
using System; using System;
using System.Threading; using System.Threading;
using Content.Server.Administration.Logs; using Content.Server.Administration.Logs;
using Content.Server.Power.Components;
using Content.Server.Power.EntitySystems; using Content.Server.Power.EntitySystems;
using Content.Server.Projectiles.Components; using Content.Server.Projectiles.Components;
using Content.Server.Singularity.Components; using Content.Server.Singularity.Components;
@@ -94,7 +95,7 @@ namespace Content.Server.Singularity.EntitySystems
public void SwitchOff(EmitterComponent component) public void SwitchOff(EmitterComponent component)
{ {
component.IsOn = false; component.IsOn = false;
if (component.PowerConsumer != null) component.PowerConsumer.DrawRate = 0; if (TryComp<PowerConsumerComponent>(component.Owner, out var powerConsumer)) powerConsumer.DrawRate = 0;
PowerOff(component); PowerOff(component);
UpdateAppearance(component); UpdateAppearance(component);
} }
@@ -102,7 +103,7 @@ namespace Content.Server.Singularity.EntitySystems
public void SwitchOn(EmitterComponent component) public void SwitchOn(EmitterComponent component)
{ {
component.IsOn = true; component.IsOn = true;
if (component.PowerConsumer != null) component.PowerConsumer.DrawRate = component.PowerUseActive; if (TryComp<PowerConsumerComponent>(component.Owner, out var powerConsumer)) powerConsumer.DrawRate = component.PowerUseActive;
// Do not directly PowerOn(). // Do not directly PowerOn().
// OnReceivedPowerChanged will get fired due to DrawRate change which will turn it on. // OnReceivedPowerChanged will get fired due to DrawRate change which will turn it on.
UpdateAppearance(component); UpdateAppearance(component);
@@ -149,7 +150,8 @@ namespace Content.Server.Singularity.EntitySystems
// and thus not firing // and thus not firing
DebugTools.Assert(component.IsPowered); DebugTools.Assert(component.IsPowered);
DebugTools.Assert(component.IsOn); DebugTools.Assert(component.IsOn);
DebugTools.Assert(component.PowerConsumer != null && (component.PowerConsumer.DrawRate <= component.PowerConsumer.ReceivedPower)); DebugTools.Assert(TryComp<PowerConsumerComponent>(component.Owner, out var powerConsumer) &&
powerConsumer.DrawRate <= powerConsumer.ReceivedPower);
Fire(component); Fire(component);
@@ -205,7 +207,7 @@ namespace Content.Server.Singularity.EntitySystems
private void UpdateAppearance(EmitterComponent component) private void UpdateAppearance(EmitterComponent component)
{ {
if (component.Appearance == null) if (!TryComp<AppearanceComponent>(component.Owner, out var appearanceComponent))
{ {
return; return;
} }
@@ -224,7 +226,7 @@ namespace Content.Server.Singularity.EntitySystems
state = EmitterVisualState.Off; state = EmitterVisualState.Off;
} }
component.Appearance.SetData(EmitterVisuals.VisualState, state); appearanceComponent.SetData(EmitterVisuals.VisualState, state);
} }
} }
} }

View File

@@ -3,6 +3,7 @@ using Content.Shared.ActionBlocker;
using Content.Shared.Physics; using Content.Shared.Physics;
using Robust.Shared.GameObjects; using Robust.Shared.GameObjects;
using Robust.Shared.GameStates; using Robust.Shared.GameStates;
using Robust.Shared.IoC;
using Robust.Shared.Physics; using Robust.Shared.Physics;
using Robust.Shared.Serialization; using Robust.Shared.Serialization;
using Robust.Shared.ViewVariables; using Robust.Shared.ViewVariables;
@@ -12,15 +13,17 @@ namespace Content.Shared.Climbing
[NetworkedComponent()] [NetworkedComponent()]
public abstract class SharedClimbingComponent : Component public abstract class SharedClimbingComponent : Component
{ {
[Dependency] private readonly IEntityManager _entMan = default!;
public sealed override string Name => "Climbing"; public sealed override string Name => "Climbing";
protected bool IsOnClimbableThisFrame protected bool IsOnClimbableThisFrame
{ {
get get
{ {
if (Body == null) return false; if (!_entMan.TryGetComponent<PhysicsComponent>(Owner, out var physicsComponent)) return false;
foreach (var entity in Body.GetBodiesIntersecting()) foreach (var entity in physicsComponent.GetBodiesIntersecting())
{ {
if ((entity.CollisionLayer & (int) CollisionGroup.SmallImpassable) != 0) return true; if ((entity.CollisionLayer & (int) CollisionGroup.SmallImpassable) != 0) return true;
} }
@@ -37,22 +40,20 @@ namespace Content.Shared.Climbing
{ {
if (_ownerIsTransitioning == value) return; if (_ownerIsTransitioning == value) return;
_ownerIsTransitioning = value; _ownerIsTransitioning = value;
if (Body == null) return; if (!_entMan.TryGetComponent<PhysicsComponent>(Owner, out var physicsComponent)) return;
if (value) if (value)
{ {
Body.BodyType = BodyType.Dynamic; physicsComponent.BodyType = BodyType.Dynamic;
} }
else else
{ {
Body.BodyType = BodyType.KinematicController; physicsComponent.BodyType = BodyType.KinematicController;
} }
} }
} }
private bool _ownerIsTransitioning = false; private bool _ownerIsTransitioning = false;
[ComponentDependency] protected PhysicsComponent? Body;
protected TimeSpan StartClimbTime = TimeSpan.Zero; protected TimeSpan StartClimbTime = TimeSpan.Zero;
/// <summary> /// <summary>
@@ -78,9 +79,9 @@ namespace Content.Shared.Climbing
private void ToggleSmallPassable(bool value) private void ToggleSmallPassable(bool value)
{ {
// Hope the mob has one fixture // Hope the mob has one fixture
if (Body == null || Body.Deleted) return; if (!_entMan.TryGetComponent<PhysicsComponent>(Owner, out var physicsComponent) || physicsComponent.Deleted) return;
foreach (var fixture in Body.Fixtures) foreach (var fixture in physicsComponent.Fixtures)
{ {
if (value) if (value)
{ {

View File

@@ -16,15 +16,11 @@ namespace Content.Shared.Doors
{ {
public override string Name => "Door"; public override string Name => "Door";
[ComponentDependency]
protected readonly AppearanceComponent? AppearanceComponent = null;
[ComponentDependency]
protected readonly IPhysBody? PhysicsComponent = null;
[Dependency] [Dependency]
protected readonly IGameTiming _gameTiming = default!; protected readonly IGameTiming _gameTiming = default!;
[Dependency] private readonly IEntityManager _entMan = default!;
[ViewVariables] [ViewVariables]
private DoorState _state = DoorState.Closed; private DoorState _state = DoorState.Closed;
/// <summary> /// <summary>
@@ -104,7 +100,10 @@ namespace Content.Shared.Doors
protected void SetAppearance(DoorVisualState state) protected void SetAppearance(DoorVisualState state)
{ {
AppearanceComponent?.SetData(DoorVisuals.VisualState, state); if (_entMan.TryGetComponent<AppearanceComponent>(Owner, out var appearanceComponent))
{
appearanceComponent.SetData(DoorVisuals.VisualState, state);
}
} }
/// <summary> /// <summary>
@@ -112,9 +111,9 @@ namespace Content.Shared.Doors
/// </summary> /// </summary>
protected virtual void OnPartialOpen() protected virtual void OnPartialOpen()
{ {
if (PhysicsComponent != null) if (_entMan.TryGetComponent<PhysicsComponent>(Owner, out var physicsComponent))
{ {
PhysicsComponent.CanCollide = false; physicsComponent.CanCollide = false;
} }
// we can't be crushing anyone anymore, since we're opening // we can't be crushing anyone anymore, since we're opening
CurrentlyCrushing.Clear(); CurrentlyCrushing.Clear();
@@ -125,9 +124,9 @@ namespace Content.Shared.Doors
/// </summary> /// </summary>
protected virtual void OnPartialClose() protected virtual void OnPartialClose()
{ {
if (PhysicsComponent != null) if (_entMan.TryGetComponent<PhysicsComponent>(Owner, out var physicsComponent))
{ {
PhysicsComponent.CanCollide = true; physicsComponent.CanCollide = true;
} }
} }

View File

@@ -38,8 +38,7 @@ namespace Content.Shared.Movement.Components
[Dependency] private readonly IConfigurationManager _configurationManager = default!; [Dependency] private readonly IConfigurationManager _configurationManager = default!;
[Dependency] private readonly IGameTiming _gameTiming = default!; [Dependency] private readonly IGameTiming _gameTiming = default!;
[Dependency] private readonly IEntityManager _entityManager = default!;
[ComponentDependency] private readonly MovementSpeedModifierComponent? _movementSpeed = default!;
public override string Name => "PlayerInputMover"; public override string Name => "PlayerInputMover";
@@ -53,9 +52,17 @@ namespace Content.Shared.Movement.Components
[ViewVariables] [ViewVariables]
public Angle LastGridAngle { get; set; } = new(0); public Angle LastGridAngle { get; set; } = new(0);
public float CurrentWalkSpeed => _movementSpeed?.CurrentWalkSpeed ?? MovementSpeedModifierComponent.DefaultBaseWalkSpeed; public float CurrentWalkSpeed =>
_entityManager.TryGetComponent<MovementSpeedModifierComponent>(Owner,
out var movementSpeedModifierComponent)
? movementSpeedModifierComponent.CurrentWalkSpeed
: MovementSpeedModifierComponent.DefaultBaseWalkSpeed;
public float CurrentSprintSpeed => _movementSpeed?.CurrentSprintSpeed ?? MovementSpeedModifierComponent.DefaultBaseSprintSpeed; public float CurrentSprintSpeed =>
_entityManager.TryGetComponent<MovementSpeedModifierComponent>(Owner,
out var movementSpeedModifierComponent)
? movementSpeedModifierComponent.CurrentSprintSpeed
: MovementSpeedModifierComponent.DefaultBaseSprintSpeed;
public bool Sprinting => !HasFlag(_heldMoveButtons, MoveButtons.Walk); public bool Sprinting => !HasFlag(_heldMoveButtons, MoveButtons.Walk);