mirror of
https://github.com/space-wizards/RobustToolbox.git
synced 2026-02-15 03:30:53 +01:00
Make tiledefinitions use spritespecifier (#3113)
This commit is contained in:
@@ -1,9 +1,11 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Robust.Client.GameObjects;
|
||||
using Robust.Client.Graphics;
|
||||
using Robust.Client.ResourceManagement;
|
||||
using Robust.Client.Utility;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Log;
|
||||
using Robust.Shared.Map;
|
||||
@@ -52,7 +54,7 @@ namespace Robust.Client.Map
|
||||
|
||||
private void _genTextureAtlas()
|
||||
{
|
||||
var defList = TileDefs.Where(t => !string.IsNullOrEmpty(t.SpriteName)).ToList();
|
||||
var defList = TileDefs.Where(t => t.Sprite != null).ToList();
|
||||
|
||||
// If there are no tile definitions, we do nothing.
|
||||
if (defList.Count <= 0)
|
||||
@@ -94,10 +96,14 @@ namespace Robust.Client.Map
|
||||
|
||||
var column = 1;
|
||||
var row = 0;
|
||||
|
||||
foreach (var def in defList)
|
||||
{
|
||||
Image<Rgba32> image;
|
||||
using (var stream = _resourceCache.ContentFileRead(new ResourcePath(def.Path) / $"{def.SpriteName}.png"))
|
||||
// Already know it's not null above
|
||||
var path = def.Sprite!;
|
||||
|
||||
using (var stream = _resourceCache.ContentFileRead(path))
|
||||
{
|
||||
image = Image.Load<Rgba32>(stream);
|
||||
}
|
||||
@@ -105,7 +111,7 @@ namespace Robust.Client.Map
|
||||
if (image.Width != (tileSize * def.Variants) || image.Height != tileSize)
|
||||
{
|
||||
throw new NotSupportedException(
|
||||
$"Unable to load {new ResourcePath(def.Path) / $"{def.SpriteName}.png"}, due to being unable to use tile texture with a dimension other than {tileSize}x({tileSize} * Variants).");
|
||||
$"Unable to load {path}, due to being unable to use tile texture with a dimension other than {tileSize}x({tileSize} * Variants).");
|
||||
}
|
||||
|
||||
var regionList = new Box2[def.Variants];
|
||||
|
||||
@@ -118,9 +118,11 @@ namespace Robust.Client.UserInterface.CustomControls
|
||||
foreach (var entry in _shownItems)
|
||||
{
|
||||
Texture? texture = null;
|
||||
if (!string.IsNullOrEmpty(entry.SpriteName))
|
||||
var path = entry.Sprite?.ToString();
|
||||
|
||||
if (path != null)
|
||||
{
|
||||
texture = _resourceCache.GetResource<TextureResource>(new ResourcePath(entry.Path) / $"{entry.SpriteName}.png");
|
||||
texture = _resourceCache.GetResource<TextureResource>(path);
|
||||
}
|
||||
TileList.AddItem(entry.Name, texture);
|
||||
}
|
||||
|
||||
@@ -176,7 +176,7 @@ namespace Robust.Shared.ContentPack
|
||||
|
||||
if (!path.IsRooted)
|
||||
{
|
||||
throw new ArgumentException("Path must be rooted", nameof(path));
|
||||
throw new ArgumentException($"Path '{path}' must be rooted", nameof(path));
|
||||
}
|
||||
#if DEBUG
|
||||
if (!IsPathValid(path))
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
namespace Robust.Shared.Map
|
||||
using Robust.Shared.Utility;
|
||||
|
||||
namespace Robust.Shared.Map
|
||||
{
|
||||
/// <summary>
|
||||
/// The definition (template) for a grid tile.
|
||||
@@ -21,16 +23,9 @@
|
||||
string ID { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The name of the sprite to draw.
|
||||
/// The path of the sprite to draw.
|
||||
/// </summary>
|
||||
string SpriteName { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Path to the folder where the tile sprite is contained.
|
||||
/// The texture dimensions should be PixelsPerMeter x (PixelsPerMeter * Variants).
|
||||
/// This is likely 32 x (32 * variants) if you're working on Space Station 14.
|
||||
/// </summary>
|
||||
string Path { get; }
|
||||
ResourcePath? Sprite { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Physics objects that are interacting on this tile are slowed down by this float.
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using Linguini.Syntax.Ast;
|
||||
using Robust.Shared.Serialization;
|
||||
using YamlDotNet.RepresentationModel;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user