-
Notifications
You must be signed in to change notification settings - Fork 3.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Pipebombs now require ignition source #26400
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
using Content.Shared.Explosion.Components; | ||
using Content.Shared.Interaction; | ||
using Content.Shared.Interaction.Events; | ||
using Content.Shared.Examine; | ||
using Content.Shared.Popups; | ||
using Content.Shared.Verbs; | ||
using Content.Shared.Temperature; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using Content.Server.Explosion.EntitySystems; | ||
using Content.Server.Explosion.Components; | ||
using Robust.Shared.Random; | ||
using Content.Shared.Trigger; | ||
using Content.Server.IgnitionSource; | ||
|
||
|
||
namespace Content.Server.Explosion | ||
{ | ||
public sealed class TriggerTimerOnIgniteSystem : EntitySystem | ||
{ | ||
[Dependency] private readonly SharedPopupSystem _popupSystem = default!; | ||
[Dependency] private readonly IRobustRandom _random = default!; | ||
[Dependency] private readonly SharedAppearanceSystem _appearance = default!; | ||
|
||
|
||
|
||
public override void Initialize() | ||
{ | ||
SubscribeLocalEvent<OnIgniteTimerTriggerComponent, InteractUsingEvent>(OnInteracted); | ||
SubscribeLocalEvent<RandomTimerTriggerComponent, MapInitEvent>(OnRandomTimerTriggerMapInit2); | ||
//SubscribeLocalEvent<OnIgniteTimerTriggerComponent, UseInHandEvent>(OnUseInHand); | ||
} | ||
|
||
private void OnInteracted(EntityUid uid, OnIgniteTimerTriggerComponent component, InteractUsingEvent args) | ||
{ | ||
if (TryComp<IgnitionSourceComponent>(args.Used, out var comp)) { | ||
if(comp.Ignited == true) | ||
{ | ||
if (args.Handled) | ||
return; | ||
|
||
var active = AddComp<ActiveTimerTriggerComponent>(uid); | ||
active.TimeRemaining = component.Delay; | ||
active.User = args.User; | ||
active.BeepSound = component.BeepSound; | ||
active.BeepInterval = component.BeepInterval; | ||
active.TimeUntilBeep = component.InitialBeepDelay ?? 0f; | ||
active.TimeUntilBeep = component.InitialBeepDelay == null ? active.BeepInterval : component.InitialBeepDelay.Value; | ||
|
||
var ev = new ActiveTimerTriggerEvent(uid, args.User); | ||
RaiseLocalEvent(uid, ref ev); | ||
_popupSystem.PopupEntity(Loc.GetString("trigger-activated", ("device", uid)), args.User, args.User); | ||
Log.Debug("You used this with another item!"); | ||
var triggerEvent = new TriggerEvent(uid, args.User); | ||
|
||
if (TryComp<AppearanceComponent>(uid, out var appearance)) | ||
_appearance.SetData(uid, TriggerVisuals.VisualState, TriggerVisualState.Primed, appearance); | ||
|
||
} | ||
} | ||
} | ||
|
||
private void OnUseInHand(EntityUid uid, OnIgniteTimerTriggerComponent component, UseInHandEvent args) | ||
{ | ||
Log.Debug("You used this in your hand!"); | ||
} | ||
private void OnRandomTimerTriggerMapInit2(Entity<RandomTimerTriggerComponent> ent, ref MapInitEvent args) | ||
{ | ||
var (_, comp) = ent; | ||
|
||
if (!TryComp<OnIgniteTimerTriggerComponent>(ent, out var timerTriggerComp)) | ||
return; | ||
|
||
timerTriggerComp.Delay = _random.NextFloat(comp.Min, comp.Max); | ||
} | ||
|
||
|
||
} | ||
} | ||
Comment on lines
+29
to
+82
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same here on copy-paste. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
using Robust.Shared.Audio; | ||
using Robust.Shared.GameStates; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace Content.Shared.Explosion.Components | ||
{ | ||
[RegisterComponent, NetworkedComponent] | ||
public sealed partial class OnIgniteTimerTriggerComponent : Component | ||
{ | ||
[DataField] public float Delay = 1f; | ||
|
||
/// <summary> | ||
/// If not null, a user can use verbs to configure the delay to one of these options. | ||
/// </summary> | ||
[DataField] public List<float>? DelayOptions = null; | ||
|
||
/// <summary> | ||
/// If not null, this timer will periodically play this sound while active. | ||
/// </summary> | ||
[DataField] public SoundSpecifier? BeepSound; | ||
|
||
/// <summary> | ||
/// Time before beeping starts. Defaults to a single beep interval. If set to zero, will emit a beep immediately after use. | ||
/// </summary> | ||
[DataField] public float? InitialBeepDelay; | ||
|
||
[DataField] public float BeepInterval = 1; | ||
|
||
/// <summary> | ||
/// Whether the timer should instead be activated through a verb in the right-click menu | ||
/// </summary> | ||
[DataField] public bool UseVerbInstead = false; | ||
|
||
/// <summary> | ||
/// Should timer be started when it was stuck to another entity. | ||
/// Used for C4 charges and similar behaviour. | ||
/// </summary> | ||
[DataField] public bool StartOnStick; | ||
|
||
/// <summary> | ||
/// Allows changing the start-on-stick quality. | ||
/// </summary> | ||
[DataField("canToggleStartOnStick")] public bool AllowToggleStartOnStick; | ||
|
||
/// <summary> | ||
/// Whether you can examine the item to see its timer or not. | ||
/// </summary> | ||
[DataField] public bool Examinable = true; | ||
} | ||
} | ||
Comment on lines
+8
to
+54
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This looks copy-pasted from OnuseTimerTrigger. Components should be made reuseable. This should just be a generic "TriggerOnIgniteComponent" instead with all these copied options removed. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I could probably remove some of these options, but why not leave some of them like beepinterval and beepsound? Wouldn't this allow for more items to use this component in the future? Same for below, IO could probably remove a bit, but why not leave some things the same if they work? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @metalgearsloth Can I get your thoughts on this? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. They should be on 1 component not spread across multiple, it just increases technical debt and makes it more of a pain to maintain the code. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. just have AutomaticTriggerComponent or whatever i called it then call TriggerSystem's public api to start the timer once its igniter |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
File-scoped namespaces please.