Replaces noSprite.png with Gmod Error Sprite (#1055)

This commit is contained in:
Swept
2020-05-18 10:31:24 +00:00
committed by GitHub
parent 1551ff1ae4
commit b89f8e396d
4 changed files with 37 additions and 35 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 875 B

View File

@@ -0,0 +1 @@
{"version":1,"size":{"x":32,"y":32},"copyright":"https://cdn.discordapp.com/attachments/277256016045932544/710024287435751429/unknown.png","states":[{"name":"error","directions":1,"delays":[[0.1,0.1,0.1,0.1]]}]}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.2 KiB

After

Width:  |  Height:  |  Size: 612 B

View File

@@ -265,7 +265,7 @@ namespace Robust.Client.GameObjects
public int AddLayer(RSI.StateId stateId, int? newIndex = null)
{
var layer = new Layer {State = stateId};
if (BaseRSI.TryGetState(stateId, out var state))
if (BaseRSI != null && BaseRSI.TryGetState(stateId, out var state))
{
layer.AnimationTimeLeft = state.GetDelay(0);
}
@@ -572,28 +572,27 @@ namespace Robust.Client.GameObjects
}
theLayer.State = stateId;
RSI.State state;
var rsi = theLayer.RSI ?? BaseRSI;
if (rsi == null)
{
state = GetFallbackState();
Logger.ErrorS(LogCategory, "No RSI to pull new state from! Trace:\n{0}", Environment.StackTrace);
theLayer.Texture = null;
}
else
{
if (rsi.TryGetState(stateId, out var state))
{
theLayer.AnimationFrame = 0;
theLayer.AnimationTime = 0;
theLayer.AnimationTimeLeft = state.GetDelay(0);
}
else
if (!rsi.TryGetState(stateId, out state))
{
state = GetFallbackState();
Logger.ErrorS(LogCategory, "State '{0}' does not exist in RSI. Trace:\n{1}", stateId,
Environment.StackTrace);
theLayer.Texture = null;
}
}
theLayer.AnimationFrame = 0;
theLayer.AnimationTime = 0;
theLayer.AnimationTimeLeft = state.GetDelay(0);
UpdateIsInert();
}
@@ -1055,32 +1054,32 @@ namespace Robust.Client.GameObjects
{
// Pull texture from RSI state instead.
var rsi = layer.RSI ?? BaseRSI;
if (rsi != null)
if (rsi == null || !rsi.TryGetState(layer.State, out var state))
{
var state = rsi[layer.State];
state = GetFallbackState();
}
RSI.State.Direction layerSpecificDir;
if (state.Directions == RSI.State.DirectionType.Dir1)
RSI.State.Direction layerSpecificDir;
if (state.Directions == RSI.State.DirectionType.Dir1)
{
layerSpecificDir = RSI.State.Direction.South;
}
else
{
RSI.State.Direction dir;
if (overrideDirection != null)
{
layerSpecificDir = RSI.State.Direction.South;
dir = overrideDirection.Value.Convert(state.Directions);
}
else
{
RSI.State.Direction dir;
if (overrideDirection != null)
{
dir = overrideDirection.Value.Convert(state.Directions);
}
else
{
dir = GetDir(state.Directions, worldRotation);
}
layerSpecificDir = OffsetRsiDir(dir, layer.DirOffset);
dir = GetDir(state.Directions, worldRotation);
}
texture = state.GetFrame(layerSpecificDir, layer.AnimationFrame);
layerSpecificDir = OffsetRsiDir(dir, layer.DirOffset);
}
texture = state.GetFrame(layerSpecificDir, layer.AnimationFrame);
}
texture ??= resourceCache.GetFallback<TextureResource>();
@@ -1307,13 +1306,11 @@ namespace Robust.Client.GameObjects
}
var rsi = layer.RSI ?? BaseRSI;
if (rsi == null)
if (rsi == null || !rsi.TryGetState(layer.State, out var state))
{
continue;
state = GetFallbackState();
}
var state = rsi[layer.State];
if (!state.IsAnimated)
{
continue;
@@ -1437,13 +1434,11 @@ namespace Robust.Client.GameObjects
}
var rsi = layer.RSI ?? BaseRSI;
if (rsi == null)
if (rsi == null || !rsi.TryGetState(layer.State, out var state))
{
continue;
state = GetFallbackState();
}
var state = rsi[layer.State];
if (state.IsAnimated)
{
IsInert = false;
@@ -1452,6 +1447,12 @@ namespace Robust.Client.GameObjects
}
}
private RSI.State GetFallbackState()
{
var rsi = resourceCache.GetResource<RSIResource>("/Textures/error.rsi").RSI;
return rsi["error"];
}
private static RSI.State.Direction OffsetRsiDir(RSI.State.Direction dir, DirectionOffset offset)
{
// There is probably a better way to do this.