diff --git a/Content.Server/Light/EntitySystems/ExpendableLightSystem.cs b/Content.Server/Light/EntitySystems/ExpendableLightSystem.cs index 7aacf3e7ad..393f564b2f 100644 --- a/Content.Server/Light/EntitySystems/ExpendableLightSystem.cs +++ b/Content.Server/Light/EntitySystems/ExpendableLightSystem.cs @@ -1,10 +1,14 @@ 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; @@ -23,7 +27,8 @@ namespace Content.Server.Light.EntitySystems [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 TrashTag = "Trash"; @@ -34,6 +39,8 @@ namespace Content.Server.Light.EntitySystems SubscribeLocalEvent(OnExpLightInit); SubscribeLocalEvent(OnExpLightUse); SubscribeLocalEvent>(AddIgniteVerb); + SubscribeLocalEvent(OnInteractUsing); + SubscribeLocalEvent(OnRefreshNameModifiers); } public override void Update(float frameTime) @@ -59,7 +66,7 @@ namespace Content.Server.Light.EntitySystems { case ExpendableLightState.Lit: component.CurrentState = ExpendableLightState.Fading; - component.StateExpiryTime = component.FadeOutDuration; + component.StateExpiryTime = (float)component.FadeOutDuration.TotalSeconds; UpdateVisualizer(ent); @@ -68,9 +75,7 @@ namespace Content.Server.Light.EntitySystems 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); @@ -104,15 +109,47 @@ namespace Content.Server.Light.EntitySystems RaiseLocalEvent(ent, ref ignite); component.CurrentState = ExpendableLightState.Lit; - component.StateExpiryTime = component.GlowDuration; UpdateSounds(ent); UpdateVisualizer(ent); + } + return true; + } - 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; + + _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 entity, ref RefreshNameModifiersEvent args) + { + if (entity.Comp.CurrentState is ExpendableLightState.Dead) + args.AddModifier("expendable-light-spent-prefix"); } private void UpdateVisualizer(Entity ent, AppearanceComponent? appearance = null) @@ -171,6 +208,7 @@ namespace Content.Server.Light.EntitySystems } component.CurrentState = ExpendableLightState.BrandNew; + component.StateExpiryTime = (float)component.GlowDuration.TotalSeconds; EntityManager.EnsureComponent(uid); } diff --git a/Content.Shared/Light/Components/SharedExpendableLightComponent.cs b/Content.Shared/Light/Components/SharedExpendableLightComponent.cs index 001794880a..ad7a0edc4e 100644 --- a/Content.Shared/Light/Components/SharedExpendableLightComponent.cs +++ b/Content.Shared/Light/Components/SharedExpendableLightComponent.cs @@ -1,5 +1,7 @@ +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; @@ -9,34 +11,37 @@ public abstract partial class SharedExpendableLightComponent : Component { [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? 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] diff --git a/Resources/Locale/en-US/light/components/expendable-light-component.ftl b/Resources/Locale/en-US/light/components/expendable-light-component.ftl index 4cd07599b9..affc52920c 100644 --- a/Resources/Locale/en-US/light/components/expendable-light-component.ftl +++ b/Resources/Locale/en-US/light/components/expendable-light-component.ftl @@ -1,14 +1,2 @@ expendable-light-start-verb = Start Light - -expendable-light-spent-flare-name = spent flare -expendable-light-spent-flare-desc = It looks like this flare has burnt out. What a bummer. - -expendable-light-burnt-torch-name = burnt torch -expendable-light-burnt-torch-desc = It looks like this torch has burnt out. What a bummer. - -expendable-light-spent-green-glowstick-name = spent green glowstick -expendable-light-spent-red-glowstick-name = spent red glowstick -expendable-light-spent-purple-glowstick-name = spent purple glowstick -expendable-light-spent-yellow-glowstick-name = spent purple glowstick -expendable-light-spent-blue-glowstick-name = spent blue glowstick -expendable-light-spent-glowstick-desc = It looks like this glowstick has stopped glowing. How tragic. \ No newline at end of file +expendable-light-spent-prefix = spent {$baseName} diff --git a/Resources/Prototypes/Entities/Objects/Misc/torch.yml b/Resources/Prototypes/Entities/Objects/Misc/torch.yml index 50e8f65890..da4886912c 100644 --- a/Resources/Prototypes/Entities/Objects/Misc/torch.yml +++ b/Resources/Prototypes/Entities/Objects/Misc/torch.yml @@ -5,9 +5,9 @@ description: A torch fashioned from some wood. components: - type: ExpendableLight - spentName: expendable-light-burnt-torch-name - spentDesc: expendable-light-burnt-torch-desc + refuelMaterialID: WoodPlank glowDuration: 100 + refuelMaximumDuration: 205 fadeOutDuration: 4 iconStateSpent: torch_spent turnOnBehaviourID: turn_on diff --git a/Resources/Prototypes/Entities/Objects/Tools/flare.yml b/Resources/Prototypes/Entities/Objects/Tools/flare.yml index d36f67d00d..34c233921e 100644 --- a/Resources/Prototypes/Entities/Objects/Tools/flare.yml +++ b/Resources/Prototypes/Entities/Objects/Tools/flare.yml @@ -10,8 +10,6 @@ - Trash - type: SpaceGarbage - type: ExpendableLight - spentName: expendable-light-spent-flare-name - spentDesc: expendable-light-spent-flare-desc glowDuration: 225 fadeOutDuration: 15 iconStateOn: flare_unlit diff --git a/Resources/Prototypes/Entities/Objects/Tools/glowstick.yml b/Resources/Prototypes/Entities/Objects/Tools/glowstick.yml index 3081f60989..c577cd8e58 100644 --- a/Resources/Prototypes/Entities/Objects/Tools/glowstick.yml +++ b/Resources/Prototypes/Entities/Objects/Tools/glowstick.yml @@ -6,8 +6,6 @@ components: - type: SpaceGarbage - type: ExpendableLight - spentName: expendable-light-spent-green-glowstick-name - spentDesc: expendable-light-spent-glowstick-desc glowDuration: 900 # time in seconds glowColorLit: "#00FF00" fadeOutDuration: 300