removes componentdependencies (#6160)
This commit is contained in:
@@ -23,20 +23,10 @@ namespace Content.Server.Doors.Components
|
||||
[RegisterComponent]
|
||||
public class AirlockComponent : Component, IWires
|
||||
{
|
||||
[Dependency] private readonly IEntityManager _entityManager = default!;
|
||||
|
||||
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>
|
||||
/// Sound to play when the bolts on the airlock go up.
|
||||
/// </summary>
|
||||
@@ -98,7 +88,7 @@ namespace Content.Server.Doors.Components
|
||||
private bool BoltLightsVisible
|
||||
{
|
||||
get => _boltLightsWirePulsed && BoltsDown && IsPowered()
|
||||
&& DoorComponent != null && DoorComponent.State == SharedDoorComponent.DoorState.Closed;
|
||||
&& _entityManager.TryGetComponent<ServerDoorComponent>(Owner, out var doorComponent) && doorComponent.State == SharedDoorComponent.DoorState.Closed;
|
||||
set
|
||||
{
|
||||
_boltLightsWirePulsed = value;
|
||||
@@ -122,9 +112,10 @@ namespace Content.Server.Doors.Components
|
||||
{
|
||||
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()
|
||||
{
|
||||
return ReceiverComponent == null || ReceiverComponent.Powered;
|
||||
return _entityManager.TryGetComponent<ApcPowerReceiverComponent>(Owner, out var receiverComponent) && receiverComponent.Powered;
|
||||
}
|
||||
|
||||
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()
|
||||
{
|
||||
if (WiresComponent == null) return;
|
||||
if (_entityManager.TryGetComponent<WiresComponent>(Owner, out var wiresComponent)) return;
|
||||
|
||||
var mainPowerCut = WiresComponent.IsWireCut(Wires.MainPower);
|
||||
var backupPowerCut = WiresComponent.IsWireCut(Wires.BackupPower);
|
||||
var mainPowerCut = wiresComponent.IsWireCut(Wires.MainPower);
|
||||
var backupPowerCut = wiresComponent.IsWireCut(Wires.BackupPower);
|
||||
var statusLightState = PowerWiresPulsed ? StatusLightState.BlinkingFast : StatusLightState.On;
|
||||
StatusLightData powerLight;
|
||||
if (mainPowerCut && backupPowerCut)
|
||||
@@ -190,42 +181,42 @@ namespace Content.Server.Doors.Components
|
||||
new StatusLightData(Color.Red, Safety ? StatusLightState.On : StatusLightState.Off, "SAFETY");
|
||||
|
||||
|
||||
WiresComponent.SetStatus(AirlockWireStatus.PowerIndicator, powerLight);
|
||||
WiresComponent.SetStatus(AirlockWireStatus.BoltIndicator, boltStatus);
|
||||
WiresComponent.SetStatus(AirlockWireStatus.BoltLightIndicator, boltLightsStatus);
|
||||
WiresComponent.SetStatus(AirlockWireStatus.AIControlIndicator, new StatusLightData(Color.Purple, StatusLightState.BlinkingSlow, "AI CTRL"));
|
||||
WiresComponent.SetStatus(AirlockWireStatus.TimingIndicator, timingStatus);
|
||||
WiresComponent.SetStatus(AirlockWireStatus.SafetyIndicator, safetyStatus);
|
||||
wiresComponent.SetStatus(AirlockWireStatus.PowerIndicator, powerLight);
|
||||
wiresComponent.SetStatus(AirlockWireStatus.BoltIndicator, boltStatus);
|
||||
wiresComponent.SetStatus(AirlockWireStatus.BoltLightIndicator, boltLightsStatus);
|
||||
wiresComponent.SetStatus(AirlockWireStatus.AIControlIndicator, new StatusLightData(Color.Purple, StatusLightState.BlinkingSlow, "AI CTRL"));
|
||||
wiresComponent.SetStatus(AirlockWireStatus.TimingIndicator, timingStatus);
|
||||
wiresComponent.SetStatus(AirlockWireStatus.SafetyIndicator, safetyStatus);
|
||||
}
|
||||
|
||||
private void UpdatePowerCutStatus()
|
||||
{
|
||||
if (ReceiverComponent == null)
|
||||
if (!_entityManager.TryGetComponent<ApcPowerReceiverComponent>(Owner, out var receiverComponent))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (PowerWiresPulsed)
|
||||
{
|
||||
ReceiverComponent.PowerDisabled = true;
|
||||
receiverComponent.PowerDisabled = true;
|
||||
return;
|
||||
}
|
||||
|
||||
if (WiresComponent == null)
|
||||
if (!_entityManager.TryGetComponent<WiresComponent>(Owner, out var wiresComponent))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
ReceiverComponent.PowerDisabled =
|
||||
WiresComponent.IsWireCut(Wires.MainPower) &&
|
||||
WiresComponent.IsWireCut(Wires.BackupPower);
|
||||
receiverComponent.PowerDisabled =
|
||||
wiresComponent.IsWireCut(Wires.MainPower) &&
|
||||
wiresComponent.IsWireCut(Wires.BackupPower);
|
||||
}
|
||||
|
||||
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
|
||||
@@ -290,7 +281,7 @@ namespace Content.Server.Doors.Components
|
||||
|
||||
public void WiresUpdate(WiresUpdateEventArgs args)
|
||||
{
|
||||
if (DoorComponent == null)
|
||||
if (!_entityManager.TryGetComponent<ServerDoorComponent>(Owner, out var doorComponent))
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -328,7 +319,7 @@ namespace Content.Server.Doors.Components
|
||||
break;
|
||||
case Wires.Timing:
|
||||
AutoCloseDelayModifier = 0.5f;
|
||||
DoorComponent.RefreshAutoClose();
|
||||
doorComponent.RefreshAutoClose();
|
||||
break;
|
||||
case Wires.Safety:
|
||||
Safety = !Safety;
|
||||
@@ -351,7 +342,7 @@ namespace Content.Server.Doors.Components
|
||||
break;
|
||||
case Wires.Timing:
|
||||
AutoClose = true;
|
||||
DoorComponent.RefreshAutoClose();
|
||||
doorComponent.RefreshAutoClose();
|
||||
break;
|
||||
case Wires.Safety:
|
||||
Safety = true;
|
||||
@@ -371,7 +362,7 @@ namespace Content.Server.Doors.Components
|
||||
break;
|
||||
case Wires.Timing:
|
||||
AutoClose = false;
|
||||
DoorComponent.RefreshAutoClose();
|
||||
doorComponent.RefreshAutoClose();
|
||||
break;
|
||||
case Wires.Safety:
|
||||
Safety = false;
|
||||
|
||||
@@ -18,9 +18,6 @@ namespace Content.Server.Doors.Components
|
||||
|
||||
public override string Name => "Firelock";
|
||||
|
||||
[ComponentDependency]
|
||||
public readonly ServerDoorComponent? DoorComponent = null;
|
||||
|
||||
/// <summary>
|
||||
/// Pry time modifier to be used when the firelock is currently closed due to fire or pressure.
|
||||
/// </summary>
|
||||
@@ -30,9 +27,9 @@ namespace Content.Server.Doors.Components
|
||||
|
||||
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))
|
||||
{
|
||||
EntitySystem.Get<AirtightSystem>().SetAirblocked(airtight, true);
|
||||
|
||||
@@ -24,6 +24,7 @@ using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Log;
|
||||
using Robust.Shared.Maths;
|
||||
using Robust.Shared.Physics;
|
||||
using Robust.Shared.Player;
|
||||
using Robust.Shared.Prototypes;
|
||||
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>
|
||||
private bool TryCrush()
|
||||
{
|
||||
if (PhysicsComponent == null)
|
||||
if (!_entMan.TryGetComponent(Owner, out PhysicsComponent physicsComponent) || physicsComponent is not IPhysBody body)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
var collidingentities = PhysicsComponent.GetCollidingEntities(Vector2.Zero, false);
|
||||
var collidingentities = body.GetCollidingEntities(Vector2.Zero, false);
|
||||
|
||||
if (!collidingentities.Any())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
var doorAABB = PhysicsComponent.GetWorldAABB();
|
||||
var doorAABB = body.GetWorldAABB();
|
||||
var hitsomebody = false;
|
||||
|
||||
// Crush
|
||||
@@ -718,7 +719,7 @@ namespace Content.Server.Doors.Components
|
||||
// no interaction occurred
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
_beingWelded = true;
|
||||
|
||||
// perform a do-after delay
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using Content.Server.Doors.Components;
|
||||
using Content.Server.Power.Components;
|
||||
using Content.Server.WireHacking;
|
||||
using Content.Shared.Doors;
|
||||
using Content.Shared.Popups;
|
||||
using Robust.Server.GameObjects;
|
||||
@@ -29,9 +30,9 @@ namespace Content.Server.Doors.Systems
|
||||
|
||||
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
|
||||
@@ -41,9 +42,9 @@ namespace Content.Server.Doors.Systems
|
||||
private void OnStateChanged(EntityUid uid, AirlockComponent component, DoorStateChangedEvent args)
|
||||
{
|
||||
// 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
|
||||
|| args.State != SharedDoorComponent.DoorState.Open;
|
||||
}
|
||||
@@ -87,10 +88,10 @@ namespace Content.Server.Doors.Systems
|
||||
|
||||
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))
|
||||
{
|
||||
component.WiresComponent.OpenInterface(actor.PlayerSession);
|
||||
wiresComponent.OpenInterface(actor.PlayerSession);
|
||||
args.Handled = true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -50,7 +50,7 @@ namespace Content.Server.Doors.Systems
|
||||
|
||||
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;
|
||||
}
|
||||
@@ -81,12 +81,12 @@ namespace Content.Server.Doors.Systems
|
||||
|
||||
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 (component.DoorComponent.State == SharedDoorComponent.DoorState.Closed)
|
||||
component.DoorComponent.Open();
|
||||
if (doorComponent.State == SharedDoorComponent.DoorState.Closed)
|
||||
doorComponent.Open();
|
||||
}
|
||||
else if (args.HighestNetworkType == AtmosMonitorAlarmType.Danger)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user