Обновление модулей (#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

@@ -1,4 +1,5 @@
using System.Diagnostics.CodeAnalysis;
using Content.Shared._White.Telescope;
using Content.Shared._White.WeaponModules;
using Content.Shared.Weapons.Ranged.Components;
using Content.Shared.Weapons.Ranged.Systems;
@@ -11,7 +12,7 @@ public sealed class WeaponModulesSystem : EntitySystem
{
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!;
@@ -36,6 +37,9 @@ public sealed class WeaponModulesSystem : EntitySystem
SubscribeLocalEvent<AcceleratorModuleComponent, EntGotInsertedIntoContainerMessage>(AcceleratorModuleOnInsert);
SubscribeLocalEvent<AcceleratorModuleComponent, EntGotRemovedFromContainerMessage>(AcceleratorModuleOnEject);
SubscribeLocalEvent<AimModuleComponent, EntGotInsertedIntoContainerMessage>(EightAimModuleOnInsert);
SubscribeLocalEvent<AimModuleComponent, EntGotRemovedFromContainerMessage>(EightAimModuleOnEject);
}
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);
}
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
#region EjectModules
@@ -213,5 +229,15 @@ public sealed class WeaponModulesSystem : EntitySystem
_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
}