[Feat] Modules Update (#268)

* add new module slot

* update priority

* sprites + changes in system

* sprites on SMGs + fix examine

* sprite fix
This commit is contained in:
CaypenNow
2024-04-04 18:44:55 +05:00
committed by GitHub
parent 543bbe0c94
commit 4938553945
23 changed files with 275 additions and 74 deletions

View File

@@ -16,12 +16,19 @@ public sealed partial class WeaponModulesVisuals : VisualizerSystem<WeaponModule
if(args.Sprite == null)
return;
args.Sprite.LayerSetVisible(ModuleVisualState.Module, false);
args.Sprite.LayerSetVisible(ModuleVisualState.HandGuardModule, false);
args.Sprite.LayerSetVisible(ModuleVisualState.BarrelModule, false);
if (AppearanceSystem.TryGetData<string>(uid, ModuleVisualState.Module, out var module, args.Component) && module.Length != 0 && module != "none")
if (AppearanceSystem.TryGetData<string>(uid, ModuleVisualState.HandGuardModule, out var handguardModule, args.Component) && handguardModule.Length != 0 && handguardModule != "none")
{
args.Sprite.LayerSetState(ModuleVisualState.Module, module);
args.Sprite.LayerSetVisible(ModuleVisualState.Module, true);
args.Sprite.LayerSetState(ModuleVisualState.HandGuardModule, handguardModule);
args.Sprite.LayerSetVisible(ModuleVisualState.HandGuardModule, true);
}
if (AppearanceSystem.TryGetData<string>(uid, ModuleVisualState.BarrelModule, out var barrelModule, args.Component) && barrelModule.Length != 0 && barrelModule != "none")
{
args.Sprite.LayerSetState(ModuleVisualState.BarrelModule, barrelModule);
args.Sprite.LayerSetVisible(ModuleVisualState.BarrelModule, true);
}
if (AppearanceSystem.TryGetData(uid, Modules.Light, out var data, args.Component))

View File

@@ -1,9 +1,7 @@
using System.Diagnostics.CodeAnalysis;
using Content.Shared._White.WeaponModules;
using Content.Shared.Weapons.Ranged.Components;
using Content.Shared.Weapons.Ranged.Events;
using Content.Shared.Weapons.Ranged.Systems;
using Linguini.Syntax.Ast;
using Robust.Server.GameObjects;
using Robust.Shared.Containers;
@@ -11,7 +9,11 @@ namespace Content.Server._White.WeaponModules;
public sealed class WeaponModulesSystem : EntitySystem
{
protected const string ModulesSlot = "gun_modules";
protected static readonly Dictionary<string, Enum> Slots = new()
{
{ "handguard_module", ModuleVisualState.HandGuardModule }, { "barrel_module", ModuleVisualState.BarrelModule }
};
[Dependency] private readonly PointLightSystem _lightSystem = default!;
[Dependency] private readonly SharedAppearanceSystem _appearanceSystem = default!;
[Dependency] private readonly SharedGunSystem _gunSystem = default!;
@@ -40,7 +42,7 @@ public sealed class WeaponModulesSystem : EntitySystem
string containerId, [NotNullWhen(true)] out WeaponModulesComponent? weaponModulesComponent)
{
if (!TryComp(weapon, out weaponModulesComponent) || !TryComp<AppearanceComponent>(weapon, out var appearanceComponent) ||
containerId != ModulesSlot)
!Slots.ContainsKey(containerId))
{
weaponModulesComponent = null;
appearanceComponent = null;
@@ -49,23 +51,32 @@ public sealed class WeaponModulesSystem : EntitySystem
if(!weaponModulesComponent.Modules.Contains(module))
weaponModulesComponent.Modules.Add(module);
_appearanceSystem.SetData(weapon, ModuleVisualState.Module, component.AppearanceValue, appearanceComponent);
if (!Slots.TryGetValue(containerId, out var value))
return false;
_appearanceSystem.SetData(weapon, value, component.AppearanceValue, appearanceComponent);
return true;
}
private bool TryEjectModule(EntityUid module, EntityUid weapon, string containerId, [NotNullWhen(true)] out WeaponModulesComponent? weaponModulesComponent)
{
if (!TryComp(weapon, out weaponModulesComponent) || !TryComp<AppearanceComponent>(weapon, out var appearanceComponent) || containerId != ModulesSlot)
if (!TryComp(weapon, out weaponModulesComponent) || !TryComp<AppearanceComponent>(weapon, out var appearanceComponent) || !Slots.ContainsKey(containerId))
{
weaponModulesComponent = null;
appearanceComponent = null;
return false;
}
if(weaponModulesComponent.Modules.Contains(module))
weaponModulesComponent.Modules.Remove(module);
_appearanceSystem.SetData(weapon, ModuleVisualState.Module, "none", appearanceComponent);
if (!Slots.TryGetValue(containerId, out var value))
return false;
_appearanceSystem.SetData(weapon, value, "none", appearanceComponent);
return true;
}

View File

@@ -1,3 +1,4 @@
using System.Linq;
using Content.Shared._White.WeaponModules;
using Content.Shared.Actions;
using Content.Shared.Examine;
@@ -30,10 +31,9 @@ public abstract partial class SharedGunSystem
return;
}
foreach (var module in weaponModulesComponent.Modules)
{
args.PushMarkup(Loc.GetString("gun-modules", ("modules", Name(module))));
}
var moduleNames = weaponModulesComponent.Modules.Select(module => Name(module)).ToArray();
args.PushMarkup(Loc.GetString("gun-modules", ("modules", string.Join(", ", moduleNames))));
}
if (!TryComp<TwoModeEnergyAmmoProviderComponent>(uid, out var comp))

View File

@@ -8,4 +8,7 @@ public partial class BaseModuleComponent : Component
{
[ViewVariables(VVAccess.ReadWrite), DataField("value")]
public string AppearanceValue;
[ViewVariables(VVAccess.ReadWrite), DataField("module_type")]
public string ModuleType;
}

View File

@@ -19,7 +19,8 @@ public partial class WeaponModulesComponent : Component
[Serializable, NetSerializable]
public enum ModuleVisualState : byte
{
Module
BarrelModule,
HandGuardModule
}
[Serializable, NetSerializable]

View File

@@ -44,19 +44,10 @@
whitelist:
tags:
- CartridgeLightRifle
gun_modules:
name: Modules
insertSound: /Audio/White/Gun/Modules/insertmodule.ogg
ejectSound: /Audio/White/Gun/Modules/ejectmodule.ogg
priority: 2
whitelist:
tags:
- BaseModule
- type: ContainerContainer
containers:
gun_magazine: !type:ContainerSlot
gun_chamber: !type:ContainerSlot
gun_modules: !type:ContainerSlot
- type: StaticPrice
price: 500
@@ -73,10 +64,14 @@
map: [ "enum.GunVisualLayers.Base" ]
- state: mag-0
map: [ "enum.GunVisualLayers.Mag" ]
- state: laser
- state: barrel_module
visible: false
sprite: White/Objects/Weapons/modulesOnWeapon.rsi
map: [ "enum.ModuleVisualState.Module" ]
map: [ "enum.ModuleVisualState.BarrelModule" ]
- state: handguard_module
visible: false
sprite: White/Objects/Weapons/modulesOnWeapon.rsi
map: [ "enum.ModuleVisualState.HandGuardModule" ]
- type: Gun
fireRate: 5
soundGunshot:
@@ -91,7 +86,7 @@
startingItem: MagazineLightRifle
insertSound: /Audio/Weapons/Guns/MagIn/ltrifle_magin.ogg
ejectSound: /Audio/Weapons/Guns/MagOut/ltrifle_magout.ogg
priority: 2
priority: 4
whitelist:
tags:
- MagazineLightRifle
@@ -102,19 +97,28 @@
whitelist:
tags:
- CartridgeLightRifle
gun_modules:
name: Modules
handguard_module:
name: Handguard Module
insertSound: /Audio/White/Gun/Modules/insertmodule.ogg
ejectSound: /Audio/White/Gun/Modules/ejectmodule.ogg
priority: 2
whitelist:
tags:
- BaseModule
- BaseHandGuardModule
barrel_module:
name: Barrel Module
insertSound: /Audio/White/Gun/Modules/insertmodule.ogg
ejectSound: /Audio/White/Gun/Modules/ejectmodule.ogg
priority: 3
whitelist:
tags:
- BaseBarrelModule
- type: ContainerContainer
containers:
gun_magazine: !type:ContainerSlot
gun_chamber: !type:ContainerSlot
gun_modules: !type:ContainerSlot
handguard_module: !type:ContainerSlot
barrel_module: !type:ContainerSlot
- type: MagazineVisuals
magState: mag
steps: 1
@@ -180,10 +184,14 @@
map: [ "enum.GunVisualLayers.Base" ]
- state: mag-0
map: [ "enum.GunVisualLayers.Mag" ]
- state: laser
- state: barrel_module
visible: false
sprite: White/Objects/Weapons/modulesOnWeapon.rsi
map: [ "enum.ModuleVisualState.Module" ]
map: [ "enum.ModuleVisualState.BarrelModule" ]
- state: handguard_module
visible: false
sprite: White/Objects/Weapons/modulesOnWeapon.rsi
map: [ "enum.ModuleVisualState.HandGuardModule" ]
- type: Clothing
sprite: Objects/Weapons/Guns/Rifles/lecter.rsi
- type: Gun
@@ -196,7 +204,7 @@
startingItem: MagazineRifle
insertSound: /Audio/Weapons/Guns/MagIn/ltrifle_magin.ogg
ejectSound: /Audio/Weapons/Guns/MagOut/ltrifle_magout.ogg
priority: 2
priority: 4
whitelist:
tags:
- MagazineRifle
@@ -207,19 +215,28 @@
whitelist:
tags:
- CartridgeRifle
gun_modules:
name: Modules
handguard_module:
name: Handguard Module
insertSound: /Audio/White/Gun/Modules/insertmodule.ogg
ejectSound: /Audio/White/Gun/Modules/ejectmodule.ogg
priority: 2
whitelist:
tags:
- BaseModule
- BaseHandGuardModule
barrel_module:
name: Barrel Module
insertSound: /Audio/White/Gun/Modules/insertmodule.ogg
ejectSound: /Audio/White/Gun/Modules/ejectmodule.ogg
priority: 3
whitelist:
tags:
- BaseBarrelModule
- type: ContainerContainer
containers:
gun_magazine: !type:ContainerSlot
gun_chamber: !type:ContainerSlot
gun_modules: !type:ContainerSlot
handguard_module: !type:ContainerSlot
barrel_module: !type:ContainerSlot
- type: MagazineVisuals
magState: mag
steps: 1
@@ -242,7 +259,7 @@
startingItem: MagazineRifleRubber
insertSound: /Audio/Weapons/Guns/MagIn/ltrifle_magin.ogg
ejectSound: /Audio/Weapons/Guns/MagOut/ltrifle_magout.ogg
priority: 2
priority: 4
whitelist:
tags:
- MagazineRifle
@@ -253,11 +270,19 @@
whitelist:
tags:
- CartridgeRifle
gun_modules:
name: Modules
handguard_module:
name: Handguard Module
insertSound: /Audio/White/Gun/Modules/insertmodule.ogg
ejectSound: /Audio/White/Gun/Modules/ejectmodule.ogg
priority: 2
whitelist:
tags:
- BaseModule
- BaseHandGuardModule
barrel_module:
name: Barrel Module
insertSound: /Audio/White/Gun/Modules/insertmodule.ogg
ejectSound: /Audio/White/Gun/Modules/ejectmodule.ogg
priority: 3
whitelist:
tags:
- BaseBarrelModule

View File

@@ -91,6 +91,14 @@
map: ["enum.GunVisualLayers.Base"]
- state: mag-0
map: ["enum.GunVisualLayers.Mag"]
- state: barrel_module
visible: false
sprite: White/Objects/Weapons/modulesOnSMGs.rsi
map: [ "enum.ModuleVisualState.BarrelModule" ]
- state: handguard_module
visible: false
sprite: White/Objects/Weapons/modulesOnSMGs.rsi
map: [ "enum.ModuleVisualState.HandGuardModule" ]
- type: Clothing
sprite: Objects/Weapons/Guns/SMGs/c20r.rsi
- type: Gun
@@ -98,11 +106,55 @@
path: /Audio/Weapons/Guns/Gunshots/c-20r.ogg
- type: ChamberMagazineAmmoProvider
autoEject: true
- type: WeaponModules
- type: ItemSlots
slots:
gun_magazine:
name: Magazine
startingItem: MagazinePistolSubMachineGun
insertSound: /Audio/Weapons/Guns/MagIn/smg_magin.ogg
ejectSound: /Audio/Weapons/Guns/MagOut/smg_magout.ogg
priority: 4
whitelist:
tags:
- MagazinePistolSubMachineGun
gun_chamber:
name: Chamber
startingItem: CartridgePistol
priority: 1
whitelist:
tags:
- CartridgePistol
barrel_module:
name: Barrel Module
insertSound: /Audio/White/Gun/Modules/insertmodule.ogg
ejectSound: /Audio/White/Gun/Modules/ejectmodule.ogg
priority: 2
whitelist:
tags:
- BaseBarrelModule
handguard_module:
name: Handguard Module
insertSound: /Audio/White/Gun/Modules/insertmodule.ogg
ejectSound: /Audio/White/Gun/Modules/ejectmodule.ogg
priority: 3
whitelist:
tags:
- BaseHandGuardModule
- type: ContainerContainer
containers:
gun_magazine: !type:ContainerSlot
gun_chamber: !type:ContainerSlot
handguard_module: !type:ContainerSlot
barrel_module: !type:ContainerSlot
- type: MagazineVisuals
magState: mag
steps: 6
zeroVisible: true
- type: Appearance
- type: PointLight
enabled: false
autoRot: true
- type: entity
name: Drozd
@@ -117,10 +169,14 @@
map: ["enum.GunVisualLayers.Base"]
- state: mag-0
map: ["enum.GunVisualLayers.Mag"]
- state: laser
- state: barrel_module
visible: false
sprite: White/Objects/Weapons/modulesOnWeapon.rsi
map: [ "enum.ModuleVisualState.Module" ]
map: [ "enum.ModuleVisualState.BarrelModule" ]
- state: handguard_module
visible: false
sprite: White/Objects/Weapons/modulesOnWeapon.rsi
map: [ "enum.ModuleVisualState.HandGuardModule" ]
- type: Clothing
sprite: Objects/Weapons/Guns/SMGs/drozd.rsi
- type: Gun
@@ -138,7 +194,7 @@
startingItem: MagazinePistolSubMachineGun
insertSound: /Audio/Weapons/Guns/MagIn/smg_magin.ogg
ejectSound: /Audio/Weapons/Guns/MagOut/smg_magout.ogg
priority: 2
priority: 4
whitelist:
tags:
- MagazinePistolSubMachineGun
@@ -149,19 +205,28 @@
whitelist:
tags:
- CartridgePistol
gun_modules:
name: Modules
barrel_module:
name: Barrel Module
insertSound: /Audio/White/Gun/Modules/insertmodule.ogg
ejectSound: /Audio/White/Gun/Modules/ejectmodule.ogg
priority: 2
whitelist:
tags:
- BaseModule
- BaseBarrelModule
handguard_module:
name: Handguard Module
insertSound: /Audio/White/Gun/Modules/insertmodule.ogg
ejectSound: /Audio/White/Gun/Modules/ejectmodule.ogg
priority: 3
whitelist:
tags:
- BaseHandGuardModule
- type: ContainerContainer
containers:
gun_magazine: !type:ContainerSlot
gun_chamber: !type:ContainerSlot
gun_modules: !type:ContainerSlot
handguard_module: !type:ContainerSlot
barrel_module: !type:ContainerSlot
- type: MagazineVisuals
magState: mag
steps: 1
@@ -237,10 +302,14 @@
- state: mag-unshaded-0
map: ["enum.GunVisualLayers.MagUnshaded"]
shader: unshaded
- state: laser
- state: barrel_module
visible: false
sprite: White/Objects/Weapons/modulesOnWeapon.rsi
map: [ "enum.ModuleVisualState.Module" ]
map: [ "enum.ModuleVisualState.BarrelModule" ]
- state: handguard_module
visible: false
sprite: White/Objects/Weapons/modulesOnWeapon.rsi
map: [ "enum.ModuleVisualState.HandGuardModule" ]
- type: Clothing
sprite: Objects/Weapons/Guns/SMGs/wt550.rsi
- type: ChamberMagazineAmmoProvider
@@ -258,7 +327,7 @@
startingItem: MagazinePistolSubMachineGunTopMounted
insertSound: /Audio/Weapons/Guns/MagIn/smg_magin.ogg
ejectSound: /Audio/Weapons/Guns/MagOut/smg_magout.ogg
priority: 2
priority: 4
whitelist:
tags:
- MagazinePistolSubMachineGunTopMounted
@@ -269,18 +338,28 @@
whitelist:
tags:
- CartridgePistol
gun_modules:
name: Modules
barrel_module:
name: Barrel Module
insertSound: /Audio/White/Gun/Modules/insertmodule.ogg
ejectSound: /Audio/White/Gun/Modules/ejectmodule.ogg
priority: 3
whitelist:
tags:
- BaseBarrelModule
handguard_module:
name: Handguard Module
insertSound: /Audio/White/Gun/Modules/insertmodule.ogg
ejectSound: /Audio/White/Gun/Modules/ejectmodule.ogg
priority: 2
whitelist:
tags:
- BaseModule
- BaseHandGuardModule
- type: ContainerContainer
containers:
gun_magazine: !type:ContainerSlot
gun_chamber: !type:ContainerSlot
handguard_module: !type:ContainerSlot
barrel_module: !type:ContainerSlot
- type: MagazineVisuals
magState: mag
steps: 6
@@ -304,7 +383,7 @@
startingItem: MagazinePistolSubMachineGunRubber
insertSound: /Audio/Weapons/Guns/MagIn/smg_magin.ogg
ejectSound: /Audio/Weapons/Guns/MagOut/smg_magout.ogg
priority: 2
priority: 4
whitelist:
tags:
- MagazinePistolSubMachineGun
@@ -315,14 +394,22 @@
whitelist:
tags:
- CartridgePistol
gun_modules:
name: Modules
barrel_module:
name: Barrel Module
insertSound: /Audio/White/Gun/Modules/insertmodule.ogg
ejectSound: /Audio/White/Gun/Modules/ejectmodule.ogg
priority: 2
whitelist:
tags:
- BaseModule
- BaseBarrelModule
handguard_module:
name: Handguard Module
insertSound: /Audio/White/Gun/Modules/insertmodule.ogg
ejectSound: /Audio/White/Gun/Modules/ejectmodule.ogg
priority: 3
whitelist:
tags:
- BaseHandGuardModule
- type: entity
name: Vector

View File

@@ -1,5 +1,5 @@
- type: entity
id: BaseModule
id: BaseHandGuardModule
parent: BaseItem
abstract: true
components:
@@ -7,17 +7,29 @@
sprite: White/Objects/Weapons/modules.rsi
- type: Tag
tags:
- BaseModule
- BaseHandGuardModule
- type: Item
sprite: White/Objects/Weapons/modules.rsi
size: Small
shape:
- 0,0,0,0
- type: Appearance
- type: entity
id: BaseBarrelModule
parent: BaseItem
abstract: true
components:
- type: Sprite
sprite: White/Objects/Weapons/modules.rsi
- type: Tag
tags:
- BaseBarrelModule
- type: Item
sprite: White/Objects/Weapons/modules.rsi
size: Small
shape:
- 0,0,0,0
layers:
- state: base
map: ["enum.GunVisualLayers.Base"]
- state: mag-1
map: ["enum.GunVisualLayers.Mag"]
- type: Appearance
# modules
@@ -25,10 +37,11 @@
id: LightModule
description: Light module for rifles (lecter, CV, drozd, WT).
name: "light module"
parent: BaseModule
parent: BaseHandGuardModule
components:
- type: LightModule
value: "light"
module_type: "handguard_module"
- type: Sprite
state: light
- type: Appearance
@@ -37,10 +50,11 @@
id: LaserModule
description: Laser module for rifles (lecter, CV, drozd, WT).
name: "laser module"
parent: BaseModule
parent: BaseHandGuardModule
components:
- type: LaserModule
value: "laser"
module_type: "handguard_module"
- type: Sprite
state: laser
- type: Appearance
@@ -49,10 +63,11 @@
id: FlameHiderModule
description: Flame Hider module for rifles (lecter, CV, drozd, WT).
name: "flamehider module"
parent: BaseModule
parent: BaseBarrelModule
components:
- type: FlameHiderModule
value: "flamehider"
module_type: "barrel_module"
- type: Sprite
state: flamehider
- type: Appearance
@@ -61,10 +76,11 @@
id: SilencerModule
description: Silencer module for rifles (lecter, CV, drozd, WT).
name: "silencer module"
parent: BaseModule
parent: BaseBarrelModule
components:
- type: SilencerModule
value: "silencer"
module_type: "barrel_module"
- type: Sprite
state: silencer
- type: Appearance
@@ -73,10 +89,11 @@
id: AcceleratorModule
description: Accelerator module for rifles (lecter, CV, drozd, WT).
name: "accelerator module"
parent: BaseModule
parent: BaseHandGuardModule
components:
- type: AcceleratorModule
value: "accelerator"
module_type: "handguard_module"
- type: Sprite
state: accelerator
- type: Appearance
- type: Appearance

View File

@@ -65,4 +65,10 @@
id: InteractivePen
- type: Tag
id: InteractiveBoard
id: InteractiveBoard
- type: Tag
id: BaseBarrelModule
- type: Tag
id: BaseHandGuardModule

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 KiB

View File

@@ -21,6 +21,12 @@
},
{
"name": "accelerator"
},
{
"name": "barrel_module"
},
{
"name": "handguard_module"
}
]
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 178 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 152 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 151 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 152 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 152 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 154 B

View File

@@ -0,0 +1,32 @@
{
"version": 1,
"license": "CC-BY-SA-3.0",
"copyright": "made by CaypenNow",
"size": {
"x": 32,
"y": 32
},
"states": [
{
"name": "flamehider"
},
{
"name": "silencer"
},
{
"name": "light"
},
{
"name": "laser"
},
{
"name": "accelerator"
},
{
"name": "handguard_module"
},
{
"name": "barrel_module"
}
]
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 145 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 152 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 152 B

View File

@@ -21,6 +21,12 @@
},
{
"name": "accelerator"
},
{
"name": "handguard_module"
},
{
"name": "barrel_module"
}
]
}