-
Notifications
You must be signed in to change notification settings - Fork 359
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
60c5291
commit b83bf33
Showing
22 changed files
with
369 additions
and
0 deletions.
There are no files selected for viewing
86 changes: 86 additions & 0 deletions
86
Content.Server/_Impstation/Containers/AntiTamper/AntiTamperComponent.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
using Content.Shared.Damage; | ||
using Content.Shared.Tools; | ||
using Robust.Shared.Audio; | ||
using Robust.Shared.Prototypes; | ||
|
||
namespace Content.Server.Containers.AntiTamper; | ||
|
||
/// <summary> | ||
/// When a locked container with this component is destroyed, it will | ||
/// acidify the contents. | ||
/// </summary> | ||
[RegisterComponent] | ||
[Access(typeof(AntiTamperSystem))] | ||
public sealed partial class AntiTamperComponent : Component | ||
{ | ||
/// <summary> | ||
/// List of containers to acidify. If null, | ||
/// all containers will acidify. | ||
/// </summary> | ||
[DataField, ViewVariables(VVAccess.ReadWrite)] | ||
public HashSet<string>? Containers; | ||
|
||
/// <summary> | ||
/// The popup message to display when the anti-tamper module | ||
/// is triggered. | ||
/// </summary> | ||
[DataField, ViewVariables(VVAccess.ReadWrite)] | ||
public LocId Message = "anti-tamper-contents-destroyed"; | ||
|
||
/// <summary> | ||
/// The sound to play when the anti-tamper module is triggered. | ||
/// </summary> | ||
[DataField, ViewVariables(VVAccess.ReadWrite)] | ||
public SoundSpecifier Sound = new SoundPathSpecifier("/Audio/Items/soda_spray.ogg"); | ||
|
||
/// <summary> | ||
/// If true, mobs with a <seealso cref="MindContainerComponent"/> will not be | ||
/// deleted, and instead will take <seealso cref="MobDamage"/>. | ||
/// </summary> | ||
[DataField, ViewVariables(VVAccess.ReadWrite)] | ||
public bool PreventRoundRemoval = true; | ||
|
||
/// <summary> | ||
/// If <seealso cref="PreventRoundRemoval"/> is <c>true</c>, mobs caught inside | ||
/// of the container when the anti-tamper is activated will receive this | ||
/// damage instead of being deleted. | ||
/// </summary> | ||
[DataField, ViewVariables(VVAccess.ReadWrite)] | ||
public DamageSpecifier MobDamage = new() | ||
{ | ||
DamageDict = new() | ||
{ | ||
{ "Caustic", 85 } | ||
}, | ||
}; | ||
|
||
/// <summary> | ||
/// If true, mobs with | ||
/// <seealso cref="Content.Shared.Interaction.Components.ComplexInteractionComponent">ComplexInteractionComponent</seealso> | ||
/// will be able to disarm the anti-tamper component the crate is open or they are inside of it. | ||
/// </summary> | ||
[DataField, ViewVariables(VVAccess.ReadWrite)] | ||
public bool CanDisarm = true; | ||
|
||
/// <summary> | ||
/// The length of time it takes to disarm the anti-tamper module. Multiplied by | ||
/// <seealso cref="DisarmLockedMultiplier"/> if the disarming mob is locked | ||
/// inside of the container. | ||
/// </summary> | ||
[DataField, ViewVariables(VVAccess.ReadWrite)] | ||
public TimeSpan DisarmTime = TimeSpan.FromSeconds(5); | ||
|
||
/// <summary> | ||
/// If the disarming mob is locked inside of the container, | ||
/// the <seealso cref="DisarmTime"/> will be multiplied by this. | ||
/// </summary> | ||
[DataField, ViewVariables(VVAccess.ReadWrite)] | ||
public float DisarmLockedMultiplier = 4; | ||
|
||
/// <summary> | ||
/// The tool required to disarm the anti-tamper module. If null, | ||
/// no tool is required. | ||
/// </summary> | ||
[DataField, ViewVariables(VVAccess.ReadWrite)] | ||
public ProtoId<ToolQualityPrototype>? DisarmToolRequired = "Screwing"; | ||
} |
153 changes: 153 additions & 0 deletions
153
Content.Server/_Impstation/Containers/AntiTamper/AntiTamperSystem.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,153 @@ | ||
using Content.Server.Storage.Components; | ||
using Content.Server.Storage.EntitySystems; | ||
using Content.Shared.Containers.AntiTamper; | ||
using Content.Shared.Damage; | ||
using Content.Shared.Destructible; | ||
using Content.Shared.DoAfter; | ||
using Content.Shared.Lock; | ||
using Content.Shared.Mind.Components; | ||
using Content.Shared.Popups; | ||
using Content.Shared.Storage.EntitySystems; | ||
using Content.Shared.Tools.Systems; | ||
using Content.Shared.Verbs; | ||
using Robust.Shared.Audio.Systems; | ||
using Robust.Shared.Containers; | ||
|
||
namespace Content.Server.Containers.AntiTamper; | ||
|
||
public sealed partial class AntiTamperSystem : EntitySystem | ||
{ | ||
[Dependency] private readonly SharedContainerSystem _containerSystem = default!; | ||
[Dependency] private readonly SharedPopupSystem _popupSystem = default!; | ||
[Dependency] private readonly LockSystem _lockSystem = default!; | ||
[Dependency] private readonly SharedAudioSystem _audioSystem = default!; | ||
[Dependency] private readonly SharedToolSystem _toolSystem = default!; | ||
[Dependency] private readonly SharedEntityStorageSystem _entityStorageSystem = default!; | ||
[Dependency] private readonly SharedDoAfterSystem _doAfterSystem = default!; | ||
[Dependency] private readonly DamageableSystem _damageableSystem = default!; | ||
|
||
public override void Initialize() | ||
{ | ||
base.Initialize(); | ||
|
||
SubscribeLocalEvent<AntiTamperComponent, DestructionEventArgs>(OnDestroy, before: [typeof(EntityStorageSystem)]); | ||
SubscribeLocalEvent<AntiTamperComponent, GetVerbsEvent<AlternativeVerb>>(OnGetVerbs); | ||
SubscribeLocalEvent<AntiTamperComponent, AntiTamperDisarmDoAfterEvent>(OnDisarmDoAfter); | ||
} | ||
|
||
private void OnDestroy(EntityUid uid, AntiTamperComponent comp, DestructionEventArgs args) | ||
{ | ||
if (!TryComp<ContainerManagerComponent>(uid, out var containerManager)) | ||
return; | ||
|
||
if (!_lockSystem.IsLocked(uid)) | ||
return; | ||
|
||
foreach (var container in _containerSystem.GetAllContainers(uid, containerManager)) | ||
{ | ||
if (comp.Containers != null && !comp.Containers.Contains(container.ID)) | ||
continue; | ||
|
||
foreach (var ent in container.ContainedEntities) | ||
{ | ||
if (comp.PreventRoundRemoval && HasComp<MindContainerComponent>(ent)) | ||
{ | ||
_damageableSystem.TryChangeDamage(ent, comp.MobDamage); | ||
} | ||
else | ||
{ | ||
QueueDel(ent); | ||
} | ||
} | ||
} | ||
|
||
var coords = Transform(uid).Coordinates; | ||
|
||
_popupSystem.PopupCoordinates(Loc.GetString(comp.Message, ("container", uid)), coords, PopupType.SmallCaution); | ||
_audioSystem.PlayPvs(comp.Sound, coords); | ||
} | ||
|
||
private void OnGetVerbs(EntityUid uid, AntiTamperComponent comp, GetVerbsEvent<AlternativeVerb> args) | ||
{ | ||
if (!args.CanAccess || !args.CanInteract || !args.CanComplexInteract) | ||
return; | ||
|
||
if (!CanDisarm((uid, comp), args.User, args.Using)) | ||
return; | ||
|
||
AlternativeVerb verb = new() | ||
{ | ||
Text = Loc.GetString("anti-tamper-disarm-verb"), | ||
Act = () => | ||
{ | ||
AttemptDisarm((uid, comp), args.User, args.Using); | ||
} | ||
}; | ||
args.Verbs.Add(verb); | ||
} | ||
|
||
private bool CanDisarm(Entity<AntiTamperComponent> ent, EntityUid user, EntityUid? used) | ||
{ | ||
var uid = ent.Owner; | ||
var comp = ent.Comp; | ||
|
||
if (comp.DisarmToolRequired != null && (used == null || !_toolSystem.HasQuality(used.Value, comp.DisarmToolRequired))) | ||
return false; | ||
|
||
// Check if crate is unlocked+open or if the player is inside | ||
if (!_containerSystem.ContainsEntity(uid, user)) | ||
{ | ||
// Disarming entity is outside of the crate | ||
// Crate must be unlocked+open | ||
|
||
if (!TryComp<EntityStorageComponent>(uid, out var entStorage)) | ||
return false; | ||
if (_lockSystem.IsLocked(uid) || !entStorage.Open) | ||
return false; | ||
} | ||
|
||
return true; | ||
} | ||
|
||
private void AttemptDisarm(Entity<AntiTamperComponent> ent, EntityUid user, EntityUid? used) | ||
{ | ||
if (!CanDisarm(ent, user, used)) | ||
return; | ||
|
||
var delay = ent.Comp.DisarmTime; | ||
if (_lockSystem.IsLocked(ent.Owner)) | ||
delay *= ent.Comp.DisarmLockedMultiplier; | ||
|
||
if (ent.Comp.DisarmToolRequired != null) | ||
_toolSystem.UseTool( | ||
used!.Value, | ||
user, | ||
ent.Owner, | ||
delay, | ||
[ent.Comp.DisarmToolRequired.Value], | ||
new AntiTamperDisarmDoAfterEvent(), | ||
out _ | ||
); | ||
else | ||
_doAfterSystem.TryStartDoAfter( | ||
new DoAfterArgs(EntityManager, user, delay, new AntiTamperDisarmDoAfterEvent(), ent, ent, used) | ||
{ | ||
BreakOnDamage = true, | ||
BreakOnMove = true, | ||
BreakOnDropItem = true, | ||
MovementThreshold = 1.0f, | ||
BlockDuplicate = true, | ||
DuplicateCondition = DuplicateConditions.SameTarget | DuplicateConditions.SameEvent, | ||
} | ||
); | ||
} | ||
|
||
private void OnDisarmDoAfter(EntityUid uid, AntiTamperComponent comp, AntiTamperDisarmDoAfterEvent args) | ||
{ | ||
if (args.Cancelled || args.Handled || args.Args.Target == null || args.Args.Used == null) | ||
return; | ||
|
||
RemComp<AntiTamperComponent>(uid); | ||
_popupSystem.PopupEntity(Loc.GetString("anti-tamper-disarmed", ("container", uid)), uid, args.User); | ||
} | ||
} |
9 changes: 9 additions & 0 deletions
9
Content.Shared/_Impstation/Containers/AntiTamper/AntiTamperDisarmDoAfterEvent.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
using Content.Shared.DoAfter; | ||
using Robust.Shared.Serialization; | ||
|
||
namespace Content.Shared.Containers.AntiTamper; | ||
|
||
[Serializable, NetSerializable] | ||
public sealed partial class AntiTamperDisarmDoAfterEvent : SimpleDoAfterEvent | ||
{ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
anti-tamper-contents-destroyed = The anti-tamper system acidifies the contents of {THE($container)}! | ||
anti-tamper-disarm-verb = Disarm Anti-Tamper | ||
anti-tamper-disarmed = You disarm {THE($container)}'s anti-tamper module. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 9 additions & 0 deletions
9
Resources/Prototypes/_Impstation/Catalog/Cargo/cargo_emergency.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
- type: cargoProduct | ||
id: EmergencyLasers | ||
icon: | ||
sprite: _Impstation/Objects/Weapons/Guns/Battery/emergency_laser_gun.rsi | ||
state: icon | ||
product: EmergencyLaserCrate | ||
cost: 5000 | ||
category: cargoproduct-category-name-emergency | ||
group: market |
12 changes: 12 additions & 0 deletions
12
Resources/Prototypes/_Impstation/Catalog/Fills/Crates/emergency.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
- type: entity | ||
id: EmergencyLaserCrate | ||
parent: CrateCommandSecure | ||
name: emergency lasers crate | ||
description: A crate of four emergency laser rifles, for situations where getting clearance isn't an option. | ||
components: | ||
- type: StorageFill | ||
contents: | ||
- id: EmergencyWeaponLaserCarbine | ||
- id: EmergencyWeaponLaserCarbine | ||
- id: EmergencyWeaponLaserCarbine | ||
- id: EmergencyWeaponLaserCarbine |
28 changes: 28 additions & 0 deletions
28
Resources/Prototypes/_Impstation/Entities/Objects/Weapons/Guns/Battery/emergencylaser.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
- type: entity | ||
name: emergency laser rifle | ||
parent: [WeaponLaserCarbinePractice, BaseGunWieldable, BaseRestrictedContraband] | ||
id: EmergencyWeaponLaserCarbine | ||
description: An emergency laser rifle, for use when getting timely clearance isn't an option. Hand this in to security once the coast is clear. | ||
components: | ||
- type: Sprite | ||
sprite: _Impstation/Objects/Weapons/Guns/Battery/emergency_laser_gun.rsi | ||
layers: | ||
- state: base | ||
map: ["enum.GunVisualLayers.Base"] | ||
- state: mag-unshaded-4 | ||
map: ["enum.GunVisualLayers.MagUnshaded"] | ||
shader: unshaded | ||
- type: StaticPrice | ||
price: 420 | ||
- type: HitscanBatteryAmmoProvider | ||
proto: EmergencyRedLaser | ||
fireCost: 50 | ||
- type: Item | ||
size: Ginormous | ||
- type: PointLight | ||
radius: 1.5 | ||
energy: 14 | ||
color: "#ff0043" | ||
mask: /Textures/Effects/LightMasks/double_cone.png | ||
- type: RotatingLight | ||
speed: 180 |
14 changes: 14 additions & 0 deletions
14
Resources/Prototypes/_Impstation/Entities/Objects/Weapons/Guns/Projectiles/hitscan.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
- type: hitscan | ||
id: EmergencyRedLaser | ||
damage: | ||
types: | ||
Heat: 12 | ||
muzzleFlash: | ||
sprite: Objects/Weapons/Guns/Projectiles/projectiles.rsi | ||
state: muzzle_laser | ||
travelFlash: | ||
sprite: Objects/Weapons/Guns/Projectiles/projectiles.rsi | ||
state: beam | ||
impactFlash: | ||
sprite: Objects/Weapons/Guns/Projectiles/projectiles.rsi | ||
state: impact_laser |
Binary file added
BIN
+341 Bytes
...tures/_Impstation/Objects/Weapons/Guns/Battery/emergency_laser_gun.rsi/base.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+1.38 KB
...tion/Objects/Weapons/Guns/Battery/emergency_laser_gun.rsi/equipped-BACKPACK.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+1.38 KB
...n/Objects/Weapons/Guns/Battery/emergency_laser_gun.rsi/equipped-SUITSTORAGE.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+750 Bytes
...tures/_Impstation/Objects/Weapons/Guns/Battery/emergency_laser_gun.rsi/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+322 Bytes
...Impstation/Objects/Weapons/Guns/Battery/emergency_laser_gun.rsi/inhand-left.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+337 Bytes
...mpstation/Objects/Weapons/Guns/Battery/emergency_laser_gun.rsi/inhand-right.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+175 Bytes
...station/Objects/Weapons/Guns/Battery/emergency_laser_gun.rsi/mag-unshaded-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+175 Bytes
...station/Objects/Weapons/Guns/Battery/emergency_laser_gun.rsi/mag-unshaded-2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+176 Bytes
...station/Objects/Weapons/Guns/Battery/emergency_laser_gun.rsi/mag-unshaded-3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+172 Bytes
...station/Objects/Weapons/Guns/Battery/emergency_laser_gun.rsi/mag-unshaded-4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
53 changes: 53 additions & 0 deletions
53
...urces/Textures/_Impstation/Objects/Weapons/Guns/Battery/emergency_laser_gun.rsi/meta.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
{ | ||
"version": 1, | ||
"license": "CC-BY-SA-3.0", | ||
"copyright": "Taken from Polaris at https://github.com/PolarisSS13/Polaris/commit/9ded73fb85b9106d6bbf1c9a34d1d2fa27ee0e2e, backpack sprite by Peptide, backpack sling sprite edited by Boaz1111, wield sprites by RiceMar1244", | ||
"size": { | ||
"x": 32, | ||
"y": 32 | ||
}, | ||
"states": [ | ||
{ | ||
"name": "icon" | ||
}, | ||
{ | ||
"name": "base" | ||
}, | ||
{ | ||
"name": "mag-unshaded-1" | ||
}, | ||
{ | ||
"name": "mag-unshaded-2" | ||
}, | ||
{ | ||
"name": "mag-unshaded-3" | ||
}, | ||
{ | ||
"name": "mag-unshaded-4" | ||
}, | ||
{ | ||
"name": "inhand-left", | ||
"directions": 4 | ||
}, | ||
{ | ||
"name": "inhand-right", | ||
"directions": 4 | ||
}, | ||
{ | ||
"name": "wielded-inhand-left", | ||
"directions": 4 | ||
}, | ||
{ | ||
"name": "wielded-inhand-right", | ||
"directions": 4 | ||
}, | ||
{ | ||
"name": "equipped-BACKPACK", | ||
"directions": 4 | ||
}, | ||
{ | ||
"name": "equipped-SUITSTORAGE", | ||
"directions": 4 | ||
} | ||
] | ||
} |
Binary file added
BIN
+929 Bytes
...on/Objects/Weapons/Guns/Battery/emergency_laser_gun.rsi/wielded-inhand-left.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+919 Bytes
...n/Objects/Weapons/Guns/Battery/emergency_laser_gun.rsi/wielded-inhand-right.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.