Files
RobustToolbox/Robust.Client/Utility/SpriteSpecifierExt.cs
T
SilverandGitHub 25926a17b7 Renames SS14.* to Robust.* (#793)
RobustToolbox projects should be named Robust.* 

This PR changes the RobustToolbox projects from SS14.* to Robust.*

Updates SS14.* prefixes/namespaces to Robust.*
Updates SpaceStation14.sln to RobustToolbox.sln
Updates MSBUILD/SS14.* to MSBUILD/Robust.*
Updates CSProject and MSBuild references for the above
Updates git_helper.py
Removes Runserver and Runclient as they are unusable
2019-04-15 20:24:59 -06:00

60 lines
2.1 KiB
C#

using System;
using Robust.Client.GameObjects;
using Robust.Client.Graphics;
using Robust.Client.Interfaces.ResourceManagement;
using Robust.Client.ResourceManagement;
using Robust.Shared.IoC;
using Robust.Shared.Utility;
namespace Robust.Client.Utility
{
public static class SpriteSpecifierExt
{
public static Texture Frame0(this SpriteSpecifier specifier)
{
var resc = IoCManager.Resolve<IResourceCache>();
switch (specifier)
{
case SpriteSpecifier.Texture tex:
return resc.GetResource<TextureResource>(SpriteComponent.TextureRoot / tex.TexturePath);
case SpriteSpecifier.Rsi rsi:
if (resc.TryGetResource<RSIResource>(SpriteComponent.TextureRoot / rsi.RsiPath, out var theRsi))
{
if (theRsi.RSI.TryGetState(rsi.RsiState, out var state))
{
return state.Frame0;
}
}
return resc.GetFallback<TextureResource>();
default:
throw new NotImplementedException();
}
}
public static IDirectionalTextureProvider DirFrame0(this SpriteSpecifier specifier)
{
var resc = IoCManager.Resolve<IResourceCache>();
switch (specifier)
{
case SpriteSpecifier.Texture tex:
return (Texture)resc.GetResource<TextureResource>(SpriteComponent.TextureRoot / tex.TexturePath);
case SpriteSpecifier.Rsi rsi:
if (resc.TryGetResource<RSIResource>(SpriteComponent.TextureRoot / rsi.RsiPath, out var theRsi))
{
if (theRsi.RSI.TryGetState(rsi.RsiState, out var state))
{
return state;
}
}
return (Texture)resc.GetFallback<TextureResource>();
default:
throw new NotImplementedException();
}
}
}
}