using Content.Server.Light.Components;
+using Content.Server.Stack;
using Content.Shared.Clothing.Components;
using Content.Shared.Clothing.EntitySystems;
using Content.Shared.IgnitionSource;
+using Content.Shared.Interaction;
using Content.Shared.Interaction.Events;
using Content.Shared.Item;
using Content.Shared.Light.Components;
+using Content.Shared.NameModifier.EntitySystems;
+using Content.Shared.Stacks;
using Content.Shared.Tag;
using Content.Shared.Verbs;
using JetBrains.Annotations;
[Dependency] private readonly TagSystem _tagSystem = default!;
[Dependency] private readonly SharedAudioSystem _audio = default!;
[Dependency] private readonly SharedAppearanceSystem _appearance = default!;
- [Dependency] private readonly MetaDataSystem _metaData = default!;
+ [Dependency] private readonly StackSystem _stackSystem = default!;
+ [Dependency] private readonly NameModifierSystem _nameModifier = default!;
private static readonly ProtoId<TagPrototype> TrashTag = "Trash";
SubscribeLocalEvent<ExpendableLightComponent, ComponentInit>(OnExpLightInit);
SubscribeLocalEvent<ExpendableLightComponent, UseInHandEvent>(OnExpLightUse);
SubscribeLocalEvent<ExpendableLightComponent, GetVerbsEvent<ActivationVerb>>(AddIgniteVerb);
+ SubscribeLocalEvent<ExpendableLightComponent, InteractUsingEvent>(OnInteractUsing);
+ SubscribeLocalEvent<ExpendableLightComponent, RefreshNameModifiersEvent>(OnRefreshNameModifiers);
}
public override void Update(float frameTime)
{
case ExpendableLightState.Lit:
component.CurrentState = ExpendableLightState.Fading;
- component.StateExpiryTime = component.FadeOutDuration;
+ component.StateExpiryTime = (float)component.FadeOutDuration.TotalSeconds;
UpdateVisualizer(ent);
default:
case ExpendableLightState.Fading:
component.CurrentState = ExpendableLightState.Dead;
- var meta = MetaData(ent);
- _metaData.SetEntityName(ent, Loc.GetString(component.SpentName), meta);
- _metaData.SetEntityDescription(ent, Loc.GetString(component.SpentDesc), meta);
+ _nameModifier.RefreshNameModifiers(ent.Owner);
_tagSystem.AddTag(ent, TrashTag);
RaiseLocalEvent(ent, ref ignite);
component.CurrentState = ExpendableLightState.Lit;
- component.StateExpiryTime = component.GlowDuration;
UpdateSounds(ent);
UpdateVisualizer(ent);
+ }
+ return true;
+ }
+
+ private void OnInteractUsing(EntityUid uid, ExpendableLightComponent component, ref InteractUsingEvent args)
+ {
+ if (args.Handled)
+ return;
+
+ if (!TryComp(args.Used, out StackComponent? stack))
+ return;
+
+ if (stack.StackTypeId != component.RefuelMaterialID)
+ return;
+
+ if (component.StateExpiryTime + component.RefuelMaterialTime.TotalSeconds >= component.RefuelMaximumDuration.TotalSeconds)
+ return;
+
+ if (component.CurrentState is ExpendableLightState.Dead)
+ {
+ component.CurrentState = ExpendableLightState.BrandNew;
+ component.StateExpiryTime = (float)component.RefuelMaterialTime.TotalSeconds;
- return true;
+ _nameModifier.RefreshNameModifiers(uid);
+ _stackSystem.SetCount(args.Used, stack.Count - 1, stack);
+ UpdateVisualizer((uid, component));
+ return;
}
- return false;
+ component.StateExpiryTime += (float)component.RefuelMaterialTime.TotalSeconds;
+ _stackSystem.SetCount(args.Used, stack.Count - 1, stack);
+ args.Handled = true;
+ }
+
+ private void OnRefreshNameModifiers(Entity<ExpendableLightComponent> entity, ref RefreshNameModifiersEvent args)
+ {
+ if (entity.Comp.CurrentState is ExpendableLightState.Dead)
+ args.AddModifier("expendable-light-spent-prefix");
}
private void UpdateVisualizer(Entity<ExpendableLightComponent> ent, AppearanceComponent? appearance = null)
}
component.CurrentState = ExpendableLightState.BrandNew;
+ component.StateExpiryTime = (float)component.GlowDuration.TotalSeconds;
EntityManager.EnsureComponent<PointLightComponent>(uid);
}
+using Content.Shared.Stacks;
using Robust.Shared.Audio;
using Robust.Shared.GameStates;
+using Robust.Shared.Prototypes;
using Robust.Shared.Serialization;
namespace Content.Shared.Light.Components;
{
[ViewVariables(VVAccess.ReadOnly)]
- public ExpendableLightState CurrentState { get; set; }
+ public ExpendableLightState CurrentState;
- [DataField("turnOnBehaviourID")]
- public string TurnOnBehaviourID { get; set; } = string.Empty;
+ [DataField]
+ public string TurnOnBehaviourID = string.Empty;
- [DataField("fadeOutBehaviourID")]
- public string FadeOutBehaviourID { get; set; } = string.Empty;
+ [DataField]
+ public string FadeOutBehaviourID = string.Empty;
- [DataField("glowDuration")]
- public float GlowDuration { get; set; } = 60 * 15f;
+ [DataField]
+ public TimeSpan GlowDuration = TimeSpan.FromSeconds(60 * 15f);
- [DataField("fadeOutDuration")]
- public float FadeOutDuration { get; set; } = 60 * 5f;
+ [DataField]
+ public TimeSpan FadeOutDuration = TimeSpan.FromSeconds(60 * 5f);
- [DataField("spentDesc")]
- public string SpentDesc { get; set; } = string.Empty;
+ [DataField]
+ public ProtoId<StackPrototype>? RefuelMaterialID;
- [DataField("spentName")]
- public string SpentName { get; set; } = string.Empty;
+ [DataField]
+ public TimeSpan RefuelMaterialTime = TimeSpan.FromSeconds(15f);
- [DataField("litSound")]
- public SoundSpecifier? LitSound { get; set; }
+ [DataField]
+ public TimeSpan RefuelMaximumDuration = TimeSpan.FromSeconds(60 * 15f * 2);
- [DataField("loopedSound")]
- public SoundSpecifier? LoopedSound { get; set; }
+ [DataField]
+ public SoundSpecifier? LitSound;
- [DataField("dieSound")]
- public SoundSpecifier? DieSound { get; set; } = null;
+ [DataField]
+ public SoundSpecifier? LoopedSound;
+
+ [DataField]
+ public SoundSpecifier? DieSound;
}
[Serializable, NetSerializable]