Skip to content

Commit

Permalink
Update tiles to modern standards (#10436)
Browse files Browse the repository at this point in the history
  • Loading branch information
metalgearsloth authored Aug 10, 2022
1 parent dfec3a1 commit a549a85
Show file tree
Hide file tree
Showing 80 changed files with 2,627 additions and 2,615 deletions.
2 changes: 1 addition & 1 deletion Content.Client/Mapping/MappingSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ private void OnFillActionSlot(FillActionSlotEvent ev)

var tileIcon = contentTileDef.IsSpace
? _spaceIcon
: new SpriteSpecifier.Texture(new ResourcePath(tileDef.Path) / $"{tileDef.SpriteName}.png");
: new SpriteSpecifier.Texture(contentTileDef.Sprite!);

ev.Action = new InstantAction()
{
Expand Down
2 changes: 1 addition & 1 deletion Content.IntegrationTests/PoolManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -436,7 +436,7 @@ await server.WaitPost(() =>
mapData.MapGrid = mapManager.CreateGrid(mapData.MapId);
mapData.GridCoords = new EntityCoordinates(mapData.MapGrid.GridEntityId, 0, 0);
var tileDefinitionManager = IoCManager.Resolve<ITileDefinitionManager>();
var plating = tileDefinitionManager["plating"];
var plating = tileDefinitionManager["Plating"];
var platingTile = new Tile(plating.TileId);
mapData.MapGrid.SetTile(mapData.GridCoords, platingTile);
mapData.MapCoords = new MapCoordinates(0, 0, mapData.MapId);
Expand Down
6 changes: 3 additions & 3 deletions Content.IntegrationTests/Tests/EntityTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ await server.WaitPost(() =>

grid = mapManager.CreateGrid(mapId);

var tileDefinition = tileDefinitionManager["underplating"];
var tileDefinition = tileDefinitionManager["UnderPlating"];
var tile = new Tile(tileDefinition.TileId);
var coordinates = grid.ToCoordinates();

Expand Down Expand Up @@ -128,7 +128,7 @@ await server.WaitPost(() =>

grid = mapManager.CreateGrid(mapId);

var tileDefinition = tileDefinitionManager["underplating"];
var tileDefinition = tileDefinitionManager["UnderPlating"];
var tile = new Tile(tileDefinition.TileId);
var coordinates = grid.ToCoordinates();

Expand Down Expand Up @@ -223,7 +223,7 @@ await server.WaitPost(() =>

grid = mapManager.CreateGrid(mapId);

var tileDefinition = tileDefinitionManager["underplating"];
var tileDefinition = tileDefinitionManager["UnderPlating"];
var tile = new Tile(tileDefinition.TileId);

grid.SetTile(Vector2i.Zero, tile);
Expand Down
2 changes: 1 addition & 1 deletion Content.IntegrationTests/Tests/Fluids/PuddleTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ await server.WaitPost(() =>
sGridId = sGrid.GridEntityId;
metaSystem.SetEntityPaused(sGridId, true); // See https://github.com/space-wizards/RobustToolbox/issues/1444

var tileDefinition = sTileDefinitionManager["underplating"];
var tileDefinition = sTileDefinitionManager["UnderPlating"];
var tile = new Tile(tileDefinition.TileId);
sCoordinates = sGrid.ToCoordinates();

Expand Down
24 changes: 15 additions & 9 deletions Content.MapRenderer/Painters/TilePainter.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Content.Shared.Maps;
using Robust.Client.Graphics;
using Robust.Client.ResourceManagement;
using Robust.Shared.Map;
Expand Down Expand Up @@ -41,10 +42,15 @@ public void Run(Image gridCanvas, IMapGrid grid)

grid.GetAllTiles().AsParallel().ForAll(tile =>
{
var sprite = _sTileDefinitionManager[tile.Tile.TypeId].Sprite;

if (sprite == null)
return;

var x = (int) (tile.X + xOffset);
var y = (int) (tile.Y + yOffset);
var sprite = _sTileDefinitionManager[tile.Tile.TypeId].SpriteName;
var image = images[sprite][tile.Tile.Variant];
var path = sprite.ToString();
var image = images[path][tile.Tile.Variant];

gridCanvas.Mutate(o => o.DrawImage(image, new Point(x * tileSize, y * tileSize), 1));

Expand All @@ -66,15 +72,15 @@ private Dictionary<string, List<Image>> GetTileImages(

foreach (var definition in tileDefinitionManager)
{
var sprite = definition.SpriteName;
images[sprite] = new List<Image>(definition.Variants);
var sprite = definition.Sprite;

if (string.IsNullOrEmpty(sprite))
{
if (sprite == null)
continue;
}

using var stream = resourceCache.ContentFileRead($"{TilesPath}{sprite}.png");
var path = sprite.ToString();
images[path] = new List<Image>(definition.Variants);

using var stream = resourceCache.ContentFileRead(path);
Image tileSheet = Image.Load<Rgba32>(stream);

if (tileSheet.Width != tileSize * definition.Variants || tileSheet.Height != tileSize)
Expand All @@ -85,7 +91,7 @@ private Dictionary<string, List<Image>> GetTileImages(
for (var i = 0; i < definition.Variants; i++)
{
var tileImage = tileSheet.Clone(o => o.Crop(new Rectangle(tileSize * i, 0, 32, 32)));
images[sprite].Add(tileImage);
images[path].Add(tileImage);
}
}

Expand Down
2 changes: 1 addition & 1 deletion Content.Server/Construction/Commands/TileWallsCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ sealed class TileWallsCommand : IConsoleCommand
public string Description => "Puts an underplating tile below every wall on a grid.";
public string Help => $"Usage: {Command} <gridId> | {Command}";

public const string TilePrototypeID = "plating";
public const string TilePrototypeID = "Plating";
public const string WallTag = "Wall";

public void Execute(IConsoleShell shell, string argStr, string[] args)
Expand Down
4 changes: 2 additions & 2 deletions Content.Server/Interaction/TilePryCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ public void Execute(IConsoleShell shell, string argStr, string[] args)

if (!tileDef.CanCrowbar) continue;

var underplating = tileDefinitionManager["underplating"];
mapGrid.SetTile(coordinates, new Robust.Shared.Map.Tile(underplating.TileId));
var underplating = tileDefinitionManager["UnderPlating"];
mapGrid.SetTile(coordinates, new Tile(underplating.TileId));
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions Content.Server/RCD/Systems/RCDSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,8 @@ private async void OnAfterInteract(EntityUid uid, RCDComponent rcd, AfterInterac
{
//Floor mode just needs the tile to be a space tile (subFloor)
case RcdMode.Floors:
mapGrid.SetTile(snapPos, new Tile(_tileDefinitionManager["floor_steel"].TileId));
_adminLogger.Add(LogType.RCD, LogImpact.High, $"{ToPrettyString(args.User):user} used RCD to set grid: {tile.GridIndex} {snapPos} to floor_steel");
mapGrid.SetTile(snapPos, new Tile(_tileDefinitionManager["FloorSteel"].TileId));
_adminLogger.Add(LogType.RCD, LogImpact.High, $"{ToPrettyString(args.User):user} used RCD to set grid: {tile.GridIndex} {snapPos} to FloorSteel");
break;
//We don't want to place a space tile on something that's already a space tile. Let's do the inverse of the last check.
case RcdMode.Deconstruct:
Expand Down
2 changes: 1 addition & 1 deletion Content.Server/Tiles/FloorTileSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ private void OnAfterInteract(EntityUid uid, FloorTileComponent component, AfterI
PlaceAt(mapGrid, location, currentTileDefinition.TileId, component.PlaceTileSound);
}
}
else if (HasBaseTurf(currentTileDefinition, "space"))
else if (HasBaseTurf(currentTileDefinition, ContentTileDefinition.SpaceID))
{
mapGrid = _mapManager.CreateGrid(locationMap.MapId);
mapGrid.WorldPosition = locationMap.Position;
Expand Down
4 changes: 2 additions & 2 deletions Content.Shared/Entry/EntryPoint.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,14 +56,14 @@ public override void PostInit()
private void _initTileDefinitions()
{
// Register space first because I'm a hard coding hack.
var spaceDef = _prototypeManager.Index<ContentTileDefinition>("space");
var spaceDef = _prototypeManager.Index<ContentTileDefinition>(ContentTileDefinition.SpaceID);

_tileDefinitionManager.Register(spaceDef);

var prototypeList = new List<ContentTileDefinition>();
foreach (var tileDef in _prototypeManager.EnumeratePrototypes<ContentTileDefinition>())
{
if (tileDef.ID == "space")
if (tileDef.ID == ContentTileDefinition.SpaceID)
{
continue;
}
Expand Down
27 changes: 17 additions & 10 deletions Content.Shared/Maps/ContentTileDefinition.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,39 +5,46 @@
using Robust.Shared.Prototypes;
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype;
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype.Array;
using Robust.Shared.Utility;

namespace Content.Shared.Maps
{
[UsedImplicitly]
[Prototype("tile")]
public sealed class ContentTileDefinition : IPrototype, IInheritingPrototype, ITileDefinition
{
public const string SpaceID = "Space";

[ParentDataFieldAttribute(typeof(AbstractPrototypeIdArraySerializer<ContentTileDefinition>))]
public string[]? Parents { get; private set; }

[NeverPushInheritance]
[AbstractDataFieldAttribute]
public bool Abstract { get; private set; }

public string Path => "/Textures/Tiles/";

[IdDataFieldAttribute] public string ID { get; } = string.Empty;

public ushort TileId { get; private set; }

[DataField("name")] public string Name { get; } = string.Empty;

[DataField("texture")] public string SpriteName { get; } = string.Empty;
[DataField("sprite")] public ResourcePath? Sprite { get; }

[DataField("is_subfloor")] public bool IsSubFloor { get; private set; }
[DataField("isSubfloor")] public bool IsSubFloor { get; private set; }

[DataField("base_turfs")] public List<string> BaseTurfs { get; } = new();
[DataField("baseTurfs")] public List<string> BaseTurfs { get; } = new();

[DataField("can_crowbar")] public bool CanCrowbar { get; private set; }
[DataField("canCrowbar")] public bool CanCrowbar { get; private set; }

[DataField("footstep_sounds")] public SoundSpecifier? FootstepSounds { get; }
/// <summary>
/// These play when the mob has shoes on.
/// </summary>
[DataField("footstepSounds")] public SoundSpecifier? FootstepSounds { get; }

[DataField("barestep_sounds")] public SoundSpecifier? BarestepSounds { get; } = new SoundCollectionSpecifier("barestep_hard");
/// <summary>
/// These play when the mob has no shoes on.
/// </summary>
[DataField("barestepSounds")] public SoundSpecifier? BarestepSounds { get; } = new SoundCollectionSpecifier("BarestepHard");

[DataField("friction")] public float Friction { get; set; }

Expand All @@ -53,10 +60,10 @@ public sealed class ContentTileDefinition : IPrototype, IInheritingPrototype, IT
// Heat capacity is opt-in, not opt-out.
[DataField("heatCapacity")] public float HeatCapacity = Atmospherics.MinimumHeatCapacity;

[DataField("item_drop", customTypeSerializer:typeof(PrototypeIdSerializer<EntityPrototype>))]
[DataField("itemDrop", customTypeSerializer:typeof(PrototypeIdSerializer<EntityPrototype>))]
public string ItemDropPrototypeName { get; } = "FloorTileItemSteel";

[DataField("is_space")] public bool IsSpace { get; private set; }
[DataField("isSpace")] public bool IsSpace { get; private set; }
[DataField("sturdy")] public bool Sturdy { get; private set; } = true;

public void AssignTileId(ushort id)
Expand Down
42 changes: 21 additions & 21 deletions Content.Tools/test/0A.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,27 +4,27 @@ meta:
author: Space-Wizards
postmapinit: false
tilemap:
0: space
7: floor_dark
8: floor_elevator_shaft
9: floor_freezer
10: floor_gold
11: floor_green_circuit
12: floor_hydro
13: floor_lino
14: floor_mono
15: floor_reinforced
16: floor_rock_vault
17: floor_showroom
18: floor_snow
19: floor_steel
20: floor_steel_dirty
21: floor_techmaint
22: floor_white
23: floor_wood
24: lattice
25: plating
26: underplating
0: Space
7: FloorDark
8: FloorElevatorShaft
9: FloorFreezer
10: FloorGold
11: FloorGreenCircuit
12: FloorHydro
13: FloorLino
14: FloorMono
15: FloorReinforced
16: FloorRockVault
17: FloorShowroom
18: FloorSnow
19: FloorSteel
20: FloorSteelDirty
21: FloorTechMaint
22: FloorWhite
23: FloorWood
24: Lattice
25: Plating
26: UnderPlating
grids:
- settings:
chunksize: 16
Expand Down
42 changes: 21 additions & 21 deletions Content.Tools/test/0B.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,27 +4,27 @@ meta:
author: Space-Wizards
postmapinit: false
tilemap:
0: space
7: floor_dark
8: floor_elevator_shaft
9: floor_freezer
10: floor_gold
11: floor_green_circuit
12: floor_hydro
13: floor_lino
14: floor_mono
15: floor_reinforced
16: floor_rock_vault
17: floor_showroom
18: floor_snow
19: floor_steel
20: floor_steel_dirty
21: floor_techmaint
22: floor_white
23: floor_wood
24: lattice
25: plating
26: underplating
0: Space
7: FloorDark
8: FloorElevatorShaft
9: FloorFreezer
10: FloorGold
11: FloorGreenCircuit
12: FloorHydro
13: FloorLino
14: FloorMono
15: FloorReinforced
16: FloorRockVault
17: FloorShowroom
18: FloorSnow
19: FloorSteel
20: FloorSteelDirty
21: FloorTechMaint
22: FloorWhite
23: FloorWood
24: Lattice
25: Plating
26: UnderPlating
grids:
- settings:
chunksize: 16
Expand Down
54 changes: 27 additions & 27 deletions Content.Tools/test/0C.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,33 +4,33 @@ meta:
author: Space-Wizards
postmapinit: false
tilemap:
0: space
1: floor_asteroid_coarse_sand0
2: floor_asteroid_coarse_sand1
3: floor_asteroid_coarse_sand2
4: floor_asteroid_coarse_sand_dug
5: floor_asteroid_sand
6: floor_asteroid_tile
7: floor_dark
8: floor_elevator_shaft
9: floor_freezer
10: floor_gold
11: floor_green_circuit
12: floor_hydro
13: floor_lino
14: floor_mono
15: floor_reinforced
16: floor_rock_vault
17: floor_showroom
18: floor_snow
19: floor_steel
20: floor_steel_dirty
21: floor_techmaint
22: floor_white
23: floor_wood
24: lattice
25: plating
26: underplating
0: Space
1: FloorAsteroidCoarseSand0
2: FloorAsteroidCoarseSand1
3: FloorAsteroidCoarseSand2
4: FloorAsteroidCoarseSandDug
5: FloorAsteroidSand
6: FloorAsteroidTile
7: FloorDark
8: FloorElevatorShaft
9: FloorFreezer
10: FloorGold
11: FloorGreenCircuit
12: FloorHydro
13: FloorLino
14: FloorMono
15: FloorReinforced
16: FloorRockVault
17: FloorShowroom
18: FloorSnow
19: FloorSteel
20: FloorSteelDirty
21: FloorTechMaint
22: FloorWhite
23: FloorWood
24: Lattice
25: Plating
26: UnderPlating
grids:
- settings:
chunksize: 16
Expand Down
Loading

0 comments on commit a549a85

Please sign in to comment.