new methods
This commit is contained in:
@@ -18,6 +18,8 @@ public sealed partial class WeaponModulesVisuals : VisualizerSystem<WeaponModule
|
|||||||
if(args.Sprite == null)
|
if(args.Sprite == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
args.Sprite.LayerSetVisible(ModuleVisualState.Module, false);
|
||||||
|
|
||||||
if (AppearanceSystem.TryGetData<string>(uid, ModuleVisualState.Module, out var module, args.Component) && module.Length != 0 && module != "none")
|
if (AppearanceSystem.TryGetData<string>(uid, ModuleVisualState.Module, out var module, args.Component) && module.Length != 0 && module != "none")
|
||||||
{
|
{
|
||||||
args.Sprite.LayerSetState(ModuleVisualState.Module, module);
|
args.Sprite.LayerSetState(ModuleVisualState.Module, module);
|
||||||
|
|||||||
@@ -33,17 +33,37 @@ public sealed class WeaponModulesSystem : EntitySystem
|
|||||||
SubscribeLocalEvent<AcceleratorModuleComponent, EntGotRemovedFromContainerMessage>(AcceleratorModuleOnEject);
|
SubscribeLocalEvent<AcceleratorModuleComponent, EntGotRemovedFromContainerMessage>(AcceleratorModuleOnEject);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private bool TryInsertModule(EntityUid module, EntityUid weapon, EntGotInsertedIntoContainerMessage args)
|
||||||
|
{
|
||||||
|
if (TryComp<WeaponModulesComponent>(weapon, out var weaponModulesComponent) && ModulesSlot == args.Container.ID)
|
||||||
|
{
|
||||||
|
if(!weaponModulesComponent.Modules.Contains(module))
|
||||||
|
weaponModulesComponent.Modules.Add(module);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
private bool TryEjectModule(EntityUid module, EntityUid weapon, EntGotRemovedFromContainerMessage args)
|
||||||
|
{
|
||||||
|
if (TryComp<WeaponModulesComponent>(weapon, out var weaponModulesComponent) && ModulesSlot == args.Container.ID)
|
||||||
|
{
|
||||||
|
if(weaponModulesComponent.Modules.Contains(module))
|
||||||
|
weaponModulesComponent.Modules.Remove(module);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
#region InsertModules
|
#region InsertModules
|
||||||
private void LightModuleOnInsert(EntityUid module, LightModuleComponent component, EntGotInsertedIntoContainerMessage args)
|
private void LightModuleOnInsert(EntityUid module, LightModuleComponent component, EntGotInsertedIntoContainerMessage args)
|
||||||
{
|
{
|
||||||
if (ModulesSlot != args.Container.ID)
|
|
||||||
return;
|
|
||||||
|
|
||||||
EntityUid weapon = args.Container.Owner;
|
EntityUid weapon = args.Container.Owner;
|
||||||
if (!TryComp<WeaponModulesComponent>(weapon, out var weaponModulesComponent)) return;
|
|
||||||
|
|
||||||
if(!weaponModulesComponent.Modules.Contains(module))
|
if(!TryInsertModule(module, weapon, args))
|
||||||
weaponModulesComponent.Modules.Add(module);
|
return;
|
||||||
|
|
||||||
if(!TryComp<AppearanceComponent>(weapon, out var appearanceComponent)) return;
|
if(!TryComp<AppearanceComponent>(weapon, out var appearanceComponent)) return;
|
||||||
|
|
||||||
@@ -60,14 +80,10 @@ public sealed class WeaponModulesSystem : EntitySystem
|
|||||||
|
|
||||||
private void LaserModuleOnInsert(EntityUid module, LaserModuleComponent component, EntGotInsertedIntoContainerMessage args)
|
private void LaserModuleOnInsert(EntityUid module, LaserModuleComponent component, EntGotInsertedIntoContainerMessage args)
|
||||||
{
|
{
|
||||||
if (ModulesSlot != args.Container.ID)
|
|
||||||
return;
|
|
||||||
|
|
||||||
EntityUid weapon = args.Container.Owner;
|
EntityUid weapon = args.Container.Owner;
|
||||||
if (!TryComp<WeaponModulesComponent>(weapon, out var weaponModulesComponent)) return;
|
|
||||||
|
|
||||||
if(!weaponModulesComponent.Modules.Contains(module))
|
if(!TryInsertModule(module, weapon, args))
|
||||||
weaponModulesComponent.Modules.Add(module);
|
return;
|
||||||
|
|
||||||
if(!TryComp<AppearanceComponent>(weapon, out var appearanceComponent)) return;
|
if(!TryComp<AppearanceComponent>(weapon, out var appearanceComponent)) return;
|
||||||
if (!TryComp<GunComponent>(weapon, out var gunComp)) return;
|
if (!TryComp<GunComponent>(weapon, out var gunComp)) return;
|
||||||
@@ -80,14 +96,10 @@ public sealed class WeaponModulesSystem : EntitySystem
|
|||||||
|
|
||||||
private void FlameHiderModuleOnInsert(EntityUid module, FlameHiderModuleComponent component, EntGotInsertedIntoContainerMessage args)
|
private void FlameHiderModuleOnInsert(EntityUid module, FlameHiderModuleComponent component, EntGotInsertedIntoContainerMessage args)
|
||||||
{
|
{
|
||||||
if (ModulesSlot != args.Container.ID)
|
|
||||||
return;
|
|
||||||
|
|
||||||
EntityUid weapon = args.Container.Owner;
|
EntityUid weapon = args.Container.Owner;
|
||||||
if (!TryComp<WeaponModulesComponent>(weapon, out var weaponModulesComponent)) return;
|
|
||||||
|
|
||||||
if(!weaponModulesComponent.Modules.Contains(module))
|
if(!TryInsertModule(module, weapon, args) || !TryComp<WeaponModulesComponent>(weapon, out var weaponModulesComponent))
|
||||||
weaponModulesComponent.Modules.Add(module);
|
return;
|
||||||
|
|
||||||
if(!TryComp<AppearanceComponent>(weapon, out var appearanceComponent)) return;
|
if(!TryComp<AppearanceComponent>(weapon, out var appearanceComponent)) return;
|
||||||
|
|
||||||
@@ -98,14 +110,10 @@ public sealed class WeaponModulesSystem : EntitySystem
|
|||||||
|
|
||||||
private void SilencerModuleOnInsert(EntityUid module, SilencerModuleComponent component, EntGotInsertedIntoContainerMessage args)
|
private void SilencerModuleOnInsert(EntityUid module, SilencerModuleComponent component, EntGotInsertedIntoContainerMessage args)
|
||||||
{
|
{
|
||||||
if (ModulesSlot != args.Container.ID)
|
|
||||||
return;
|
|
||||||
|
|
||||||
EntityUid weapon = args.Container.Owner;
|
EntityUid weapon = args.Container.Owner;
|
||||||
if (!TryComp<WeaponModulesComponent>(weapon, out var weaponModulesComponent)) return;
|
|
||||||
|
|
||||||
if(!weaponModulesComponent.Modules.Contains(module))
|
if(!TryInsertModule(module, weapon, args) || !TryComp<WeaponModulesComponent>(weapon, out var weaponModulesComponent))
|
||||||
weaponModulesComponent.Modules.Add(module);
|
return;
|
||||||
|
|
||||||
if(!TryComp<AppearanceComponent>(weapon, out var appearanceComponent)) return;
|
if(!TryComp<AppearanceComponent>(weapon, out var appearanceComponent)) return;
|
||||||
if (!TryComp<GunComponent>(weapon, out var gunComp)) return;
|
if (!TryComp<GunComponent>(weapon, out var gunComp)) return;
|
||||||
@@ -121,14 +129,10 @@ public sealed class WeaponModulesSystem : EntitySystem
|
|||||||
|
|
||||||
private void AcceleratorModuleOnInsert(EntityUid module, AcceleratorModuleComponent component, EntGotInsertedIntoContainerMessage args)
|
private void AcceleratorModuleOnInsert(EntityUid module, AcceleratorModuleComponent component, EntGotInsertedIntoContainerMessage args)
|
||||||
{
|
{
|
||||||
if (ModulesSlot != args.Container.ID)
|
|
||||||
return;
|
|
||||||
|
|
||||||
EntityUid weapon = args.Container.Owner;
|
EntityUid weapon = args.Container.Owner;
|
||||||
if (!TryComp<WeaponModulesComponent>(weapon, out var weaponModulesComponent)) return;
|
|
||||||
|
|
||||||
if(!weaponModulesComponent.Modules.Contains(module))
|
if(!TryInsertModule(module, weapon, args))
|
||||||
weaponModulesComponent.Modules.Add(module);
|
return;
|
||||||
|
|
||||||
if(!TryComp<AppearanceComponent>(weapon, out var appearanceComponent)) return;
|
if(!TryComp<AppearanceComponent>(weapon, out var appearanceComponent)) return;
|
||||||
|
|
||||||
@@ -144,14 +148,10 @@ public sealed class WeaponModulesSystem : EntitySystem
|
|||||||
#region EjectModules
|
#region EjectModules
|
||||||
private void LightModuleOnEject(EntityUid module, LightModuleComponent component, EntGotRemovedFromContainerMessage args)
|
private void LightModuleOnEject(EntityUid module, LightModuleComponent component, EntGotRemovedFromContainerMessage args)
|
||||||
{
|
{
|
||||||
if (ModulesSlot != args.Container.ID)
|
|
||||||
return;
|
|
||||||
|
|
||||||
EntityUid weapon = args.Container.Owner;
|
EntityUid weapon = args.Container.Owner;
|
||||||
if (!TryComp<WeaponModulesComponent>(weapon, out var weaponModulesComponent)) return;
|
|
||||||
|
|
||||||
if(weaponModulesComponent.Modules.Contains(module))
|
if(!TryEjectModule(module, weapon, args))
|
||||||
weaponModulesComponent.Modules.Remove(module);
|
return;
|
||||||
|
|
||||||
if(!TryComp<AppearanceComponent>(weapon, out var appearanceComponent)) return;
|
if(!TryComp<AppearanceComponent>(weapon, out var appearanceComponent)) return;
|
||||||
|
|
||||||
@@ -163,14 +163,10 @@ public sealed class WeaponModulesSystem : EntitySystem
|
|||||||
|
|
||||||
private void LaserModuleOnEject(EntityUid module, LaserModuleComponent component, EntGotRemovedFromContainerMessage args)
|
private void LaserModuleOnEject(EntityUid module, LaserModuleComponent component, EntGotRemovedFromContainerMessage args)
|
||||||
{
|
{
|
||||||
if (ModulesSlot != args.Container.ID)
|
|
||||||
return;
|
|
||||||
|
|
||||||
EntityUid weapon = args.Container.Owner;
|
EntityUid weapon = args.Container.Owner;
|
||||||
if (!TryComp<WeaponModulesComponent>(weapon, out var weaponModulesComponent)) return;
|
|
||||||
|
|
||||||
if(weaponModulesComponent.Modules.Contains(module))
|
if(!TryEjectModule(module, weapon, args))
|
||||||
weaponModulesComponent.Modules.Remove(module);
|
return;
|
||||||
|
|
||||||
if(!TryComp<AppearanceComponent>(weapon, out var appearanceComponent)) return;
|
if(!TryComp<AppearanceComponent>(weapon, out var appearanceComponent)) return;
|
||||||
|
|
||||||
@@ -180,14 +176,10 @@ public sealed class WeaponModulesSystem : EntitySystem
|
|||||||
|
|
||||||
private void FlameHiderModuleOnEject(EntityUid module, FlameHiderModuleComponent component, EntGotRemovedFromContainerMessage args)
|
private void FlameHiderModuleOnEject(EntityUid module, FlameHiderModuleComponent component, EntGotRemovedFromContainerMessage args)
|
||||||
{
|
{
|
||||||
if (ModulesSlot != args.Container.ID)
|
|
||||||
return;
|
|
||||||
|
|
||||||
EntityUid weapon = args.Container.Owner;
|
EntityUid weapon = args.Container.Owner;
|
||||||
if (!TryComp<WeaponModulesComponent>(weapon, out var weaponModulesComponent)) return;
|
|
||||||
|
|
||||||
if(weaponModulesComponent.Modules.Contains(module))
|
if(!TryEjectModule(module, weapon, args) || !TryComp<WeaponModulesComponent>(weapon, out var weaponModulesComponent))
|
||||||
weaponModulesComponent.Modules.Remove(module);
|
return;
|
||||||
|
|
||||||
if(!TryComp<AppearanceComponent>(weapon, out var appearanceComponent)) return;
|
if(!TryComp<AppearanceComponent>(weapon, out var appearanceComponent)) return;
|
||||||
|
|
||||||
@@ -198,14 +190,10 @@ public sealed class WeaponModulesSystem : EntitySystem
|
|||||||
|
|
||||||
private void SilencerModuleOnEject(EntityUid module, SilencerModuleComponent component, EntGotRemovedFromContainerMessage args)
|
private void SilencerModuleOnEject(EntityUid module, SilencerModuleComponent component, EntGotRemovedFromContainerMessage args)
|
||||||
{
|
{
|
||||||
if (ModulesSlot != args.Container.ID)
|
|
||||||
return;
|
|
||||||
|
|
||||||
EntityUid weapon = args.Container.Owner;
|
EntityUid weapon = args.Container.Owner;
|
||||||
if (!TryComp<WeaponModulesComponent>(weapon, out var weaponModulesComponent)) return;
|
|
||||||
|
|
||||||
if(weaponModulesComponent.Modules.Contains(module))
|
if(!TryEjectModule(module, weapon, args) || !TryComp<WeaponModulesComponent>(weapon, out var weaponModulesComponent))
|
||||||
weaponModulesComponent.Modules.Remove(module);
|
return;
|
||||||
|
|
||||||
if(!TryComp<AppearanceComponent>(weapon, out var appearanceComponent)) return;
|
if(!TryComp<AppearanceComponent>(weapon, out var appearanceComponent)) return;
|
||||||
|
|
||||||
@@ -217,14 +205,10 @@ public sealed class WeaponModulesSystem : EntitySystem
|
|||||||
|
|
||||||
private void AcceleratorModuleOnEject(EntityUid module, AcceleratorModuleComponent component, EntGotRemovedFromContainerMessage args)
|
private void AcceleratorModuleOnEject(EntityUid module, AcceleratorModuleComponent component, EntGotRemovedFromContainerMessage args)
|
||||||
{
|
{
|
||||||
if (ModulesSlot != args.Container.ID)
|
|
||||||
return;
|
|
||||||
|
|
||||||
EntityUid weapon = args.Container.Owner;
|
EntityUid weapon = args.Container.Owner;
|
||||||
if (!TryComp<WeaponModulesComponent>(weapon, out var weaponModulesComponent)) return;
|
|
||||||
|
|
||||||
if(weaponModulesComponent.Modules.Contains(module))
|
if(!TryEjectModule(module, weapon, args))
|
||||||
weaponModulesComponent.Modules.Remove(module);
|
return;
|
||||||
|
|
||||||
if(!TryComp<AppearanceComponent>(weapon, out var appearanceComponent)) return;
|
if(!TryComp<AppearanceComponent>(weapon, out var appearanceComponent)) return;
|
||||||
|
|
||||||
|
|||||||
@@ -18,6 +18,7 @@
|
|||||||
- id: BoxMindshield
|
- id: BoxMindshield
|
||||||
- id: ClothingOuterHardsuitWarden
|
- id: ClothingOuterHardsuitWarden
|
||||||
- id: OxygenTankFilled
|
- id: OxygenTankFilled
|
||||||
|
- id: LightModule
|
||||||
|
|
||||||
- type: entity
|
- type: entity
|
||||||
id: LockerWardenFilled
|
id: LockerWardenFilled
|
||||||
@@ -37,6 +38,7 @@
|
|||||||
- id: WeaponPistolMk58Nonlethal
|
- id: WeaponPistolMk58Nonlethal
|
||||||
- id: MagazinePistol
|
- id: MagazinePistol
|
||||||
- id: BoxMindshield
|
- id: BoxMindshield
|
||||||
|
- id: LightModule
|
||||||
|
|
||||||
- type: entity
|
- type: entity
|
||||||
id: LockerSecurityFilled
|
id: LockerSecurityFilled
|
||||||
@@ -66,6 +68,7 @@
|
|||||||
- id: WeaponPistolMk58Nonlethal
|
- id: WeaponPistolMk58Nonlethal
|
||||||
- id: SurveillanceBodyCamera
|
- id: SurveillanceBodyCamera
|
||||||
- id: MagazinePistol
|
- id: MagazinePistol
|
||||||
|
- id: LightModule
|
||||||
|
|
||||||
- type: entity
|
- type: entity
|
||||||
id: LockerBrigmedicFilled
|
id: LockerBrigmedicFilled
|
||||||
@@ -126,6 +129,7 @@
|
|||||||
- id: VoiceRecorder
|
- id: VoiceRecorder
|
||||||
- id: ClothingEyesGlassesSecurity
|
- id: ClothingEyesGlassesSecurity
|
||||||
- id: BoxZipLocks
|
- id: BoxZipLocks
|
||||||
|
- id: LightModule
|
||||||
|
|
||||||
- type: entity
|
- type: entity
|
||||||
id: ClosetBombFilled
|
id: ClosetBombFilled
|
||||||
|
|||||||
Reference in New Issue
Block a user