Deathrattle implant for uplink and slight tracking implant tweak (#17722)
This commit is contained in:
@@ -5,10 +5,13 @@ using Content.Server.Chemistry.Components.SolutionManager;
|
||||
using Content.Server.Explosion.Components;
|
||||
using Content.Server.Flash;
|
||||
using Content.Server.Flash.Components;
|
||||
using Content.Server.Radio.EntitySystems;
|
||||
using Content.Shared.Database;
|
||||
using Content.Shared.Implants.Components;
|
||||
using Content.Shared.Interaction;
|
||||
using Content.Shared.Payload.Components;
|
||||
using Robust.Shared.Prototypes;
|
||||
using Content.Shared.Radio;
|
||||
using Content.Shared.Slippery;
|
||||
using Content.Shared.StepTrigger.Systems;
|
||||
using Content.Shared.Trigger;
|
||||
@@ -17,6 +20,8 @@ using Robust.Shared.Audio;
|
||||
using Robust.Shared.Containers;
|
||||
using Robust.Shared.Physics.Events;
|
||||
using Robust.Shared.Physics.Systems;
|
||||
using Content.Shared.Mobs;
|
||||
using Content.Shared.Mobs.Components;
|
||||
using Robust.Shared.Player;
|
||||
|
||||
namespace Content.Server.Explosion.EntitySystems
|
||||
@@ -53,6 +58,8 @@ namespace Content.Server.Explosion.EntitySystems
|
||||
[Dependency] private readonly SharedContainerSystem _container = default!;
|
||||
[Dependency] private readonly BodySystem _body = default!;
|
||||
[Dependency] private readonly SharedAudioSystem _audio = default!;
|
||||
[Dependency] private readonly RadioSystem _radioSystem = default!;
|
||||
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
@@ -76,6 +83,7 @@ namespace Content.Server.Explosion.EntitySystems
|
||||
SubscribeLocalEvent<ExplodeOnTriggerComponent, TriggerEvent>(HandleExplodeTrigger);
|
||||
SubscribeLocalEvent<FlashOnTriggerComponent, TriggerEvent>(HandleFlashTrigger);
|
||||
SubscribeLocalEvent<GibOnTriggerComponent, TriggerEvent>(HandleGibTrigger);
|
||||
SubscribeLocalEvent<RattleComponent, TriggerEvent>(HandleRattleTrigger);
|
||||
}
|
||||
|
||||
private void OnSpawnTrigger(EntityUid uid, SpawnOnTriggerComponent component, TriggerEvent args)
|
||||
@@ -121,11 +129,40 @@ namespace Content.Server.Explosion.EntitySystems
|
||||
args.Handled = true;
|
||||
}
|
||||
|
||||
private void HandleRattleTrigger(EntityUid uid, RattleComponent component, TriggerEvent args)
|
||||
{
|
||||
if (!TryComp<SubdermalImplantComponent?>(uid, out var implanted))
|
||||
return;
|
||||
|
||||
if (implanted.ImplantedEntity == null)
|
||||
return;
|
||||
|
||||
// Gets location of the implant
|
||||
var ownerXform = Transform(uid);
|
||||
var pos = ownerXform.MapPosition;
|
||||
var x = (int) pos.X;
|
||||
var y = (int) pos.Y;
|
||||
var posText = $"({x}, {y})";
|
||||
|
||||
var critMessage = Loc.GetString(component.CritMessage, ("user", implanted.ImplantedEntity.Value), ("position", posText));
|
||||
var deathMessage = Loc.GetString(component.DeathMessage, ("user", implanted.ImplantedEntity.Value), ("position", posText));
|
||||
|
||||
if (!TryComp<MobStateComponent>(implanted.ImplantedEntity, out var mobstate))
|
||||
return;
|
||||
|
||||
// Sends a message to the radio channel specified by the implant
|
||||
if (mobstate.CurrentState == MobState.Critical)
|
||||
_radioSystem.SendRadioMessage(uid, critMessage, _prototypeManager.Index<RadioChannelPrototype>(component.RadioChannel), uid);
|
||||
if (mobstate.CurrentState == MobState.Dead)
|
||||
_radioSystem.SendRadioMessage(uid, deathMessage, _prototypeManager.Index<RadioChannelPrototype>(component.RadioChannel), uid);
|
||||
|
||||
args.Handled = true;
|
||||
}
|
||||
|
||||
private void OnTriggerCollide(EntityUid uid, TriggerOnCollideComponent component, ref StartCollideEvent args)
|
||||
{
|
||||
if(args.OurFixture.ID == component.FixtureID && (!component.IgnoreOtherNonHard || args.OtherFixture.Hard))
|
||||
Trigger(component.Owner);
|
||||
if (args.OurFixture.ID == component.FixtureID && (!component.IgnoreOtherNonHard || args.OtherFixture.Hard))
|
||||
Trigger(component.Owner);
|
||||
}
|
||||
|
||||
private void OnActivate(EntityUid uid, TriggerOnActivateComponent component, ActivateInWorldEvent args)
|
||||
|
||||
Reference in New Issue
Block a user