Content changes for tile ID refactor.
This commit is contained in:
@@ -83,6 +83,7 @@
|
||||
<Compile Include="GameObjects\PhysicalConstants.cs" />
|
||||
<Compile Include="Interfaces\ISharedNotifyManager.cs" />
|
||||
<Compile Include="GameObjects\Verb.cs" />
|
||||
<Compile Include="Maps\ContentTileDefinition.cs" />
|
||||
<Compile Include="Physics\CollisionGroup.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="GameObjects\Components\Items\SharedHandsComponent.cs" />
|
||||
@@ -116,4 +117,4 @@
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
</Project>
|
||||
</Project>
|
||||
|
||||
@@ -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<IResourceManager>();
|
||||
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<ContentTileDefinition>("space");
|
||||
|
||||
_tileDefinitionManager.Register(spaceDef);
|
||||
|
||||
var prototypeList = new List<ContentTileDefinition>();
|
||||
foreach (var tileDef in _prototypeManager.EnumeratePrototypes<ContentTileDefinition>())
|
||||
{
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
32
Content.Shared/Maps/ContentTileDefinition.cs
Normal file
32
Content.Shared/Maps/ContentTileDefinition.cs
Normal file
@@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
- type: tile
|
||||
name: Space
|
||||
name: space
|
||||
display_name: Space
|
||||
texture: ""
|
||||
id: 0
|
||||
|
||||
Submodule RobustToolbox updated: 2bb73aa93d...d7d0363cc3
Reference in New Issue
Block a user