2022-01-29 22:45:50 +11:00
|
|
|
using Content.Server.Explosion.Components;
|
2022-04-15 01:00:50 +03:00
|
|
|
using Content.Server.Sticky.Events;
|
2022-03-25 17:17:29 +13:00
|
|
|
using Content.Shared.Examine;
|
2022-03-13 01:33:23 +13:00
|
|
|
using Content.Shared.Interaction.Events;
|
2022-11-20 21:51:44 -05:00
|
|
|
using Content.Shared.Popups;
|
2022-03-25 17:17:29 +13:00
|
|
|
using Content.Shared.Verbs;
|
|
|
|
|
using Robust.Shared.Player;
|
2022-01-29 22:45:50 +11:00
|
|
|
|
|
|
|
|
namespace Content.Server.Explosion.EntitySystems;
|
|
|
|
|
|
|
|
|
|
public sealed partial class TriggerSystem
|
|
|
|
|
{
|
2022-03-25 17:17:29 +13:00
|
|
|
[Dependency] private readonly SharedPopupSystem _popupSystem = default!;
|
|
|
|
|
|
2022-01-29 22:45:50 +11:00
|
|
|
private void InitializeOnUse()
|
|
|
|
|
{
|
|
|
|
|
SubscribeLocalEvent<OnUseTimerTriggerComponent, UseInHandEvent>(OnTimerUse);
|
2022-03-25 17:17:29 +13:00
|
|
|
SubscribeLocalEvent<OnUseTimerTriggerComponent, ExaminedEvent>(OnExamined);
|
|
|
|
|
SubscribeLocalEvent<OnUseTimerTriggerComponent, GetVerbsEvent<AlternativeVerb>>(OnGetAltVerbs);
|
2022-04-15 01:00:50 +03:00
|
|
|
SubscribeLocalEvent<OnUseTimerTriggerComponent, EntityStuckEvent>(OnStuck);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void OnStuck(EntityUid uid, OnUseTimerTriggerComponent component, EntityStuckEvent args)
|
|
|
|
|
{
|
|
|
|
|
if (!component.StartOnStick)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
HandleTimerTrigger(
|
|
|
|
|
uid,
|
|
|
|
|
args.User,
|
|
|
|
|
component.Delay,
|
|
|
|
|
component.BeepInterval,
|
|
|
|
|
component.InitialBeepDelay,
|
|
|
|
|
component.BeepSound,
|
|
|
|
|
component.BeepParams);
|
2022-01-29 22:45:50 +11:00
|
|
|
}
|
|
|
|
|
|
2022-03-25 17:17:29 +13:00
|
|
|
private void OnExamined(EntityUid uid, OnUseTimerTriggerComponent component, ExaminedEvent args)
|
2022-01-29 22:45:50 +11:00
|
|
|
{
|
2023-03-20 19:32:28 +00:00
|
|
|
if (args.IsInDetailsRange && component.Examinable)
|
2022-03-25 17:17:29 +13:00
|
|
|
args.PushText(Loc.GetString("examine-trigger-timer", ("time", component.Delay)));
|
|
|
|
|
}
|
2022-01-29 22:45:50 +11:00
|
|
|
|
2022-03-25 17:17:29 +13:00
|
|
|
/// <summary>
|
|
|
|
|
/// Add an alt-click interaction that cycles through delays.
|
|
|
|
|
/// </summary>
|
|
|
|
|
private void OnGetAltVerbs(EntityUid uid, OnUseTimerTriggerComponent component, GetVerbsEvent<AlternativeVerb> args)
|
|
|
|
|
{
|
|
|
|
|
if (!args.CanInteract || !args.CanAccess)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
if (component.DelayOptions == null || component.DelayOptions.Count == 1)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
args.Verbs.Add(new AlternativeVerb()
|
|
|
|
|
{
|
|
|
|
|
Category = TimerOptions,
|
|
|
|
|
Text = Loc.GetString("verb-trigger-timer-cycle"),
|
|
|
|
|
Act = () => CycleDelay(component, args.User),
|
|
|
|
|
Priority = 1
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
foreach (var option in component.DelayOptions)
|
|
|
|
|
{
|
|
|
|
|
if (MathHelper.CloseTo(option, component.Delay))
|
|
|
|
|
{
|
|
|
|
|
args.Verbs.Add(new AlternativeVerb()
|
|
|
|
|
{
|
|
|
|
|
Category = TimerOptions,
|
|
|
|
|
Text = Loc.GetString("verb-trigger-timer-set-current", ("time", option)),
|
|
|
|
|
Disabled = true,
|
|
|
|
|
Priority = (int) (-100 * option)
|
|
|
|
|
});
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
args.Verbs.Add(new AlternativeVerb()
|
|
|
|
|
{
|
|
|
|
|
Category = TimerOptions,
|
|
|
|
|
Text = Loc.GetString("verb-trigger-timer-set", ("time", option)),
|
|
|
|
|
Priority = (int) (-100 * option),
|
|
|
|
|
|
|
|
|
|
Act = () =>
|
|
|
|
|
{
|
|
|
|
|
component.Delay = option;
|
2022-12-19 10:41:47 +13:00
|
|
|
_popupSystem.PopupEntity(Loc.GetString("popup-trigger-timer-set", ("time", option)), args.User, args.User);
|
2022-03-25 17:17:29 +13:00
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
}
|
2022-08-14 15:48:02 +10:00
|
|
|
|
|
|
|
|
if (component.AllowToggleStartOnStick)
|
|
|
|
|
{
|
|
|
|
|
args.Verbs.Add(new AlternativeVerb()
|
|
|
|
|
{
|
|
|
|
|
Text = Loc.GetString("verb-toggle-start-on-stick"),
|
|
|
|
|
Act = () => ToggleStartOnStick(uid, args.User, component)
|
|
|
|
|
});
|
|
|
|
|
}
|
2022-01-29 22:45:50 +11:00
|
|
|
}
|
|
|
|
|
|
2022-03-25 17:17:29 +13:00
|
|
|
private void CycleDelay(OnUseTimerTriggerComponent component, EntityUid user)
|
2022-01-29 22:45:50 +11:00
|
|
|
{
|
2022-03-25 17:17:29 +13:00
|
|
|
if (component.DelayOptions == null || component.DelayOptions.Count == 1)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
// This is somewhat inefficient, but its good enough. This is run rarely, and the lists should be short.
|
2022-01-29 22:45:50 +11:00
|
|
|
|
2022-03-25 17:17:29 +13:00
|
|
|
component.DelayOptions.Sort();
|
|
|
|
|
|
|
|
|
|
if (component.DelayOptions[^1] <= component.Delay)
|
|
|
|
|
{
|
|
|
|
|
component.Delay = component.DelayOptions[0];
|
2022-12-19 10:41:47 +13:00
|
|
|
_popupSystem.PopupEntity(Loc.GetString("popup-trigger-timer-set", ("time", component.Delay)), user, user);
|
2022-03-25 17:17:29 +13:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
foreach (var option in component.DelayOptions)
|
|
|
|
|
{
|
|
|
|
|
if (option > component.Delay)
|
|
|
|
|
{
|
|
|
|
|
component.Delay = option;
|
2022-12-19 10:41:47 +13:00
|
|
|
_popupSystem.PopupEntity(Loc.GetString("popup-trigger-timer-set", ("time", option)), user, user);
|
2022-03-25 17:17:29 +13:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
2022-01-29 22:45:50 +11:00
|
|
|
}
|
2022-03-25 17:17:29 +13:00
|
|
|
|
2022-08-14 15:48:02 +10:00
|
|
|
private void ToggleStartOnStick(EntityUid grenade, EntityUid user, OnUseTimerTriggerComponent comp)
|
|
|
|
|
{
|
|
|
|
|
if (comp.StartOnStick)
|
|
|
|
|
{
|
|
|
|
|
comp.StartOnStick = false;
|
2022-12-19 10:41:47 +13:00
|
|
|
_popupSystem.PopupEntity(Loc.GetString("popup-start-on-stick-off"), grenade, user);
|
2022-08-14 15:48:02 +10:00
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
comp.StartOnStick = true;
|
2022-12-19 10:41:47 +13:00
|
|
|
_popupSystem.PopupEntity(Loc.GetString("popup-start-on-stick-on"), grenade, user);
|
2022-08-14 15:48:02 +10:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2022-03-25 17:17:29 +13:00
|
|
|
private void OnTimerUse(EntityUid uid, OnUseTimerTriggerComponent component, UseInHandEvent args)
|
|
|
|
|
{
|
[Antag] add space ninja as midround antag (#14069)
* start of space ninja midround antag
* suit has powercell, can be upgraded only (not replaced with equal or worse battery)
* add doorjacking to ninja gloves, power cell, doorjack objective (broken), tweaks
* :skull:
* add basic suit power display that uses stamina rsi
* add draining apc/sub/smes - no wires yet
* add research downloading
* ninja starts implanted, move some stuff to yaml
* add Automated field to OnUseTimerTrigger
* implement spider charge and objective
* fix client crash when taking suit off, some refactor
* add survive condition and tweak locale
* add comms console icon for objective
* add calling in a threat - currently revenant and dragon
* combine all glove abilities
* locale
* spark sounds when draining, refactoring
* toggle is actually toggle now
* prevent crash if disabling stealth with outline
* add antag ctrl for ninja, hopefully show greentext
* fix greentext and some other things
* disabling gloves if taken off or suit taken off
* basic energy katana, change ninja loadout
* recallable katana, refactoring
* start of dash - not done yet
* katana dashing ability
* merge upstream + compiling, make AutomatedTimer its own component
* docs and stuff
* partial refactor of glove abilities, still need to move handling
* make dooremaggedevent by ref
* move bunch of stuff to shared - broken
* clean ninja antag verb
* doc
* mark rule config fields as required
* fix client crash
* wip systems refactor
* big refactor of systems
* fuck
* make TryDoElectrocution callable from shared
* finish refactoring?
* no guns
* start with internals on
* clean up glove abilities, add range check
* create soap, in place of ninja throwing stars
* add emp suit ability
* able to eat chefs stolen food in space
* stuff, tell client when un/cloaked but there is bug with gloves
* fix prediction breaking gloves on client
* ninja soap despawns after a minute
* ninja spawns outside the station now, with gps + station coords to navigate
* add cooldown to stun ability
* cant use glove abilities in combat mode
* require empty hand to use glove abilities
* use ghost role spawner
* Update Content.Server/Ninja/Systems/NinjaSuitSystem.cs
Co-authored-by: keronshb <54602815+keronshb@users.noreply.github.com>
* some review changes
* show powercell charge on examine
* new is needed
* address some reviews
* ninja starts with jetpack, i hope
* partial feedback
* uhh
* pro
* remove pirate from threats list
* use doafter refactor
* pro i gave skeleton jetpack
* some stuff
* use auto gen state
* mr handy
* use EntityQueryEnumerator
* cleanup
* spider charge target anti-troll
* mmmmmm
---------
Co-authored-by: deltanedas <deltanedas@laptop>
Co-authored-by: deltanedas <user@zenith>
Co-authored-by: deltanedas <@deltanedas:kde.org>
Co-authored-by: keronshb <54602815+keronshb@users.noreply.github.com>
2023-04-17 07:33:27 +00:00
|
|
|
if (args.Handled || HasComp<AutomatedTimerComponent>(uid))
|
2022-11-20 21:51:44 -05:00
|
|
|
return;
|
2022-03-25 17:17:29 +13:00
|
|
|
|
|
|
|
|
HandleTimerTrigger(
|
|
|
|
|
uid,
|
|
|
|
|
args.User,
|
|
|
|
|
component.Delay,
|
|
|
|
|
component.BeepInterval,
|
|
|
|
|
component.InitialBeepDelay,
|
|
|
|
|
component.BeepSound,
|
|
|
|
|
component.BeepParams);
|
|
|
|
|
|
|
|
|
|
args.Handled = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static VerbCategory TimerOptions = new("verb-categories-timer", "/Textures/Interface/VerbIcons/clock.svg.192dpi.png");
|
2022-01-29 22:45:50 +11:00
|
|
|
}
|