metal foam grenades (#29428)

* metal foam grenades

* wow okay

* meh

* bruh

* test

* push
This commit is contained in:
Nemanja
2024-07-07 10:26:58 -04:00
committed by GitHub
parent ff93070d25
commit 21d0f85cc2
19 changed files with 219 additions and 14 deletions

View File

@@ -1,4 +1,5 @@
using Content.Server.Fluids.EntitySystems; using Content.Server.Fluids.EntitySystems;
using Content.Server.Spreader;
using Content.Shared.Audio; using Content.Shared.Audio;
using Content.Shared.Coordinates.Helpers; using Content.Shared.Coordinates.Helpers;
using Content.Shared.Database; using Content.Shared.Database;
@@ -64,16 +65,19 @@ public sealed partial class AreaReactionEffect : EntityEffect
var transform = reagentArgs.EntityManager.GetComponent<TransformComponent>(reagentArgs.TargetEntity); var transform = reagentArgs.EntityManager.GetComponent<TransformComponent>(reagentArgs.TargetEntity);
var mapManager = IoCManager.Resolve<IMapManager>(); var mapManager = IoCManager.Resolve<IMapManager>();
var mapSys = reagentArgs.EntityManager.System<MapSystem>(); var mapSys = reagentArgs.EntityManager.System<MapSystem>();
var sys = reagentArgs.EntityManager.System<TransformSystem>(); var spreaderSys = args.EntityManager.System<SpreaderSystem>();
var sys = args.EntityManager.System<TransformSystem>();
var mapCoords = sys.GetMapCoordinates(reagentArgs.TargetEntity, xform: transform); var mapCoords = sys.GetMapCoordinates(reagentArgs.TargetEntity, xform: transform);
if (!mapManager.TryFindGridAt(mapCoords, out var gridUid, out var grid) || if (!mapManager.TryFindGridAt(mapCoords, out var gridUid, out var grid) ||
!mapSys.TryGetTileRef(gridUid, grid, transform.Coordinates, out var tileRef) || !mapSys.TryGetTileRef(gridUid, grid, transform.Coordinates, out var tileRef))
tileRef.Tile.IsSpace())
{ {
return; return;
} }
if (spreaderSys.RequiresFloorToSpread(_prototypeId) && tileRef.Tile.IsSpace())
return;
var coords = mapSys.MapToGrid(gridUid, mapCoords); var coords = mapSys.MapToGrid(gridUid, mapCoords);
var ent = reagentArgs.EntityManager.SpawnEntity(_prototypeId, coords.SnapToGrid()); var ent = reagentArgs.EntityManager.SpawnEntity(_prototypeId, coords.SnapToGrid());

View File

@@ -1,6 +1,7 @@
using Content.Shared.Explosion.Components; using Content.Shared.Explosion.Components;
using Content.Shared.Explosion.EntitySystems; using Content.Shared.Explosion.EntitySystems;
using Content.Server.Fluids.EntitySystems; using Content.Server.Fluids.EntitySystems;
using Content.Server.Spreader;
using Content.Shared.Chemistry.Components; using Content.Shared.Chemistry.Components;
using Content.Shared.Coordinates.Helpers; using Content.Shared.Coordinates.Helpers;
using Content.Shared.Maps; using Content.Shared.Maps;
@@ -17,6 +18,7 @@ public sealed class SmokeOnTriggerSystem : SharedSmokeOnTriggerSystem
[Dependency] private readonly IMapManager _mapMan = default!; [Dependency] private readonly IMapManager _mapMan = default!;
[Dependency] private readonly SmokeSystem _smoke = default!; [Dependency] private readonly SmokeSystem _smoke = default!;
[Dependency] private readonly TransformSystem _transform = default!; [Dependency] private readonly TransformSystem _transform = default!;
[Dependency] private readonly SpreaderSystem _spreader = default!;
public override void Initialize() public override void Initialize()
{ {
@@ -31,11 +33,14 @@ public sealed class SmokeOnTriggerSystem : SharedSmokeOnTriggerSystem
var mapCoords = _transform.GetMapCoordinates(uid, xform); var mapCoords = _transform.GetMapCoordinates(uid, xform);
if (!_mapMan.TryFindGridAt(mapCoords, out _, out var grid) || if (!_mapMan.TryFindGridAt(mapCoords, out _, out var grid) ||
!grid.TryGetTileRef(xform.Coordinates, out var tileRef) || !grid.TryGetTileRef(xform.Coordinates, out var tileRef) ||
tileRef.Tile.IsSpace()) tileRef.Tile.IsEmpty)
{ {
return; return;
} }
if (_spreader.RequiresFloorToSpread(comp.SmokePrototype.ToString()) && tileRef.Tile.IsSpace())
return;
var coords = grid.MapToGrid(mapCoords); var coords = grid.MapToGrid(mapCoords);
var ent = Spawn(comp.SmokePrototype, coords.SnapToGrid()); var ent = Spawn(comp.SmokePrototype, coords.SnapToGrid());
if (!TryComp<SmokeComponent>(ent, out var smoke)) if (!TryComp<SmokeComponent>(ent, out var smoke))

View File

@@ -2,6 +2,7 @@ using Content.Server.Atmos.Components;
using Content.Server.Atmos.EntitySystems; using Content.Server.Atmos.EntitySystems;
using Content.Server.Shuttles.Components; using Content.Server.Shuttles.Components;
using Content.Shared.Atmos; using Content.Shared.Atmos;
using Content.Shared.Maps;
using Content.Shared.Spreader; using Content.Shared.Spreader;
using Content.Shared.Tag; using Content.Shared.Tag;
using Robust.Shared.Collections; using Robust.Shared.Collections;
@@ -175,11 +176,12 @@ public sealed class SpreaderSystem : EntitySystem
/// </summary> /// </summary>
public void GetNeighbors(EntityUid uid, TransformComponent comp, ProtoId<EdgeSpreaderPrototype> prototype, out ValueList<(MapGridComponent, TileRef)> freeTiles, out ValueList<Vector2i> occupiedTiles, out ValueList<EntityUid> neighbors) public void GetNeighbors(EntityUid uid, TransformComponent comp, ProtoId<EdgeSpreaderPrototype> prototype, out ValueList<(MapGridComponent, TileRef)> freeTiles, out ValueList<Vector2i> occupiedTiles, out ValueList<EntityUid> neighbors)
{ {
// TODO remove occupiedTiles -- its currently unused and just slows this method down.
DebugTools.Assert(_prototype.HasIndex(prototype));
freeTiles = []; freeTiles = [];
occupiedTiles = []; occupiedTiles = [];
neighbors = []; neighbors = [];
// TODO remove occupiedTiles -- its currently unused and just slows this method down.
if (!_prototype.TryIndex(prototype, out var spreaderPrototype))
return;
if (!TryComp<MapGridComponent>(comp.GridUid, out var grid)) if (!TryComp<MapGridComponent>(comp.GridUid, out var grid))
return; return;
@@ -244,6 +246,9 @@ public sealed class SpreaderSystem : EntitySystem
if (!_map.TryGetTileRef(neighborEnt, neighborGrid, neighborPos, out var tileRef) || tileRef.Tile.IsEmpty) if (!_map.TryGetTileRef(neighborEnt, neighborGrid, neighborPos, out var tileRef) || tileRef.Tile.IsEmpty)
continue; continue;
if (spreaderPrototype.PreventSpreadOnSpaced && tileRef.Tile.IsSpace())
continue;
var directionEnumerator = _map.GetAnchoredEntitiesEnumerator(neighborEnt, neighborGrid, neighborPos); var directionEnumerator = _map.GetAnchoredEntitiesEnumerator(neighborEnt, neighborGrid, neighborPos);
var occupied = false; var occupied = false;
@@ -335,4 +340,12 @@ public sealed class SpreaderSystem : EntitySystem
} }
} }
} }
public bool RequiresFloorToSpread(EntProtoId<EdgeSpreaderComponent> spreader)
{
if (!_prototype.Index(spreader).TryGetComponent<EdgeSpreaderComponent>(out var spreaderComp, EntityManager.ComponentFactory))
return false;
return _prototype.Index(spreaderComp.Id).PreventSpreadOnSpaced;
}
} }

View File

@@ -10,4 +10,10 @@ public sealed partial class EdgeSpreaderPrototype : IPrototype
{ {
[IdDataField] public string ID { get; } = string.Empty; [IdDataField] public string ID { get; } = string.Empty;
[DataField(required:true)] public int UpdatesPerSecond; [DataField(required:true)] public int UpdatesPerSecond;
/// <summary>
/// If true, this spreader can't spread onto spaced tiles like lattice.
/// </summary>
[DataField]
public bool PreventSpreadOnSpaced = true;
} }

View File

@@ -0,0 +1,36 @@
using Content.Shared.Maps;
using Robust.Shared.GameStates;
using Robust.Shared.Prototypes;
namespace Content.Shared.Tiles;
/// <summary>
/// Replaces floor tiles around this entity when it spawns
/// </summary>
[RegisterComponent, NetworkedComponent, Access(typeof(ReplaceFloorOnSpawnSystem))]
public sealed partial class ReplaceFloorOnSpawnComponent : Component
{
/// <summary>
/// The floor tiles that will be replaced. If null, will replace all.
/// </summary>
[DataField]
public List<ProtoId<ContentTileDefinition>>? ReplaceableTiles = new();
/// <summary>
/// The tiles that it will replace. Randomly picked from the list.
/// </summary>
[DataField]
public List<ProtoId<ContentTileDefinition>> ReplacementTiles = new();
/// <summary>
/// Whether or not there has to be a tile in the location to be replaced.
/// </summary>
[DataField]
public bool ReplaceSpace = true;
/// <summary>
/// List of offsets from the base tile, used to determine which tiles will be replaced.
/// </summary>
[DataField]
public List<Vector2i> Offsets = new() { Vector2i.Up, Vector2i.Down, Vector2i.Left, Vector2i.Right, Vector2i.Zero };
}

View File

@@ -0,0 +1,48 @@
using Robust.Shared.Map;
using Robust.Shared.Map.Components;
using Robust.Shared.Prototypes;
using Robust.Shared.Random;
namespace Content.Shared.Tiles;
public sealed class ReplaceFloorOnSpawnSystem : EntitySystem
{
[Dependency] private readonly ITileDefinitionManager _tile = default!;
[Dependency] private readonly IPrototypeManager _prototype = default!;
[Dependency] private readonly IRobustRandom _random = default!;
[Dependency] private readonly SharedMapSystem _map = default!;
/// <inheritdoc/>
public override void Initialize()
{
SubscribeLocalEvent<ReplaceFloorOnSpawnComponent, MapInitEvent>(OnMapInit);
}
private void OnMapInit(Entity<ReplaceFloorOnSpawnComponent> ent, ref MapInitEvent args)
{
var xform = Transform(ent);
if (xform.GridUid is not { } grid || !TryComp<MapGridComponent>(grid, out var gridComp))
return;
if (ent.Comp.ReplaceableTiles != null && ent.Comp.ReplaceableTiles.Count == 0)
return;
var tileIndices = _map.LocalToTile(grid, gridComp, xform.Coordinates);
foreach (var offset in ent.Comp.Offsets)
{
var actualIndices = tileIndices + offset;
if (!_map.TryGetTileRef(grid, gridComp, actualIndices, out var tile))
continue;
if (ent.Comp.ReplaceableTiles != null &&
!tile.Tile.IsEmpty &&
!ent.Comp.ReplaceableTiles.Contains(_tile[tile.Tile.TypeId].ID))
continue;
var tileToSet = _random.Pick(ent.Comp.ReplacementTiles);
_map.SetTile(grid, gridComp, tile.GridIndices, new Tile(_prototype.Index(tileToSet).TileId));
}
}
}

View File

@@ -87,6 +87,7 @@ tiles-gold-tile = gold tile
tiles-silver-tile = silver tile tiles-silver-tile = silver tile
tiles-glass-floor = glass floor tiles-glass-floor = glass floor
tiles-reinforced-glass-floor = reinforced glass floor tiles-reinforced-glass-floor = reinforced glass floor
tiles-metal-foam = metal foam floor
tiles-green-circuit-floor = green circuit floor tiles-green-circuit-floor = green circuit floor
tiles-blue-circuit-floor = blue circuit floor tiles-blue-circuit-floor = blue circuit floor
tiles-snow = snow tiles-snow = snow

View File

@@ -28,6 +28,16 @@
category: cargoproduct-category-name-engineering category: cargoproduct-category-name-engineering
group: market group: market
- type: cargoProduct
id: EngineeringFoamGrenade
icon:
sprite: Objects/Weapons/Grenades/metalfoam.rsi
state: icon
product: CrateEngineeringFoamGrenade
cost: 2500
category: cargoproduct-category-name-engineering
group: market
- type: cargoProduct - type: cargoProduct
id: EngineeringCableBulk id: EngineeringCableBulk
icon: icon:

View File

@@ -76,6 +76,17 @@
- id: CableHVStack - id: CableHVStack
amount: 3 amount: 3
- type: entity
id: CrateEngineeringFoamGrenade
parent: CrateEngineeringSecure
name: sealant grenade crate
description: 5 metal foam sealant grenades.
components:
- type: StorageFill
contents:
- id: MetalFoamGrenade
amount: 5
- type: entity - type: entity
id: CrateEngineeringCableBulk id: CrateEngineeringCableBulk
parent: CrateElectrical parent: CrateElectrical

View File

@@ -101,6 +101,8 @@
state: m_foam-north state: m_foam-north
- map: [ "enum.EdgeLayer.West" ] - map: [ "enum.EdgeLayer.West" ]
state: m_foam-west state: m_foam-west
- type: EdgeSpreader
id: MetalFoam
- type: FoamVisuals - type: FoamVisuals
animationTime: 0.6 animationTime: 0.6
animationState: m_foam-dissolve animationState: m_foam-dissolve
@@ -159,6 +161,13 @@
- type: Transform - type: Transform
anchored: true anchored: true
- type: Airtight - type: Airtight
- type: ReplaceFloorOnSpawn
replaceableTiles:
- Plating
- Lattice
- TrainLattice
replacementTiles:
- FloorMetalFoam
- type: Damageable - type: Damageable
damageContainer: Inorganic damageContainer: Inorganic
damageModifierSet: Metallic damageModifierSet: Metallic

View File

@@ -422,6 +422,21 @@
- ReagentId: TearGas - ReagentId: TearGas
Quantity: 50 Quantity: 50
- type: entity
parent: SmokeGrenade
id: MetalFoamGrenade
name: metal foam grenade
description: An emergency tool used for patching up holes. Almost as good as real walls.
components:
- type: Sprite
sprite: Objects/Weapons/Grenades/metalfoam.rsi
- type: SmokeOnTrigger
duration: 10
spreadAmount: 13
smokePrototype: AluminiumMetalFoam
- type: StaticPrice
price: 350
# Non-explosive "dummy" grenades to use as a distraction. # Non-explosive "dummy" grenades to use as a distraction.
- type: entity - type: entity

View File

@@ -1391,6 +1391,21 @@
itemDrop: SheetRGlass1 itemDrop: SheetRGlass1
heatCapacity: 10000 heatCapacity: 10000
- type: tile
id: FloorMetalFoam
name: tiles-metal-foam
sprite: /Textures/Tiles/foammetal.png
variants: 1
placementVariants:
- 1.0
baseTurf: Plating
isSubfloor: false
deconstructTools: [ Prying ]
footstepSounds:
collection: FootstepHull
itemDrop: SheetSteel1
heatCapacity: 10000
# Circuits # Circuits
- type: tile - type: tile
id: FloorGreenCircuit id: FloorGreenCircuit

View File

@@ -9,3 +9,8 @@
- type: edgeSpreader - type: edgeSpreader
id: Smoke id: Smoke
updatesPerSecond: 8 updatesPerSecond: 8
- type: edgeSpreader
id: MetalFoam
updatesPerSecond: 16
preventSpreadOnSpaced: false

Binary file not shown.

After

Width:  |  Height:  |  Size: 240 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 335 B

View File

@@ -0,0 +1,27 @@
{
"version": 1,
"license": "CC-BY-SA-3.0",
"copyright": "Created by EmoGarbage404",
"size": {
"x": 32,
"y": 32
},
"states": [
{
"name": "icon"
},
{
"name": "primed",
"delays": [
[
0.2,
0.1
]
]
},
{
"name": "equipped-BELT",
"directions": 4
}
]
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 454 B

View File

@@ -16,7 +16,7 @@
copyright: "Modified by github user @Flareguy from plating.png, using damaged plating sprites from /tg/station at commit https://github.com/tgstation/tgstation/blob/6665eec76c98a4f3f89bebcd10b34b47dcc0b8ae/icons/turf/floors.dmi" copyright: "Modified by github user @Flareguy from plating.png, using damaged plating sprites from /tg/station at commit https://github.com/tgstation/tgstation/blob/6665eec76c98a4f3f89bebcd10b34b47dcc0b8ae/icons/turf/floors.dmi"
source: "https://github.com/space-wizards/space-station-14/pull/21711" source: "https://github.com/space-wizards/space-station-14/pull/21711"
- files: [ "asteroid_red.png", "asteroid_tile.png", "elevator_shaft.png", "freezer.png", "green_circuit.png", "lino.png", "mono.png", "rock_vault.png", "showroom.png"] - files: [ "asteroid_red.png", "asteroid_tile.png", "elevator_shaft.png", "freezer.png", "foammetal.png", "green_circuit.png", "lino.png", "mono.png", "rock_vault.png", "showroom.png"]
license: "CC-BY-SA-3.0" license: "CC-BY-SA-3.0"
copyright: "vgstation13 at roughly commit e4d3ea7f69d21c3667be12b114fa935c4640cb05, asteroid_red and asteroid_tile taken from commit /vg/station at commit 02b9f6894af4419c9f7e699a22c402b086d8067e." copyright: "vgstation13 at roughly commit e4d3ea7f69d21c3667be12b114fa935c4640cb05, asteroid_red and asteroid_tile taken from commit /vg/station at commit 02b9f6894af4419c9f7e699a22c402b086d8067e."
source: "https://github.com/vgstation-coders/vgstation13" source: "https://github.com/vgstation-coders/vgstation13"

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB