Refactors smoking to ECS, smoking actually makes you inhale reagents. (#4678)
This commit is contained in:
committed by
GitHub
parent
0767bd3777
commit
f913d8361d
@@ -21,7 +21,7 @@ namespace Content.Server.Light.Components
|
||||
/// Current state to matchstick. Can be <code>Unlit</code>, <code>Lit</code> or <code>Burnt</code>.
|
||||
/// </summary>
|
||||
[ViewVariables]
|
||||
public SharedBurningStates CurrentState = SharedBurningStates.Unlit;
|
||||
public SmokableState CurrentState = SmokableState.Unlit;
|
||||
|
||||
/// <summary>
|
||||
/// How long will matchstick last in seconds.
|
||||
|
||||
@@ -17,7 +17,7 @@ namespace Content.Server.Light.EntitySystems
|
||||
{
|
||||
if (!args.Handled
|
||||
&& args.Used.TryGetComponent<MatchstickComponent>(out var matchstick)
|
||||
&& matchstick.CurrentState == SharedBurningStates.Unlit)
|
||||
&& matchstick.CurrentState == SmokableState.Unlit)
|
||||
{
|
||||
Get<MatchstickSystem>().Ignite(matchstick, args.User);
|
||||
args.Handled = true;
|
||||
|
||||
@@ -32,7 +32,7 @@ namespace Content.Server.Light.EntitySystems
|
||||
base.Update(frameTime);
|
||||
foreach (var match in _litMatches)
|
||||
{
|
||||
if (match.CurrentState != SharedBurningStates.Lit)
|
||||
if (match.CurrentState != SmokableState.Lit)
|
||||
continue;
|
||||
|
||||
_atmosphereSystem.HotspotExpose(match.Owner.Transform.Coordinates, 400, 50, true);
|
||||
@@ -41,7 +41,7 @@ namespace Content.Server.Light.EntitySystems
|
||||
|
||||
private void OnInteractUsing(EntityUid uid, MatchstickComponent component, InteractUsingEvent args)
|
||||
{
|
||||
if (args.Handled || component.CurrentState != SharedBurningStates.Unlit)
|
||||
if (args.Handled || component.CurrentState != SmokableState.Unlit)
|
||||
return;
|
||||
|
||||
var isHotEvent = new IsHotEvent();
|
||||
@@ -56,7 +56,7 @@ namespace Content.Server.Light.EntitySystems
|
||||
|
||||
private void OnIsHotEvent(EntityUid uid, MatchstickComponent component, IsHotEvent args)
|
||||
{
|
||||
args.IsHot = component.CurrentState == SharedBurningStates.Lit;
|
||||
args.IsHot = component.CurrentState == SmokableState.Lit;
|
||||
}
|
||||
|
||||
public void Ignite(MatchstickComponent component, IEntity user)
|
||||
@@ -67,29 +67,29 @@ namespace Content.Server.Light.EntitySystems
|
||||
AudioHelpers.WithVariation(0.125f).WithVolume(-0.125f));
|
||||
|
||||
// Change state
|
||||
SetState(component, SharedBurningStates.Lit);
|
||||
SetState(component, SmokableState.Lit);
|
||||
_litMatches.Add(component);
|
||||
component.Owner.SpawnTimer(component.Duration * 1000, delegate
|
||||
{
|
||||
SetState(component, SharedBurningStates.Burnt);
|
||||
SetState(component, SmokableState.Burnt);
|
||||
_litMatches.Remove(component);
|
||||
});
|
||||
}
|
||||
|
||||
private void SetState(MatchstickComponent component, SharedBurningStates value)
|
||||
private void SetState(MatchstickComponent component, SmokableState value)
|
||||
{
|
||||
component.CurrentState = value;
|
||||
|
||||
if (component.PointLightComponent != null)
|
||||
{
|
||||
component.PointLightComponent.Enabled = component.CurrentState == SharedBurningStates.Lit;
|
||||
component.PointLightComponent.Enabled = component.CurrentState == SmokableState.Lit;
|
||||
}
|
||||
|
||||
if (component.Owner.TryGetComponent(out ItemComponent? item))
|
||||
{
|
||||
switch (component.CurrentState)
|
||||
{
|
||||
case SharedBurningStates.Lit:
|
||||
case SmokableState.Lit:
|
||||
item.EquippedPrefix = "lit";
|
||||
break;
|
||||
default:
|
||||
|
||||
Reference in New Issue
Block a user