BorgInfo.SetMessage(text);
// how the turntables
- DisableButton.Disabled = !data.HasBrain;
+ DisableButton.Disabled = !(data.HasBrain && data.CanDisable);
DestroyButton.Disabled = _timing.CurTime < _console.Comp1.NextDestroy;
}
namespace Content.Server.Explosion.Components;
/// <summary>
-/// Disallows starting the timer by hand, must be stuck or triggered by a system.
+/// Disallows starting the timer by hand, must be stuck or triggered by a system using <c>StartTimer</c>.
/// </summary>
[RegisterComponent]
public sealed partial class AutomatedTimerComponent : Component
if (!component.StartOnStick)
return;
- HandleTimerTrigger(
- uid,
- args.User,
- component.Delay,
- component.BeepInterval,
- component.InitialBeepDelay,
- component.BeepSound);
+ StartTimer((uid, component), args.User);
}
private void OnExamined(EntityUid uid, OnUseTimerTriggerComponent component, ExaminedEvent args)
args.Verbs.Add(new AlternativeVerb()
{
Text = Loc.GetString("verb-start-detonation"),
- Act = () => HandleTimerTrigger(
- uid,
- args.User,
- component.Delay,
- component.BeepInterval,
- component.InitialBeepDelay,
- component.BeepSound
- ),
+ Act = () => StartTimer((uid, component), args.User),
Priority = 2
});
}
if (component.DoPopup)
_popupSystem.PopupEntity(Loc.GetString("trigger-activated", ("device", uid)), args.User, args.User);
- HandleTimerTrigger(
- uid,
- args.User,
- component.Delay,
- component.BeepInterval,
- component.InitialBeepDelay,
- component.BeepSound);
+ StartTimer((uid, component), args.User);
args.Handled = true;
}
comp.TimeRemaining += amount;
}
+ /// <summary>
+ /// Start the timer for triggering the device.
+ /// </summary>
+ public void StartTimer(Entity<OnUseTimerTriggerComponent?> ent, EntityUid? user)
+ {
+ if (!Resolve(ent, ref ent.Comp, false))
+ return;
+
+ var comp = ent.Comp;
+ HandleTimerTrigger(ent, user, comp.Delay, comp.BeepInterval, comp.InitialBeepDelay, comp.BeepSound);
+ }
+
public void HandleTimerTrigger(EntityUid uid, EntityUid? user, float delay, float beepInterval, float? initialBeepDelay, SoundSpecifier? beepSound)
{
if (delay <= 0)
using Content.Shared.DeviceNetwork;
using Content.Shared.Emag.Components;
+using Content.Shared.Movement.Components;
using Content.Shared.Popups;
using Content.Shared.Robotics;
using Content.Shared.Silicons.Borgs.Components;
var query = EntityQueryEnumerator<BorgTransponderComponent, BorgChassisComponent, DeviceNetworkComponent, MetaDataComponent>();
while (query.MoveNext(out var uid, out var comp, out var chassis, out var device, out var meta))
{
+ if (comp.NextDisable is {} nextDisable && now >= nextDisable)
+ DoDisable((uid, comp, chassis, meta));
+
if (now < comp.NextBroadcast)
continue;
if (_powerCell.TryGetBatteryFromSlot(uid, out var battery))
charge = battery.CurrentCharge / battery.MaxCharge;
+ var hasBrain = chassis.BrainEntity != null && !comp.FakeDisabled;
+ var canDisable = comp.NextDisable == null && !comp.FakeDisabling;
var data = new CyborgControlData(
comp.Sprite,
comp.Name,
meta.EntityName,
charge,
chassis.ModuleCount,
- chassis.BrainEntity != null);
+ hasBrain,
+ canDisable);
var payload = new NetworkPayload()
{
}
}
+ private void DoDisable(Entity<BorgTransponderComponent, BorgChassisComponent, MetaDataComponent> ent)
+ {
+ ent.Comp1.NextDisable = null;
+ if (ent.Comp1.FakeDisabling)
+ {
+ ent.Comp1.FakeDisabled = true;
+ ent.Comp1.FakeDisabling = false;
+ return;
+ }
+
+ if (ent.Comp2.BrainEntity is not {} brain)
+ return;
+
+ var message = Loc.GetString(ent.Comp1.DisabledPopup, ("name", Name(ent, ent.Comp3)));
+ Popup.PopupEntity(message, ent);
+ _container.Remove(brain, ent.Comp2.BrainContainer);
+ }
+
private void OnPacketReceived(Entity<BorgTransponderComponent> ent, ref DeviceNetworkPacketEvent args)
{
var payload = args.Data;
if (command == RoboticsConsoleConstants.NET_DISABLE_COMMAND)
Disable(ent);
else if (command == RoboticsConsoleConstants.NET_DESTROY_COMMAND)
- Destroy(ent.Owner);
+ Destroy(ent);
}
private void Disable(Entity<BorgTransponderComponent, BorgChassisComponent?> ent)
{
- if (!Resolve(ent, ref ent.Comp2) || ent.Comp2.BrainEntity is not {} brain)
+ if (!Resolve(ent, ref ent.Comp2) || ent.Comp2.BrainEntity == null || ent.Comp1.NextDisable != null)
return;
- // this won't exactly be stealthy but if you are malf its better than actually disabling you
+ // update ui immediately
+ ent.Comp1.NextBroadcast = _timing.CurTime;
+
+ // pretend the borg is being disabled forever now
if (CheckEmagged(ent, "disabled"))
- return;
+ ent.Comp1.FakeDisabling = true;
+ else
+ Popup.PopupEntity(Loc.GetString(ent.Comp1.DisablingPopup), ent);
- var message = Loc.GetString(ent.Comp1.DisabledPopup, ("name", Name(ent)));
- Popup.PopupEntity(message, ent);
- _container.Remove(brain, ent.Comp2.BrainContainer);
+ ent.Comp1.NextDisable = _timing.CurTime + ent.Comp1.DisableDelay;
}
- private void Destroy(Entity<ExplosiveComponent?> ent)
+ private void Destroy(Entity<BorgTransponderComponent> ent)
{
- if (!Resolve(ent, ref ent.Comp))
- return;
-
// this is stealthy until someone realises you havent exploded
if (CheckEmagged(ent, "destroyed"))
{
return;
}
- _explosion.TriggerExplosive(ent, ent.Comp, delete: false);
+ var message = Loc.GetString(ent.Comp.DestroyingPopup, ("name", Name(ent)));
+ Popup.PopupEntity(message, ent);
+ _trigger.StartTimer(ent.Owner, user: null);
+
+ // prevent a shitter borg running into people
+ RemComp<InputMoverComponent>(ent);
}
private bool CheckEmagged(EntityUid uid, string name)
[Dependency] private readonly ActionsSystem _actions = default!;
[Dependency] private readonly AlertsSystem _alerts = default!;
[Dependency] private readonly DeviceNetworkSystem _deviceNetwork = default!;
- [Dependency] private readonly ExplosionSystem _explosion = default!;
[Dependency] private readonly SharedAppearanceSystem _appearance = default!;
+ [Dependency] private readonly TriggerSystem _trigger = default!;
[Dependency] private readonly HandsSystem _hands = default!;
[Dependency] private readonly MetaDataSystem _metaData = default!;
[Dependency] private readonly SharedMindSystem _mind = default!;
/// Radio message sent when destroying a borg.
/// </summary>
[DataField]
- public LocId DestroyMessage = "robotics-console-cyborg-destroyed";
+ public LocId DestroyMessage = "robotics-console-cyborg-destroying";
/// <summary>
/// Cooldown on destroying borgs to prevent complete abuse.
[DataField]
public bool HasBrain;
+ /// <summary>
+ /// Whether the borg can currently be disabled if the brain is installed,
+ /// if on cooldown then can't queue up multiple disables.
+ /// </summary>
+ [DataField]
+ public bool CanDisable;
+
/// <summary>
/// When this cyborg's data will be deleted.
/// Set by the console when receiving the packet.
[DataField(customTypeSerializer: typeof(TimeOffsetSerializer))]
public TimeSpan Timeout = TimeSpan.Zero;
- public CyborgControlData(SpriteSpecifier? chassisSprite, string chassisName, string name, float charge, int moduleCount, bool hasBrain)
+ public CyborgControlData(SpriteSpecifier? chassisSprite, string chassisName, string name, float charge, int moduleCount, bool hasBrain, bool canDisable)
{
ChassisSprite = chassisSprite;
ChassisName = chassisName;
Charge = charge;
ModuleCount = moduleCount;
HasBrain = hasBrain;
+ CanDisable = canDisable;
}
}
public string Name = string.Empty;
/// <summary>
- /// Popup shown to everyone when a borg is disabled.
+ /// Popup shown to everyone after a borg is disabled.
/// Gets passed a string "name".
/// </summary>
[DataField]
public LocId DisabledPopup = "borg-transponder-disabled-popup";
+ /// <summary>
+ /// Popup shown to the borg when it is being disabled.
+ /// </summary>
+ [DataField]
+ public LocId DisablingPopup = "borg-transponder-disabling-popup";
+
+ /// <summary>
+ /// Popup shown to everyone when a borg is being destroyed.
+ /// Gets passed a string "name".
+ /// </summary>
+ [DataField]
+ public LocId DestroyingPopup = "borg-transponder-destroying-popup";
+
/// <summary>
/// How long to wait between each broadcast.
/// </summary>
/// </summary>
[DataField(customTypeSerializer: typeof(TimeOffsetSerializer))]
public TimeSpan NextBroadcast = TimeSpan.Zero;
+
+ /// <summary>
+ /// When to next disable the borg.
+ /// </summary>
+ [DataField(customTypeSerializer: typeof(TimeOffsetSerializer))]
+ public TimeSpan? NextDisable;
+
+ /// <summary>
+ /// How long to wait to disable the borg after RD has ordered it.
+ /// </summary>
+ [DataField]
+ public TimeSpan DisableDelay = TimeSpan.FromSeconds(5);
+
+ /// <summary>
+ /// Pretend that the borg cannot be disabled due to being on delay.
+ /// </summary>
+ [DataField]
+ public bool FakeDisabling;
+
+ /// <summary>
+ /// Pretend that the borg has no brain inserted.
+ /// </summary>
+ [DataField]
+ public bool FakeDisabled;
}
# Transponder
borg-transponder-disabled-popup = A brain shoots out the top of {$name}!
+borg-transponder-disabling-popup = Your transponder begins to lock you out of the chassis!
+borg-transponder-destroying-popup = The self destruct of {$name} starts beeping!
borg-transponder-emagged-disabled-popup = Your transponder's lights go out!
borg-transponder-emagged-destroyed-popup = Your transponder's fuse blows!
robotics-console-disable = Disable
robotics-console-destroy = Destroy
-robotics-console-cyborg-destroyed = The cyborg {$name} has been remotely destroyed.
+robotics-console-cyborg-destroying = {$name} is being remotely detonated!
deviceNetId: Wireless
receiveFrequencyId: CyborgControl
transmitFrequencyId: RoboticsConsole
+ - type: OnUseTimerTrigger
+ delay: 10
+ examinable: false
+ beepSound:
+ path: /Audio/Effects/Cargo/buzz_two.ogg
+ params:
+ volume: -4
+ # prevent any funnies if someone makes a cyborg item...
+ - type: AutomatedTimer
+ - type: ExplodeOnTrigger
# explosion does most of its damage in the center and less at the edges
- type: Explosive
explosionType: Minibomb
+ deleteAfterExplosion: false # let damage threshold gib the borg
totalIntensity: 30
intensitySlope: 20
maxIntensity: 20