# Conflicts: # Content.Client/Construction/UI/ConstructionMenu.xaml # Content.Client/Construction/UI/ConstructionMenu.xaml.cs # Content.Client/Construction/UI/ConstructionMenuPresenter.cs # Content.Server/Warps/WarpPointSystem.cs # Content.Server/Weapons/Ranged/Systems/GunSystem.Battery.cs # Content.Server/Weapons/Ranged/Systems/GunSystem.cs # Content.Shared/Construction/Steps/ArbitraryInsertConstructionGraphStep.cs # Content.Shared/Construction/Steps/MaterialConstructionGraphStep.cs # Content.Shared/Humanoid/SharedHumanoidAppearanceSystem.cs # Content.Shared/Inventory/InventorySystem.Relay.cs # Content.Shared/Weapons/Reflect/ReflectSystem.cs # Resources/Locale/en-US/_strings/plants/mutations.ftl # Resources/Locale/en-US/_strings/stack/stacks.ftl # Resources/Locale/en-US/_strings/teleportation/teleportation-menu-gui.ftl # Resources/Prototypes/Catalog/Fills/Backpacks/duffelbag.yml # Resources/Prototypes/Catalog/Fills/Lockers/heads.yml # Resources/Prototypes/Catalog/VendingMachines/Inventories/winterdrobe.yml # Resources/Prototypes/Entities/Clothing/Eyes/glasses.yml # Resources/Prototypes/Entities/Clothing/OuterClothing/armor.yml # Resources/Prototypes/Entities/Objects/Power/powercells.yml # Resources/Prototypes/Entities/Objects/Specific/Cargo/cargo_pallet.yml # Resources/Prototypes/Entities/Objects/Weapons/Guns/Ammunition/Projectiles/shotgun.yml # Resources/Prototypes/Entities/Objects/Weapons/Guns/Battery/battery_guns.yml # Resources/Prototypes/Entities/Objects/Weapons/Melee/sword.yml # Resources/Prototypes/Entities/Stations/base.yml # Resources/Prototypes/Entities/Structures/Machines/nuke.yml # Resources/Prototypes/Reagents/toxins.yml # Resources/Prototypes/Recipes/Construction/Graphs/clothing/clown_banana.yml # Resources/Prototypes/Recipes/Construction/Graphs/machines/computer.yml # Resources/Prototypes/Recipes/Construction/Graphs/mechs/hamtr_construction.yml # Resources/Prototypes/Recipes/Construction/Graphs/mechs/honker_construction.yml # Resources/Prototypes/Recipes/Construction/Graphs/mechs/ripley_construction.yml # Resources/Prototypes/Recipes/Construction/Graphs/mechs/vim_construction.yml # Resources/Prototypes/Recipes/Construction/Graphs/structures/airlock.yml # Resources/Prototypes/Recipes/Construction/Graphs/structures/airlock_clockwork.yml # Resources/Prototypes/Recipes/Construction/Graphs/structures/blast_door.yml # Resources/Prototypes/Recipes/Construction/Graphs/structures/conveyor.yml # Resources/Prototypes/Recipes/Construction/Graphs/structures/firelock.yml # Resources/Prototypes/Recipes/Construction/Graphs/structures/glassbox.yml # Resources/Prototypes/Recipes/Construction/Graphs/structures/secretdoor.yml # Resources/Prototypes/Recipes/Construction/Graphs/structures/shutter.yml # Resources/Prototypes/Recipes/Construction/Graphs/structures/shuttle.yml # Resources/Prototypes/Recipes/Construction/Graphs/structures/windoor.yml # Resources/Prototypes/Recipes/Construction/Graphs/tools/logic_gate.yml # Resources/Prototypes/Recipes/Construction/Graphs/utilities/APC.yml # Resources/Prototypes/Recipes/Construction/Graphs/utilities/air_alarms.yml # Resources/Prototypes/Recipes/Construction/Graphs/utilities/disposal_machines.yml # Resources/Prototypes/Recipes/Construction/Graphs/utilities/intercom.yml # Resources/Prototypes/Recipes/Construction/Graphs/utilities/lighting.yml # Resources/Prototypes/Recipes/Construction/Graphs/utilities/solarpanel.yml # Resources/Prototypes/Recipes/Construction/Graphs/utilities/station_maps.yml # Resources/Prototypes/Recipes/Construction/Graphs/utilities/wallmount_generator.yml # Resources/Prototypes/Recipes/Construction/Graphs/utilities/wallmount_substation.yml # Resources/Prototypes/Recipes/Construction/Graphs/weapons/bladed_hats.yml # Resources/Prototypes/Recipes/Construction/Graphs/weapons/bola.yml # Resources/Prototypes/Recipes/Construction/Graphs/weapons/improvised_arrow.yml # Resources/Prototypes/Recipes/Construction/Graphs/weapons/modular_grenade.yml # Resources/Prototypes/Recipes/Construction/Graphs/weapons/modular_mine.yml # Resources/Prototypes/Recipes/Construction/Graphs/weapons/shiv.yml # Resources/Prototypes/Recipes/Construction/Graphs/weapons/spear.yml # Resources/Prototypes/Recipes/Construction/structures.yml # Resources/Prototypes/Recipes/Crafting/Graphs/bots/cleanbot.yml # Resources/Prototypes/Recipes/Crafting/Graphs/bots/firebot.yml # Resources/Prototypes/Recipes/Crafting/Graphs/bots/honkbot.yml # Resources/Prototypes/Recipes/Crafting/Graphs/bots/medibot.yml # Resources/Prototypes/Recipes/Crafting/Graphs/bots/mimebot.yml # Resources/Prototypes/Recipes/Crafting/Graphs/bots/supplybot.yml # Resources/Prototypes/Recipes/Crafting/Graphs/improvised/firebomb.yml # Resources/Prototypes/Recipes/Crafting/Graphs/improvised/improvised_shotgun.yml # Resources/Prototypes/Recipes/Crafting/Graphs/improvised/improvised_shotgun_shell.yml # Resources/Prototypes/Recipes/Crafting/Graphs/improvised/makeshiftstunprod.yml # Resources/Prototypes/Recipes/Crafting/Graphs/improvised/pipebomb.yml # Resources/Prototypes/Recipes/Crafting/Graphs/improvised/pneumatic_cannon.yml # Resources/Prototypes/Recipes/Crafting/Graphs/improvised/potato.yml # Resources/Prototypes/Recipes/Crafting/Graphs/storage/cratefreezer.yml # Resources/Prototypes/Recipes/Crafting/Graphs/storage/tallbox.yml # Resources/Prototypes/Recipes/Crafting/Graphs/strawhat.yml # Resources/Prototypes/Recipes/Crafting/Graphs/toys.yml # Resources/Prototypes/Recipes/Crafting/improvised.yml # Resources/Prototypes/Recipes/Reactions/medicine.yml # Resources/Prototypes/Roles/Jobs/CentComm/official.yml # Resources/Textures/Clothing/Neck/mantles/cemantle.rsi/equipped-NECK.png # Resources/Textures/Clothing/Neck/mantles/cemantle.rsi/icon.png # Resources/Textures/Clothing/Neck/mantles/cemantle.rsi/meta.json # Resources/Textures/Clothing/Uniforms/Jumpskirt/mime.rsi/equipped-INNERCLOTHING.png # Resources/Textures/Clothing/Uniforms/Jumpskirt/mime.rsi/icon.png # Resources/Textures/Clothing/Uniforms/Jumpskirt/mime.rsi/inhand-left.png # Resources/Textures/Clothing/Uniforms/Jumpskirt/mime.rsi/inhand-right.png # Resources/Textures/Clothing/Uniforms/Jumpskirt/mime.rsi/meta.json # Resources/Textures/Clothing/Uniforms/Jumpsuit/mime.rsi/equipped-INNERCLOTHING.png # Resources/Textures/Clothing/Uniforms/Jumpsuit/mime.rsi/icon.png # Resources/Textures/Clothing/Uniforms/Jumpsuit/mime.rsi/inhand-left.png # Resources/Textures/Clothing/Uniforms/Jumpsuit/mime.rsi/inhand-right.png # Resources/Textures/Clothing/Uniforms/Jumpsuit/mime.rsi/meta.json
194 lines
9.4 KiB
C#
194 lines
9.4 KiB
C#
using Content.Shared.Armor;
|
|
using Content.Shared.Atmos;
|
|
using Content.Shared.Chat;
|
|
using Content.Shared.Chemistry;
|
|
using Content.Shared.Chemistry.Hypospray.Events;
|
|
using Content.Shared.Climbing.Events;
|
|
using Content.Shared.Contraband;
|
|
using Content.Shared.Damage;
|
|
using Content.Shared.Damage.Events;
|
|
using Content.Shared.Damage.Systems;
|
|
using Content.Shared.Electrocution;
|
|
using Content.Shared.Explosion;
|
|
using Content.Shared.Eye.Blinding.Systems;
|
|
using Content.Shared.Gravity;
|
|
using Content.Shared.IdentityManagement.Components;
|
|
using Content.Shared.Inventory.Events;
|
|
using Content.Shared.Movement.Events;
|
|
using Content.Shared.Movement.Systems;
|
|
using Content.Shared.NameModifier.EntitySystems;
|
|
using Content.Shared.Overlays;
|
|
using Content.Shared.Projectiles;
|
|
using Content.Shared.Radio;
|
|
using Content.Shared.Slippery;
|
|
using Content.Shared.Strip.Components;
|
|
using Content.Shared.Temperature;
|
|
using Content.Shared.Verbs;
|
|
using Content.Shared.Weapons.Ranged.Events;
|
|
using Content.Shared.Zombies;
|
|
using Content.Shared._Sunrise.Eye.NightVision.Components;
|
|
using Content.Shared.Weapons.Ranged.Events; // Sunrise-Edit
|
|
|
|
namespace Content.Shared.Inventory;
|
|
|
|
public partial class InventorySystem
|
|
{
|
|
public void InitializeRelay()
|
|
{
|
|
SubscribeLocalEvent<InventoryComponent, DamageModifyEvent>(RelayInventoryEvent);
|
|
SubscribeLocalEvent<InventoryComponent, ElectrocutionAttemptEvent>(RelayInventoryEvent);
|
|
SubscribeLocalEvent<InventoryComponent, SlipAttemptEvent>(RelayInventoryEvent);
|
|
SubscribeLocalEvent<InventoryComponent, RefreshMovementSpeedModifiersEvent>(RelayInventoryEvent);
|
|
SubscribeLocalEvent<InventoryComponent, BeforeStripEvent>(RelayInventoryEvent);
|
|
SubscribeLocalEvent<InventoryComponent, SeeIdentityAttemptEvent>(RelayInventoryEvent);
|
|
SubscribeLocalEvent<InventoryComponent, ModifyChangedTemperatureEvent>(RelayInventoryEvent);
|
|
SubscribeLocalEvent<InventoryComponent, GetDefaultRadioChannelEvent>(RelayInventoryEvent);
|
|
SubscribeLocalEvent<InventoryComponent, RefreshNameModifiersEvent>(RelayInventoryEvent);
|
|
SubscribeLocalEvent<InventoryComponent, TransformSpeakerNameEvent>(RelayInventoryEvent);
|
|
SubscribeLocalEvent<InventoryComponent, SelfBeforeHyposprayInjectsEvent>(RelayInventoryEvent);
|
|
SubscribeLocalEvent<InventoryComponent, TargetBeforeHyposprayInjectsEvent>(RelayInventoryEvent);
|
|
SubscribeLocalEvent<InventoryComponent, SelfBeforeGunShotEvent>(RelayInventoryEvent);
|
|
SubscribeLocalEvent<InventoryComponent, SelfBeforeClimbEvent>(RelayInventoryEvent);
|
|
SubscribeLocalEvent<InventoryComponent, CoefficientQueryEvent>(RelayInventoryEvent);
|
|
SubscribeLocalEvent<InventoryComponent, ZombificationResistanceQueryEvent>(RelayInventoryEvent);
|
|
|
|
// by-ref events
|
|
SubscribeLocalEvent<InventoryComponent, RefreshFrictionModifiersEvent>(RefRelayInventoryEvent);
|
|
SubscribeLocalEvent<InventoryComponent, BeforeStaminaDamageEvent>(RefRelayInventoryEvent);
|
|
SubscribeLocalEvent<InventoryComponent, GetExplosionResistanceEvent>(RefRelayInventoryEvent);
|
|
SubscribeLocalEvent<InventoryComponent, IsWeightlessEvent>(RefRelayInventoryEvent);
|
|
SubscribeLocalEvent<InventoryComponent, GetSpeedModifierContactCapEvent>(RefRelayInventoryEvent);
|
|
SubscribeLocalEvent<InventoryComponent, GetSlowedOverSlipperyModifierEvent>(RefRelayInventoryEvent);
|
|
SubscribeLocalEvent<InventoryComponent, ModifySlowOnDamageSpeedEvent>(RefRelayInventoryEvent);
|
|
SubscribeLocalEvent<InventoryComponent, ExtinguishEvent>(RefRelayInventoryEvent);
|
|
SubscribeLocalEvent<InventoryComponent, ProjectileReflectAttemptEvent>(RefRelayInventoryEvent);
|
|
SubscribeLocalEvent<InventoryComponent, HitScanReflectAttemptEvent>(RefRelayInventoryEvent);
|
|
SubscribeLocalEvent<InventoryComponent, GetContrabandDetailsEvent>(RefRelayInventoryEvent);
|
|
SubscribeLocalEvent<InventoryComponent, ShotAttemptedEvent>(RefRelayInventoryEvent); // Sunrise-Edit
|
|
|
|
// Eye/vision events
|
|
SubscribeLocalEvent<InventoryComponent, CanSeeAttemptEvent>(RelayInventoryEvent);
|
|
SubscribeLocalEvent<InventoryComponent, GetEyeProtectionEvent>(RelayInventoryEvent);
|
|
SubscribeLocalEvent<InventoryComponent, GetBlurEvent>(RelayInventoryEvent);
|
|
SubscribeLocalEvent<InventoryComponent, SolutionScanEvent>(RelayInventoryEvent);
|
|
|
|
// ComponentActivatedClientSystems
|
|
SubscribeLocalEvent<InventoryComponent, RefreshEquipmentHudEvent<ShowJobIconsComponent>>(RefRelayInventoryEvent);
|
|
SubscribeLocalEvent<InventoryComponent, RefreshEquipmentHudEvent<ShowHealthBarsComponent>>(RefRelayInventoryEvent);
|
|
SubscribeLocalEvent<InventoryComponent, RefreshEquipmentHudEvent<ShowHealthIconsComponent>>(RefRelayInventoryEvent);
|
|
SubscribeLocalEvent<InventoryComponent, RefreshEquipmentHudEvent<ShowHungerIconsComponent>>(RefRelayInventoryEvent);
|
|
SubscribeLocalEvent<InventoryComponent, RefreshEquipmentHudEvent<ShowThirstIconsComponent>>(RefRelayInventoryEvent);
|
|
SubscribeLocalEvent<InventoryComponent, RefreshEquipmentHudEvent<ShowMindShieldIconsComponent>>(RefRelayInventoryEvent);
|
|
SubscribeLocalEvent<InventoryComponent, RefreshEquipmentHudEvent<ShowSyndicateIconsComponent>>(RefRelayInventoryEvent);
|
|
SubscribeLocalEvent<InventoryComponent, RefreshEquipmentHudEvent<ShowCriminalRecordIconsComponent>>(RefRelayInventoryEvent);
|
|
SubscribeLocalEvent<InventoryComponent, RefreshEquipmentHudEvent<BlackAndWhiteOverlayComponent>>(RefRelayInventoryEvent);
|
|
SubscribeLocalEvent<InventoryComponent, RefreshEquipmentHudEvent<NightVisionDeviceComponent>>(RefRelayInventoryEvent);
|
|
|
|
SubscribeLocalEvent<InventoryComponent, GetVerbsEvent<EquipmentVerb>>(OnGetEquipmentVerbs);
|
|
SubscribeLocalEvent<InventoryComponent, GetVerbsEvent<InnateVerb>>(OnGetInnateVerbs);
|
|
|
|
}
|
|
|
|
protected void RefRelayInventoryEvent<T>(EntityUid uid, InventoryComponent component, ref T args) where T : IInventoryRelayEvent
|
|
{
|
|
RelayEvent((uid, component), ref args);
|
|
}
|
|
|
|
protected void RelayInventoryEvent<T>(EntityUid uid, InventoryComponent component, T args) where T : IInventoryRelayEvent
|
|
{
|
|
RelayEvent((uid, component), args);
|
|
}
|
|
|
|
public void RelayEvent<T>(Entity<InventoryComponent> inventory, ref T args) where T : IInventoryRelayEvent
|
|
{
|
|
if (args.TargetSlots == SlotFlags.NONE)
|
|
return;
|
|
|
|
// this copies the by-ref event if it is a struct
|
|
var ev = new InventoryRelayedEvent<T>(args);
|
|
var enumerator = new InventorySlotEnumerator(inventory, args.TargetSlots);
|
|
while (enumerator.NextItem(out var item))
|
|
{
|
|
RaiseLocalEvent(item, ev);
|
|
}
|
|
|
|
// and now we copy it back
|
|
args = ev.Args;
|
|
}
|
|
|
|
public void RelayEvent<T>(Entity<InventoryComponent> inventory, T args) where T : IInventoryRelayEvent
|
|
{
|
|
if (args.TargetSlots == SlotFlags.NONE)
|
|
return;
|
|
|
|
var ev = new InventoryRelayedEvent<T>(args);
|
|
var enumerator = new InventorySlotEnumerator(inventory, args.TargetSlots);
|
|
while (enumerator.NextItem(out var item))
|
|
{
|
|
RaiseLocalEvent(item, ev);
|
|
}
|
|
}
|
|
|
|
private void OnGetEquipmentVerbs(EntityUid uid, InventoryComponent component, GetVerbsEvent<EquipmentVerb> args)
|
|
{
|
|
// Automatically relay stripping related verbs to all equipped clothing.
|
|
var ev = new InventoryRelayedEvent<GetVerbsEvent<EquipmentVerb>>(args);
|
|
var enumerator = new InventorySlotEnumerator(component);
|
|
while (enumerator.NextItem(out var item, out var slotDef))
|
|
{
|
|
if (!_strippable.IsStripHidden(slotDef, args.User) || args.User == uid)
|
|
RaiseLocalEvent(item, ev);
|
|
}
|
|
}
|
|
|
|
private void OnGetInnateVerbs(EntityUid uid, InventoryComponent component, GetVerbsEvent<InnateVerb> args)
|
|
{
|
|
// Automatically relay stripping related verbs to all equipped clothing.
|
|
var ev = new InventoryRelayedEvent<GetVerbsEvent<InnateVerb>>(args);
|
|
var enumerator = new InventorySlotEnumerator(component, SlotFlags.WITHOUT_POCKET);
|
|
while (enumerator.NextItem(out var item))
|
|
{
|
|
RaiseLocalEvent(item, ev);
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
/// <summary>
|
|
/// Event wrapper for relayed events.
|
|
/// </summary>
|
|
/// <remarks>
|
|
/// This avoids nested inventory relays, and makes it easy to have certain events only handled by the initial
|
|
/// target entity. E.g. health based movement speed modifiers should not be handled by a hat, even if that hat
|
|
/// happens to be a dead mouse. Clothing that wishes to modify movement speed must subscribe to
|
|
/// InventoryRelayedEvent<RefreshMovementSpeedModifiersEvent>
|
|
/// </remarks>
|
|
public sealed class InventoryRelayedEvent<TEvent> : EntityEventArgs
|
|
{
|
|
public TEvent Args;
|
|
|
|
public InventoryRelayedEvent(TEvent args)
|
|
{
|
|
Args = args;
|
|
}
|
|
}
|
|
|
|
public interface IClothingSlots
|
|
{
|
|
SlotFlags Slots { get; }
|
|
}
|
|
|
|
/// <summary>
|
|
/// Events that should be relayed to inventory slots should implement this interface.
|
|
/// </summary>
|
|
public interface IInventoryRelayEvent
|
|
{
|
|
/// <summary>
|
|
/// What inventory slots should this event be relayed to, if any?
|
|
/// </summary>
|
|
/// <remarks>
|
|
/// In general you may want to exclude <see cref="SlotFlags.POCKET"/>, given that those items are not truly
|
|
/// "equipped" by the user.
|
|
/// </remarks>
|
|
public SlotFlags TargetSlots { get; }
|
|
}
|