GasCanisterSystem cleanup, use EntityUid more.
This commit is contained in:
@@ -29,6 +29,7 @@ namespace Content.Server.Atmos.Piping.Unary.EntitySystems
|
|||||||
{
|
{
|
||||||
[Dependency] private readonly UserInterfaceSystem _userInterfaceSystem = default!;
|
[Dependency] private readonly UserInterfaceSystem _userInterfaceSystem = default!;
|
||||||
[Dependency] private readonly AtmosphereSystem _atmosphereSystem = default!;
|
[Dependency] private readonly AtmosphereSystem _atmosphereSystem = default!;
|
||||||
|
[Dependency] private readonly ActionBlockerSystem _actionBlockerSystem = default!;
|
||||||
|
|
||||||
public override void Initialize()
|
public override void Initialize()
|
||||||
{
|
{
|
||||||
@@ -53,7 +54,8 @@ namespace Content.Server.Atmos.Piping.Unary.EntitySystems
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public void PurgeContents(EntityUid uid, GasCanisterComponent? canister = null, TransformComponent? transform = null)
|
public void PurgeContents(EntityUid uid, GasCanisterComponent? canister = null, TransformComponent? transform = null)
|
||||||
{
|
{
|
||||||
if (!Resolve(uid, ref canister, ref transform)) return;
|
if (!Resolve(uid, ref canister, ref transform))
|
||||||
|
return;
|
||||||
|
|
||||||
var environment = _atmosphereSystem.GetTileMixture(transform.Coordinates, true);
|
var environment = _atmosphereSystem.GetTileMixture(transform.Coordinates, true);
|
||||||
|
|
||||||
@@ -66,10 +68,7 @@ namespace Content.Server.Atmos.Piping.Unary.EntitySystems
|
|||||||
private void OnCanisterStartup(EntityUid uid, GasCanisterComponent canister, ComponentStartup args)
|
private void OnCanisterStartup(EntityUid uid, GasCanisterComponent canister, ComponentStartup args)
|
||||||
{
|
{
|
||||||
// Ensure container manager.
|
// Ensure container manager.
|
||||||
if (!EntityManager.TryGetComponent(uid, out ContainerManagerComponent? containerManager))
|
var containerManager = EntityManager.EnsureComponent<ContainerManagerComponent>(uid);
|
||||||
{
|
|
||||||
containerManager = EntityManager.AddComponent<ContainerManagerComponent>(EntityManager.GetEntity(uid));
|
|
||||||
}
|
|
||||||
|
|
||||||
// Ensure container.
|
// Ensure container.
|
||||||
if (!containerManager.TryGetContainer(canister.ContainerName, out _))
|
if (!containerManager.TryGetContainer(canister.ContainerName, out _))
|
||||||
@@ -80,9 +79,9 @@ namespace Content.Server.Atmos.Piping.Unary.EntitySystems
|
|||||||
|
|
||||||
private bool CheckInteract(ICommonSession session)
|
private bool CheckInteract(ICommonSession session)
|
||||||
{
|
{
|
||||||
if (session.AttachedEntity is not {} entity
|
if (session.AttachedEntityUid is not {} uid
|
||||||
|| !Get<ActionBlockerSystem>().CanInteract(entity)
|
|| !_actionBlockerSystem.CanInteract(uid)
|
||||||
|| !Get<ActionBlockerSystem>().CanUse(entity))
|
|| !_actionBlockerSystem.CanUse(uid))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@@ -105,9 +104,9 @@ namespace Content.Server.Atmos.Piping.Unary.EntitySystems
|
|||||||
if (containerManager.TryGetContainer(canister.ContainerName, out var tankContainer)
|
if (containerManager.TryGetContainer(canister.ContainerName, out var tankContainer)
|
||||||
&& tankContainer.ContainedEntities.Count > 0)
|
&& tankContainer.ContainedEntities.Count > 0)
|
||||||
{
|
{
|
||||||
var tank = tankContainer.ContainedEntities[0];
|
var tank = tankContainer.ContainedEntities[0].Uid;
|
||||||
var tankComponent = tank.GetComponent<GasTankComponent>();
|
var tankComponent = EntityManager.GetComponent<GasTankComponent>(tank);
|
||||||
tankLabel = tank.Name;
|
tankLabel = EntityManager.GetComponent<MetaDataComponent>(tank).EntityName;
|
||||||
tankPressure = tankComponent.Air.Pressure;
|
tankPressure = tankComponent.Air.Pressure;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -231,7 +230,7 @@ namespace Content.Server.Atmos.Piping.Unary.EntitySystems
|
|||||||
if (!args.User.TryGetComponent(out ActorComponent? actor))
|
if (!args.User.TryGetComponent(out ActorComponent? actor))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
component.Owner.GetUIOrNull(GasCanisterUiKey.Key)?.Open(actor.PlayerSession);
|
_userInterfaceSystem.GetUiOrNull(uid, GasCanisterUiKey.Key)?.Open(actor.PlayerSession);
|
||||||
args.Handled = true;
|
args.Handled = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -241,7 +240,7 @@ namespace Content.Server.Atmos.Piping.Unary.EntitySystems
|
|||||||
if (!args.User.TryGetComponent(out ActorComponent? actor))
|
if (!args.User.TryGetComponent(out ActorComponent? actor))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
component.Owner.GetUIOrNull(GasCanisterUiKey.Key)?.Open(actor.PlayerSession);
|
_userInterfaceSystem.GetUiOrNull(uid, GasCanisterUiKey.Key)?.Open(actor.PlayerSession);
|
||||||
args.Handled = true;
|
args.Handled = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user