Implant whitelist/blacklisting (#20678)
* add whitelist and blacklist to implant and implanter components * handle whitelist and blacklist in systems * move hardcoded whitelist/blacklist to base implanter + add admeme implanter * give implants sensible whitelists * cleaner CheckTarget and fix * remove unused imports * network lists --------- Co-authored-by: deltanedas <@deltanedas:kde.org>
This commit is contained in:
@@ -1,11 +1,9 @@
|
|||||||
using Content.Server.Guardian;
|
|
||||||
using Content.Server.Popups;
|
using Content.Server.Popups;
|
||||||
using Content.Shared.DoAfter;
|
using Content.Shared.DoAfter;
|
||||||
using Content.Shared.IdentityManagement;
|
using Content.Shared.IdentityManagement;
|
||||||
using Content.Shared.Implants;
|
using Content.Shared.Implants;
|
||||||
using Content.Shared.Implants.Components;
|
using Content.Shared.Implants.Components;
|
||||||
using Content.Shared.Interaction;
|
using Content.Shared.Interaction;
|
||||||
using Content.Shared.Mobs.Components;
|
|
||||||
using Content.Shared.Popups;
|
using Content.Shared.Popups;
|
||||||
using Robust.Shared.Containers;
|
using Robust.Shared.Containers;
|
||||||
|
|
||||||
@@ -33,28 +31,39 @@ public sealed partial class ImplanterSystem : SharedImplanterSystem
|
|||||||
if (args.Target == null || !args.CanReach || args.Handled)
|
if (args.Target == null || !args.CanReach || args.Handled)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
//Simplemobs and regular mobs should be injectable, but only regular mobs have mind.
|
var target = args.Target.Value;
|
||||||
//So just don't implant/draw anything that isn't living or is a guardian
|
if (!CheckTarget(target, component.Whitelist, component.Blacklist))
|
||||||
//TODO: Rework a bit when surgery is in to work with implant cases
|
|
||||||
if (!HasComp<MobStateComponent>(args.Target.Value) || HasComp<GuardianComponent>(args.Target.Value))
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
//TODO: Rework when surgery is in for implant cases
|
//TODO: Rework when surgery is in for implant cases
|
||||||
if (component.CurrentMode == ImplanterToggleMode.Draw && !component.ImplantOnly)
|
if (component.CurrentMode == ImplanterToggleMode.Draw && !component.ImplantOnly)
|
||||||
{
|
{
|
||||||
TryDraw(component, args.User, args.Target.Value, uid);
|
TryDraw(component, args.User, target, uid);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (!CanImplant(args.User, args.Target.Value, uid, component, out _, out _))
|
if (!CanImplant(args.User, target, uid, component, out var implant, out _))
|
||||||
|
{
|
||||||
|
// no popup if implant doesn't exist
|
||||||
|
if (implant == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
// show popup to the user saying implant failed
|
||||||
|
var name = Identity.Name(target, EntityManager, args.User);
|
||||||
|
var msg = Loc.GetString("implanter-component-implant-failed", ("implant", implant), ("target", name));
|
||||||
|
_popup.PopupEntity(msg, target, args.User);
|
||||||
|
// prevent further interaction since popup was shown
|
||||||
|
args.Handled = true;
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
//Implant self instantly, otherwise try to inject the target.
|
//Implant self instantly, otherwise try to inject the target.
|
||||||
if (args.User == args.Target)
|
if (args.User == target)
|
||||||
Implant(args.User, args.Target.Value, uid, component);
|
Implant(target, target, uid, component);
|
||||||
else
|
else
|
||||||
TryImplant(component, args.User, args.Target.Value, uid);
|
TryImplant(component, args.User, target, uid);
|
||||||
}
|
}
|
||||||
|
|
||||||
args.Handled = true;
|
args.Handled = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
using Content.Shared.Containers.ItemSlots;
|
using Content.Shared.Containers.ItemSlots;
|
||||||
|
using Content.Shared.Whitelist;
|
||||||
using Robust.Shared.GameStates;
|
using Robust.Shared.GameStates;
|
||||||
using Robust.Shared.Prototypes;
|
using Robust.Shared.Prototypes;
|
||||||
using Robust.Shared.Serialization;
|
using Robust.Shared.Serialization;
|
||||||
@@ -15,6 +16,19 @@ public sealed partial class ImplanterComponent : Component
|
|||||||
public const string ImplanterSlotId = "implanter_slot";
|
public const string ImplanterSlotId = "implanter_slot";
|
||||||
public const string ImplantSlotId = "implant";
|
public const string ImplantSlotId = "implant";
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Whitelist to check entities against before implanting.
|
||||||
|
/// Implants get their own whitelist which is checked afterwards.
|
||||||
|
/// </summary>
|
||||||
|
[DataField, AutoNetworkedField]
|
||||||
|
public EntityWhitelist? Whitelist;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Blacklist to check entities against before implanting.
|
||||||
|
/// </summary>
|
||||||
|
[DataField, AutoNetworkedField]
|
||||||
|
public EntityWhitelist? Blacklist;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Used for implanters that start with specific implants
|
/// Used for implanters that start with specific implants
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
using Content.Shared.Actions;
|
using Content.Shared.Actions;
|
||||||
|
using Content.Shared.Whitelist;
|
||||||
using Robust.Shared.GameStates;
|
using Robust.Shared.GameStates;
|
||||||
using Robust.Shared.Prototypes;
|
using Robust.Shared.Prototypes;
|
||||||
|
|
||||||
@@ -34,6 +35,20 @@ public sealed partial class SubdermalImplantComponent : Component
|
|||||||
[ViewVariables(VVAccess.ReadWrite)]
|
[ViewVariables(VVAccess.ReadWrite)]
|
||||||
[DataField("permanent"), AutoNetworkedField]
|
[DataField("permanent"), AutoNetworkedField]
|
||||||
public bool Permanent = false;
|
public bool Permanent = false;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Target whitelist for this implant specifically.
|
||||||
|
/// Only checked if the implanter allows implanting on the target to begin with.
|
||||||
|
/// </summary>
|
||||||
|
[DataField]
|
||||||
|
public EntityWhitelist? Whitelist;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Target blacklist for this implant specifically.
|
||||||
|
/// Only checked if the implanter allows implanting on the target to begin with.
|
||||||
|
/// </summary>
|
||||||
|
[DataField]
|
||||||
|
public EntityWhitelist? Blacklist;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ using Content.Shared.Examine;
|
|||||||
using Content.Shared.IdentityManagement;
|
using Content.Shared.IdentityManagement;
|
||||||
using Content.Shared.Implants.Components;
|
using Content.Shared.Implants.Components;
|
||||||
using Content.Shared.Popups;
|
using Content.Shared.Popups;
|
||||||
|
using Content.Shared.Whitelist;
|
||||||
using Robust.Shared.Containers;
|
using Robust.Shared.Containers;
|
||||||
using Robust.Shared.Serialization;
|
using Robust.Shared.Serialization;
|
||||||
|
|
||||||
@@ -85,11 +86,23 @@ public abstract class SharedImplanterSystem : EntitySystem
|
|||||||
if (!TryComp(implant, out implantComp))
|
if (!TryComp(implant, out implantComp))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
if (!CheckTarget(target, component.Whitelist, component.Blacklist) ||
|
||||||
|
!CheckTarget(target, implantComp.Whitelist, implantComp.Blacklist))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
var ev = new AddImplantAttemptEvent(user, target, implant.Value, implanter);
|
var ev = new AddImplantAttemptEvent(user, target, implant.Value, implanter);
|
||||||
RaiseLocalEvent(target, ev);
|
RaiseLocalEvent(target, ev);
|
||||||
return !ev.Cancelled;
|
return !ev.Cancelled;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected bool CheckTarget(EntityUid target, EntityWhitelist? whitelist, EntityWhitelist? blacklist)
|
||||||
|
{
|
||||||
|
return whitelist?.IsValid(target, EntityManager) != false &&
|
||||||
|
blacklist?.IsValid(target, EntityManager) != true;
|
||||||
|
}
|
||||||
|
|
||||||
//Draw the implant out of the target
|
//Draw the implant out of the target
|
||||||
//TODO: Rework when surgery is in so implant cases can be a thing
|
//TODO: Rework when surgery is in so implant cases can be a thing
|
||||||
public void Draw(EntityUid implanter, EntityUid user, EntityUid target, ImplanterComponent component)
|
public void Draw(EntityUid implanter, EntityUid user, EntityUid target, ImplanterComponent component)
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
## Implanter Attempt Messages
|
## Implanter Attempt Messages
|
||||||
|
|
||||||
implanter-component-implanting-target = {$user} is trying to implant you with something!
|
implanter-component-implanting-target = {$user} is trying to implant you with something!
|
||||||
|
implanter-component-implant-failed = The {$implant} cannot be given to {$target}!
|
||||||
implanter-draw-failed-permanent = The {$implant} in {$target} is fused with them and cannot be removed!
|
implanter-draw-failed-permanent = The {$implant} in {$target} is fused with them and cannot be removed!
|
||||||
implanter-draw-failed = You tried to remove an implant but found nothing.
|
implanter-draw-failed = You tried to remove an implant but found nothing.
|
||||||
|
|
||||||
|
|||||||
@@ -12,6 +12,12 @@
|
|||||||
containers:
|
containers:
|
||||||
implanter_slot: !type:ContainerSlot { }
|
implanter_slot: !type:ContainerSlot { }
|
||||||
- type: Implanter
|
- type: Implanter
|
||||||
|
whitelist:
|
||||||
|
components:
|
||||||
|
- Body # no chair microbomb
|
||||||
|
blacklist:
|
||||||
|
components:
|
||||||
|
- Guardian # no holoparasite macrobomb wombo combo
|
||||||
currentMode: Draw
|
currentMode: Draw
|
||||||
implanterSlot:
|
implanterSlot:
|
||||||
name: Implant
|
name: Implant
|
||||||
@@ -54,6 +60,16 @@
|
|||||||
tags:
|
tags:
|
||||||
- Trash
|
- Trash
|
||||||
|
|
||||||
|
- type: entity
|
||||||
|
parent: Implanter
|
||||||
|
id: ImplanterAdmeme
|
||||||
|
suffix: Admeme
|
||||||
|
components:
|
||||||
|
- type: Implanter
|
||||||
|
# go wild with sentient chairs with macrobombs
|
||||||
|
whitelist: null
|
||||||
|
blacklist: null
|
||||||
|
|
||||||
- type: entity
|
- type: entity
|
||||||
id: BaseImplantOnlyImplanter
|
id: BaseImplantOnlyImplanter
|
||||||
parent: Implanter
|
parent: Implanter
|
||||||
|
|||||||
@@ -21,6 +21,9 @@
|
|||||||
noSpawn: true
|
noSpawn: true
|
||||||
components:
|
components:
|
||||||
- type: SubdermalImplant
|
- type: SubdermalImplant
|
||||||
|
whitelist:
|
||||||
|
components:
|
||||||
|
- MobState # admeme implanting a chair with trombone implant needs to give the chair mobstate so it can die first
|
||||||
- type: TriggerOnMobstateChange
|
- type: TriggerOnMobstateChange
|
||||||
mobState:
|
mobState:
|
||||||
- Dead
|
- Dead
|
||||||
@@ -81,6 +84,9 @@
|
|||||||
noSpawn: true
|
noSpawn: true
|
||||||
components:
|
components:
|
||||||
- type: SubdermalImplant
|
- type: SubdermalImplant
|
||||||
|
whitelist:
|
||||||
|
components:
|
||||||
|
- MobState # admeme implanting a chair with tracking implant needs to give the chair mobstate so it can die first
|
||||||
- type: SuitSensor
|
- type: SuitSensor
|
||||||
randomMode: false
|
randomMode: false
|
||||||
controlsLocked: true
|
controlsLocked: true
|
||||||
@@ -109,6 +115,9 @@
|
|||||||
components:
|
components:
|
||||||
- type: SubdermalImplant
|
- type: SubdermalImplant
|
||||||
implantAction: ActionOpenStorageImplant
|
implantAction: ActionOpenStorageImplant
|
||||||
|
whitelist:
|
||||||
|
components:
|
||||||
|
- Hands # no use giving a mouse a storage implant, but a monkey is another story...
|
||||||
- type: Item
|
- type: Item
|
||||||
size: 9999
|
size: 9999
|
||||||
- type: Storage
|
- type: Storage
|
||||||
@@ -131,6 +140,9 @@
|
|||||||
components:
|
components:
|
||||||
- type: SubdermalImplant
|
- type: SubdermalImplant
|
||||||
implantAction: ActionActivateFreedomImplant
|
implantAction: ActionActivateFreedomImplant
|
||||||
|
whitelist:
|
||||||
|
components:
|
||||||
|
- Cuffable # useless if you cant be cuffed
|
||||||
|
|
||||||
- type: entity
|
- type: entity
|
||||||
parent: BaseSubdermalImplant
|
parent: BaseSubdermalImplant
|
||||||
@@ -141,6 +153,9 @@
|
|||||||
components:
|
components:
|
||||||
- type: SubdermalImplant
|
- type: SubdermalImplant
|
||||||
implantAction: ActionOpenUplinkImplant
|
implantAction: ActionOpenUplinkImplant
|
||||||
|
whitelist:
|
||||||
|
components:
|
||||||
|
- Hands # prevent mouse buying grenade penguin since its not telepathic
|
||||||
- type: Store
|
- type: Store
|
||||||
preset: StorePresetUplink
|
preset: StorePresetUplink
|
||||||
balance:
|
balance:
|
||||||
@@ -174,6 +189,9 @@
|
|||||||
components:
|
components:
|
||||||
- type: SubdermalImplant
|
- type: SubdermalImplant
|
||||||
implantAction: ActionActivateDnaScramblerImplant
|
implantAction: ActionActivateDnaScramblerImplant
|
||||||
|
whitelist:
|
||||||
|
components:
|
||||||
|
- HumanoidAppearance # syndies cant turn hamlet into a human
|
||||||
|
|
||||||
#Nuclear Operative/Special Exclusive implants
|
#Nuclear Operative/Special Exclusive implants
|
||||||
|
|
||||||
@@ -250,6 +268,9 @@
|
|||||||
components:
|
components:
|
||||||
- type: SubdermalImplant
|
- type: SubdermalImplant
|
||||||
permanent: true
|
permanent: true
|
||||||
|
whitelist:
|
||||||
|
components:
|
||||||
|
- MobState # admeme implanting a chair with rattle implant needs to give the chair mobstate so it can die first
|
||||||
- type: TriggerOnMobstateChange
|
- type: TriggerOnMobstateChange
|
||||||
mobState:
|
mobState:
|
||||||
- Critical
|
- Critical
|
||||||
|
|||||||
Reference in New Issue
Block a user