diff --git a/Content.Server/_White/WeaponModules/WeaponModulesSystem.cs b/Content.Server/_White/WeaponModules/WeaponModulesSystem.cs index e48fd36bb1..a399034b20 100644 --- a/Content.Server/_White/WeaponModules/WeaponModulesSystem.cs +++ b/Content.Server/_White/WeaponModules/WeaponModulesSystem.cs @@ -33,27 +33,29 @@ public sealed class WeaponModulesSystem : EntitySystem SubscribeLocalEvent(AcceleratorModuleOnInsert); SubscribeLocalEvent(AcceleratorModuleOnEject); } - private bool TryInsertModule(EntityUid module, EntityUid weapon, EntGotInsertedIntoContainerMessage args) + private bool TryInsertModule(EntityUid module, EntityUid weapon, EntGotInsertedIntoContainerMessage args, [NotNullWhen(true)] out WeaponModulesComponent? weaponModulesComponent) { - if (TryComp(weapon, out var weaponModulesComponent) && ModulesSlot == args.Container.ID) + if (TryComp(weapon, out var weaponModulesComponents) && ModulesSlot == args.Container.ID) { - if(!weaponModulesComponent.Modules.Contains(module)) - weaponModulesComponent.Modules.Add(module); + if(!weaponModulesComponents.Modules.Contains(module)) + weaponModulesComponents.Modules.Add(module); + weaponModulesComponent = weaponModulesComponents; return true; } - + weaponModulesComponent = weaponModulesComponents; return false; } - private bool TryEjectModule(EntityUid module, EntityUid weapon, EntGotRemovedFromContainerMessage args) + private bool TryEjectModule(EntityUid module, EntityUid weapon, EntGotRemovedFromContainerMessage args, [NotNullWhen(true)] out WeaponModulesComponent? weaponModulesComponent) { - if (TryComp(weapon, out var weaponModulesComponent) && ModulesSlot == args.Container.ID) + if (TryComp(weapon, out var weaponModulesComponents) && ModulesSlot == args.Container.ID) { - if(weaponModulesComponent.Modules.Contains(module)) - weaponModulesComponent.Modules.Remove(module); + if(weaponModulesComponents.Modules.Contains(module)) + weaponModulesComponents.Modules.Remove(module); + weaponModulesComponent = weaponModulesComponents; return true; } - + weaponModulesComponent = weaponModulesComponents; return false; } @@ -67,7 +69,7 @@ public sealed class WeaponModulesSystem : EntitySystem { EntityUid weapon = args.Container.Owner; - if(!TryInsertModule(module, weapon, args)) + if(!TryInsertModule(module, weapon, args, out var weaponModulesComponent)) return; if(!TryComp(weapon, out var appearanceComponent)) return; @@ -87,7 +89,7 @@ public sealed class WeaponModulesSystem : EntitySystem { EntityUid weapon = args.Container.Owner; - if(!TryInsertModule(module, weapon, args)) + if(!TryInsertModule(module, weapon, args, out var weaponModulesComponent)) return; if(!TryComp(weapon, out var appearanceComponent)) return; @@ -103,7 +105,7 @@ public sealed class WeaponModulesSystem : EntitySystem { EntityUid weapon = args.Container.Owner; - if(!TryInsertModule(module, weapon, args) || !TryComp(weapon, out var weaponModulesComponent)) + if(!TryInsertModule(module, weapon, args, out var weaponModulesComponent)) return; if(!TryComp(weapon, out var appearanceComponent)) return; @@ -117,7 +119,7 @@ public sealed class WeaponModulesSystem : EntitySystem { EntityUid weapon = args.Container.Owner; - if(!TryInsertModule(module, weapon, args) || !TryComp(weapon, out var weaponModulesComponent)) + if(!TryInsertModule(module, weapon, args, out var weaponModulesComponent)) return; if(!TryComp(weapon, out var appearanceComponent)) return; @@ -136,7 +138,7 @@ public sealed class WeaponModulesSystem : EntitySystem { EntityUid weapon = args.Container.Owner; - if(!TryInsertModule(module, weapon, args)) + if(!TryInsertModule(module, weapon, args, out var weaponModulesComponent)) return; if(!TryComp(weapon, out var appearanceComponent)) return; @@ -155,7 +157,7 @@ public sealed class WeaponModulesSystem : EntitySystem { EntityUid weapon = args.Container.Owner; - if(!TryEjectModule(module, weapon, args)) + if(!TryEjectModule(module, weapon, args, out var weaponModulesComponent)) return; if(!TryComp(weapon, out var appearanceComponent)) return; @@ -170,7 +172,7 @@ public sealed class WeaponModulesSystem : EntitySystem { EntityUid weapon = args.Container.Owner; - if(!TryEjectModule(module, weapon, args)) + if(!TryEjectModule(module, weapon, args, out var weaponModulesComponent)) return; if(!TryComp(weapon, out var appearanceComponent)) return; @@ -183,7 +185,7 @@ public sealed class WeaponModulesSystem : EntitySystem { EntityUid weapon = args.Container.Owner; - if(!TryEjectModule(module, weapon, args) || !TryComp(weapon, out var weaponModulesComponent)) + if(!TryEjectModule(module, weapon, args, out var weaponModulesComponent)) return; if(!TryComp(weapon, out var appearanceComponent)) return; @@ -197,7 +199,7 @@ public sealed class WeaponModulesSystem : EntitySystem { EntityUid weapon = args.Container.Owner; - if(!TryEjectModule(module, weapon, args) || !TryComp(weapon, out var weaponModulesComponent)) + if(!TryEjectModule(module, weapon, args, out var weaponModulesComponent)) return; if(!TryComp(weapon, out var appearanceComponent)) return; @@ -212,7 +214,7 @@ public sealed class WeaponModulesSystem : EntitySystem { EntityUid weapon = args.Container.Owner; - if(!TryEjectModule(module, weapon, args)) + if(!TryEjectModule(module, weapon, args, out var weaponModulesComponent)) return; if(!TryComp(weapon, out var appearanceComponent)) return; diff --git a/Content.Shared/_White/WeaponModules/AcceleratorModuleComponent.cs b/Content.Shared/_White/WeaponModules/AcceleratorModuleComponent.cs index 31e10e6214..389c84c198 100644 --- a/Content.Shared/_White/WeaponModules/AcceleratorModuleComponent.cs +++ b/Content.Shared/_White/WeaponModules/AcceleratorModuleComponent.cs @@ -8,7 +8,4 @@ public sealed partial class AcceleratorModuleComponent : BaseModuleComponent { [ViewVariables(VVAccess.ReadWrite), DataField] public float OldFireRate; - - [ViewVariables(VVAccess.ReadWrite), DataField] - public string AppearanceValue = "accelerator"; } diff --git a/Content.Shared/_White/WeaponModules/BaseModuleComponent.cs b/Content.Shared/_White/WeaponModules/BaseModuleComponent.cs index 6ad8040090..73a4a4b938 100644 --- a/Content.Shared/_White/WeaponModules/BaseModuleComponent.cs +++ b/Content.Shared/_White/WeaponModules/BaseModuleComponent.cs @@ -6,4 +6,6 @@ namespace Content.Shared._White.WeaponModules; [RegisterComponent, NetworkedComponent] public partial class BaseModuleComponent : Component { + [ViewVariables(VVAccess.ReadWrite), DataField("value")] + public string AppearanceValue; } diff --git a/Content.Shared/_White/WeaponModules/FlameHiderModuleComponent.cs b/Content.Shared/_White/WeaponModules/FlameHiderModuleComponent.cs index 19a1e58bd4..94c9a9f02b 100644 --- a/Content.Shared/_White/WeaponModules/FlameHiderModuleComponent.cs +++ b/Content.Shared/_White/WeaponModules/FlameHiderModuleComponent.cs @@ -6,6 +6,4 @@ [RegisterComponent] public sealed partial class FlameHiderModuleComponent : BaseModuleComponent { - [ViewVariables(VVAccess.ReadWrite), DataField] - public string AppearanceValue = "flamehider"; } diff --git a/Content.Shared/_White/WeaponModules/LaserModuleComponent.cs b/Content.Shared/_White/WeaponModules/LaserModuleComponent.cs index b2230a7d1b..3f8404931b 100644 --- a/Content.Shared/_White/WeaponModules/LaserModuleComponent.cs +++ b/Content.Shared/_White/WeaponModules/LaserModuleComponent.cs @@ -8,7 +8,4 @@ public sealed partial class LaserModuleComponent : BaseModuleComponent { [ViewVariables(VVAccess.ReadWrite), DataField] public float OldProjectileSpeed; - - [ViewVariables(VVAccess.ReadWrite), DataField] - public string AppearanceValue = "laser"; } diff --git a/Content.Shared/_White/WeaponModules/LightModuleComponent.cs b/Content.Shared/_White/WeaponModules/LightModuleComponent.cs index 689311586d..b90bbfe04c 100644 --- a/Content.Shared/_White/WeaponModules/LightModuleComponent.cs +++ b/Content.Shared/_White/WeaponModules/LightModuleComponent.cs @@ -8,7 +8,4 @@ public sealed partial class LightModuleComponent : BaseModuleComponent { [ViewVariables(VVAccess.ReadWrite), DataField] public bool Enabled; - - [ViewVariables(VVAccess.ReadWrite), DataField] - public string AppearanceValue = "light"; } diff --git a/Content.Shared/_White/WeaponModules/SilencerModuleComponent.cs b/Content.Shared/_White/WeaponModules/SilencerModuleComponent.cs index 146d8bae52..074a21ae77 100644 --- a/Content.Shared/_White/WeaponModules/SilencerModuleComponent.cs +++ b/Content.Shared/_White/WeaponModules/SilencerModuleComponent.cs @@ -13,7 +13,4 @@ public sealed partial class SilencerModuleComponent : BaseModuleComponent [ViewVariables(VVAccess.ReadWrite), DataField] public SoundSpecifier NewSoundGunshot = new SoundPathSpecifier("/Audio/White/Weapons/Modules/silence.ogg"); - - [ViewVariables(VVAccess.ReadWrite), DataField] - public string AppearanceValue = "silencer"; } diff --git a/Resources/Prototypes/_White/Entities/Objects/Weapons/Guns/Modules/modules.yml b/Resources/Prototypes/_White/Entities/Objects/Weapons/Guns/Modules/modules.yml index 7592dc5192..cca40c558e 100644 --- a/Resources/Prototypes/_White/Entities/Objects/Weapons/Guns/Modules/modules.yml +++ b/Resources/Prototypes/_White/Entities/Objects/Weapons/Guns/Modules/modules.yml @@ -29,6 +29,7 @@ components: - type: Item - type: LightModule + value: "light" - type: Sprite state: light - type: Appearance @@ -41,6 +42,7 @@ components: - type: Item - type: LaserModule + value: "laser" - type: Sprite state: laser - type: Appearance @@ -53,6 +55,7 @@ components: - type: Item - type: FlameHiderModule + value: "flamehider" - type: Sprite state: flamehider - type: Appearance @@ -65,6 +68,7 @@ components: - type: Item - type: SilencerModule + value: "silencer" - type: Sprite state: silencer - type: Appearance @@ -77,6 +81,7 @@ components: - type: Item - type: AcceleratorModule + value: "accelerator" - type: Sprite state: accelerator - type: Appearance \ No newline at end of file