Skip to content
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

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ private void InitializeOnUse()
SubscribeLocalEvent<OnUseTimerTriggerComponent, ExaminedEvent>(OnExamined);
SubscribeLocalEvent<OnUseTimerTriggerComponent, GetVerbsEvent<AlternativeVerb>>(OnGetAltVerbs);
SubscribeLocalEvent<OnUseTimerTriggerComponent, EntityStuckEvent>(OnStuck);
SubscribeLocalEvent<RandomTimerTriggerComponent, MapInitEvent>(OnRandomTimerTriggerMapInit);
//SubscribeLocalEvent<RandomTimerTriggerComponent, MapInitEvent>(OnRandomTimerTriggerMapInit);
}

private void OnStuck(EntityUid uid, OnUseTimerTriggerComponent component, EntityStuckEvent args)
Expand Down
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
{
Comment on lines +19 to +21
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

File-scoped namespaces please.

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
Copy link
Contributor

Choose a reason for hiding this comment

The 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
Copy link
Contributor

Choose a reason for hiding this comment

The 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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The 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?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@metalgearsloth Can I get your thoughts on this?

Copy link
Contributor

Choose a reason for hiding this comment

The 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.

Copy link
Contributor

Choose a reason for hiding this comment

The 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

2 changes: 2 additions & 0 deletions Resources/Prototypes/Entities/Objects/Tools/lighters.yml
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,8 @@
- type: ItemToggleSize
activatedSize: Small
- type: ItemToggleHot
- type: IgnitionSource
ignited: false
- type: Item
size: Tiny
sprite: Objects/Tools/lighters.rsi
Expand Down
47 changes: 44 additions & 3 deletions Resources/Prototypes/Entities/Objects/Weapons/Bombs/pipebomb.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,44 @@
- type: entity
parent: GrenadeBase
abstract: true
parent: BaseItem
id: IgniteBombBase
components:
- type: Sprite
sprite: Objects/Weapons/Grenades/grenade.rsi
layers:
- state: icon
map: ["enum.TriggerVisualLayers.Base"]
- type: Item
size: Small
- type: Clothing
quickEquip: false
slots:
- Belt
# - type: OnUseTimerTrigger
# delay: 3.5
- type: Damageable
damageContainer: Inorganic
- type: Destructible
thresholds:
- trigger:
!type:DamageTrigger
damage: 10
behaviors:
- !type:TriggerBehavior
- !type:DoActsBehavior
acts: ["Destruction"]
- type: Appearance
- type: AnimationPlayer
- type: GenericVisualizer
visuals:
enum.Trigger.TriggerVisuals.VisualState:
enum.ConstructionVisuals.Layer:
Primed: { state: primed }
Unprimed: { state: icon }


- type: entity
parent: IgniteBombBase
id: PipeBomb
name: pipe bomb
description: An improvised explosive made from pipes and wire.
Expand All @@ -10,7 +49,7 @@
- state: base
map: ["enum.TriggerVisualLayers.Base"]
- state: wires
- type: OnUseTimerTrigger # todo: make it activate through welder/lighter/fire instead
- type: OnIgniteTimerTrigger
delay: 5
examinable: false
initialBeepDelay: 0
Expand Down Expand Up @@ -59,4 +98,6 @@
- type: Construction
graph: PipeBomb
node: cable
defaultTarget: pipebomb
defaultTarget: pipebomb


Empty file added git
Empty file.
Loading