make mindshields removable (#1631)
* make mindshields removable * use new logic stolen from upstream pr * a * remove unused mafia trollage --------- Co-authored-by: deltanedas <@deltanedas:kde.org>
This commit is contained in:
parent
40c9187592
commit
8ba57f61e5
|
|
@ -28,19 +28,26 @@ public sealed class MindShieldSystem : EntitySystem
|
|||
public override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
SubscribeLocalEvent<SubdermalImplantComponent, ImplantImplantedEvent>(ImplantCheck);
|
||||
SubscribeLocalEvent<SubdermalImplantComponent, ImplantImplantedEvent>(OnImplanted); // DeltaV: separate handlers for implanting and removal
|
||||
SubscribeLocalEvent<SubdermalImplantComponent, ImplantRemovedEvent>(OnRemoved); // DeltaV
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Checks if the implant was a mindshield or not
|
||||
/// DeltaV: Adds components when implantedChecks if the implant was a mindshield or not
|
||||
/// </summary>
|
||||
public void ImplantCheck(EntityUid uid, SubdermalImplantComponent comp, ref ImplantImplantedEvent ev)
|
||||
public void OnImplanted(EntityUid uid, SubdermalImplantComponent comp, ref ImplantImplantedEvent ev)
|
||||
{
|
||||
if (_tag.HasTag(ev.Implant, MindShieldTag) && ev.Implanted != null)
|
||||
{
|
||||
EnsureComp<MindShieldComponent>(ev.Implanted.Value);
|
||||
MindShieldRemovalCheck(ev.Implanted.Value, ev.Implant);
|
||||
}
|
||||
if (comp.AddedComponents is {} components && ev.Implanted is {} user)
|
||||
EntityManager.AddComponents(user, components);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// DeltaV: Removes components when implanted.
|
||||
/// </summary>
|
||||
private void OnRemoved(Entity<SubdermalImplantComponent> ent, ref ImplantRemovedEvent args)
|
||||
{
|
||||
if (ent.Comp.AddedComponents is {} components && args.Implanted is {} user)
|
||||
EntityManager.RemoveComponents(user, components);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
|
|||
|
|
@ -49,6 +49,13 @@ public sealed partial class SubdermalImplantComponent : Component
|
|||
/// </summary>
|
||||
[DataField]
|
||||
public EntityWhitelist? Blacklist;
|
||||
|
||||
/// <summary>
|
||||
/// DeltaV: Used to replace mindshield tag logic
|
||||
/// Components to add to and remove from the user when implanted and removed.
|
||||
/// </summary>
|
||||
[DataField]
|
||||
public ComponentRegistry? AddedComponents;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
|
|||
|
|
@ -72,6 +72,9 @@ public abstract class SharedSubdermalImplantSystem : EntitySystem
|
|||
if (component.ImplantAction != null)
|
||||
_actionsSystem.RemoveProvidedActions(component.ImplantedEntity.Value, uid);
|
||||
|
||||
var ev = new ImplantRemovedEvent(uid, component.ImplantedEntity.Value); // DeltaV
|
||||
RaiseLocalEvent(uid, ref ev); // DeltaV
|
||||
|
||||
if (!_container.TryGetContainer(uid, BaseStorageId, out var storageImplant))
|
||||
return;
|
||||
|
||||
|
|
@ -205,3 +208,19 @@ public readonly struct ImplantImplantedEvent
|
|||
Implanted = implanted;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// DeltaV: Event that is raised whenever someone gets an implant removed from them.
|
||||
/// </summary>
|
||||
[ByRefEvent]
|
||||
public readonly struct ImplantRemovedEvent
|
||||
{
|
||||
public readonly EntityUid Implant;
|
||||
public readonly EntityUid? Implanted;
|
||||
|
||||
public ImplantRemovedEvent(EntityUid implant, EntityUid? implanted)
|
||||
{
|
||||
Implant = implant;
|
||||
Implanted = implanted;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -321,7 +321,6 @@
|
|||
categories: [ HideSpawnMenu ]
|
||||
components:
|
||||
- type: SubdermalImplant
|
||||
permanent: true
|
||||
- type: Tag
|
||||
tags:
|
||||
- MindShield
|
||||
permanent: false # DeltaV - let peaceful revs etc remove mindshields
|
||||
addedComponents: # DeltaV - replaces mindshield tag logic
|
||||
- type: MindShield
|
||||
|
|
|
|||
Loading…
Reference in New Issue