Add cigarettes and matches to SS14 (#2522)
* Add resources for cigs/matches * Add files for cigarettes * Remove Shared Components * Applied some of the suggestions * Change priority to allow matches to be set alight by matchbox * Added item for pack of cigars * Add swepts resources. Fix naming * Fix naming, implement suggestions. * Addressed Paul's suggestions * Remove unused resources * Fix Paul's suggestions
This commit is contained in:
@@ -0,0 +1,66 @@
|
||||
using Content.Shared.GameObjects.Components;
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Client.GameObjects;
|
||||
using Robust.Client.Interfaces.GameObjects.Components;
|
||||
using Robust.Shared.Utility;
|
||||
using YamlDotNet.RepresentationModel;
|
||||
|
||||
namespace Content.Client.GameObjects.Components.Nutrition
|
||||
{
|
||||
[UsedImplicitly]
|
||||
public class BurnStateVisualizer : AppearanceVisualizer
|
||||
{
|
||||
private string _burntIcon = "burnt-icon";
|
||||
private string _litIcon = "lit-icon";
|
||||
private string _unlitIcon = "icon";
|
||||
|
||||
public override void LoadData(YamlMappingNode node)
|
||||
{
|
||||
base.LoadData(node);
|
||||
|
||||
if (node.TryGetNode("unlitIcon", out var unlitIcon))
|
||||
{
|
||||
_unlitIcon = unlitIcon.AsString();
|
||||
}
|
||||
|
||||
if (node.TryGetNode("litIcon", out var litIcon))
|
||||
{
|
||||
_litIcon = litIcon.AsString();
|
||||
}
|
||||
|
||||
if (node.TryGetNode("burntIcon", out var burntIcon))
|
||||
{
|
||||
_burntIcon = burntIcon.AsString();
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnChangeData(AppearanceComponent component)
|
||||
{
|
||||
base.OnChangeData(component);
|
||||
|
||||
if (component.TryGetData<SharedBurningStates>(SmokingVisuals.Smoking, out var smoking))
|
||||
{
|
||||
SetState(component, smoking);
|
||||
}
|
||||
}
|
||||
|
||||
private void SetState(AppearanceComponent component, SharedBurningStates burnState)
|
||||
{
|
||||
if (component.Owner.TryGetComponent<ISpriteComponent>(out var sprite))
|
||||
{
|
||||
switch (burnState)
|
||||
{
|
||||
case SharedBurningStates.Lit:
|
||||
sprite.LayerSetState(0, _litIcon);
|
||||
break;
|
||||
case SharedBurningStates.Burnt:
|
||||
sprite.LayerSetState(0, _burntIcon);
|
||||
break;
|
||||
default:
|
||||
sprite.LayerSetState(0, _unlitIcon);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user