diff --git a/Content.Server/_White/WeaponModules/WeaponModulesComponent.cs b/Content.Server/_White/WeaponModules/WeaponModulesComponent.cs
new file mode 100644
index 0000000000..479e8a858d
--- /dev/null
+++ b/Content.Server/_White/WeaponModules/WeaponModulesComponent.cs
@@ -0,0 +1,11 @@
+namespace Content.Server._White.WeaponModules;
+
+///
+/// This is used for...
+///
+[RegisterComponent]
+public sealed partial class WeaponModulesComponent : Component
+{
+ [ViewVariables(VVAccess.ReadWrite)]
+ public List Modules = new();
+}
diff --git a/Content.Server/_White/WeaponModules/WeaponModulesSystem.cs b/Content.Server/_White/WeaponModules/WeaponModulesSystem.cs
new file mode 100644
index 0000000000..bb9114489a
--- /dev/null
+++ b/Content.Server/_White/WeaponModules/WeaponModulesSystem.cs
@@ -0,0 +1,96 @@
+using Content.Server.Light.Events;
+using Content.Server.Lightning;
+using Robust.Server.GameObjects;
+using Robust.Shared.Containers;
+
+namespace Content.Server._White.WeaponModules;
+
+public sealed class WeaponModulesSystem : EntitySystem
+{
+ protected const string ModulesSlot = "gun_modules";
+ [Dependency] private readonly SharedPointLightSystem _lightSystem = default!;
+ public override void Initialize()
+ {
+ base.Initialize();
+
+ SubscribeLocalEvent(OnInsert);
+ SubscribeLocalEvent(OnEject);
+ }
+
+ private void OnInsert(EntityUid uid, WeaponModulesComponent comp, EntInsertedIntoContainerMessage args)
+ {
+ if (ModulesSlot != args.Container.ID)
+ return;
+
+ string weapon = Prototype(args.Entity)!.ID;
+ EntityUid target = args.Container.Owner;
+
+ insertModules(weapon, comp);
+ moduleEffect(weapon, target);
+ }
+
+ private void OnEject(EntityUid uid, WeaponModulesComponent comp, EntRemovedFromContainerMessage args)
+ {
+ if (ModulesSlot != args.Container.ID)
+ return;
+
+ string weapon = Prototype(args.Entity)!.ID;
+ EntityUid target = args.Container.Owner;
+
+ removeModules(weapon, comp);
+ removeModuleEffect(weapon, target);
+ }
+
+ private void insertModules(string module, WeaponModulesComponent comp)
+ {
+ switch (module)
+ {
+ case "LightModule":
+ if(comp.Modules.Contains("LightModule")) break;
+ comp.Modules.Add("LightModule");
+ break;
+ }
+ }
+
+ private void moduleEffect(string module, EntityUid target)
+ {
+ switch (module)
+ {
+ case "LightModule":
+ if (HasComp(target))
+ {
+ _lightSystem.SetEnabled(target, true);
+ break;
+ }
+
+ _lightSystem.TryGetLight(target, out var light);
+ _lightSystem.EnsureLight(target);
+ _lightSystem.SetRadius(target, 2F, light);
+ break;
+ }
+ }
+
+ private void removeModules(string module, WeaponModulesComponent comp)
+ {
+ switch (module)
+ {
+ case "LightModule":
+ comp.Modules.Remove("LightModule");
+ break;
+ }
+ }
+
+ private void removeModuleEffect(string module, EntityUid target)
+ {
+ switch (module)
+ {
+ case "LightModule":
+ if(!HasComp(target))
+ break;
+
+ _lightSystem.TryGetLight(target, out var light);
+ _lightSystem.SetEnabled(target, false, light);
+ break;
+ }
+ }
+}
diff --git a/Resources/Prototypes/Entities/Objects/Weapons/Guns/Rifles/rifles.yml b/Resources/Prototypes/Entities/Objects/Weapons/Guns/Rifles/rifles.yml
index 82c0770c7f..9baf951015 100644
--- a/Resources/Prototypes/Entities/Objects/Weapons/Guns/Rifles/rifles.yml
+++ b/Resources/Prototypes/Entities/Objects/Weapons/Guns/Rifles/rifles.yml
@@ -15,6 +15,7 @@
- Back
- suitStorage
- type: AmmoCounter
+ - type: WeaponModules
- type: Gun
fireRate: 5
selectedMode: FullAuto
@@ -32,7 +33,7 @@
startingItem: MagazineLightRifle
insertSound: /Audio/Weapons/Guns/MagIn/batrifle_magin.ogg
ejectSound: /Audio/Weapons/Guns/MagOut/batrifle_magout.ogg
- priority: 2
+ priority: 3
whitelist:
tags:
- MagazineLightRifle
@@ -43,10 +44,17 @@
whitelist:
tags:
- CartridgeLightRifle
+ gun_modules:
+ name: Modules
+ priority: 2
+ whitelist:
+ tags:
+ - BaseModule
- type: ContainerContainer
containers:
gun_magazine: !type:ContainerSlot
gun_chamber: !type:ContainerSlot
+ gun_modules: !type:ContainerSlot
- type: StaticPrice
price: 500
@@ -88,10 +96,17 @@
whitelist:
tags:
- CartridgeLightRifle
+ gun_modules:
+ name: Modules
+ priority: 2
+ whitelist:
+ tags:
+ - BaseModule
- type: ContainerContainer
containers:
gun_magazine: !type:ContainerSlot
gun_chamber: !type:ContainerSlot
+ gun_modules: !type:ContainerSlot
- type: MagazineVisuals
magState: mag
steps: 1
diff --git a/Resources/Prototypes/White/Entities/Objects/Weapons/Guns/Modules/modules.yml b/Resources/Prototypes/White/Entities/Objects/Weapons/Guns/Modules/modules.yml
new file mode 100644
index 0000000000..be8ce29fbd
--- /dev/null
+++ b/Resources/Prototypes/White/Entities/Objects/Weapons/Guns/Modules/modules.yml
@@ -0,0 +1,32 @@
+- type: entity
+ id: BaseModule
+ parent: BaseItem
+ abstract: true
+ components:
+ - type: Sprite
+ sprite: White/Objects/Weapons/modules.rsi
+ - type: Tag
+ tags:
+ - BaseModule
+ - type: Item
+ sprite: White/Objects/Weapons/modules.rsi
+ size: Small
+ shape:
+ - 0,0,1,1
+ layers:
+ - state: base
+ map: ["enum.GunVisualLayers.Base"]
+ - state: mag-1
+ map: ["enum.GunVisualLayers.Mag"]
+ - type: Appearance
+
+# modules
+- type: entity
+ id: LightModule
+ name: "light module for rifle"
+ parent: BaseModule
+ components:
+ - type: Item
+ - type: Sprite
+ state: light
+ - type: Appearance
\ No newline at end of file
diff --git a/Resources/Prototypes/White/tags.yml b/Resources/Prototypes/White/tags.yml
index 466a1ddb17..73d3311562 100644
--- a/Resources/Prototypes/White/tags.yml
+++ b/Resources/Prototypes/White/tags.yml
@@ -54,3 +54,6 @@
- type: Tag
id: MindSlave
+
+- type: Tag
+ id: BaseModule
diff --git a/Resources/Textures/White/Objects/Weapons/modules.rsi/light.png b/Resources/Textures/White/Objects/Weapons/modules.rsi/light.png
new file mode 100644
index 0000000000..347e76a4b2
Binary files /dev/null and b/Resources/Textures/White/Objects/Weapons/modules.rsi/light.png differ
diff --git a/Resources/Textures/White/Objects/Weapons/modules.rsi/meta.json b/Resources/Textures/White/Objects/Weapons/modules.rsi/meta.json
new file mode 100644
index 0000000000..edc936e871
--- /dev/null
+++ b/Resources/Textures/White/Objects/Weapons/modules.rsi/meta.json
@@ -0,0 +1,14 @@
+{
+ "version": 1,
+ "license": "CC-BY-SA-3.0",
+ "copyright": "Maked by CaypenNow",
+ "size": {
+ "x": 32,
+ "y": 32
+ },
+ "states": [
+ {
+ "name": "light"
+ }
+ ]
+}