Fix firelock danger indicators (#12327)

* Fix firelock danger indicators

* remove unused arg
This commit is contained in:
Leon Friedrich
2022-11-09 08:55:45 +13:00
committed by GitHub
parent 5f71fc1ea1
commit 8620899a4a
5 changed files with 243 additions and 53 deletions

View File

@@ -89,6 +89,28 @@ public partial class AtmosphereSystem
RaiseLocalEvent(gridUid, ref ev);
}
public GasMixture?[]? GetTileMixtures(EntityUid? gridUid, EntityUid? mapUid, List<Vector2i> tiles, bool excite = false)
{
var ev = new GetTileMixturesMethodEvent(gridUid, mapUid, tiles, excite);
// If we've been passed a grid, try to let it handle it.
if (gridUid.HasValue)
RaiseLocalEvent(gridUid.Value, ref ev, false);
if (ev.Handled)
return ev.Mixtures;
// We either don't have a grid, or the event wasn't handled.
// Let the map handle it instead, and also broadcast the event.
if (mapUid.HasValue)
RaiseLocalEvent(mapUid.Value, ref ev, true);
else
RaiseLocalEvent(ref ev);
// Default to a space mixture... This is a space game, after all!
return ev.Mixtures ?? new GasMixture?[tiles.Count];
}
public GasMixture? GetTileMixture(EntityUid? gridUid, EntityUid? mapUid, Vector2i tile, bool excite = false)
{
var ev = new GetTileMixtureMethodEvent(gridUid, mapUid, tile, excite);
@@ -256,6 +278,9 @@ public partial class AtmosphereSystem
[ByRefEvent] private record struct InvalidateTileMethodEvent
(EntityUid Grid, Vector2i Tile, bool Handled = false);
[ByRefEvent] private record struct GetTileMixturesMethodEvent
(EntityUid? GridUid, EntityUid? MapUid, List<Vector2i> Tiles, bool Excite = false, GasMixture?[]? Mixtures = null, bool Handled = false);
[ByRefEvent] private record struct GetTileMixtureMethodEvent
(EntityUid? GridUid, EntityUid? MapUid, Vector2i Tile, bool Excite = false, GasMixture? Mixture = null, bool Handled = false);

View File

@@ -21,6 +21,7 @@ public sealed partial class AtmosphereSystem
SubscribeLocalEvent<GridAtmosphereComponent, GetAllMixturesMethodEvent>(GridGetAllMixtures);
SubscribeLocalEvent<GridAtmosphereComponent, InvalidateTileMethodEvent>(GridInvalidateTile);
SubscribeLocalEvent<GridAtmosphereComponent, GetTileMixtureMethodEvent>(GridGetTileMixture);
SubscribeLocalEvent<GridAtmosphereComponent, GetTileMixturesMethodEvent>(GridGetTileMixtures);
SubscribeLocalEvent<GridAtmosphereComponent, ReactTileMethodEvent>(GridReactTile);
SubscribeLocalEvent<GridAtmosphereComponent, IsTileAirBlockedMethodEvent>(GridIsTileAirBlocked);
SubscribeLocalEvent<GridAtmosphereComponent, IsTileSpaceMethodEvent>(GridIsTileSpace);
@@ -178,6 +179,28 @@ public sealed partial class AtmosphereSystem
args.Handled = true;
}
private void GridGetTileMixtures(EntityUid uid, GridAtmosphereComponent component,
ref GetTileMixturesMethodEvent args)
{
if (args.Handled)
return;
args.Handled = true;
args.Mixtures = new GasMixture?[args.Tiles.Count];
for (var i = 0; i < args.Tiles.Count; i++)
{
var tile = args.Tiles[i];
if (!component.Tiles.TryGetValue(tile, out var atmosTile))
continue;
if (args.Excite)
component.InvalidatedCoords.Add(tile);
args.Mixtures[i] = atmosTile.Air;
}
}
private void GridReactTile(EntityUid uid, GridAtmosphereComponent component, ref ReactTileMethodEvent args)
{
if (args.Handled)

View File

@@ -8,6 +8,7 @@ public partial class AtmosphereSystem
{
SubscribeLocalEvent<MapAtmosphereComponent, IsTileSpaceMethodEvent>(MapIsTileSpace);
SubscribeLocalEvent<MapAtmosphereComponent, GetTileMixtureMethodEvent>(MapGetTileMixture);
SubscribeLocalEvent<MapAtmosphereComponent, GetTileMixturesMethodEvent>(MapGetTileMixtures);
}
private void MapIsTileSpace(EntityUid uid, MapAtmosphereComponent component, ref IsTileSpaceMethodEvent args)
@@ -28,4 +29,20 @@ public partial class AtmosphereSystem
args.Mixture = component.Mixture?.Clone();
args.Handled = true;
}
private void MapGetTileMixtures(EntityUid uid, MapAtmosphereComponent component, ref GetTileMixturesMethodEvent args)
{
if (args.Handled)
return;
args.Handled = true;
args.Mixtures = new GasMixture?[args.Tiles.Count];
if (component.Mixture == null)
return;
for (var i = 0; i < args.Tiles.Count; i++)
{
args.Mixtures[i] = component.Mixture.Clone();
}
}
}