Files
crystall-punk-14/Content.Client/_CP14/Workbench/CP14WorkbenchRequirementControl.cs

50 lines
1.4 KiB
C#
Raw Normal View History

/*
* This file is sublicensed under MIT License
* https://github.com/space-wizards/space-station-14/blob/master/LICENSE.TXT
*/
using Content.Shared._CP14.Workbench;
using Robust.Client.AutoGenerated;
using Robust.Client.GameObjects;
using Robust.Client.UserInterface;
using Robust.Client.UserInterface.XAML;
using Robust.Shared.Prototypes;
namespace Content.Client._CP14.Workbench;
[GenerateTypedNameReferences]
public sealed partial class CP14WorkbenchRequirementControl : Control
{
[Dependency] private readonly IEntityManager _entity = default!;
[Dependency] private readonly IPrototypeManager _proto = default!;
private readonly SpriteSystem _sprite;
public CP14WorkbenchRequirementControl()
{
RobustXamlLoader.Load(this);
IoCManager.InjectDependencies(this);
_sprite = _entity.System<SpriteSystem>();
}
public CP14WorkbenchRequirementControl(CP14WorkbenchCraftRequirement requirement) : this()
{
Name.Text = requirement.GetRequirementTitle(_proto);
var texture = requirement.GetRequirementTexture(_proto);
if (texture is not null)
{
View.Visible = true;
View.Texture = _sprite.Frame0(texture);
}
var entityView = requirement.GetRequirementEntityView(_proto);
if (entityView is not null)
{
EntityView.Visible = true;
EntityView.SetPrototype(entityView);
}
}
}