Обновление модулей (#365)

* base aim module

* sprites, prototypes

* more prototypes

* fix

* fix

* fix2
This commit is contained in:
CaypenNow
2024-06-21 15:24:13 +05:00
committed by GitHub
parent 0181d4fc8b
commit fa348657f9
21 changed files with 189 additions and 7 deletions

View File

@@ -18,6 +18,7 @@ public sealed partial class WeaponModulesVisuals : VisualizerSystem<WeaponModule
args.Sprite.LayerSetVisible(ModuleVisualState.HandGuardModule, false); args.Sprite.LayerSetVisible(ModuleVisualState.HandGuardModule, false);
args.Sprite.LayerSetVisible(ModuleVisualState.BarrelModule, false); args.Sprite.LayerSetVisible(ModuleVisualState.BarrelModule, false);
args.Sprite.LayerSetVisible(ModuleVisualState.AimModule, false);
if (AppearanceSystem.TryGetData<string>(uid, ModuleVisualState.HandGuardModule, out var handguardModule, args.Component) && handguardModule.Length != 0 && handguardModule != "none") if (AppearanceSystem.TryGetData<string>(uid, ModuleVisualState.HandGuardModule, out var handguardModule, args.Component) && handguardModule.Length != 0 && handguardModule != "none")
{ {
@@ -31,6 +32,12 @@ public sealed partial class WeaponModulesVisuals : VisualizerSystem<WeaponModule
args.Sprite.LayerSetVisible(ModuleVisualState.BarrelModule, true); args.Sprite.LayerSetVisible(ModuleVisualState.BarrelModule, true);
} }
if (AppearanceSystem.TryGetData<string>(uid, ModuleVisualState.AimModule, out var aimModule, args.Component) && aimModule.Length != 0 && aimModule != "none")
{
args.Sprite.LayerSetState(ModuleVisualState.AimModule, aimModule);
args.Sprite.LayerSetVisible(ModuleVisualState.AimModule, true);
}
if (AppearanceSystem.TryGetData(uid, Modules.Light, out var data, args.Component)) if (AppearanceSystem.TryGetData(uid, Modules.Light, out var data, args.Component))
{ {
if (TryComp<PointLightComponent>(uid, out var pointLightComponent)) if (TryComp<PointLightComponent>(uid, out var pointLightComponent))

View File

@@ -1,4 +1,5 @@
using System.Diagnostics.CodeAnalysis; using System.Diagnostics.CodeAnalysis;
using Content.Shared._White.Telescope;
using Content.Shared._White.WeaponModules; using Content.Shared._White.WeaponModules;
using Content.Shared.Weapons.Ranged.Components; using Content.Shared.Weapons.Ranged.Components;
using Content.Shared.Weapons.Ranged.Systems; using Content.Shared.Weapons.Ranged.Systems;
@@ -11,7 +12,7 @@ public sealed class WeaponModulesSystem : EntitySystem
{ {
protected static readonly Dictionary<string, Enum> Slots = new() protected static readonly Dictionary<string, Enum> Slots = new()
{ {
{ "handguard_module", ModuleVisualState.HandGuardModule }, { "barrel_module", ModuleVisualState.BarrelModule } { "handguard_module", ModuleVisualState.HandGuardModule }, { "barrel_module", ModuleVisualState.BarrelModule }, { "aim_module", ModuleVisualState.AimModule }
}; };
[Dependency] private readonly PointLightSystem _lightSystem = default!; [Dependency] private readonly PointLightSystem _lightSystem = default!;
@@ -36,6 +37,9 @@ public sealed class WeaponModulesSystem : EntitySystem
SubscribeLocalEvent<AcceleratorModuleComponent, EntGotInsertedIntoContainerMessage>(AcceleratorModuleOnInsert); SubscribeLocalEvent<AcceleratorModuleComponent, EntGotInsertedIntoContainerMessage>(AcceleratorModuleOnInsert);
SubscribeLocalEvent<AcceleratorModuleComponent, EntGotRemovedFromContainerMessage>(AcceleratorModuleOnEject); SubscribeLocalEvent<AcceleratorModuleComponent, EntGotRemovedFromContainerMessage>(AcceleratorModuleOnEject);
SubscribeLocalEvent<AimModuleComponent, EntGotInsertedIntoContainerMessage>(EightAimModuleOnInsert);
SubscribeLocalEvent<AimModuleComponent, EntGotRemovedFromContainerMessage>(EightAimModuleOnEject);
} }
private bool TryInsertModule(EntityUid module, EntityUid weapon, BaseModuleComponent component, private bool TryInsertModule(EntityUid module, EntityUid weapon, BaseModuleComponent component,
@@ -154,6 +158,18 @@ public sealed class WeaponModulesSystem : EntitySystem
_gunSystem.SetFireRate(weapon, component.OldFireRate + component.FireRateAdd); _gunSystem.SetFireRate(weapon, component.OldFireRate + component.FireRateAdd);
} }
private void EightAimModuleOnInsert(EntityUid module, AimModuleComponent component, EntGotInsertedIntoContainerMessage args)
{
EntityUid weapon = args.Container.Owner;
if (!TryComp<GunComponent>(weapon, out var gunComp)) return;
if(!TryInsertModule(module, weapon, component, args.Container.ID, out var weaponModulesComponent))
return;
EnsureComp<TelescopeComponent>(weapon).Divisor = component.Divisor;
}
#endregion #endregion
#region EjectModules #region EjectModules
@@ -213,5 +229,15 @@ public sealed class WeaponModulesSystem : EntitySystem
_gunSystem.SetFireRate(weapon, component.OldFireRate); _gunSystem.SetFireRate(weapon, component.OldFireRate);
} }
private void EightAimModuleOnEject(EntityUid module, AimModuleComponent component, EntGotRemovedFromContainerMessage args)
{
EntityUid weapon = args.Container.Owner;
if(!TryEjectModule(module, weapon, args.Container.ID, out var weaponModulesComponent))
return;
RemComp<TelescopeComponent>(weapon);
}
#endregion #endregion
} }

View File

@@ -0,0 +1,8 @@
namespace Content.Shared._White.WeaponModules;
[RegisterComponent]
public sealed partial class AimModuleComponent : BaseModuleComponent
{
[ViewVariables(VVAccess.ReadWrite), DataField("divisor")]
public float Divisor = 0.3F;
}

View File

@@ -2,7 +2,6 @@
namespace Content.Shared._White.WeaponModules; namespace Content.Shared._White.WeaponModules;
[RegisterComponent, NetworkedComponent] [RegisterComponent, NetworkedComponent]
public partial class BaseModuleComponent : Component public partial class BaseModuleComponent : Component
{ {

View File

@@ -1,8 +1,5 @@
namespace Content.Shared._White.WeaponModules; namespace Content.Shared._White.WeaponModules;
/// <summary>
/// This is used for...
/// </summary>
[RegisterComponent] [RegisterComponent]
public sealed partial class FlameHiderModuleComponent : BaseModuleComponent public sealed partial class FlameHiderModuleComponent : BaseModuleComponent
{ {

View File

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

View File

@@ -285,6 +285,7 @@
- id: MagazinePistol - id: MagazinePistol
- id: BoxMindshield - id: BoxMindshield
- id: TagillaHammer - id: TagillaHammer
- id: EightAimModule
- type: entity - type: entity
id: LockerFreezerVaultFilled id: LockerFreezerVaultFilled
suffix: Vault, Locked suffix: Vault, Locked

View File

@@ -15,7 +15,6 @@
- Back - Back
- suitStorage - suitStorage
- type: AmmoCounter - type: AmmoCounter
- type: WeaponModules
- type: Gun - type: Gun
fireRate: 5 fireRate: 5
selectedMode: FullAuto selectedMode: FullAuto
@@ -81,10 +80,15 @@
visible: false visible: false
sprite: White/Objects/Weapons/modulesOnWeapon.rsi sprite: White/Objects/Weapons/modulesOnWeapon.rsi
map: [ "enum.ModuleVisualState.HandGuardModule" ] map: [ "enum.ModuleVisualState.HandGuardModule" ]
- state: aim_module
visible: false
sprite: White/Objects/Weapons/modulesOnWeapon.rsi
map: [ "enum.ModuleVisualState.AimModule" ]
- type: Gun - type: Gun
fireRate: 5 fireRate: 5
soundGunshot: soundGunshot:
path: /Audio/Weapons/Guns/Gunshots/ak.ogg path: /Audio/Weapons/Guns/Gunshots/ak.ogg
- type: WeaponModules
- type: ChamberMagazineAmmoProvider - type: ChamberMagazineAmmoProvider
soundRack: soundRack:
path: /Audio/Weapons/Guns/Cock/ltrifle_cock.ogg path: /Audio/Weapons/Guns/Cock/ltrifle_cock.ogg
@@ -122,12 +126,21 @@
whitelist: whitelist:
tags: tags:
- BaseBarrelModule - BaseBarrelModule
aim_module:
name: Aim Module
insertSound: /Audio/White/Gun/Modules/insertmodule.ogg
ejectSound: /Audio/White/Gun/Modules/ejectmodule.ogg
priority: 3
whitelist:
tags:
- BaseAimModule
- type: ContainerContainer - type: ContainerContainer
containers: containers:
gun_magazine: !type:ContainerSlot gun_magazine: !type:ContainerSlot
gun_chamber: !type:ContainerSlot gun_chamber: !type:ContainerSlot
handguard_module: !type:ContainerSlot handguard_module: !type:ContainerSlot
barrel_module: !type:ContainerSlot barrel_module: !type:ContainerSlot
aim_module: !type:ContainerSlot
- type: MagazineVisuals - type: MagazineVisuals
magState: mag magState: mag
steps: 1 steps: 1
@@ -201,11 +214,16 @@
visible: false visible: false
sprite: White/Objects/Weapons/modulesOnWeapon.rsi sprite: White/Objects/Weapons/modulesOnWeapon.rsi
map: [ "enum.ModuleVisualState.HandGuardModule" ] map: [ "enum.ModuleVisualState.HandGuardModule" ]
- state: aim_module
visible: false
sprite: White/Objects/Weapons/modulesOnWeapon.rsi
map: [ "enum.ModuleVisualState.AimModule" ]
- type: Clothing - type: Clothing
sprite: Objects/Weapons/Guns/Rifles/lecter.rsi sprite: Objects/Weapons/Guns/Rifles/lecter.rsi
- type: Gun - type: Gun
soundGunshot: soundGunshot:
path: /Audio/Weapons/Guns/Gunshots/ltrifle.ogg path: /Audio/Weapons/Guns/Gunshots/ltrifle.ogg
- type: WeaponModules
- type: ItemSlots - type: ItemSlots
slots: slots:
gun_magazine: gun_magazine:
@@ -240,12 +258,21 @@
whitelist: whitelist:
tags: tags:
- BaseBarrelModule - BaseBarrelModule
aim_module:
name: Aim Module
insertSound: /Audio/White/Gun/Modules/insertmodule.ogg
ejectSound: /Audio/White/Gun/Modules/ejectmodule.ogg
priority: 3
whitelist:
tags:
- BaseAimModule
- type: ContainerContainer - type: ContainerContainer
containers: containers:
gun_magazine: !type:ContainerSlot gun_magazine: !type:ContainerSlot
gun_chamber: !type:ContainerSlot gun_chamber: !type:ContainerSlot
handguard_module: !type:ContainerSlot handguard_module: !type:ContainerSlot
barrel_module: !type:ContainerSlot barrel_module: !type:ContainerSlot
aim_module: !type:ContainerSlot
- type: MagazineVisuals - type: MagazineVisuals
magState: mag magState: mag
steps: 1 steps: 1
@@ -261,6 +288,7 @@
id: WeaponRifleLecterRubber id: WeaponRifleLecterRubber
suffix: Non-lethal suffix: Non-lethal
components: components:
- type: WeaponModules
- type: ItemSlots - type: ItemSlots
slots: slots:
gun_magazine: gun_magazine:
@@ -295,3 +323,11 @@
whitelist: whitelist:
tags: tags:
- BaseBarrelModule - BaseBarrelModule
aim_module:
name: Aim Module
insertSound: /Audio/White/Gun/Modules/insertmodule.ogg
ejectSound: /Audio/White/Gun/Modules/ejectmodule.ogg
priority: 3
whitelist:
tags:
- BaseAimModule

View File

@@ -108,6 +108,10 @@
visible: false visible: false
sprite: White/Objects/Weapons/modulesOnSMGs.rsi sprite: White/Objects/Weapons/modulesOnSMGs.rsi
map: [ "enum.ModuleVisualState.HandGuardModule" ] map: [ "enum.ModuleVisualState.HandGuardModule" ]
- state: aim_module
visible: false
sprite: White/Objects/Weapons/modulesOnSMGs.rsi
map: [ "enum.ModuleVisualState.AimModule" ]
- type: Clothing - type: Clothing
sprite: Objects/Weapons/Guns/SMGs/c20r.rsi sprite: Objects/Weapons/Guns/SMGs/c20r.rsi
- type: Gun - type: Gun
@@ -150,12 +154,21 @@
whitelist: whitelist:
tags: tags:
- BaseHandGuardModule - BaseHandGuardModule
aim_module:
name: Aim Module
insertSound: /Audio/White/Gun/Modules/insertmodule.ogg
ejectSound: /Audio/White/Gun/Modules/ejectmodule.ogg
priority: 3
whitelist:
tags:
- BaseAimModule
- type: ContainerContainer - type: ContainerContainer
containers: containers:
gun_magazine: !type:ContainerSlot gun_magazine: !type:ContainerSlot
gun_chamber: !type:ContainerSlot gun_chamber: !type:ContainerSlot
handguard_module: !type:ContainerSlot handguard_module: !type:ContainerSlot
barrel_module: !type:ContainerSlot barrel_module: !type:ContainerSlot
aim_module: !type:ContainerSlot
- type: MagazineVisuals - type: MagazineVisuals
magState: mag magState: mag
steps: 6 steps: 6
@@ -186,6 +199,10 @@
visible: false visible: false
sprite: White/Objects/Weapons/modulesOnWeapon.rsi sprite: White/Objects/Weapons/modulesOnWeapon.rsi
map: [ "enum.ModuleVisualState.HandGuardModule" ] map: [ "enum.ModuleVisualState.HandGuardModule" ]
- state: aim_module
visible: false
sprite: White/Objects/Weapons/modulesOnWeapon.rsi
map: [ "enum.ModuleVisualState.AimModule" ]
- type: Clothing - type: Clothing
sprite: Objects/Weapons/Guns/SMGs/drozd.rsi sprite: Objects/Weapons/Guns/SMGs/drozd.rsi
- type: Gun - type: Gun
@@ -230,12 +247,21 @@
whitelist: whitelist:
tags: tags:
- BaseHandGuardModule - BaseHandGuardModule
aim_module:
name: Aim Module
insertSound: /Audio/White/Gun/Modules/insertmodule.ogg
ejectSound: /Audio/White/Gun/Modules/ejectmodule.ogg
priority: 3
whitelist:
tags:
- BaseAimModule
- type: ContainerContainer - type: ContainerContainer
containers: containers:
gun_magazine: !type:ContainerSlot gun_magazine: !type:ContainerSlot
gun_chamber: !type:ContainerSlot gun_chamber: !type:ContainerSlot
handguard_module: !type:ContainerSlot handguard_module: !type:ContainerSlot
barrel_module: !type:ContainerSlot barrel_module: !type:ContainerSlot
aim_module: !type:ContainerSlot
- type: MagazineVisuals - type: MagazineVisuals
magState: mag magState: mag
steps: 1 steps: 1
@@ -319,6 +345,10 @@
visible: false visible: false
sprite: White/Objects/Weapons/modulesOnWeapon.rsi sprite: White/Objects/Weapons/modulesOnWeapon.rsi
map: [ "enum.ModuleVisualState.HandGuardModule" ] map: [ "enum.ModuleVisualState.HandGuardModule" ]
- state: aim_module
visible: false
sprite: White/Objects/Weapons/modulesOnWeapon.rsi
map: [ "enum.ModuleVisualState.AimModule" ]
- type: Clothing - type: Clothing
sprite: Objects/Weapons/Guns/SMGs/wt550.rsi sprite: Objects/Weapons/Guns/SMGs/wt550.rsi
- type: ChamberMagazineAmmoProvider - type: ChamberMagazineAmmoProvider
@@ -363,12 +393,21 @@
whitelist: whitelist:
tags: tags:
- BaseHandGuardModule - BaseHandGuardModule
aim_module:
name: Aim Module
insertSound: /Audio/White/Gun/Modules/insertmodule.ogg
ejectSound: /Audio/White/Gun/Modules/ejectmodule.ogg
priority: 2
whitelist:
tags:
- BaseAimModule
- type: ContainerContainer - type: ContainerContainer
containers: containers:
gun_magazine: !type:ContainerSlot gun_magazine: !type:ContainerSlot
gun_chamber: !type:ContainerSlot gun_chamber: !type:ContainerSlot
handguard_module: !type:ContainerSlot handguard_module: !type:ContainerSlot
barrel_module: !type:ContainerSlot barrel_module: !type:ContainerSlot
aim_module: !type:ContainerSlot
- type: MagazineVisuals - type: MagazineVisuals
magState: mag magState: mag
steps: 6 steps: 6
@@ -419,6 +458,14 @@
whitelist: whitelist:
tags: tags:
- BaseHandGuardModule - BaseHandGuardModule
aim_module:
name: Aim Module
insertSound: /Audio/White/Gun/Modules/insertmodule.ogg
ejectSound: /Audio/White/Gun/Modules/ejectmodule.ogg
priority: 3
whitelist:
tags:
- BaseAimModule
- type: entity - type: entity
name: Vector name: Vector

View File

@@ -701,3 +701,12 @@
Plastic: 1000 Plastic: 1000
Glass: 500 Glass: 500
Gold: 1000 Gold: 1000
- type: latheRecipe
id: EightAimRecipe
result: EightAimModule
completetime: 15
materials:
Steel: 500
Plastic: 700
Glass: 300

View File

@@ -32,6 +32,23 @@
- 0,0,0,0 - 0,0,0,0
- type: Appearance - type: Appearance
- type: entity
id: BaseAimModule
parent: BaseItem
abstract: true
components:
- type: Sprite
sprite: White/Objects/Weapons/modules.rsi
- type: Tag
tags:
- BaseAimModule
- type: Item
sprite: White/Objects/Weapons/modules.rsi
size: Small
shape:
- 0,0,0,0
- type: Appearance
# modules # modules
- type: entity - type: entity
id: LightModule id: LightModule
@@ -97,3 +114,16 @@
- type: Sprite - type: Sprite
state: accelerator state: accelerator
- type: Appearance - type: Appearance
- type: entity
id: EightAimModule
description: 8X Aim Module for rifles.
name: "aim module"
parent: BaseAimModule
components:
- type: AimModule
value: "eightaim"
module_type: "aim_module"
- type: Sprite
state: eightaim
- type: Appearance

View File

@@ -75,3 +75,6 @@
- type: Tag - type: Tag
id: BaseHandGuardModule id: BaseHandGuardModule
- type: Tag
id: BaseAimModule

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 KiB

View File

@@ -22,11 +22,17 @@
{ {
"name": "accelerator" "name": "accelerator"
}, },
{
"name": "eightaim"
},
{ {
"name": "barrel_module" "name": "barrel_module"
}, },
{ {
"name": "handguard_module" "name": "handguard_module"
},
{
"name": "aim_module"
} }
] ]
} }

Binary file not shown.

After

Width:  |  Height:  |  Size: 157 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 157 B

View File

@@ -22,11 +22,17 @@
{ {
"name": "accelerator" "name": "accelerator"
}, },
{
"name": "eightaim"
},
{ {
"name": "handguard_module" "name": "handguard_module"
}, },
{ {
"name": "barrel_module" "name": "barrel_module"
},
{
"name": "aim_module"
} }
] ]
} }

Binary file not shown.

After

Width:  |  Height:  |  Size: 157 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 157 B

View File

@@ -22,11 +22,17 @@
{ {
"name": "accelerator" "name": "accelerator"
}, },
{
"name": "eightaim"
},
{ {
"name": "handguard_module" "name": "handguard_module"
}, },
{ {
"name": "barrel_module" "name": "barrel_module"
},
{
"name": "aim_module"
} }
] ]
} }