Refactors smoking to ECS, smoking actually makes you inhale reagents. (#4678)
This commit is contained in:
committed by
GitHub
parent
0767bd3777
commit
f913d8361d
@@ -1,4 +1,5 @@
|
||||
using Content.Shared.Smoking;
|
||||
using Content.Client.Clothing;
|
||||
using Content.Shared.Smoking;
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Client.GameObjects;
|
||||
using Robust.Shared.Serialization.Manager.Attributes;
|
||||
@@ -15,29 +16,46 @@ namespace Content.Client.Smoking
|
||||
[DataField("unlitIcon")]
|
||||
private string _unlitIcon = "icon";
|
||||
|
||||
[DataField("burntPrefix")]
|
||||
private string _burntPrefix = "unlit";
|
||||
[DataField("litPrefix")]
|
||||
private string _litPrefix = "lit";
|
||||
[DataField("unlitPrefix")]
|
||||
private string _unlitPrefix = "unlit";
|
||||
|
||||
|
||||
|
||||
public override void OnChangeData(AppearanceComponent component)
|
||||
{
|
||||
base.OnChangeData(component);
|
||||
|
||||
if (component.TryGetData<SharedBurningStates>(SmokingVisuals.Smoking, out var smoking))
|
||||
if (component.TryGetData<SmokableState>(SmokingVisuals.Smoking, out var smoking))
|
||||
{
|
||||
SetState(component, smoking);
|
||||
}
|
||||
}
|
||||
|
||||
private void SetState(AppearanceComponent component, SharedBurningStates burnState)
|
||||
private void SetState(AppearanceComponent component, SmokableState burnState)
|
||||
{
|
||||
var clothing = component.Owner.GetComponentOrNull<ClothingComponent>();
|
||||
|
||||
if (component.Owner.TryGetComponent<ISpriteComponent>(out var sprite))
|
||||
{
|
||||
switch (burnState)
|
||||
{
|
||||
case SharedBurningStates.Lit:
|
||||
case SmokableState.Lit:
|
||||
if (clothing != null)
|
||||
clothing.ClothingEquippedPrefix = _litPrefix;
|
||||
sprite.LayerSetState(0, _litIcon);
|
||||
break;
|
||||
case SharedBurningStates.Burnt:
|
||||
case SmokableState.Burnt:
|
||||
if (clothing != null)
|
||||
clothing.ClothingEquippedPrefix = _burntPrefix;
|
||||
sprite.LayerSetState(0, _burntIcon);
|
||||
break;
|
||||
default:
|
||||
case SmokableState.Unlit:
|
||||
if (clothing != null)
|
||||
clothing.ClothingEquippedPrefix = _unlitPrefix;
|
||||
sprite.LayerSetState(0, _unlitIcon);
|
||||
break;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user