This commit is contained in:
CaYpeN1
2024-03-25 21:18:12 +05:00
parent 0796ca7bee
commit afc0d5f713
12 changed files with 55 additions and 52 deletions

View File

@@ -8,9 +8,7 @@ namespace Content.Client._White.WeaponsModules;
public sealed partial class WeaponModulesVisuals : VisualizerSystem<WeaponModulesComponent> public sealed partial class WeaponModulesVisuals : VisualizerSystem<WeaponModulesComponent>
{ {
[Dependency] private readonly PointLightSystem _lightSystem = default!; [Dependency] private readonly PointLightSystem _lightSystem = default!;
protected override void OnAppearanceChange(EntityUid uid, WeaponModulesComponent component, ref AppearanceChangeEvent args) protected override void OnAppearanceChange(EntityUid uid, WeaponModulesComponent component, ref AppearanceChangeEvent args)
{ {
base.OnAppearanceChange(uid, component, ref args); base.OnAppearanceChange(uid, component, ref args);

View File

@@ -1,6 +1,7 @@
using System.Diagnostics.CodeAnalysis; using System.Diagnostics.CodeAnalysis;
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.Events;
using Content.Shared.Weapons.Ranged.Systems; using Content.Shared.Weapons.Ranged.Systems;
using Linguini.Syntax.Ast; using Linguini.Syntax.Ast;
using Robust.Server.GameObjects; using Robust.Server.GameObjects;
@@ -34,12 +35,12 @@ public sealed class WeaponModulesSystem : EntitySystem
SubscribeLocalEvent<AcceleratorModuleComponent, EntGotInsertedIntoContainerMessage>(AcceleratorModuleOnInsert); SubscribeLocalEvent<AcceleratorModuleComponent, EntGotInsertedIntoContainerMessage>(AcceleratorModuleOnInsert);
SubscribeLocalEvent<AcceleratorModuleComponent, EntGotRemovedFromContainerMessage>(AcceleratorModuleOnEject); SubscribeLocalEvent<AcceleratorModuleComponent, EntGotRemovedFromContainerMessage>(AcceleratorModuleOnEject);
} }
private bool TryInsertModule(EntityUid module, EntityUid weapon, BaseModuleComponent component, private bool TryInsertModule(EntityUid module, EntityUid weapon, BaseModuleComponent component,
EntGotInsertedIntoContainerMessage args, [NotNullWhen(true)] out WeaponModulesComponent? weaponModulesComponent, string containerId, [NotNullWhen(true)] out WeaponModulesComponent? weaponModulesComponent)
[NotNullWhen(true)] out AppearanceComponent? appearanceComponent)
{ {
if (!TryComp(weapon, out weaponModulesComponent) || !TryComp(weapon, out appearanceComponent) || if (!TryComp(weapon, out weaponModulesComponent) || !TryComp<AppearanceComponent>(weapon, out var appearanceComponent) ||
ModulesSlot != args.Container.ID) containerId != ModulesSlot)
{ {
weaponModulesComponent = null; weaponModulesComponent = null;
appearanceComponent = null; appearanceComponent = null;
@@ -53,9 +54,9 @@ public sealed class WeaponModulesSystem : EntitySystem
return true; return true;
} }
private bool TryEjectModule(EntityUid module, EntityUid weapon, EntGotRemovedFromContainerMessage args, [NotNullWhen(true)] out WeaponModulesComponent? weaponModulesComponent, [NotNullWhen(true)] out AppearanceComponent? appearanceComponent) private bool TryEjectModule(EntityUid module, EntityUid weapon, string containerId, [NotNullWhen(true)] out WeaponModulesComponent? weaponModulesComponent)
{ {
if (!TryComp(weapon, out weaponModulesComponent) || !TryComp(weapon, out appearanceComponent) || ModulesSlot != args.Container.ID) if (!TryComp(weapon, out weaponModulesComponent) || !TryComp<AppearanceComponent>(weapon, out var appearanceComponent) || containerId != ModulesSlot)
{ {
weaponModulesComponent = null; weaponModulesComponent = null;
appearanceComponent = null; appearanceComponent = null;
@@ -74,12 +75,13 @@ public sealed class WeaponModulesSystem : EntitySystem
{ {
EntityUid weapon = args.Container.Owner; EntityUid weapon = args.Container.Owner;
if(!TryInsertModule(module, weapon, component, args, out var weaponModulesComponent, out var appearanceComponent)) if(!TryInsertModule(module, weapon, component, args.Container.ID, out var weaponModulesComponent))
return; return;
_lightSystem.EnsureLight(weapon); TryComp<AppearanceComponent>(weapon, out var appearanceComponent);
SharedPointLightComponent light = _lightSystem.EnsureLight(weapon);
_lightSystem.TryGetLight(weapon, out var light);
_appearanceSystem.SetData(weapon, Modules.Light, "none", appearanceComponent); _appearanceSystem.SetData(weapon, Modules.Light, "none", appearanceComponent);
_lightSystem.SetRadius(weapon, component.Radius, light); _lightSystem.SetRadius(weapon, component.Radius, light);
@@ -90,11 +92,11 @@ public sealed class WeaponModulesSystem : EntitySystem
{ {
EntityUid weapon = args.Container.Owner; EntityUid weapon = args.Container.Owner;
if(!TryInsertModule(module, weapon, component, args, out var weaponModulesComponent, out var appearanceComponent))
return;
if (!TryComp<GunComponent>(weapon, out var gunComp)) return; if (!TryComp<GunComponent>(weapon, out var gunComp)) return;
if(!TryInsertModule(module, weapon, component, args.Container.ID, out var weaponModulesComponent))
return;
component.OldProjectileSpeed = gunComp.ProjectileSpeed; component.OldProjectileSpeed = gunComp.ProjectileSpeed;
_gunSystem.SetProjectileSpeed(weapon, component.OldProjectileSpeed + component.ProjectileSpeedAdd); _gunSystem.SetProjectileSpeed(weapon, component.OldProjectileSpeed + component.ProjectileSpeedAdd);
@@ -104,10 +106,10 @@ public sealed class WeaponModulesSystem : EntitySystem
{ {
EntityUid weapon = args.Container.Owner; EntityUid weapon = args.Container.Owner;
if(!TryInsertModule(module, weapon, component, args, out var weaponModulesComponent, out var appearanceComponent)) if(!TryInsertModule(module, weapon, component, args.Container.ID, out var weaponModulesComponent))
return; return;
weaponModulesComponent.UseEffect = true; weaponModulesComponent.WeaponFireEffect = true;
Dirty(module, weaponModulesComponent); Dirty(module, weaponModulesComponent);
} }
@@ -115,14 +117,14 @@ public sealed class WeaponModulesSystem : EntitySystem
{ {
EntityUid weapon = args.Container.Owner; EntityUid weapon = args.Container.Owner;
if(!TryInsertModule(module, weapon, component, args, out var weaponModulesComponent, out var appearanceComponent))
return;
if (!TryComp<GunComponent>(weapon, out var gunComp)) return; if (!TryComp<GunComponent>(weapon, out var gunComp)) return;
if(!TryInsertModule(module, weapon, component, args.Container.ID, out var weaponModulesComponent))
return;
component.OldSoundGunshot = gunComp.SoundGunshot; component.OldSoundGunshot = gunComp.SoundGunshot;
weaponModulesComponent.UseEffect = true; weaponModulesComponent.WeaponFireEffect = true;
_gunSystem.SetSound(weapon, component.NewSoundGunshot); _gunSystem.SetSound(weapon, component.NewSoundGunshot);
Dirty(module, weaponModulesComponent); Dirty(module, weaponModulesComponent);
@@ -132,11 +134,11 @@ public sealed class WeaponModulesSystem : EntitySystem
{ {
EntityUid weapon = args.Container.Owner; EntityUid weapon = args.Container.Owner;
if(!TryInsertModule(module, weapon, component, args, out var weaponModulesComponent, out var appearanceComponent))
return;
if (!TryComp<GunComponent>(weapon, out var gunComp)) return; if (!TryComp<GunComponent>(weapon, out var gunComp)) return;
if(!TryInsertModule(module, weapon, component, args.Container.ID, out var weaponModulesComponent))
return;
component.OldFireRate = gunComp.FireRate; component.OldFireRate = gunComp.FireRate;
_gunSystem.SetFireRate(weapon, component.OldFireRate + component.FireRateAdd); _gunSystem.SetFireRate(weapon, component.OldFireRate + component.FireRateAdd);
@@ -148,10 +150,12 @@ public sealed class WeaponModulesSystem : EntitySystem
{ {
EntityUid weapon = args.Container.Owner; EntityUid weapon = args.Container.Owner;
if(!TryEjectModule(module, weapon, args, out var weaponModulesComponent, out var appearanceComponent)) if(!TryEjectModule(module, weapon, args.Container.ID, out var weaponModulesComponent))
return;
if(!_lightSystem.TryGetLight(weapon, out var light))
return; return;
_lightSystem.TryGetLight(weapon, out var light);
_lightSystem.SetRadius(weapon, 0F, light); _lightSystem.SetRadius(weapon, 0F, light);
_lightSystem.SetEnabled(weapon, false, light); _lightSystem.SetEnabled(weapon, false, light);
} }
@@ -160,7 +164,7 @@ public sealed class WeaponModulesSystem : EntitySystem
{ {
EntityUid weapon = args.Container.Owner; EntityUid weapon = args.Container.Owner;
if(!TryEjectModule(module, weapon, args, out var weaponModulesComponent, out var appearanceComponent)) if(!TryEjectModule(module, weapon, args.Container.ID, out var weaponModulesComponent))
return; return;
_gunSystem.SetProjectileSpeed(weapon, component.OldProjectileSpeed); _gunSystem.SetProjectileSpeed(weapon, component.OldProjectileSpeed);
@@ -170,10 +174,10 @@ public sealed class WeaponModulesSystem : EntitySystem
{ {
EntityUid weapon = args.Container.Owner; EntityUid weapon = args.Container.Owner;
if(!TryEjectModule(module, weapon, args, out var weaponModulesComponent, out var appearanceComponent)) if(!TryEjectModule(module, weapon, args.Container.ID, out var weaponModulesComponent))
return; return;
weaponModulesComponent.UseEffect = false; weaponModulesComponent.WeaponFireEffect = false;
Dirty(module, weaponModulesComponent); Dirty(module, weaponModulesComponent);
} }
@@ -181,10 +185,10 @@ public sealed class WeaponModulesSystem : EntitySystem
{ {
EntityUid weapon = args.Container.Owner; EntityUid weapon = args.Container.Owner;
if(!TryEjectModule(module, weapon, args, out var weaponModulesComponent, out var appearanceComponent)) if(!TryEjectModule(module, weapon, args.Container.ID, out var weaponModulesComponent))
return; return;
weaponModulesComponent.UseEffect = false; weaponModulesComponent.WeaponFireEffect = false;
_gunSystem.SetSound(weapon, component.OldSoundGunshot!); _gunSystem.SetSound(weapon, component.OldSoundGunshot!);
Dirty(module, weaponModulesComponent); Dirty(module, weaponModulesComponent);
} }
@@ -193,7 +197,7 @@ public sealed class WeaponModulesSystem : EntitySystem
{ {
EntityUid weapon = args.Container.Owner; EntityUid weapon = args.Container.Owner;
if(!TryEjectModule(module, weapon, args, out var weaponModulesComponent, out var appearanceComponent)) if(!TryEjectModule(module, weapon, args.Container.ID, out var weaponModulesComponent))
return; return;
_gunSystem.SetFireRate(weapon, component.OldFireRate); _gunSystem.SetFireRate(weapon, component.OldFireRate);

View File

@@ -1,3 +1,4 @@
using Content.Shared._White.WeaponModules;
using Content.Shared.Actions; using Content.Shared.Actions;
using Content.Shared.Examine; using Content.Shared.Examine;
using Content.Shared.Hands; using Content.Shared.Hands;
@@ -21,6 +22,20 @@ public abstract partial class SharedGunSystem
args.PushMarkup(Loc.GetString("gun-fire-rate-examine", ("color", FireRateExamineColor), args.PushMarkup(Loc.GetString("gun-fire-rate-examine", ("color", FireRateExamineColor),
("fireRate", $"{component.FireRateModified:0.0}"))); ("fireRate", $"{component.FireRateModified:0.0}")));
if (TryComp<WeaponModulesComponent>(uid, out var weaponModulesComponent))
{
if (weaponModulesComponent.Modules.Count == 0)
{
args.PushMarkup(Loc.GetString("gun-modules", ("modules", "Пусто")));
return;
}
foreach (var module in weaponModulesComponent.Modules)
{
args.PushMarkup(Loc.GetString("gun-modules", ("modules", Name(module))));
}
}
if (!TryComp<TwoModeEnergyAmmoProviderComponent>(uid, out var comp)) if (!TryComp<TwoModeEnergyAmmoProviderComponent>(uid, out var comp))
return; return;

View File

@@ -477,8 +477,8 @@ public abstract partial class SharedGunSystem : EntitySystem
protected void MuzzleFlash(EntityUid gun, AmmoComponent component, EntityUid? user = null) protected void MuzzleFlash(EntityUid gun, AmmoComponent component, EntityUid? user = null)
{ {
bool cancelled = TryComp<WeaponModulesComponent>(gun, out var weaponModulesComponent) && weaponModulesComponent.UseEffect; bool cancelled = TryComp<WeaponModulesComponent>(gun, out var weaponModulesComponent) && weaponModulesComponent.WeaponFireEffect; // WD EDIT
if(cancelled) return; if(cancelled) return; // WD EDIT END
var attemptEv = new GunMuzzleFlashAttemptEvent(); var attemptEv = new GunMuzzleFlashAttemptEvent();
RaiseLocalEvent(gun, ref attemptEv); RaiseLocalEvent(gun, ref attemptEv);

View File

@@ -6,9 +6,7 @@
[RegisterComponent] [RegisterComponent]
public sealed partial class AcceleratorModuleComponent : BaseModuleComponent public sealed partial class AcceleratorModuleComponent : BaseModuleComponent
{ {
[ViewVariables(VVAccess.ReadWrite), DataField]
public float OldFireRate; public float OldFireRate;
[ViewVariables(VVAccess.ReadWrite), DataField]
public float FireRateAdd = 2.4F; public float FireRateAdd = 2.4F;
} }

View File

@@ -6,9 +6,7 @@
[RegisterComponent] [RegisterComponent]
public sealed partial class LaserModuleComponent : BaseModuleComponent public sealed partial class LaserModuleComponent : BaseModuleComponent
{ {
[ViewVariables(VVAccess.ReadWrite), DataField]
public float OldProjectileSpeed; public float OldProjectileSpeed;
[ViewVariables(VVAccess.ReadWrite), DataField]
public float ProjectileSpeedAdd = 15F; public float ProjectileSpeedAdd = 15F;
} }

View File

@@ -6,9 +6,7 @@
[RegisterComponent] [RegisterComponent]
public sealed partial class LightModuleComponent : BaseModuleComponent public sealed partial class LightModuleComponent : BaseModuleComponent
{ {
[ViewVariables(VVAccess.ReadWrite), DataField]
public bool Enabled; public bool Enabled;
[ViewVariables(VVAccess.ReadWrite), DataField]
public float Radius = 4F; public float Radius = 4F;
} }

View File

@@ -8,9 +8,7 @@ namespace Content.Shared._White.WeaponModules;
[RegisterComponent] [RegisterComponent]
public sealed partial class SilencerModuleComponent : BaseModuleComponent public sealed partial class SilencerModuleComponent : BaseModuleComponent
{ {
[ViewVariables(VVAccess.ReadWrite), DataField]
public SoundSpecifier? OldSoundGunshot; public SoundSpecifier? OldSoundGunshot;
[ViewVariables(VVAccess.ReadWrite), DataField]
public SoundSpecifier NewSoundGunshot = new SoundPathSpecifier("/Audio/White/Weapons/Modules/silence.ogg"); public SoundSpecifier NewSoundGunshot = new SoundPathSpecifier("/Audio/White/Weapons/Modules/silence.ogg");
} }

View File

@@ -13,7 +13,7 @@ public partial class WeaponModulesComponent : Component
public List<EntityUid> Modules = new(); public List<EntityUid> Modules = new();
[ViewVariables(VVAccess.ReadWrite), AutoNetworkedField] [ViewVariables(VVAccess.ReadWrite), AutoNetworkedField]
public bool UseEffect; public bool WeaponFireEffect;
} }
[Serializable, NetSerializable] [Serializable, NetSerializable]

View File

@@ -1,10 +1,11 @@
ent-LightModule = модульный фонарик ent-LightModule = модульный фонарик
.desc = Излучает свет. .desc = Излучает свет.
ent-LaserModule = лазерный модуль (улучшенный) ent-LaserModule = лазерный модуль
.desc = Улучшенный модуль. Увеличивает скорость ваших пуль. .desc = За счет лазерной обработки пуль, увеличивает их скорость.
ent-FlameHiderModule = пламегаситель ent-FlameHiderModule = пламегаситель
.desc = Скрывает пламя огня во время выстрела. .desc = Скрывает пламя огня во время выстрела.
ent-SilencerModule = глушитель ent-SilencerModule = глушитель
.desc = Скрывает пламя огня и приглушает звук во время выстрела. .desc = Скрывает пламя огня и приглушает звук во время выстрела.
ent-AcceleratorModule = продвинутый модуль ent-AcceleratorModule = продвинутый модуль
.desc = Увеличивает скорострельность оружия. .desc = Разработка NanoTrasen специально для отдела Службы Безопасности. Меняет затворную раму без видимых изменений, за счет этого увеличивает скорострельность оружия.
gun-modules = Установленные модули: [color=cyan]{ $modules }[/color].

View File

@@ -248,8 +248,6 @@
Plastic: 15 Plastic: 15
Steel: 10 Steel: 10
Glass: 5 Glass: 5
Plasma: 10
Silver: 5
- type: latheRecipe - type: latheRecipe
id: TargetHuman id: TargetHuman

View File

@@ -27,7 +27,6 @@
name: "light module" name: "light module"
parent: BaseModule parent: BaseModule
components: components:
- type: Item
- type: LightModule - type: LightModule
value: "light" value: "light"
- type: Sprite - type: Sprite
@@ -40,7 +39,6 @@
name: "laser module" name: "laser module"
parent: BaseModule parent: BaseModule
components: components:
- type: Item
- type: LaserModule - type: LaserModule
value: "laser" value: "laser"
- type: Sprite - type: Sprite
@@ -53,7 +51,6 @@
name: "flamehider module" name: "flamehider module"
parent: BaseModule parent: BaseModule
components: components:
- type: Item
- type: FlameHiderModule - type: FlameHiderModule
value: "flamehider" value: "flamehider"
- type: Sprite - type: Sprite
@@ -66,7 +63,6 @@
name: "silencer module" name: "silencer module"
parent: BaseModule parent: BaseModule
components: components:
- type: Item
- type: SilencerModule - type: SilencerModule
value: "silencer" value: "silencer"
- type: Sprite - type: Sprite
@@ -79,7 +75,6 @@
name: "accelerator module" name: "accelerator module"
parent: BaseModule parent: BaseModule
components: components:
- type: Item
- type: AcceleratorModule - type: AcceleratorModule
value: "accelerator" value: "accelerator"
- type: Sprite - type: Sprite