fix: appvalue to basemodule
This commit is contained in:
@@ -33,27 +33,29 @@ public sealed class WeaponModulesSystem : EntitySystem
|
||||
SubscribeLocalEvent<AcceleratorModuleComponent, EntGotInsertedIntoContainerMessage>(AcceleratorModuleOnInsert);
|
||||
SubscribeLocalEvent<AcceleratorModuleComponent, EntGotRemovedFromContainerMessage>(AcceleratorModuleOnEject);
|
||||
}
|
||||
private bool TryInsertModule(EntityUid module, EntityUid weapon, EntGotInsertedIntoContainerMessage args)
|
||||
private bool TryInsertModule(EntityUid module, EntityUid weapon, EntGotInsertedIntoContainerMessage args, [NotNullWhen(true)] out WeaponModulesComponent? weaponModulesComponent)
|
||||
{
|
||||
if (TryComp<WeaponModulesComponent>(weapon, out var weaponModulesComponent) && ModulesSlot == args.Container.ID)
|
||||
if (TryComp<WeaponModulesComponent>(weapon, out var weaponModulesComponents) && ModulesSlot == args.Container.ID)
|
||||
{
|
||||
if(!weaponModulesComponent.Modules.Contains(module))
|
||||
weaponModulesComponent.Modules.Add(module);
|
||||
if(!weaponModulesComponents.Modules.Contains(module))
|
||||
weaponModulesComponents.Modules.Add(module);
|
||||
weaponModulesComponent = weaponModulesComponents;
|
||||
return true;
|
||||
}
|
||||
|
||||
weaponModulesComponent = weaponModulesComponents;
|
||||
return false;
|
||||
}
|
||||
|
||||
private bool TryEjectModule(EntityUid module, EntityUid weapon, EntGotRemovedFromContainerMessage args)
|
||||
private bool TryEjectModule(EntityUid module, EntityUid weapon, EntGotRemovedFromContainerMessage args, [NotNullWhen(true)] out WeaponModulesComponent? weaponModulesComponent)
|
||||
{
|
||||
if (TryComp<WeaponModulesComponent>(weapon, out var weaponModulesComponent) && ModulesSlot == args.Container.ID)
|
||||
if (TryComp<WeaponModulesComponent>(weapon, out var weaponModulesComponents) && ModulesSlot == args.Container.ID)
|
||||
{
|
||||
if(weaponModulesComponent.Modules.Contains(module))
|
||||
weaponModulesComponent.Modules.Remove(module);
|
||||
if(weaponModulesComponents.Modules.Contains(module))
|
||||
weaponModulesComponents.Modules.Remove(module);
|
||||
weaponModulesComponent = weaponModulesComponents;
|
||||
return true;
|
||||
}
|
||||
|
||||
weaponModulesComponent = weaponModulesComponents;
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -67,7 +69,7 @@ public sealed class WeaponModulesSystem : EntitySystem
|
||||
{
|
||||
EntityUid weapon = args.Container.Owner;
|
||||
|
||||
if(!TryInsertModule(module, weapon, args))
|
||||
if(!TryInsertModule(module, weapon, args, out var weaponModulesComponent))
|
||||
return;
|
||||
|
||||
if(!TryComp<AppearanceComponent>(weapon, out var appearanceComponent)) return;
|
||||
@@ -87,7 +89,7 @@ public sealed class WeaponModulesSystem : EntitySystem
|
||||
{
|
||||
EntityUid weapon = args.Container.Owner;
|
||||
|
||||
if(!TryInsertModule(module, weapon, args))
|
||||
if(!TryInsertModule(module, weapon, args, out var weaponModulesComponent))
|
||||
return;
|
||||
|
||||
if(!TryComp<AppearanceComponent>(weapon, out var appearanceComponent)) return;
|
||||
@@ -103,7 +105,7 @@ public sealed class WeaponModulesSystem : EntitySystem
|
||||
{
|
||||
EntityUid weapon = args.Container.Owner;
|
||||
|
||||
if(!TryInsertModule(module, weapon, args) || !TryComp<WeaponModulesComponent>(weapon, out var weaponModulesComponent))
|
||||
if(!TryInsertModule(module, weapon, args, out var weaponModulesComponent))
|
||||
return;
|
||||
|
||||
if(!TryComp<AppearanceComponent>(weapon, out var appearanceComponent)) return;
|
||||
@@ -117,7 +119,7 @@ public sealed class WeaponModulesSystem : EntitySystem
|
||||
{
|
||||
EntityUid weapon = args.Container.Owner;
|
||||
|
||||
if(!TryInsertModule(module, weapon, args) || !TryComp<WeaponModulesComponent>(weapon, out var weaponModulesComponent))
|
||||
if(!TryInsertModule(module, weapon, args, out var weaponModulesComponent))
|
||||
return;
|
||||
|
||||
if(!TryComp<AppearanceComponent>(weapon, out var appearanceComponent)) return;
|
||||
@@ -136,7 +138,7 @@ public sealed class WeaponModulesSystem : EntitySystem
|
||||
{
|
||||
EntityUid weapon = args.Container.Owner;
|
||||
|
||||
if(!TryInsertModule(module, weapon, args))
|
||||
if(!TryInsertModule(module, weapon, args, out var weaponModulesComponent))
|
||||
return;
|
||||
|
||||
if(!TryComp<AppearanceComponent>(weapon, out var appearanceComponent)) return;
|
||||
@@ -155,7 +157,7 @@ public sealed class WeaponModulesSystem : EntitySystem
|
||||
{
|
||||
EntityUid weapon = args.Container.Owner;
|
||||
|
||||
if(!TryEjectModule(module, weapon, args))
|
||||
if(!TryEjectModule(module, weapon, args, out var weaponModulesComponent))
|
||||
return;
|
||||
|
||||
if(!TryComp<AppearanceComponent>(weapon, out var appearanceComponent)) return;
|
||||
@@ -170,7 +172,7 @@ public sealed class WeaponModulesSystem : EntitySystem
|
||||
{
|
||||
EntityUid weapon = args.Container.Owner;
|
||||
|
||||
if(!TryEjectModule(module, weapon, args))
|
||||
if(!TryEjectModule(module, weapon, args, out var weaponModulesComponent))
|
||||
return;
|
||||
|
||||
if(!TryComp<AppearanceComponent>(weapon, out var appearanceComponent)) return;
|
||||
@@ -183,7 +185,7 @@ public sealed class WeaponModulesSystem : EntitySystem
|
||||
{
|
||||
EntityUid weapon = args.Container.Owner;
|
||||
|
||||
if(!TryEjectModule(module, weapon, args) || !TryComp<WeaponModulesComponent>(weapon, out var weaponModulesComponent))
|
||||
if(!TryEjectModule(module, weapon, args, out var weaponModulesComponent))
|
||||
return;
|
||||
|
||||
if(!TryComp<AppearanceComponent>(weapon, out var appearanceComponent)) return;
|
||||
@@ -197,7 +199,7 @@ public sealed class WeaponModulesSystem : EntitySystem
|
||||
{
|
||||
EntityUid weapon = args.Container.Owner;
|
||||
|
||||
if(!TryEjectModule(module, weapon, args) || !TryComp<WeaponModulesComponent>(weapon, out var weaponModulesComponent))
|
||||
if(!TryEjectModule(module, weapon, args, out var weaponModulesComponent))
|
||||
return;
|
||||
|
||||
if(!TryComp<AppearanceComponent>(weapon, out var appearanceComponent)) return;
|
||||
@@ -212,7 +214,7 @@ public sealed class WeaponModulesSystem : EntitySystem
|
||||
{
|
||||
EntityUid weapon = args.Container.Owner;
|
||||
|
||||
if(!TryEjectModule(module, weapon, args))
|
||||
if(!TryEjectModule(module, weapon, args, out var weaponModulesComponent))
|
||||
return;
|
||||
|
||||
if(!TryComp<AppearanceComponent>(weapon, out var appearanceComponent)) return;
|
||||
|
||||
@@ -8,7 +8,4 @@ public sealed partial class AcceleratorModuleComponent : BaseModuleComponent
|
||||
{
|
||||
[ViewVariables(VVAccess.ReadWrite), DataField]
|
||||
public float OldFireRate;
|
||||
|
||||
[ViewVariables(VVAccess.ReadWrite), DataField]
|
||||
public string AppearanceValue = "accelerator";
|
||||
}
|
||||
|
||||
@@ -6,4 +6,6 @@ namespace Content.Shared._White.WeaponModules;
|
||||
[RegisterComponent, NetworkedComponent]
|
||||
public partial class BaseModuleComponent : Component
|
||||
{
|
||||
[ViewVariables(VVAccess.ReadWrite), DataField("value")]
|
||||
public string AppearanceValue;
|
||||
}
|
||||
|
||||
@@ -6,6 +6,4 @@
|
||||
[RegisterComponent]
|
||||
public sealed partial class FlameHiderModuleComponent : BaseModuleComponent
|
||||
{
|
||||
[ViewVariables(VVAccess.ReadWrite), DataField]
|
||||
public string AppearanceValue = "flamehider";
|
||||
}
|
||||
|
||||
@@ -8,7 +8,4 @@ public sealed partial class LaserModuleComponent : BaseModuleComponent
|
||||
{
|
||||
[ViewVariables(VVAccess.ReadWrite), DataField]
|
||||
public float OldProjectileSpeed;
|
||||
|
||||
[ViewVariables(VVAccess.ReadWrite), DataField]
|
||||
public string AppearanceValue = "laser";
|
||||
}
|
||||
|
||||
@@ -8,7 +8,4 @@ public sealed partial class LightModuleComponent : BaseModuleComponent
|
||||
{
|
||||
[ViewVariables(VVAccess.ReadWrite), DataField]
|
||||
public bool Enabled;
|
||||
|
||||
[ViewVariables(VVAccess.ReadWrite), DataField]
|
||||
public string AppearanceValue = "light";
|
||||
}
|
||||
|
||||
@@ -13,7 +13,4 @@ public sealed partial class SilencerModuleComponent : BaseModuleComponent
|
||||
|
||||
[ViewVariables(VVAccess.ReadWrite), DataField]
|
||||
public SoundSpecifier NewSoundGunshot = new SoundPathSpecifier("/Audio/White/Weapons/Modules/silence.ogg");
|
||||
|
||||
[ViewVariables(VVAccess.ReadWrite), DataField]
|
||||
public string AppearanceValue = "silencer";
|
||||
}
|
||||
|
||||
@@ -29,6 +29,7 @@
|
||||
components:
|
||||
- type: Item
|
||||
- type: LightModule
|
||||
value: "light"
|
||||
- type: Sprite
|
||||
state: light
|
||||
- type: Appearance
|
||||
@@ -41,6 +42,7 @@
|
||||
components:
|
||||
- type: Item
|
||||
- type: LaserModule
|
||||
value: "laser"
|
||||
- type: Sprite
|
||||
state: laser
|
||||
- type: Appearance
|
||||
@@ -53,6 +55,7 @@
|
||||
components:
|
||||
- type: Item
|
||||
- type: FlameHiderModule
|
||||
value: "flamehider"
|
||||
- type: Sprite
|
||||
state: flamehider
|
||||
- type: Appearance
|
||||
@@ -65,6 +68,7 @@
|
||||
components:
|
||||
- type: Item
|
||||
- type: SilencerModule
|
||||
value: "silencer"
|
||||
- type: Sprite
|
||||
state: silencer
|
||||
- type: Appearance
|
||||
@@ -77,6 +81,7 @@
|
||||
components:
|
||||
- type: Item
|
||||
- type: AcceleratorModule
|
||||
value: "accelerator"
|
||||
- type: Sprite
|
||||
state: accelerator
|
||||
- type: Appearance
|
||||
Reference in New Issue
Block a user