forked from space-wizards/space-station-14
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
metal foam grenades (space-wizards#29428)
* metal foam grenades * wow okay * meh * bruh * test * push
- Loading branch information
1 parent
c9bdf14
commit 44f8728
Showing
19 changed files
with
219 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 }; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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)); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file added
BIN
+240 Bytes
Resources/Textures/Objects/Weapons/Grenades/metalfoam.rsi/equipped-BELT.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
27 changes: 27 additions & 0 deletions
27
Resources/Textures/Objects/Weapons/Grenades/metalfoam.rsi/meta.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 added
BIN
+454 Bytes
Resources/Textures/Objects/Weapons/Grenades/metalfoam.rsi/primed.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.