Crowbar floor tiles and placement (#429)

* Adds tile removing behavior to CrowbarComponent.
Add FloorTileItemComponent.
Add genhit.ogg
Add tile.png for testing

* fixes

* Gives ContentTileDefinition a default value for tile item to drop.
Adds a few more tileitems.

* Changes per review request

* move stack.use and if statement
This commit is contained in:
Ephememory
2019-11-23 16:10:05 -05:00
committed by Pieter-Jan Briers
parent 35f9de3366
commit d63c879404
76 changed files with 176 additions and 0 deletions

View File

@@ -42,6 +42,10 @@ namespace Content.Server.GameObjects.Components.Interactable.Tools
var underplating = _tileDefinitionManager["underplating"]; var underplating = _tileDefinitionManager["underplating"];
mapGrid.SetTile(eventArgs.ClickLocation, new Tile(underplating.TileId)); mapGrid.SetTile(eventArgs.ClickLocation, new Tile(underplating.TileId));
_entitySystemManager.GetEntitySystem<AudioSystem>().Play("/Audio/items/crowbar.ogg", Owner); _entitySystemManager.GetEntitySystem<AudioSystem>().Play("/Audio/items/crowbar.ogg", Owner);
//Actually spawn the relevant tile item at the right position and give it some offset to the corner.
var tileItem = Owner.EntityManager.SpawnEntity(tileDef.ItemDropPrototypeName);
tileItem.Transform.GridPosition = coordinates;
tileItem.Transform.WorldPosition += (0.2f, 0.2f);
} }
} }
} }

View File

@@ -0,0 +1,70 @@
using Content.Server.GameObjects.Components.Stack;
using Content.Server.GameObjects.EntitySystems;
using Content.Shared.Maps;
using Robust.Server.GameObjects.EntitySystems;
using Robust.Shared.GameObjects;
using Robust.Shared.Interfaces.GameObjects;
using Robust.Shared.Interfaces.Map;
using Robust.Shared.IoC;
using Robust.Shared.Localization;
using Robust.Shared.Map;
using Robust.Shared.Serialization;
using Robust.Shared.Utility;
namespace Content.Server.GameObjects.Components.Items
{
[RegisterComponent]
public class FloorTileItemComponent : Component, IAfterAttack
{
#pragma warning disable 649
[Dependency] private readonly ITileDefinitionManager _tileDefinitionManager;
[Dependency] private readonly IEntitySystemManager _entitySystemManager;
[Dependency] private readonly IMapManager _mapManager;
#pragma warning restore 649
public override string Name => "FloorTile";
private StackComponent Stack;
public string _outputTile;
public override void ExposeData(ObjectSerializer serializer)
{
base.ExposeData(serializer);
serializer.DataField(ref _outputTile, "output", "floor_steel");
}
public override void Initialize()
{
base.Initialize();
Stack = Owner.GetComponent<StackComponent>();
}
public void AfterAttack(AfterAttackEventArgs eventArgs)
{
var attacked = eventArgs.Attacked;
var mapGrid = _mapManager.GetGrid(eventArgs.ClickLocation.GridID);
var tile = mapGrid.GetTileRef(eventArgs.ClickLocation);
var coordinates = mapGrid.GridTileToLocal(tile.GridIndices);
float distance = coordinates.Distance(_mapManager, Owner.Transform.GridPosition);
if (distance > InteractionSystem.InteractionRange)
{
return;
}
var tileDef = (ContentTileDefinition)_tileDefinitionManager[tile.Tile.TypeId];
if (tileDef.IsSubFloor && attacked == null && Stack.Use(1))
{
var desiredTile = _tileDefinitionManager[_outputTile];
mapGrid.SetTile(eventArgs.ClickLocation, new Tile(desiredTile.TileId));
_entitySystemManager.GetEntitySystem<AudioSystem>().Play("/Audio/items/genhit.ogg", Owner);
if(Stack.Count < 1){
Owner.Delete();
}
}
}
}
}

View File

@@ -132,5 +132,6 @@ namespace Content.Server.GameObjects.Components.Stack
Cable, Cable,
Ointment, Ointment,
Brutepack, Brutepack,
FloorTileSteel
} }
} }

View File

@@ -3,6 +3,8 @@ using Robust.Shared.Interfaces.Map;
using Robust.Shared.Prototypes; using Robust.Shared.Prototypes;
using Robust.Shared.Utility; using Robust.Shared.Utility;
using YamlDotNet.RepresentationModel; using YamlDotNet.RepresentationModel;
using Robust.Shared.GameObjects;
using Robust.Shared.Serialization;
namespace Content.Shared.Maps namespace Content.Shared.Maps
{ {
@@ -21,6 +23,7 @@ namespace Content.Shared.Maps
public bool CanCrowbar { get; private set; } public bool CanCrowbar { get; private set; }
public string FootstepSounds { get; private set; } public string FootstepSounds { get; private set; }
public float Friction { get; set; } public float Friction { get; set; }
public string ItemDropPrototypeName { get; private set; }
public void AssignTileId(ushort id) public void AssignTileId(ushort id)
{ {
@@ -60,6 +63,16 @@ namespace Content.Shared.Maps
{ {
Friction = 0; Friction = 0;
} }
if (mapping.TryGetNode("item_drop", out node))
{
ItemDropPrototypeName = node.ToString();
}
else
{
ItemDropPrototypeName = "FloorTileItemSteel";
}
} }
} }
} }

Binary file not shown.

View File

@@ -0,0 +1,83 @@
- type: entity
name: Carpet Floor Tile
parent: BaseItem
id: FloorTileItemCarpet
description: Those could work as a pretty decent throwing weapon.
components:
- type: Sprite
sprite: Objects/Tiles/tile.rsi
state: tile_carpet
- type: Icon
sprite: Objects/Tiles/tile.rsi
state: tile_carpet
- type: Item
Size: 25
- type: FloorTile
output: floor_carpet
- type: Stack
stacktype: FloorTileCarpet
count: 1
max: 8
- type: entity
name: White Floor Tile
parent: BaseItem
id: FloorTileItemWhite
description: Those could work as a pretty decent throwing weapon.
components:
- type: Sprite
sprite: Objects/Tiles/tile.rsi
state: tile_white
- type: Icon
sprite: Objects/Tiles/tile.rsi
state: tile_white
- type: Item
Size: 25
- type: FloorTile
output: floor_white
- type: Stack
stacktype: FloorTileWhite
count: 1
max: 8
- type: entity
name: Dark Floor Tile
parent: BaseItem
id: FloorTileItemDark
description: Those could work as a pretty decent throwing weapon.
components:
- type: Sprite
sprite: Objects/Tiles/tile.rsi
state: tile_dark
- type: Icon
sprite: Objects/Tiles/tile.rsi
state: tile_dark
- type: Item
Size: 25
- type: FloorTile
output: floor_dark
- type: Stack
stacktype: FloorTileDark
count: 1
max: 8
- type: entity
name: Steel Floor Tile
parent: BaseItem
id: FloorTileItemSteel
description: Those could work as a pretty decent throwing weapon.
components:
- type: Sprite
sprite: Objects/Tiles/tile.rsi
state: tile_steel
- type: Icon
sprite: Objects/Tiles/tile.rsi
state: tile_steel
- type: Item
Size: 25
- type: FloorTile
output: floor_steel
- type: Stack
stacktype: FloorTileSteel
count: 1
max: 8

View File

@@ -7,6 +7,7 @@
footstep_sounds: footstep_carpet footstep_sounds: footstep_carpet
friction: 0.35 friction: 0.35
subfloor: plating subfloor: plating
item_drop: FloorTileItemCarpet
- type: tile - type: tile
name: floor_dark name: floor_dark
@@ -17,6 +18,7 @@
footstep_sounds: footstep_floor footstep_sounds: footstep_floor
friction: 0.35 friction: 0.35
subfloor: plating subfloor: plating
item_drop: FloorTileItemDark
- type: tile - type: tile
name: floor_elevator_shaft name: floor_elevator_shaft
@@ -117,6 +119,7 @@
footstep_sounds: footstep_floor footstep_sounds: footstep_floor
friction: 0.35 friction: 0.35
subfloor: plating subfloor: plating
item_drop: FloorTileItemSteel
- type: tile - type: tile
name: floor_steel_dirty name: floor_steel_dirty
@@ -147,6 +150,7 @@
footstep_sounds: footstep_floor footstep_sounds: footstep_floor
friction: 0.1 friction: 0.1
subfloor: underplating subfloor: underplating
item_drop: FloorTileItemWhite
- type: tile - type: tile
name: floor_asteroid_sand name: floor_asteroid_sand

Binary file not shown.

After

Width:  |  Height:  |  Size: 211 B

View File

@@ -0,0 +1 @@
{"version": 1, "size": {"x": 32, "y": 32}, "states": [{"name": "", "directions": 1, "delays": [[1.0]]}, {"name": "tile", "directions": 1, "delays": [[1.0]]}, {"name": "tile-white-techfloor", "directions": 1, "delays": [[1.0]]}, {"name": "tile_bcarpet", "directions": 1, "delays": [[1.0]]}, {"name": "tile_blucarpet", "directions": 1, "delays": [[1.0]]}, {"name": "tile_cafe", "directions": 1, "delays": [[1.0]]}, {"name": "tile_carpet", "directions": 1, "delays": [[1.0]]}, {"name": "tile_dark", "directions": 1, "delays": [[1.0]]}, {"name": "tile_dark_bluecorner", "directions": 1, "delays": [[1.0]]}, {"name": "tile_dark_brownperforated", "directions": 1, "delays": [[1.0]]}, {"name": "tile_dark_brownplatform", "directions": 1, "delays": [[1.0]]}, {"name": "tile_dark_cargo", "directions": 1, "delays": [[1.0]]}, {"name": "tile_dark_cyancorner", "directions": 1, "delays": [[1.0]]}, {"name": "tile_dark_danger", "directions": 1, "delays": [[1.0]]}, {"name": "tile_dark_golden", "directions": 1, "delays": [[1.0]]}, {"name": "tile_dark_grayperforated", "directions": 1, "delays": [[1.0]]}, {"name": "tile_dark_grayplatform", "directions": 1, "delays": [[1.0]]}, {"name": "tile_dark_monofloor", "directions": 1, "delays": [[1.0]]}, {"name": "tile_dark_orangecorner", "directions": 1, "delays": [[1.0]]}, {"name": "tile_dark_panels", "directions": 1, "delays": [[1.0]]}, {"name": "tile_dark_techfloor", "directions": 1, "delays": [[1.0]]}, {"name": "tile_dark_techfloor_grid", "directions": 1, "delays": [[1.0]]}, {"name": "tile_dark_violetcorener", "directions": 1, "delays": [[1.0]]}, {"name": "tile_gaycarpet", "directions": 1, "delays": [[1.0]]}, {"name": "tile_grass", "directions": 1, "delays": [[1.0]]}, {"name": "tile_oracarpet", "directions": 1, "delays": [[1.0]]}, {"name": "tile_purcarpet", "directions": 1, "delays": [[1.0]]}, {"name": "tile_sblucarpet", "directions": 1, "delays": [[1.0]]}, {"name": "tile_steel", "directions": 1, "delays": [[1.0]]}, {"name": "tile_steel_bar_dance", "directions": 1, "delays": [[1.0]]}, {"name": "tile_steel_bar_flat", "directions": 1, "delays": [[1.0]]}, {"name": "tile_steel_bar_light", "directions": 1, "delays": [[1.0]]}, {"name": "tile_steel_bluecorner", "directions": 1, "delays": [[1.0]]}, {"name": "tile_steel_brownperforated", "directions": 1, "delays": [[1.0]]}, {"name": "tile_steel_brownplatform", "directions": 1, "delays": [[1.0]]}, {"name": "tile_steel_cargo", "directions": 1, "delays": [[1.0]]}, {"name": "tile_steel_cyancorner", "directions": 1, "delays": [[1.0]]}, {"name": "tile_steel_danger", "directions": 1, "delays": [[1.0]]}, {"name": "tile_steel_golden", "directions": 1, "delays": [[1.0]]}, {"name": "tile_steel_grayperforated", "directions": 1, "delays": [[1.0]]}, {"name": "tile_steel_grayplatform", "directions": 1, "delays": [[1.0]]}, {"name": "tile_steel_monofloor", "directions": 1, "delays": [[1.0]]}, {"name": "tile_steel_orangecorner", "directions": 1, "delays": [[1.0]]}, {"name": "tile_steel_panels", "directions": 1, "delays": [[1.0]]}, {"name": "tile_steel_techfloor", "directions": 1, "delays": [[1.0]]}, {"name": "tile_steel_techfloor_grid", "directions": 1, "delays": [[1.0]]}, {"name": "tile_steel_violetcorener", "directions": 1, "delays": [[1.0]]}, {"name": "tile_techmaint", "directions": 1, "delays": [[1.0]]}, {"name": "tile_techmaint_cargo", "directions": 1, "delays": [[1.0]]}, {"name": "tile_techmaint_panels", "directions": 1, "delays": [[1.0]]}, {"name": "tile_techmaint_perforated", "directions": 1, "delays": [[1.0]]}, {"name": "tile_turcarpet", "directions": 1, "delays": [[1.0]]}, {"name": "tile_white", "directions": 1, "delays": [[1.0]]}, {"name": "tile_white_bluecorner", "directions": 1, "delays": [[1.0]]}, {"name": "tile_white_brownperforated", "directions": 1, "delays": [[1.0]]}, {"name": "tile_white_brownplatform", "directions": 1, "delays": [[1.0]]}, {"name": "tile_white_cargo", "directions": 1, "delays": [[1.0]]}, {"name": "tile_white_cyancorner", "directions": 1, "delays": [[1.0]]}, {"name": "tile_white_danger", "directions": 1, "delays": [[1.0]]}, {"name": "tile_white_golden", "directions": 1, "delays": [[1.0]]}, {"name": "tile_white_grayperforated", "directions": 1, "delays": [[1.0]]}, {"name": "tile_white_grayplatform", "directions": 1, "delays": [[1.0]]}, {"name": "tile_white_monofloor", "directions": 1, "delays": [[1.0]]}, {"name": "tile_white_orangecorner", "directions": 1, "delays": [[1.0]]}, {"name": "tile_white_panels", "directions": 1, "delays": [[1.0]]}, {"name": "tile_white_techfloor_grid", "directions": 1, "delays": [[1.0]]}, {"name": "tile_white_violetcorener", "directions": 1, "delays": [[1.0]]}, {"name": "tile_wood", "directions": 1, "delays": [[1.0]]}]}

Binary file not shown.

After

Width:  |  Height:  |  Size: 237 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 182 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 203 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 202 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 232 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 202 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 198 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 229 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 260 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 210 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 210 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 221 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 249 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 249 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 260 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 210 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 217 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 225 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 312 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 235 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 173 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 223 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 202 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 386 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 202 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 203 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 202 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 204 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 385 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 224 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 269 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 241 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 254 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 207 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 210 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 237 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 257 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 253 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 257 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 207 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 225 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 237 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 315 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 235 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 173 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 236 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 210 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 210 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 255 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 242 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 202 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 203 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 234 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 247 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 198 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 214 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 234 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 259 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 252 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 245 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 196 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 226 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 233 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 325 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 172 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 241 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 314 B