using Robust.Shared.Analyzers;
using Robust.Shared.GameObjects;
using Robust.Shared.Map;
+using Robust.Shared.Prototypes;
namespace Content.Benchmarks;
[Virtual, MemoryDiagnoser]
public class SpawnEquipDeleteBenchmark
{
+ private static readonly EntProtoId Mob = "MobHuman";
+ private static readonly ProtoId<StartingGearPrototype> CaptainStartingGear = "CaptainGear";
+
private TestPair _pair = default!;
private StationSpawningSystem _spawnSys = default!;
- private const string Mob = "MobHuman";
private StartingGearPrototype _gear = default!;
private EntityUid _entity;
private EntityCoordinates _coords;
var mapData = await _pair.CreateTestMap();
_coords = mapData.GridCoords;
_spawnSys = server.System<StationSpawningSystem>();
- _gear = server.ProtoMan.Index<StartingGearPrototype>("CaptainGear");
+ _gear = server.ProtoMan.Index(CaptainStartingGear);
}
[GlobalCleanup]
{
public sealed class GasTileOverlay : Overlay
{
+ private static readonly ProtoId<ShaderPrototype> UnshadedShader = "unshaded";
+
private readonly IEntityManager _entManager;
private readonly IMapManager _mapManager;
private readonly SharedMapSystem _mapSystem;
_mapManager = IoCManager.Resolve<IMapManager>();
_mapSystem = entManager.System<SharedMapSystem>();
_xformSys = xformSys;
- _shader = protoMan.Index<ShaderPrototype>("unshaded").Instance();
+ _shader = protoMan.Index(UnshadedShader).Instance();
ZIndex = GasOverlayZIndex;
_gasCount = system.VisibleGasId.Length;
{
public sealed class ColoredScreenBorderOverlay : Overlay
{
+ private static readonly ProtoId<ShaderPrototype> Shader = "ColoredScreenBorder";
+
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
public override OverlaySpace Space => OverlaySpace.WorldSpace;
public ColoredScreenBorderOverlay()
{
IoCManager.InjectDependencies(this);
- _shader = _prototypeManager.Index<ShaderPrototype>("ColoredScreenBorder").Instance();
+ _shader = _prototypeManager.Index(Shader).Instance();
}
protected override void Draw(in OverlayDrawArgs args)
{
public sealed class CooldownGraphic : Control
{
+ private static readonly ProtoId<ShaderPrototype> Shader = "CooldownAnimation";
+
[Dependency] private readonly IGameTiming _gameTiming = default!;
[Dependency] private readonly IPrototypeManager _protoMan = default!;
public CooldownGraphic()
{
IoCManager.InjectDependencies(this);
- _shader = _protoMan.Index<ShaderPrototype>("CooldownAnimation").InstanceUnique();
+ _shader = _protoMan.Index(Shader).InstanceUnique();
}
/// <summary>
public sealed class DoAfterOverlay : Overlay
{
+ private static readonly ProtoId<ShaderPrototype> UnshadedShader = "unshaded";
+
private readonly IEntityManager _entManager;
private readonly IGameTiming _timing;
private readonly IPlayerManager _player;
var sprite = new SpriteSpecifier.Rsi(new("/Textures/Interface/Misc/progress_bar.rsi"), "icon");
_barTexture = _entManager.EntitySysManager.GetEntitySystem<SpriteSystem>().Frame0(sprite);
- _unshadedShader = protoManager.Index<ShaderPrototype>("unshaded").Instance();
+ _unshadedShader = protoManager.Index(UnshadedShader).Instance();
}
protected override void Draw(in OverlayDrawArgs args)
public sealed class DrowsinessOverlay : Overlay
{
+ private static readonly ProtoId<ShaderPrototype> Shader = "Drowsiness";
+
[Dependency] private readonly IEntityManager _entityManager = default!;
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
[Dependency] private readonly IPlayerManager _playerManager = default!;
_statusEffects = _sysMan.GetEntitySystem<SharedStatusEffectsSystem>();
- _drowsinessShader = _prototypeManager.Index<ShaderPrototype>("Drowsiness").InstanceUnique();
+ _drowsinessShader = _prototypeManager.Index(Shader).InstanceUnique();
}
protected override void FrameUpdate(FrameEventArgs args)
public sealed class RainbowOverlay : Overlay
{
+ private static readonly ProtoId<ShaderPrototype> Shader = "Rainbow";
+
[Dependency] private readonly IConfigurationManager _config = default!;
[Dependency] private readonly IEntityManager _entityManager = default!;
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
_statusEffects = _sysMan.GetEntitySystem<SharedStatusEffectsSystem>();
- _rainbowShader = _prototypeManager.Index<ShaderPrototype>("Rainbow").InstanceUnique();
+ _rainbowShader = _prototypeManager.Index(Shader).InstanceUnique();
_config.OnValueChanged(CCVars.ReducedMotion, OnReducedMotionChanged, invokeImmediately: true);
}
public sealed class DrunkOverlay : Overlay
{
+ private static readonly ProtoId<ShaderPrototype> Shader = "Drunk";
+
[Dependency] private readonly IEntityManager _entityManager = default!;
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
[Dependency] private readonly IPlayerManager _playerManager = default!;
public DrunkOverlay()
{
IoCManager.InjectDependencies(this);
- _drunkShader = _prototypeManager.Index<ShaderPrototype>("Drunk").InstanceUnique();
+ _drunkShader = _prototypeManager.Index(Shader).InstanceUnique();
}
protected override void FrameUpdate(FrameEventArgs args)
[UsedImplicitly]
public sealed class ExplosionOverlay : Overlay
{
+ private static readonly ProtoId<ShaderPrototype> UnshadedShader = "unshaded";
+
[Dependency] private readonly IRobustRandom _robustRandom = default!;
[Dependency] private readonly IEntityManager _entMan = default!;
[Dependency] private readonly IPrototypeManager _proto = default!;
public ExplosionOverlay(SharedAppearanceSystem appearanceSystem)
{
IoCManager.InjectDependencies(this);
- _shader = _proto.Index<ShaderPrototype>("unshaded").Instance();
+ _shader = _proto.Index(UnshadedShader).Instance();
_transformSystem = _entMan.System<SharedTransformSystem>();
_appearance = appearanceSystem;
}
{
public sealed class BlindOverlay : Overlay
{
+ private static readonly ProtoId<ShaderPrototype> GreyscaleShader = "GreyscaleFullscreen";
+ private static readonly ProtoId<ShaderPrototype> CircleShader = "CircleMask";
+
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
[Dependency] private readonly IPlayerManager _playerManager = default!;
[Dependency] private readonly IEntityManager _entityManager = default!;
public BlindOverlay()
{
IoCManager.InjectDependencies(this);
- _greyscaleShader = _prototypeManager.Index<ShaderPrototype>("GreyscaleFullscreen").InstanceUnique();
- _circleMaskShader = _prototypeManager.Index<ShaderPrototype>("CircleMask").InstanceUnique();
+ _greyscaleShader = _prototypeManager.Index(GreyscaleShader).InstanceUnique();
+ _circleMaskShader = _prototypeManager.Index(CircleShader).InstanceUnique();
}
protected override bool BeforeDraw(in OverlayDrawArgs args)
{
{
public sealed class BlurryVisionOverlay : Overlay
{
+ private static readonly ProtoId<ShaderPrototype> CataractsShader = "Cataracts";
+ private static readonly ProtoId<ShaderPrototype> CircleShader = "CircleMask";
+
[Dependency] private readonly IEntityManager _entityManager = default!;
[Dependency] private readonly IPlayerManager _playerManager = default!;
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
public BlurryVisionOverlay()
{
IoCManager.InjectDependencies(this);
- _cataractsShader = _prototypeManager.Index<ShaderPrototype>("Cataracts").InstanceUnique();
- _circleMaskShader = _prototypeManager.Index<ShaderPrototype>("CircleMask").InstanceUnique();
+ _cataractsShader = _prototypeManager.Index(CataractsShader).InstanceUnique();
+ _circleMaskShader = _prototypeManager.Index(CircleShader).InstanceUnique();
_circleMaskShader.SetParameter("CircleMinDist", 0.0f);
_circleMaskShader.SetParameter("CirclePow", NoMotion_Pow);
{
public sealed class FlashOverlay : Overlay
{
+ private static readonly ProtoId<ShaderPrototype> FlashedEffectShader = "FlashedEffect";
+
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
[Dependency] private readonly IEntityManager _entityManager = default!;
[Dependency] private readonly IPlayerManager _playerManager = default!;
public FlashOverlay()
{
IoCManager.InjectDependencies(this);
- _shader = _prototypeManager.Index<ShaderPrototype>("FlashedEffect").InstanceUnique();
+ _shader = _prototypeManager.Index(FlashedEffectShader).InstanceUnique();
_flash = _entityManager.System<SharedFlashSystem>();
_statusSys = _entityManager.System<StatusEffectsSystem>();
}
[RegisterComponent]
public sealed partial class InteractionOutlineComponent : Component
{
+ private static readonly ProtoId<ShaderPrototype> ShaderInRange = "SelectionOutlineInrange";
+ private static readonly ProtoId<ShaderPrototype> ShaderOutOfRange = "SelectionOutline";
+
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
[Dependency] private readonly IEntityManager _entMan = default!;
private const float DefaultWidth = 1;
- [ValidatePrototypeId<ShaderPrototype>]
- private const string ShaderInRange = "SelectionOutlineInrange";
-
- [ValidatePrototypeId<ShaderPrototype>]
- private const string ShaderOutOfRange = "SelectionOutline";
-
private bool _inRange;
private ShaderInstance? _shader;
private int _lastRenderScale;
{
var shaderName = inRange ? ShaderInRange : ShaderOutOfRange;
- var instance = _prototypeManager.Index<ShaderPrototype>(shaderName).InstanceUnique();
+ var instance = _prototypeManager.Index(shaderName).InstanceUnique();
instance.SetParameter("outline_width", DefaultWidth * renderScale);
return instance;
}
/// </summary>
public sealed class DragDropSystem : SharedDragDropSystem
{
+ private static readonly ProtoId<ShaderPrototype> ShaderDropTargetInRange = "SelectionOutlineInrange";
+
+ private static readonly ProtoId<ShaderPrototype> ShaderDropTargetOutOfRange = "SelectionOutline";
+
[Dependency] private readonly IStateManager _stateManager = default!;
[Dependency] private readonly IInputManager _inputManager = default!;
[Dependency] private readonly IEyeManager _eyeManager = default!;
// mousedown event so it can be treated like a regular click
private const float MaxMouseDownTimeForReplayingClick = 0.85f;
- [ValidatePrototypeId<ShaderPrototype>]
- private const string ShaderDropTargetInRange = "SelectionOutlineInrange";
-
- [ValidatePrototypeId<ShaderPrototype>]
- private const string ShaderDropTargetOutOfRange = "SelectionOutline";
-
/// <summary>
/// Current entity being dragged around.
/// </summary>
Subs.CVar(_cfgMan, CCVars.DragDropDeadZone, SetDeadZone, true);
- _dropTargetInRangeShader = _prototypeManager.Index<ShaderPrototype>(ShaderDropTargetInRange).Instance();
- _dropTargetOutOfRangeShader = _prototypeManager.Index<ShaderPrototype>(ShaderDropTargetOutOfRange).Instance();
+ _dropTargetInRangeShader = _prototypeManager.Index(ShaderDropTargetInRange).Instance();
+ _dropTargetOutOfRangeShader = _prototypeManager.Index(ShaderDropTargetOutOfRange).Instance();
// needs to fire on mouseup and mousedown so we can detect a drag / drop
CommandBinds.Builder
.BindBefore(EngineKeyFunctions.Use, new PointerInputCmdHandler(OnUse, false, true), new[] { typeof(SharedInteractionSystem) })
/// </summary>
public sealed class AmbientOcclusionOverlay : Overlay
{
+ private static readonly ProtoId<ShaderPrototype> UnshadedShader = "unshaded";
+ private static readonly ProtoId<ShaderPrototype> StencilMaskShader = "StencilMask";
+ private static readonly ProtoId<ShaderPrototype> StencilEqualDrawShader = "StencilEqualDraw";
+
[Dependency] private readonly IClyde _clyde = default!;
[Dependency] private readonly IConfigurationManager _cfgManager = default!;
[Dependency] private readonly IEntityManager _entManager = default!;
args.WorldHandle.RenderInRenderTarget(_aoTarget,
() =>
{
- worldHandle.UseShader(_proto.Index<ShaderPrototype>("unshaded").Instance());
+ worldHandle.UseShader(_proto.Index(UnshadedShader).Instance());
var invMatrix = _aoTarget.GetWorldToLocalMatrix(viewport.Eye!, scale);
foreach (var entry in query.QueryAabb(mapId, worldBounds))
() =>
{
// Don't want lighting affecting it.
- worldHandle.UseShader(_proto.Index<ShaderPrototype>("unshaded").Instance());
+ worldHandle.UseShader(_proto.Index(UnshadedShader).Instance());
foreach (var grid in _mapManager.FindGridsIntersecting(mapId, worldBounds))
{
}, Color.Transparent);
// Draw the stencil texture to depth buffer.
- worldHandle.UseShader(_proto.Index<ShaderPrototype>("StencilMask").Instance());
+ worldHandle.UseShader(_proto.Index(StencilMaskShader).Instance());
worldHandle.DrawTextureRect(_aoStencilTarget!.Texture, worldBounds);
// Draw the Blurred AO texture finally.
- worldHandle.UseShader(_proto.Index<ShaderPrototype>("StencilEqualDraw").Instance());
+ worldHandle.UseShader(_proto.Index(StencilEqualDrawShader).Instance());
worldHandle.DrawTextureRect(_aoTarget!.Texture, worldBounds, color);
args.WorldHandle.SetTransform(Matrix3x2.Identity);
public sealed class SunShadowOverlay : Overlay
{
+ private static readonly ProtoId<ShaderPrototype> MixShader = "Mix";
+
public override OverlaySpace Space => OverlaySpace.BeforeLighting;
[Dependency] private readonly IClyde _clyde = default!;
viewport.LightRenderTarget.GetWorldToLocalMatrix(eye, scale);
worldHandle.SetTransform(invMatrix);
- var maskShader = _protoManager.Index<ShaderPrototype>("Mix").Instance();
+ var maskShader = _protoManager.Index(MixShader).Instance();
worldHandle.UseShader(maskShader);
worldHandle.DrawTextureRect(_target.Texture, worldBounds, Color.Black.WithAlpha(alpha));
public sealed class MappingOverlay : Overlay
{
+ private static readonly ProtoId<ShaderPrototype> UnshadedShader = "unshaded";
+
[Dependency] private readonly IEntityManager _entities = default!;
[Dependency] private readonly IPlayerManager _player = default!;
[Dependency] private readonly IPrototypeManager _prototypes = default!;
_sprite = _entities.System<SpriteSystem>();
_state = state;
- _shader = _prototypes.Index<ShaderPrototype>("unshaded").Instance();
+ _shader = _prototypes.Index(UnshadedShader).Instance();
}
protected override void Draw(in OverlayDrawArgs args)
public sealed class FloorOcclusionSystem : SharedFloorOcclusionSystem
{
+ private static readonly ProtoId<ShaderPrototype> HorizontalCut = "HorizontalCut";
+
[Dependency] private readonly IPrototypeManager _proto = default!;
private EntityQuery<SpriteComponent> _spriteQuery;
if (!_spriteQuery.Resolve(sprite.Owner, ref sprite.Comp, false))
return;
- var shader = _proto.Index<ShaderPrototype>("HorizontalCut").Instance();
+ var shader = _proto.Index(HorizontalCut).Instance();
if (sprite.Comp.PostShader is not null && sprite.Comp.PostShader != shader)
return;
/// </summary>
public sealed class TargetOutlineSystem : EntitySystem
{
+ private static readonly ProtoId<ShaderPrototype> ShaderTargetValid = "SelectionOutlineInrange";
+ private static readonly ProtoId<ShaderPrototype> ShaderTargetInvalid = "SelectionOutline";
+
[Dependency] private readonly IEyeManager _eyeManager = default!;
[Dependency] private readonly IGameTiming _timing = default!;
[Dependency] private readonly EntityLookupSystem _lookup = default!;
private Vector2 LookupVector => new(LookupSize, LookupSize);
- [ValidatePrototypeId<ShaderPrototype>]
- private const string ShaderTargetValid = "SelectionOutlineInrange";
-
- [ValidatePrototypeId<ShaderPrototype>]
- private const string ShaderTargetInvalid = "SelectionOutline";
-
private ShaderInstance? _shaderTargetValid;
private ShaderInstance? _shaderTargetInvalid;
{
base.Initialize();
- _shaderTargetValid = _prototypeManager.Index<ShaderPrototype>(ShaderTargetValid).InstanceUnique();
- _shaderTargetInvalid = _prototypeManager.Index<ShaderPrototype>(ShaderTargetInvalid).InstanceUnique();
+ _shaderTargetValid = _prototypeManager.Index(ShaderTargetValid).InstanceUnique();
+ _shaderTargetInvalid = _prototypeManager.Index(ShaderTargetInvalid).InstanceUnique();
}
public void Disable()
public sealed partial class BlackAndWhiteOverlay : Overlay
{
+ private static readonly ProtoId<ShaderPrototype> Shader = "GreyscaleFullscreen";
+
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
public override OverlaySpace Space => OverlaySpace.WorldSpace;
public BlackAndWhiteOverlay()
{
IoCManager.InjectDependencies(this);
- _greyscaleShader = _prototypeManager.Index<ShaderPrototype>("GreyscaleFullscreen").InstanceUnique();
+ _greyscaleShader = _prototypeManager.Index(Shader).InstanceUnique();
ZIndex = 10; // draw this over the DamageOverlay, RainbowOverlay etc.
}
public sealed partial class NoirOverlay : Overlay
{
+ private static readonly ProtoId<ShaderPrototype> Shader = "Noir";
+
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
public override OverlaySpace Space => OverlaySpace.WorldSpace;
public NoirOverlay()
{
IoCManager.InjectDependencies(this);
- _noirShader = _prototypeManager.Index<ShaderPrototype>("Noir").InstanceUnique();
+ _noirShader = _prototypeManager.Index(Shader).InstanceUnique();
ZIndex = 9; // draw this over the DamageOverlay, RainbowOverlay etc, but before the black and white shader
}
}, Color.Transparent);
worldHandle.SetTransform(Matrix3x2.Identity);
- worldHandle.UseShader(_protoManager.Index<ShaderPrototype>("StencilMask").Instance());
+ worldHandle.UseShader(_protoManager.Index(StencilMask).Instance());
worldHandle.DrawTextureRect(_blep!.Texture, worldBounds);
var curTime = _timing.RealTime;
var sprite = _sprite.GetFrame(new SpriteSpecifier.Texture(new ResPath("/Textures/Parallaxes/noise.png")), curTime);
// Draw the rain
- worldHandle.UseShader(_protoManager.Index<ShaderPrototype>("StencilDraw").Instance());
+ worldHandle.UseShader(_protoManager.Index(StencilDraw).Instance());
_parallax.DrawParallax(worldHandle, worldAABB, sprite, curTime, position, new Vector2(0.5f, 0f));
}
}
}, Color.Transparent);
worldHandle.SetTransform(Matrix3x2.Identity);
- worldHandle.UseShader(_protoManager.Index<ShaderPrototype>("StencilMask").Instance());
+ worldHandle.UseShader(_protoManager.Index(StencilMask).Instance());
worldHandle.DrawTextureRect(_blep!.Texture, worldBounds);
var curTime = _timing.RealTime;
var sprite = _sprite.GetFrame(weatherProto.Sprite, curTime);
// Draw the rain
- worldHandle.UseShader(_protoManager.Index<ShaderPrototype>("StencilDraw").Instance());
+ worldHandle.UseShader(_protoManager.Index(StencilDraw).Instance());
_parallax.DrawParallax(worldHandle, worldAABB, sprite, curTime, position, Vector2.Zero, modulate: (weatherProto.Color ?? Color.White).WithAlpha(alpha));
worldHandle.SetTransform(Matrix3x2.Identity);
/// </summary>
public sealed partial class StencilOverlay : Overlay
{
+ private static readonly ProtoId<ShaderPrototype> CircleShader = "WorldGradientCircle";
+ private static readonly ProtoId<ShaderPrototype> StencilMask = "StencilMask";
+ private static readonly ProtoId<ShaderPrototype> StencilDraw = "StencilDraw";
+
[Dependency] private readonly IClyde _clyde = default!;
[Dependency] private readonly IEntityManager _entManager = default!;
[Dependency] private readonly IGameTiming _timing = default!;
_sprite = sprite;
_weather = weather;
IoCManager.InjectDependencies(this);
- _shader = _protoManager.Index<ShaderPrototype>("WorldGradientCircle").InstanceUnique();
+ _shader = _protoManager.Index(CircleShader).InstanceUnique();
}
protected override void Draw(in OverlayDrawArgs args)
[GenerateTypedNameReferences]
public sealed partial class StampLabel : Label
{
+ private static readonly ProtoId<ShaderPrototype> PaperStamp = "PaperStamp";
+
/// A scale that's applied to the text to ensure it
/// fits in the allowed space.
private Vector2 _textScaling = Vector2.One;
RobustXamlLoader.Load(this);
var prototypes = IoCManager.Resolve<IPrototypeManager>();
- _stampShader = prototypes.Index<ShaderPrototype>("PaperStamp").InstanceUnique();
+ _stampShader = prototypes.Index(PaperStamp).InstanceUnique();
}
protected override Vector2 MeasureOverride(Vector2 availableSize)
[GenerateTypedNameReferences]
public sealed partial class StampWidget : PanelContainer
{
+ private static readonly ProtoId<ShaderPrototype> PaperStamp = "PaperStamp";
+
private StyleBoxTexture _borderTexture;
private ShaderInstance? _stampShader;
PanelOverride = _borderTexture;
var prototypes = IoCManager.Resolve<IPrototypeManager>();
- _stampShader = prototypes.Index<ShaderPrototype>("PaperStamp").InstanceUnique();
+ _stampShader = prototypes.Index(PaperStamp).InstanceUnique();
}
protected override void Draw(DrawingHandleScreen handle)
public sealed class PASegmentControl : Control
{
+ private static readonly ProtoId<ShaderPrototype> GreyscaleShaderId = "Greyscale";
private readonly ShaderInstance _greyScaleShader;
private readonly TextureRect _base;
private readonly TextureRect _unlit;
public PASegmentControl()
{
- _greyScaleShader = IoCManager.Resolve<IPrototypeManager>().Index<ShaderPrototype>("Greyscale").Instance();
+ _greyScaleShader = IoCManager.Resolve<IPrototypeManager>().Index(GreyscaleShaderId).Instance();
AddChild(_base = new TextureRect());
AddChild(_unlit = new TextureRect());
/// </summary>
public sealed class PopupOverlay : Overlay
{
+ private static readonly ProtoId<ShaderPrototype> UnshadedShader = "unshaded";
+
private readonly IConfigurationManager _configManager;
private readonly IEntityManager _entManager;
private readonly IPlayerManager _playerMgr;
_popup = popup;
_controller = controller;
- _shader = protoManager.Index<ShaderPrototype>("unshaded").Instance();
+ _shader = protoManager.Index(UnshadedShader).Instance();
}
protected override void Draw(in OverlayDrawArgs args)
{
public sealed class RadiationPulseOverlay : Overlay
{
+ private static readonly ProtoId<ShaderPrototype> RadiationShader = "Radiation";
+
[Dependency] private readonly IEntityManager _entityManager = default!;
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
[Dependency] private readonly IGameTiming _gameTiming = default!;
public RadiationPulseOverlay()
{
IoCManager.InjectDependencies(this);
- _baseShader = _prototypeManager.Index<ShaderPrototype>("Radiation").Instance().Duplicate();
+ _baseShader = _prototypeManager.Index(RadiationShader).Instance().Duplicate();
}
protected override bool BeforeDraw(in OverlayDrawArgs args)
/// </summary>
public sealed class FtlArrivalOverlay : Overlay
{
+ private static readonly ProtoId<ShaderPrototype> UnshadedShader = "unshaded";
+
public override OverlaySpace Space => OverlaySpace.WorldSpaceBelowEntities;
private EntityLookupSystem _lookups;
_maps = _entManager.System<SharedMapSystem>();
_sprites = _entManager.System<SpriteSystem>();
- _shader = _protos.Index<ShaderPrototype>("unshaded").Instance();
+ _shader = _protos.Index(UnshadedShader).Instance();
}
protected override bool BeforeDraw(in OverlayDrawArgs args)
public sealed class StationAiOverlay : Overlay
{
+ private static readonly ProtoId<ShaderPrototype> CameraStaticShader = "CameraStatic";
+ private static readonly ProtoId<ShaderPrototype> StencilMaskShader = "StencilMask";
+ private static readonly ProtoId<ShaderPrototype> StencilDrawShader = "StencilDraw";
+
[Dependency] private readonly IClyde _clyde = default!;
[Dependency] private readonly IEntityManager _entManager = default!;
[Dependency] private readonly IGameTiming _timing = default!;
() =>
{
worldHandle.SetTransform(invMatrix);
- var shader = _proto.Index<ShaderPrototype>("CameraStatic").Instance();
+ var shader = _proto.Index(CameraStaticShader).Instance();
worldHandle.UseShader(shader);
worldHandle.DrawRect(worldBounds, Color.White);
},
}
// Use the lighting as a mask
- worldHandle.UseShader(_proto.Index<ShaderPrototype>("StencilMask").Instance());
+ worldHandle.UseShader(_proto.Index(StencilMaskShader).Instance());
worldHandle.DrawTextureRect(_stencilTexture!.Texture, worldBounds);
// Draw the static
- worldHandle.UseShader(_proto.Index<ShaderPrototype>("StencilDraw").Instance());
+ worldHandle.UseShader(_proto.Index(StencilDrawShader).Instance());
worldHandle.DrawTextureRect(_staticTexture!.Texture, worldBounds);
worldHandle.SetTransform(Matrix3x2.Identity);
{
public sealed class SingularityOverlay : Overlay, IEntityEventSubscriber
{
+ private static readonly ProtoId<ShaderPrototype> Shader = "Singularity";
+
[Dependency] private readonly IEntityManager _entMan = default!;
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
private SharedTransformSystem? _xformSystem = null;
public SingularityOverlay()
{
IoCManager.InjectDependencies(this);
- _shader = _prototypeManager.Index<ShaderPrototype>("Singularity").Instance().Duplicate();
+ _shader = _prototypeManager.Index(Shader).Instance().Duplicate();
_shader.SetParameter("maxDistance", MaxDistance * EyeManager.PixelsPerMeter);
_entMan.EventBus.SubscribeEvent<PixelToMapEvent>(EventSource.Local, this, OnProjectFromScreenToMap);
ZIndex = 101; // Should be drawn after the placement overlay so admins placing items near the singularity can tell where they're going.
public sealed class StatusIconOverlay : Overlay
{
+ private static readonly ProtoId<ShaderPrototype> UnshadedShader = "unshaded";
+
[Dependency] private readonly IEntityManager _entity = default!;
[Dependency] private readonly IPrototypeManager _prototype = default!;
[Dependency] private readonly IGameTiming _timing = default!;
_sprite = _entity.System<SpriteSystem>();
_transform = _entity.System<TransformSystem>();
_statusIcon = _entity.System<StatusIconSystem>();
- _unshadedShader = _prototype.Index<ShaderPrototype>("unshaded").Instance();
+ _unshadedShader = _prototype.Index(UnshadedShader).Instance();
}
protected override void Draw(in OverlayDrawArgs args)
public sealed class StealthSystem : SharedStealthSystem
{
+ private static readonly ProtoId<ShaderPrototype> Shader = "Stealth";
+
[Dependency] private readonly IPrototypeManager _protoMan = default!;
[Dependency] private readonly SharedTransformSystem _transformSystem = default!;
[Dependency] private readonly SpriteSystem _sprite = default!;
{
base.Initialize();
- _shader = _protoMan.Index<ShaderPrototype>("Stealth").InstanceUnique();
+ _shader = _protoMan.Index(Shader).InstanceUnique();
SubscribeLocalEvent<StealthComponent, ComponentShutdown>(OnShutdown);
SubscribeLocalEvent<StealthComponent, ComponentStartup>(OnStartup);
[GenerateTypedNameReferences]
public sealed partial class SurveillanceCameraMonitorWindow : DefaultWindow
{
+ private static readonly ProtoId<ShaderPrototype> CameraStaticShader = "CameraStatic";
+
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
[Dependency] private readonly IResourceCache _resourceCache = default!;
// This could be done better. I don't want to deal with stylesheets at the moment.
var texture = _resourceCache.GetTexture("/Textures/Interface/Nano/square_black.png");
- var shader = _prototypeManager.Index<ShaderPrototype>("CameraStatic").Instance().Duplicate();
+ var shader = _prototypeManager.Index(CameraStaticShader).Instance().Duplicate();
CameraView.ViewportSize = new Vector2i(500, 500);
CameraView.Eye = _defaultEye; // sure
public sealed class DamageOverlay : Overlay
{
+ private static readonly ProtoId<ShaderPrototype> CircleMaskShader = "GradientCircleMask";
+
[Dependency] private readonly IGameTiming _timing = default!;
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
[Dependency] private readonly IEntityManager _entityManager = default!;
{
// TODO: Replace
IoCManager.InjectDependencies(this);
- _oxygenShader = _prototypeManager.Index<ShaderPrototype>("GradientCircleMask").InstanceUnique();
- _critShader = _prototypeManager.Index<ShaderPrototype>("GradientCircleMask").InstanceUnique();
- _bruteShader = _prototypeManager.Index<ShaderPrototype>("GradientCircleMask").InstanceUnique();
+ _oxygenShader = _prototypeManager.Index(CircleMaskShader).InstanceUnique();
+ _critShader = _prototypeManager.Index(CircleMaskShader).InstanceUnique();
+ _bruteShader = _prototypeManager.Index(CircleMaskShader).InstanceUnique();
}
protected override void Draw(in OverlayDrawArgs args)