Files
crystall-punk-14/Content.Server/Doors/Components/FirelockComponent.cs

88 lines
3.1 KiB
C#
Raw Normal View History

using Content.Server.Atmos.Components;
Atmos pipe rework (#3833) * Initial * Cleanup a bunch of things * some changes dunno * RequireAnchored * a * stuff * more work * Lots of progress * delete pipe visualizer * a * b * pipenet and pipenode cleanup * Fixes * Adds GasValve * Adds GasMiner * Fix stuff, maybe? * More fixes * Ignored components on the client * Adds thermomachine behavior, change a bunch of stuff * Remove Anchored * some work, but it's shitcode * significantly more ECS * ECS AtmosDevices * Cleanup * fix appearance * when the pipe direction is sus * Gas tanks and canisters * pipe anchoring and stuff * coding is my passion * Unsafe pipes take longer to unanchor * turns out we're no longer using eris canisters * Gas canister inserted tank appearance, improvements * Work on a bunch of appearances * Scrubber appearance * Reorganize AtmosphereSystem.Piping into a bunch of different systems * Appearance for vent/scrubber/pump turns off when leaving atmosphere * ThermoMachine appearance * Cleanup gas tanks * Remove passive gate unused imports * remove old canister UI functionality * PipeNode environment air, make everything use AssumeAir instead of merging manually * a * Reorganize atmos to follow new structure * ????? * Canister UI, restructure client * Restructure shared * Fix build tho * listen, at least the canister UI works entirely... * fix build : ) * Atmos device prototypes have names and descriptions * gas canister ui slider doesn't jitter * trinary prototypes * sprite for miners * ignore components * fix YAML * Fix port system doing useless thing * Fix build * fix thinking moment * fix build again because * canister direction * pipenode is a word * GasTank Air will throw on invalid states * fix build.... * Unhardcode volume pump thresholds * Volume pump and filter take time into account * Rename Join/Leave atmosphere events to AtmosDeviceEnabled/Disabled Event * Gas tank node volume is set by initial mixtuer * I love node container
2021-06-19 13:25:05 +02:00
using Content.Server.Atmos.EntitySystems;
2022-01-30 13:49:56 +13:00
using Content.Server.Doors.Systems;
using Content.Shared.Doors.Components;
Atmos pipe rework (#3833) * Initial * Cleanup a bunch of things * some changes dunno * RequireAnchored * a * stuff * more work * Lots of progress * delete pipe visualizer * a * b * pipenet and pipenode cleanup * Fixes * Adds GasValve * Adds GasMiner * Fix stuff, maybe? * More fixes * Ignored components on the client * Adds thermomachine behavior, change a bunch of stuff * Remove Anchored * some work, but it's shitcode * significantly more ECS * ECS AtmosDevices * Cleanup * fix appearance * when the pipe direction is sus * Gas tanks and canisters * pipe anchoring and stuff * coding is my passion * Unsafe pipes take longer to unanchor * turns out we're no longer using eris canisters * Gas canister inserted tank appearance, improvements * Work on a bunch of appearances * Scrubber appearance * Reorganize AtmosphereSystem.Piping into a bunch of different systems * Appearance for vent/scrubber/pump turns off when leaving atmosphere * ThermoMachine appearance * Cleanup gas tanks * Remove passive gate unused imports * remove old canister UI functionality * PipeNode environment air, make everything use AssumeAir instead of merging manually * a * Reorganize atmos to follow new structure * ????? * Canister UI, restructure client * Restructure shared * Fix build tho * listen, at least the canister UI works entirely... * fix build : ) * Atmos device prototypes have names and descriptions * gas canister ui slider doesn't jitter * trinary prototypes * sprite for miners * ignore components * fix YAML * Fix port system doing useless thing * Fix build * fix thinking moment * fix build again because * canister direction * pipenode is a word * GasTank Air will throw on invalid states * fix build.... * Unhardcode volume pump thresholds * Volume pump and filter take time into account * Rename Join/Leave atmosphere events to AtmosDeviceEnabled/Disabled Event * Gas tank node volume is set by initial mixtuer * I love node container
2021-06-19 13:25:05 +02:00
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.Serialization.Manager.Attributes;
2020-08-19 12:23:42 +02:00
namespace Content.Server.Doors.Components
2020-08-19 12:23:42 +02:00
{
/// <summary>
/// Companion component to ServerDoorComponent that handles firelock-specific behavior -- primarily prying,
/// and not being openable on open-hand click.
/// </summary>
2020-08-19 12:23:42 +02:00
[RegisterComponent]
public sealed class FirelockComponent : Component
2020-08-19 12:23:42 +02:00
{
2021-12-08 17:17:12 +01:00
[Dependency] private readonly IEntityManager _entMan = default!;
/// <summary>
/// Pry time modifier to be used when the firelock is currently closed due to fire or pressure.
/// </summary>
/// <returns></returns>
[DataField("lockedPryTimeModifier")]
public float LockedPryTimeModifier = 1.5f;
2020-08-19 12:23:42 +02:00
public bool EmergencyPressureStop()
2020-08-19 12:23:42 +02:00
{
2022-01-30 13:49:56 +13:00
var doorSys = EntitySystem.Get<DoorSystem>();
if (_entMan.TryGetComponent<DoorComponent>(Owner, out var door) &&
door.State == DoorState.Open &&
doorSys.CanClose(Owner, door))
{
2022-01-30 13:49:56 +13:00
doorSys.StartClosing(Owner, door);
// Door system also sets airtight, but only after a delay. We want it to be immediate.
2021-12-08 17:17:12 +01:00
if (_entMan.TryGetComponent(Owner, out AirtightComponent? airtight))
{
EntitySystem.Get<AirtightSystem>().SetAirblocked(airtight, true);
}
return true;
}
return false;
2020-08-19 12:23:42 +02:00
}
public bool IsHoldingPressure(float threshold = 20)
2020-08-19 12:23:42 +02:00
{
var atmosphereSystem = EntitySystem.Get<AtmosphereSystem>();
(Smaller) Construction PR - (IC Construction) (#2575) * Disable Pulling When Buckling an entity * Projectile Improvements If you shoot at a person that is critted now it will only hit if you aim at that person otherwise go "above" him and hit other targets. - Dead people are still unhitable * Update Content.Server/GameObjects/Components/Buckle/BuckleComponent.cs Co-authored-by: Víctor Aguilera Puerto <6766154+Zumorica@users.noreply.github.com> * Firelock In Progress * Revert "Projectile Improvements" This reverts commit 5821afc798e49e530d4086d7a9ddbe097805fdc4. * Firelock Graph * Revert "Merge branch 'master' into test2" This reverts commit c69661cc7d9dcdc6d8c0dd45770f9eb94b231463, reversing changes made to 5f1de8b8d24cd52190addb3df5617cb1012fd52c. * Bunch of stuff - Metal Rods - Reinforced Glass - SetStackCount Condition - Tables - Lattice * Output2 to FloorTileItemComponent * Plating, Underplating and Tiles (+FloorTile Improvements) * Turf Fixes + APC Electronics * Reinforced Glass In-hand textures * All the fixes * Final Changes * (Hopefully) Last commit * Update Resources/Prototypes/Entities/Constructible/Doors/firelock_frame.yml Co-authored-by: Paul Ritter <ritter.paul1@googlemail.com> * Update Content.Server/GameObjects/Components/Atmos/FirelockComponent.cs Co-authored-by: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com> * A Few more things * Edit FirelockComponent.cs Co-authored-by: DrSmugleaf <DrSmugleaf@users.noreply.github.com> Co-authored-by: Víctor Aguilera Puerto <6766154+Zumorica@users.noreply.github.com> Co-authored-by: Paul Ritter <ritter.paul1@googlemail.com> Co-authored-by: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com>
2020-11-20 16:58:06 +02:00
var minMoles = float.MaxValue;
var maxMoles = 0f;
2021-12-08 17:17:12 +01:00
foreach (var adjacent in atmosphereSystem.GetAdjacentTileMixtures(_entMan.GetComponent<TransformComponent>(Owner).Coordinates))
2020-08-21 18:29:43 +02:00
{
var moles = adjacent.TotalMoles;
if (moles < minMoles)
minMoles = moles;
if (moles > maxMoles)
maxMoles = moles;
}
2020-08-21 18:29:43 +02:00
return (maxMoles - minMoles) > threshold;
}
2020-08-19 12:23:42 +02:00
public bool IsHoldingFire()
{
var atmosphereSystem = EntitySystem.Get<AtmosphereSystem>();
(Smaller) Construction PR - (IC Construction) (#2575) * Disable Pulling When Buckling an entity * Projectile Improvements If you shoot at a person that is critted now it will only hit if you aim at that person otherwise go "above" him and hit other targets. - Dead people are still unhitable * Update Content.Server/GameObjects/Components/Buckle/BuckleComponent.cs Co-authored-by: Víctor Aguilera Puerto <6766154+Zumorica@users.noreply.github.com> * Firelock In Progress * Revert "Projectile Improvements" This reverts commit 5821afc798e49e530d4086d7a9ddbe097805fdc4. * Firelock Graph * Revert "Merge branch 'master' into test2" This reverts commit c69661cc7d9dcdc6d8c0dd45770f9eb94b231463, reversing changes made to 5f1de8b8d24cd52190addb3df5617cb1012fd52c. * Bunch of stuff - Metal Rods - Reinforced Glass - SetStackCount Condition - Tables - Lattice * Output2 to FloorTileItemComponent * Plating, Underplating and Tiles (+FloorTile Improvements) * Turf Fixes + APC Electronics * Reinforced Glass In-hand textures * All the fixes * Final Changes * (Hopefully) Last commit * Update Resources/Prototypes/Entities/Constructible/Doors/firelock_frame.yml Co-authored-by: Paul Ritter <ritter.paul1@googlemail.com> * Update Content.Server/GameObjects/Components/Atmos/FirelockComponent.cs Co-authored-by: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com> * A Few more things * Edit FirelockComponent.cs Co-authored-by: DrSmugleaf <DrSmugleaf@users.noreply.github.com> Co-authored-by: Víctor Aguilera Puerto <6766154+Zumorica@users.noreply.github.com> Co-authored-by: Paul Ritter <ritter.paul1@googlemail.com> Co-authored-by: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com>
2020-11-20 16:58:06 +02:00
2021-12-08 17:17:12 +01:00
if (!atmosphereSystem.TryGetGridAndTile(_entMan.GetComponent<TransformComponent>(Owner).Coordinates, out var tuple))
return false;
2020-08-21 18:29:43 +02:00
if (atmosphereSystem.GetTileMixture(tuple.Value.Grid, tuple.Value.Tile) == null)
return false;
2020-08-19 12:23:42 +02:00
if (atmosphereSystem.IsHotspotActive(tuple.Value.Grid, tuple.Value.Tile))
return true;
2021-12-08 17:17:12 +01:00
foreach (var adjacent in atmosphereSystem.GetAdjacentTiles(_entMan.GetComponent<TransformComponent>(Owner).Coordinates))
{
if (atmosphereSystem.IsHotspotActive(tuple.Value.Grid, adjacent))
return true;
}
(Smaller) Construction PR - (IC Construction) (#2575) * Disable Pulling When Buckling an entity * Projectile Improvements If you shoot at a person that is critted now it will only hit if you aim at that person otherwise go "above" him and hit other targets. - Dead people are still unhitable * Update Content.Server/GameObjects/Components/Buckle/BuckleComponent.cs Co-authored-by: Víctor Aguilera Puerto <6766154+Zumorica@users.noreply.github.com> * Firelock In Progress * Revert "Projectile Improvements" This reverts commit 5821afc798e49e530d4086d7a9ddbe097805fdc4. * Firelock Graph * Revert "Merge branch 'master' into test2" This reverts commit c69661cc7d9dcdc6d8c0dd45770f9eb94b231463, reversing changes made to 5f1de8b8d24cd52190addb3df5617cb1012fd52c. * Bunch of stuff - Metal Rods - Reinforced Glass - SetStackCount Condition - Tables - Lattice * Output2 to FloorTileItemComponent * Plating, Underplating and Tiles (+FloorTile Improvements) * Turf Fixes + APC Electronics * Reinforced Glass In-hand textures * All the fixes * Final Changes * (Hopefully) Last commit * Update Resources/Prototypes/Entities/Constructible/Doors/firelock_frame.yml Co-authored-by: Paul Ritter <ritter.paul1@googlemail.com> * Update Content.Server/GameObjects/Components/Atmos/FirelockComponent.cs Co-authored-by: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com> * A Few more things * Edit FirelockComponent.cs Co-authored-by: DrSmugleaf <DrSmugleaf@users.noreply.github.com> Co-authored-by: Víctor Aguilera Puerto <6766154+Zumorica@users.noreply.github.com> Co-authored-by: Paul Ritter <ritter.paul1@googlemail.com> Co-authored-by: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com>
2020-11-20 16:58:06 +02:00
2020-08-21 18:29:43 +02:00
return false;
2020-08-19 12:23:42 +02:00
}
}
}