feat: перенос лазеров-снарядов
This commit is contained in:
@@ -9,27 +9,33 @@ namespace Content.Shared.Weapons.Ranged.Components;
|
||||
public sealed partial class TwoModeEnergyAmmoProviderComponent : BatteryAmmoProviderComponent
|
||||
{
|
||||
[ViewVariables(VVAccess.ReadOnly),
|
||||
DataField("projProto", required: true, customTypeSerializer: typeof(PrototypeIdSerializer<EntityPrototype>))]
|
||||
public string ProjectilePrototype = default!;
|
||||
DataField("stunPrototype", required: true, customTypeSerializer: typeof(PrototypeIdSerializer<EntityPrototype>))]
|
||||
public string StunPrototype = default!;
|
||||
|
||||
[ViewVariables(VVAccess.ReadOnly),
|
||||
DataField("hitscanProto", required: true, customTypeSerializer: typeof(PrototypeIdSerializer<HitscanPrototype>))]
|
||||
public string HitscanPrototype = default!;
|
||||
DataField("laserPrototype", required: true, customTypeSerializer: typeof(PrototypeIdSerializer<EntityPrototype>))]
|
||||
public string LaserPrototype = default!;
|
||||
|
||||
[ViewVariables(VVAccess.ReadOnly), DataField("projFireCost")]
|
||||
public float ProjFireCost = 50;
|
||||
[ViewVariables(VVAccess.ReadOnly), DataField("stunFireCost")]
|
||||
public float StunFireCost = 142;
|
||||
|
||||
[ViewVariables(VVAccess.ReadOnly), DataField("hitscanFireCost")]
|
||||
public float HitscanFireCost = 100;
|
||||
[ViewVariables(VVAccess.ReadOnly), DataField("laserFireCost")]
|
||||
public float LaserFireCost = 65;
|
||||
|
||||
[ViewVariables(VVAccess.ReadOnly), DataField("stunProjectileSpeed")]
|
||||
public float StunProjectileSpeed = 12;
|
||||
|
||||
[ViewVariables(VVAccess.ReadOnly), DataField("laserProjectileSpeed")]
|
||||
public float LaserProjectileSpeed = 25;
|
||||
|
||||
[ViewVariables(VVAccess.ReadOnly), DataField("currentMode")]
|
||||
public EnergyModes CurrentMode { get; set; } = EnergyModes.Stun;
|
||||
|
||||
[ViewVariables(VVAccess.ReadOnly), DataField("projSound")]
|
||||
public SoundSpecifier? ProjSound = new SoundPathSpecifier("/Audio/Weapons/Guns/Gunshots/taser2.ogg");
|
||||
[ViewVariables(VVAccess.ReadOnly), DataField("stunSound")]
|
||||
public SoundSpecifier? StunSound = new SoundPathSpecifier("/Audio/Weapons/Guns/Gunshots/taser2.ogg");
|
||||
|
||||
[ViewVariables(VVAccess.ReadOnly), DataField("hitscanSound")]
|
||||
public SoundSpecifier? HitscanSound = new SoundPathSpecifier("/Audio/Weapons/Guns/Gunshots/laser_cannon.ogg");
|
||||
[ViewVariables(VVAccess.ReadOnly), DataField("laserSound")]
|
||||
public SoundSpecifier? LaserSound = new SoundPathSpecifier("/Audio/Weapons/Guns/Gunshots/laser_cannon.ogg");
|
||||
|
||||
public SoundSpecifier? ToggleSound = new SoundPathSpecifier("/Audio/Weapons/Guns/Misc/egun_toggle.ogg");
|
||||
|
||||
|
||||
@@ -38,15 +38,18 @@ public abstract partial class SharedGunSystem
|
||||
SubscribeLocalEvent<TwoModeEnergyAmmoProviderComponent, ExaminedEvent>(OnBatteryExamine);
|
||||
}
|
||||
|
||||
|
||||
private void OnTwoModeInit(EntityUid uid, TwoModeEnergyAmmoProviderComponent component, ComponentInit args)
|
||||
{
|
||||
if (!Timing.IsFirstTimePredicted || !TryComp<AppearanceComponent>(component.Owner, out var appearance)) return;
|
||||
if (!Timing.IsFirstTimePredicted || !TryComp<AppearanceComponent>(component.Owner, out var appearance))
|
||||
return;
|
||||
|
||||
Appearance.SetData(appearance.Owner, AmmoVisuals.InStun, component.InStun, appearance);
|
||||
}
|
||||
|
||||
private void OnBatteryTwoModeHandleState(EntityUid uid, TwoModeEnergyAmmoProviderComponent component, ref ComponentHandleState args)
|
||||
private void OnBatteryTwoModeHandleState(
|
||||
EntityUid uid,
|
||||
TwoModeEnergyAmmoProviderComponent component,
|
||||
ref ComponentHandleState args)
|
||||
{
|
||||
if (args.Current is not TwoModeComponentState state)
|
||||
return;
|
||||
@@ -58,7 +61,10 @@ public abstract partial class SharedGunSystem
|
||||
component.InStun = state.InStun;
|
||||
}
|
||||
|
||||
private void OnBatteryTwoModeGetState(EntityUid uid, TwoModeEnergyAmmoProviderComponent component, ref ComponentGetState args)
|
||||
private void OnBatteryTwoModeGetState(
|
||||
EntityUid uid,
|
||||
TwoModeEnergyAmmoProviderComponent component,
|
||||
ref ComponentGetState args)
|
||||
{
|
||||
args.State = new TwoModeComponentState()
|
||||
{
|
||||
@@ -74,19 +80,20 @@ public abstract partial class SharedGunSystem
|
||||
{
|
||||
if (!TryComp<AppearanceComponent>(uid, out var appearance))
|
||||
return;
|
||||
|
||||
if (!TryComp<ItemComponent>(uid, out var item))
|
||||
return;
|
||||
|
||||
if (component.InStun)
|
||||
_item.SetHeldPrefix(uid, null, false, item);
|
||||
else
|
||||
_item.SetHeldPrefix(uid, "laser", false, item);
|
||||
|
||||
_item.SetHeldPrefix(uid, component.InStun ? null : "laser", false, item);
|
||||
|
||||
Appearance.SetData(uid, AmmoVisuals.InStun, component.InStun, appearance);
|
||||
Dirty(uid, component);
|
||||
}
|
||||
|
||||
private void OnBatteryHandleState(EntityUid uid, BatteryAmmoProviderComponent component, ref ComponentHandleState args)
|
||||
private void OnBatteryHandleState(
|
||||
EntityUid uid,
|
||||
BatteryAmmoProviderComponent component,
|
||||
ref ComponentHandleState args)
|
||||
{
|
||||
if (args.Current is not BatteryAmmoProviderComponentState state)
|
||||
return;
|
||||
@@ -139,7 +146,7 @@ public abstract partial class SharedGunSystem
|
||||
/// <summary>
|
||||
/// Update the battery (server-only) whenever fired.
|
||||
/// </summary>
|
||||
protected virtual void TakeCharge(EntityUid uid, BatteryAmmoProviderComponent component) {}
|
||||
protected virtual void TakeCharge(EntityUid uid, BatteryAmmoProviderComponent component) { }
|
||||
|
||||
protected void UpdateBatteryAppearance(EntityUid uid, BatteryAmmoProviderComponent component)
|
||||
{
|
||||
@@ -151,7 +158,9 @@ public abstract partial class SharedGunSystem
|
||||
Appearance.SetData(uid, AmmoVisuals.AmmoMax, component.Capacity, appearance);
|
||||
}
|
||||
|
||||
private (EntityUid? Entity, IShootable) GetShootable(BatteryAmmoProviderComponent component, EntityCoordinates coordinates)
|
||||
private (EntityUid? Entity, IShootable) GetShootable(
|
||||
BatteryAmmoProviderComponent component,
|
||||
EntityCoordinates coordinates)
|
||||
{
|
||||
switch (component)
|
||||
{
|
||||
@@ -161,12 +170,13 @@ public abstract partial class SharedGunSystem
|
||||
case HitscanBatteryAmmoProviderComponent hitscan:
|
||||
return (null, ProtoManager.Index<HitscanPrototype>(hitscan.Prototype));
|
||||
case TwoModeEnergyAmmoProviderComponent twoMode:
|
||||
if (twoMode.CurrentMode == EnergyModes.Stun)
|
||||
{
|
||||
var projEnt = Spawn(twoMode.ProjectilePrototype, coordinates);
|
||||
return (projEnt, EnsureComp<AmmoComponent>(projEnt));
|
||||
}
|
||||
return (null, ProtoManager.Index<HitscanPrototype>(twoMode.HitscanPrototype));
|
||||
var projEntity =
|
||||
Spawn(twoMode.CurrentMode == EnergyModes.Stun
|
||||
? twoMode.StunPrototype
|
||||
: twoMode.LaserPrototype,
|
||||
coordinates);
|
||||
|
||||
return (projEntity, EnsureComp<AmmoComponent>(projEntity));
|
||||
default:
|
||||
throw new ArgumentOutOfRangeException();
|
||||
}
|
||||
@@ -184,6 +194,7 @@ public abstract partial class SharedGunSystem
|
||||
public sealed class TwoModeComponentState : ComponentState
|
||||
{
|
||||
public EnergyModes CurrentMode { get; init; }
|
||||
|
||||
public int Shots;
|
||||
public int MaxShots;
|
||||
public float FireCost;
|
||||
|
||||
Reference in New Issue
Block a user