]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
metal foam grenades (#29428)
authorNemanja <98561806+EmoGarbage404@users.noreply.github.com>
Sun, 7 Jul 2024 14:26:58 +0000 (10:26 -0400)
committerGitHub <noreply@github.com>
Sun, 7 Jul 2024 14:26:58 +0000 (00:26 +1000)
* metal foam grenades

* wow okay

* meh

* bruh

* test

* push

19 files changed:
Content.Server/EntityEffects/Effects/AreaReactionEffect.cs
Content.Server/Explosion/EntitySystems/SmokeOnTriggerSystem.cs
Content.Server/Spreader/SpreaderSystem.cs
Content.Shared/Spreader/EdgeSpreaderPrototype.cs
Content.Shared/Tiles/ReplaceFloorOnSpawnComponent.cs [new file with mode: 0644]
Content.Shared/Tiles/ReplaceFloorOnSpawnSystem.cs [new file with mode: 0644]
Resources/Locale/en-US/tiles/tiles.ftl
Resources/Prototypes/Catalog/Cargo/cargo_engineering.yml
Resources/Prototypes/Catalog/Fills/Crates/engineering.yml
Resources/Prototypes/Entities/Effects/chemistry_effects.yml
Resources/Prototypes/Entities/Objects/Weapons/Throwable/grenades.yml
Resources/Prototypes/Tiles/floors.yml
Resources/Prototypes/edge_spreaders.yml
Resources/Textures/Objects/Weapons/Grenades/metalfoam.rsi/equipped-BELT.png [new file with mode: 0644]
Resources/Textures/Objects/Weapons/Grenades/metalfoam.rsi/icon.png [new file with mode: 0644]
Resources/Textures/Objects/Weapons/Grenades/metalfoam.rsi/meta.json [new file with mode: 0644]
Resources/Textures/Objects/Weapons/Grenades/metalfoam.rsi/primed.png [new file with mode: 0644]
Resources/Textures/Tiles/attributions.yml
Resources/Textures/Tiles/foammetal.png [new file with mode: 0644]

index 481f1fc27c5da25c0561f6dc48dc27ca93f4791d..858da2b360569d5d27bbdf4d2c9a8aebf5741b0f 100644 (file)
@@ -1,4 +1,5 @@
 using Content.Server.Fluids.EntitySystems;
+using Content.Server.Spreader;
 using Content.Shared.Audio;
 using Content.Shared.Coordinates.Helpers;
 using Content.Shared.Database;
@@ -64,16 +65,19 @@ public sealed partial class AreaReactionEffect : EntityEffect
             var transform = reagentArgs.EntityManager.GetComponent<TransformComponent>(reagentArgs.TargetEntity);
             var mapManager = IoCManager.Resolve<IMapManager>();
             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);
 
             if (!mapManager.TryFindGridAt(mapCoords, out var gridUid, out var grid) ||
-                !mapSys.TryGetTileRef(gridUid, grid, transform.Coordinates, out var tileRef) ||
-                tileRef.Tile.IsSpace())
+                !mapSys.TryGetTileRef(gridUid, grid, transform.Coordinates, out var tileRef))
             {
                 return;
             }
 
+            if (spreaderSys.RequiresFloorToSpread(_prototypeId) && tileRef.Tile.IsSpace())
+                return;
+
             var coords = mapSys.MapToGrid(gridUid, mapCoords);
             var ent = reagentArgs.EntityManager.SpawnEntity(_prototypeId, coords.SnapToGrid());
 
index f958373ac74f007d647e45aeaef70ab5329fd8bd..3d3c5d85630c02aa7a0556f75b19e1a7648422e1 100644 (file)
@@ -1,6 +1,7 @@
 using Content.Shared.Explosion.Components;
 using Content.Shared.Explosion.EntitySystems;
 using Content.Server.Fluids.EntitySystems;
+using Content.Server.Spreader;
 using Content.Shared.Chemistry.Components;
 using Content.Shared.Coordinates.Helpers;
 using Content.Shared.Maps;
@@ -17,6 +18,7 @@ public sealed class SmokeOnTriggerSystem : SharedSmokeOnTriggerSystem
     [Dependency] private readonly IMapManager _mapMan = default!;
     [Dependency] private readonly SmokeSystem _smoke = default!;
     [Dependency] private readonly TransformSystem _transform = default!;
+    [Dependency] private readonly SpreaderSystem _spreader = default!;
 
     public override void Initialize()
     {
@@ -31,11 +33,14 @@ public sealed class SmokeOnTriggerSystem : SharedSmokeOnTriggerSystem
         var mapCoords = _transform.GetMapCoordinates(uid, xform);
         if (!_mapMan.TryFindGridAt(mapCoords, out _, out var grid) ||
             !grid.TryGetTileRef(xform.Coordinates, out var tileRef) ||
-            tileRef.Tile.IsSpace())
+            tileRef.Tile.IsEmpty)
         {
             return;
         }
 
+        if (_spreader.RequiresFloorToSpread(comp.SmokePrototype.ToString()) && tileRef.Tile.IsSpace())
+            return;
+
         var coords = grid.MapToGrid(mapCoords);
         var ent = Spawn(comp.SmokePrototype, coords.SnapToGrid());
         if (!TryComp<SmokeComponent>(ent, out var smoke))
index 7de8a43d354ff4eae4e18dfc1d4345e00ee55943..50f5d81183b6d327c037477edb724b2fa39831e3 100644 (file)
@@ -2,6 +2,7 @@ using Content.Server.Atmos.Components;
 using Content.Server.Atmos.EntitySystems;
 using Content.Server.Shuttles.Components;
 using Content.Shared.Atmos;
+using Content.Shared.Maps;
 using Content.Shared.Spreader;
 using Content.Shared.Tag;
 using Robust.Shared.Collections;
@@ -175,11 +176,12 @@ public sealed class SpreaderSystem : EntitySystem
     /// </summary>
     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 = [];
         occupiedTiles = [];
         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))
             return;
@@ -244,6 +246,9 @@ public sealed class SpreaderSystem : EntitySystem
             if (!_map.TryGetTileRef(neighborEnt, neighborGrid, neighborPos, out var tileRef) || tileRef.Tile.IsEmpty)
                 continue;
 
+            if (spreaderPrototype.PreventSpreadOnSpaced && tileRef.Tile.IsSpace())
+                continue;
+
             var directionEnumerator = _map.GetAnchoredEntitiesEnumerator(neighborEnt, neighborGrid, neighborPos);
             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;
+    }
 }
index fee8f93a6d3c467a00e19475c419338d9a41d34b..33665d82b5dff65bef61e2077ee4d1774492b135 100644 (file)
@@ -10,4 +10,10 @@ public sealed partial class EdgeSpreaderPrototype : IPrototype
 {
     [IdDataField] public string ID { get; } = string.Empty;
     [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;
 }
diff --git a/Content.Shared/Tiles/ReplaceFloorOnSpawnComponent.cs b/Content.Shared/Tiles/ReplaceFloorOnSpawnComponent.cs
new file mode 100644 (file)
index 0000000..1b87082
--- /dev/null
@@ -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 };
+}
diff --git a/Content.Shared/Tiles/ReplaceFloorOnSpawnSystem.cs b/Content.Shared/Tiles/ReplaceFloorOnSpawnSystem.cs
new file mode 100644 (file)
index 0000000..818991f
--- /dev/null
@@ -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));
+        }
+    }
+}
index e5b6810fcab7e04dc459e3129d722bdf4784f8b0..35cea19f7862e6f0a1b192abff759ffb8244995c 100644 (file)
@@ -87,6 +87,7 @@ tiles-gold-tile = gold tile
 tiles-silver-tile = silver tile
 tiles-glass-floor = glass floor
 tiles-reinforced-glass-floor = reinforced glass floor
+tiles-metal-foam = metal foam floor
 tiles-green-circuit-floor = green circuit floor
 tiles-blue-circuit-floor = blue circuit floor
 tiles-snow = snow
@@ -126,4 +127,4 @@ tiles-mowed-astro-grass = mowed astro-grass
 tiles-jungle-astro-grass = jungle astro-grass
 tiles-astro-ice = astro-ice
 tiles-astro-snow = astro-snow
-tiles-wood-large = large wood
\ No newline at end of file
+tiles-wood-large = large wood
index 7ca6af84518d53c511e48a34ada02112de37384d..d4e2b4c60dc8a656265d05d6c2daeb6b313bda57 100644 (file)
   category: cargoproduct-category-name-engineering
   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
   id: EngineeringCableBulk
   icon:
index 26a8910c735e95505a71b77df1dd660e446c43d9..62d07b0beda27811824f38b35227545838be7776 100644 (file)
       - id: CableHVStack
         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
   id: CrateEngineeringCableBulk
   parent: CrateElectrical
index 096e88bcb6fef0a64d75f134c36daca76de12570..ee300e9aeafff588fb47820fe2c705100568dc64 100644 (file)
       state: m_foam-north
     - map: [ "enum.EdgeLayer.West" ]
       state: m_foam-west
+  - type: EdgeSpreader
+    id: MetalFoam
   - type: FoamVisuals
     animationTime: 0.6
     animationState: m_foam-dissolve
   - type: RCDDeconstructable
     cost: 2
     delay: 2
-    fx: EffectRCDDeconstruct2  
+    fx: EffectRCDDeconstruct2
   - type: Clickable
   - type: InteractionOutline
   - type: Sprite
   - type: Transform
     anchored: true
   - type: Airtight
+  - type: ReplaceFloorOnSpawn
+    replaceableTiles:
+    - Plating
+    - Lattice
+    - TrainLattice
+    replacementTiles:
+    - FloorMetalFoam
   - type: Damageable
     damageContainer: Inorganic
     damageModifierSet: Metallic
index b1d260c32761f1f89b6bd974dfcecff2f7f848da..eb382c01e5fc578f2c65f79fa726bb2037f348a8 100644 (file)
       - ReagentId: TearGas
         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.
 
 - type: entity
index 602e9bc441cc8e044ee32f407c6c476bcad94ec5..91b61bec0942c1d490be9e1de8aa8c652fe3f88f 100644 (file)
     collection: FootstepHull
   itemDrop: FloorTileItemBrassFilled
   heatCapacity: 10000
-  
+
 - type: tile
   id: FloorBrassReebe
   name: tiles-brass-floor-reebe
   itemDrop: SheetRGlass1
   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
 - type: tile
   id: FloorGreenCircuit
index 061932c706db3cf38bebbd9f0053b915cf8a6004..c93cc02ba9774ef483cf8507fee3dd2e99eaa58e 100644 (file)
@@ -9,3 +9,8 @@
 - type: edgeSpreader
   id: Smoke
   updatesPerSecond: 8
+
+- type: edgeSpreader
+  id: MetalFoam
+  updatesPerSecond: 16
+  preventSpreadOnSpaced: false
diff --git a/Resources/Textures/Objects/Weapons/Grenades/metalfoam.rsi/equipped-BELT.png b/Resources/Textures/Objects/Weapons/Grenades/metalfoam.rsi/equipped-BELT.png
new file mode 100644 (file)
index 0000000..d3cf1cf
Binary files /dev/null and b/Resources/Textures/Objects/Weapons/Grenades/metalfoam.rsi/equipped-BELT.png differ
diff --git a/Resources/Textures/Objects/Weapons/Grenades/metalfoam.rsi/icon.png b/Resources/Textures/Objects/Weapons/Grenades/metalfoam.rsi/icon.png
new file mode 100644 (file)
index 0000000..a13dedf
Binary files /dev/null and b/Resources/Textures/Objects/Weapons/Grenades/metalfoam.rsi/icon.png differ
diff --git a/Resources/Textures/Objects/Weapons/Grenades/metalfoam.rsi/meta.json b/Resources/Textures/Objects/Weapons/Grenades/metalfoam.rsi/meta.json
new file mode 100644 (file)
index 0000000..139eebb
--- /dev/null
@@ -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
+    }
+  ]
+}
diff --git a/Resources/Textures/Objects/Weapons/Grenades/metalfoam.rsi/primed.png b/Resources/Textures/Objects/Weapons/Grenades/metalfoam.rsi/primed.png
new file mode 100644 (file)
index 0000000..dafc378
Binary files /dev/null and b/Resources/Textures/Objects/Weapons/Grenades/metalfoam.rsi/primed.png differ
index 7cfe5535a0aff3079e263a608f0ab686c58a26c5..6a6f545d1e9fea52485a62c982296a62353468d4 100644 (file)
   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"
 
-- 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"
   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"
-  
+
 - files: [ "asteroid.png", "asteroid_dug.png", "asteroid0.png"]
   license: "CC-BY-SA-3.0"
   copyright: "Taken from /tg/station at commit 6665eec76c98a4f3f89bebcd10b34b47dcc0b8ae."
@@ -40,7 +40,7 @@
   license: "CC-BY-SA-3.0"
   copyright: "Modified from plating.png by github user @Flareguy"
   source: "https://github.com/space-wizards/space-station-14/"
-  
+
 - files: ["rglass.png"]
   license: "CC-BY-SA-3.0"
   copyright: "tgstation commit 8abb19545828230d92ba18827feeb42a67a55d49, rglass modified by github user @notquitehadouken."
@@ -90,7 +90,7 @@
   license: "CC-BY-SA-3.0"
   copyright: "Fortuna commit 2a9408a47e2f83d945335e4feeeeafb552173e6f, grasslight and dirt by Peptide based on grassdark.png and dirt."
   source: "https://github.com/FortunaSS13/Fortuna"
-  
+
 - files: ["steel_maint.png", "grating_maint.png", "wood_tile.png"]
   license: "CC-BY-SA-3.0"
   copyright: "by brainfood for space-station-14, ."
   license: "CC-BY-SA-3.0"
   copyright: "taken at https://github.com/ParadiseSS13/Paradise/blob/8b7f4c8b69c74c6de5a755272eb8d3520f3d87c7/icons/turf/floors.dmi"
   source: "https://github.com/ParadiseSS13/Paradise"
-  
+
 - files: ["chromite.png"]
   license: "CC-BY-NC-SA-3.0"
   copyright: "taken at commit 0587dd16e28108bdf0b0a28e2caae4319845e861, and recolored by TheShuEd"
diff --git a/Resources/Textures/Tiles/foammetal.png b/Resources/Textures/Tiles/foammetal.png
new file mode 100644 (file)
index 0000000..a6afd53
Binary files /dev/null and b/Resources/Textures/Tiles/foammetal.png differ