Some work
This commit is contained in:
@@ -28,7 +28,7 @@ namespace Content.Server.GameObjects.Components.Atmos
|
||||
set
|
||||
{
|
||||
_airBlocked = value;
|
||||
EntitySystem.Get<AtmosphereSystem>().GetGridAtmosphere(Owner.Transform.GridID)?.Invalidate(_snapGrid.Position);
|
||||
EntitySystem.Get<AtmosphereSystem>().GetGridAtmosphere(Owner.Transform.GridID)?.Revalidate(_snapGrid.Position);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,85 @@
|
||||
using System.Threading.Tasks;
|
||||
using Content.Server.GameObjects.Components.Doors;
|
||||
using Content.Server.GameObjects.Components.Interactable;
|
||||
using Content.Shared.GameObjects.Components.Doors;
|
||||
using Content.Shared.GameObjects.Components.Interactable;
|
||||
using Content.Shared.Interfaces.GameObjects.Components;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.GameObjects.Components;
|
||||
using Robust.Shared.Interfaces.GameObjects;
|
||||
|
||||
namespace Content.Server.GameObjects.Components.Atmos
|
||||
{
|
||||
[RegisterComponent]
|
||||
public class FirelockComponent : ServerDoorComponent, IInteractUsing, IActivate, ICollideBehavior
|
||||
{
|
||||
public override string Name => "Firelock";
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
}
|
||||
|
||||
public void CollideWith(IEntity collidedWith)
|
||||
{
|
||||
// We do nothing.
|
||||
}
|
||||
|
||||
public void Activate(ActivateEventArgs eventArgs)
|
||||
{
|
||||
// We do nothing.
|
||||
}
|
||||
|
||||
protected override void Startup()
|
||||
{
|
||||
base.Startup();
|
||||
|
||||
var airtightComponent = Owner.EnsureComponent<AirtightComponent>();
|
||||
var collidableComponent = Owner.GetComponent<ICollidableComponent>();
|
||||
|
||||
Safety = false;
|
||||
airtightComponent.AirBlocked = false;
|
||||
collidableComponent.Hard = false;
|
||||
|
||||
if (Occludes && Owner.TryGetComponent(out OccluderComponent occluder))
|
||||
{
|
||||
occluder.Enabled = false;
|
||||
}
|
||||
|
||||
State = DoorState.Open;
|
||||
SetAppearance(DoorVisualState.Open);
|
||||
}
|
||||
|
||||
public bool EmergencyPressureStop()
|
||||
{
|
||||
var closed = State == DoorState.Open && Close();
|
||||
|
||||
if(closed)
|
||||
Owner.GetComponent<AirtightComponent>().AirBlocked = true;
|
||||
|
||||
return closed;
|
||||
}
|
||||
|
||||
public override void Deny()
|
||||
{
|
||||
}
|
||||
|
||||
public override bool CanClose(IEntity user) => true;
|
||||
public override bool CanOpen(IEntity user) => true;
|
||||
|
||||
public async Task<bool> InteractUsing(InteractUsingEventArgs eventArgs)
|
||||
{
|
||||
if (!eventArgs.Using.TryGetComponent<ToolComponent>(out var tool))
|
||||
return false;
|
||||
|
||||
if (!await tool.UseTool(eventArgs.User, Owner, 3f, ToolQuality.Prying)) return false;
|
||||
|
||||
if (State == DoorState.Closed)
|
||||
Open();
|
||||
else if (State == DoorState.Open)
|
||||
Close();
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -147,55 +147,62 @@ namespace Content.Server.GameObjects.Components.Atmos
|
||||
{
|
||||
foreach (var indices in _invalidatedCoords.ToArray())
|
||||
{
|
||||
var tile = GetTile(indices);
|
||||
AddActiveTile(tile);
|
||||
|
||||
if (tile == null)
|
||||
{
|
||||
tile = new TileAtmosphere(this, _grid.Index, indices, new GasMixture(GetVolumeForCells(1)){Temperature = Atmospherics.T20C});
|
||||
_tiles[indices] = tile;
|
||||
}
|
||||
|
||||
if (IsSpace(indices))
|
||||
{
|
||||
tile.Air = new GasMixture(GetVolumeForCells(1));
|
||||
tile.Air.MarkImmutable();
|
||||
_tiles[indices] = tile;
|
||||
|
||||
} else if (IsAirBlocked(indices))
|
||||
{
|
||||
tile.Air = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
var obs = GetObstructingComponent(indices);
|
||||
|
||||
if (obs != null)
|
||||
{
|
||||
if (tile.Air == null && obs.FixVacuum)
|
||||
{
|
||||
FixVacuum(tile.GridIndices);
|
||||
}
|
||||
}
|
||||
|
||||
tile.Air ??= new GasMixture(GetVolumeForCells(1)){Temperature = Atmospherics.T20C};
|
||||
}
|
||||
|
||||
tile.UpdateAdjacent();
|
||||
tile.UpdateVisuals();
|
||||
|
||||
foreach (var direction in Cardinal)
|
||||
{
|
||||
var otherIndices = indices.Offset(direction);
|
||||
var otherTile = GetTile(otherIndices);
|
||||
AddActiveTile(otherTile);
|
||||
otherTile?.UpdateAdjacent(direction.GetOpposite());
|
||||
}
|
||||
Revalidate(indices);
|
||||
}
|
||||
|
||||
_invalidatedCoords.Clear();
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void Revalidate(MapIndices indices)
|
||||
{
|
||||
var tile = GetTile(indices);
|
||||
AddActiveTile(tile);
|
||||
|
||||
if (tile == null)
|
||||
{
|
||||
tile = new TileAtmosphere(this, _grid.Index, indices, new GasMixture(GetVolumeForCells(1)){Temperature = Atmospherics.T20C});
|
||||
_tiles[indices] = tile;
|
||||
}
|
||||
|
||||
if (IsSpace(indices))
|
||||
{
|
||||
tile.Air = new GasMixture(GetVolumeForCells(1));
|
||||
tile.Air.MarkImmutable();
|
||||
_tiles[indices] = tile;
|
||||
|
||||
} else if (IsAirBlocked(indices))
|
||||
{
|
||||
tile.Air = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
var obs = GetObstructingComponent(indices);
|
||||
|
||||
if (obs != null)
|
||||
{
|
||||
if (tile.Air == null && obs.FixVacuum)
|
||||
{
|
||||
FixVacuum(tile.GridIndices);
|
||||
}
|
||||
}
|
||||
|
||||
tile.Air ??= new GasMixture(GetVolumeForCells(1)){Temperature = Atmospherics.T20C};
|
||||
}
|
||||
|
||||
tile.UpdateAdjacent();
|
||||
tile.UpdateVisuals();
|
||||
|
||||
foreach (var direction in Cardinal)
|
||||
{
|
||||
var otherIndices = indices.Offset(direction);
|
||||
var otherTile = GetTile(otherIndices);
|
||||
AddActiveTile(otherTile);
|
||||
otherTile?.UpdateAdjacent(direction.GetOpposite());
|
||||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public void FixVacuum(MapIndices indices)
|
||||
{
|
||||
|
||||
@@ -61,6 +61,8 @@ namespace Content.Server.GameObjects.Components.Doors
|
||||
|
||||
[ViewVariables] private bool _occludes;
|
||||
|
||||
public bool Occludes => _occludes;
|
||||
|
||||
public override void ExposeData(ObjectSerializer serializer)
|
||||
{
|
||||
base.ExposeData(serializer);
|
||||
@@ -133,7 +135,7 @@ namespace Content.Server.GameObjects.Components.Doors
|
||||
}
|
||||
}
|
||||
|
||||
private void SetAppearance(DoorVisualState state)
|
||||
protected void SetAppearance(DoorVisualState state)
|
||||
{
|
||||
if (_appearance != null || Owner.TryGetComponent(out _appearance))
|
||||
_appearance.SetData(DoorVisuals.VisualState, state);
|
||||
@@ -144,7 +146,7 @@ namespace Content.Server.GameObjects.Components.Doors
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool CanOpen(IEntity user)
|
||||
public virtual bool CanOpen(IEntity user)
|
||||
{
|
||||
if (!CanOpen()) return false;
|
||||
if (!Owner.TryGetComponent(out AccessReader accessReader))
|
||||
@@ -205,7 +207,7 @@ namespace Content.Server.GameObjects.Components.Doors
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool CanClose(IEntity user)
|
||||
public virtual bool CanClose(IEntity user)
|
||||
{
|
||||
if (!CanClose()) return false;
|
||||
if (!Owner.TryGetComponent(out AccessReader accessReader))
|
||||
|
||||
Reference in New Issue
Block a user