diff --git a/Content.Shared/Content.Shared.csproj b/Content.Shared/Content.Shared.csproj index b5df0060cb..7160372905 100644 --- a/Content.Shared/Content.Shared.csproj +++ b/Content.Shared/Content.Shared.csproj @@ -83,6 +83,7 @@ + @@ -116,4 +117,4 @@ - \ No newline at end of file + diff --git a/Content.Shared/EntryPoint.cs b/Content.Shared/EntryPoint.cs index 5020f8bbac..8211f38b6c 100644 --- a/Content.Shared/EntryPoint.cs +++ b/Content.Shared/EntryPoint.cs @@ -1,18 +1,65 @@ -using SS14.Shared.ContentPack; -using SS14.Shared.Interfaces; +using System; +using System.Collections.Generic; +using Content.Shared.Maps; +using SS14.Shared.ContentPack; +using SS14.Shared.Interfaces.Map; using SS14.Shared.Interfaces.Resources; using SS14.Shared.IoC; +using SS14.Shared.Prototypes; namespace Content.Shared { public class EntryPoint : GameShared { +#pragma warning disable 649 + [Dependency] private readonly IPrototypeManager _prototypeManager; + [Dependency] private readonly ITileDefinitionManager _tileDefinitionManager; +#pragma warning restore 649 + public override void Init() { + IoCManager.InjectDependencies(this); + #if DEBUG var resm = IoCManager.Resolve(); resm.MountContentDirectory(@"../../../Resources/"); #endif } + + public override void PostInit() + { + base.PostInit(); + + _initTileDefinitions(); + } + + private void _initTileDefinitions() + { + // Register space first because I'm a hard coding hack. + var spaceDef = _prototypeManager.Index("space"); + + _tileDefinitionManager.Register(spaceDef); + + var prototypeList = new List(); + foreach (var tileDef in _prototypeManager.EnumeratePrototypes()) + { + if (tileDef.Name == "space") + { + continue; + } + prototypeList.Add(tileDef); + } + + // Sort ordinal to ensure it's consistent client and server. + // So that tile IDs match up. + prototypeList.Sort((a, b) => string.Compare(a.Name, b.Name, StringComparison.Ordinal)); + + foreach (var tileDef in prototypeList) + { + _tileDefinitionManager.Register(tileDef); + } + + _tileDefinitionManager.Initialize(); + } } } diff --git a/Content.Shared/Maps/ContentTileDefinition.cs b/Content.Shared/Maps/ContentTileDefinition.cs new file mode 100644 index 0000000000..2cc4fdcc26 --- /dev/null +++ b/Content.Shared/Maps/ContentTileDefinition.cs @@ -0,0 +1,32 @@ +using JetBrains.Annotations; +using SS14.Shared.Interfaces.Map; +using SS14.Shared.Prototypes; +using SS14.Shared.Utility; +using YamlDotNet.RepresentationModel; + +namespace Content.Shared.Maps +{ + [UsedImplicitly] + [Prototype("tile")] + public sealed class ContentTileDefinition : IPrototype, IIndexedPrototype, ITileDefinition + { + string IIndexedPrototype.ID => Name; + + public string Name { get; private set; } + public ushort TileId { get; private set; } + public string DisplayName { get; private set; } + public string SpriteName { get; private set; } + + public void AssignTileId(ushort id) + { + TileId = id; + } + + public void LoadFrom(YamlMappingNode mapping) + { + Name = mapping.GetNode("name").ToString(); + DisplayName = mapping.GetNode("display_name").ToString(); + SpriteName = mapping.GetNode("texture").ToString(); + } + } +} diff --git a/Resources/Maps/stationstation.yml b/Resources/Maps/stationstation.yml index 3776887cd8..f9093e2180 100644 --- a/Resources/Maps/stationstation.yml +++ b/Resources/Maps/stationstation.yml @@ -2,6 +2,13 @@ meta: format: 2 name: DemoStation author: Space-Wizards +tilemap: + 0: space + 1: floor + 2: plating + 3: underplating + 4: floor_white + 5: floor_techmaint grids: - settings: chunksize: 16 diff --git a/Resources/Prototypes/Tiles/floors.yml b/Resources/Prototypes/Tiles/floors.yml index 73492df400..9a05599dbe 100644 --- a/Resources/Prototypes/Tiles/floors.yml +++ b/Resources/Prototypes/Tiles/floors.yml @@ -1,14 +1,14 @@ - type: tile - name: Floor + name: floor + display_name: Floor texture: "floor_steel" - id: 1 - type: tile - name: White Floor + name: floor_white + display_name: White Floor texture: "floor_white" - id: 4 - type: tile - name: Techmaint Floor + name: floor_techmaint + display_name: Techmaint Floor texture: "floor_techmaint" - id: 5 diff --git a/Resources/Prototypes/Tiles/plating.yml b/Resources/Prototypes/Tiles/plating.yml index 4f9601d106..da2af74abe 100644 --- a/Resources/Prototypes/Tiles/plating.yml +++ b/Resources/Prototypes/Tiles/plating.yml @@ -1,9 +1,9 @@ - type: tile - name: Plating + name: plating + display_name: Plating texture: plating - id: 2 - type: tile - name: Underplating + name: underplating + display_name: Underplating texture: underplating - id: 3 diff --git a/Resources/Prototypes/Tiles/space.yml b/Resources/Prototypes/Tiles/space.yml index 533f4bcb4a..7807d85b61 100644 --- a/Resources/Prototypes/Tiles/space.yml +++ b/Resources/Prototypes/Tiles/space.yml @@ -1,4 +1,4 @@ - type: tile - name: Space + name: space + display_name: Space texture: "" - id: 0 diff --git a/RobustToolbox b/RobustToolbox index 2bb73aa93d..d7d0363cc3 160000 --- a/RobustToolbox +++ b/RobustToolbox @@ -1 +1 @@ -Subproject commit 2bb73aa93d356242f09d0ba69bf9ece341ff9fdf +Subproject commit d7d0363cc36b3ba12a744ced1ac2246daa7a7cc2