Fix weapon cooldown serialization while mapping (#15123)
This commit is contained in:
@@ -53,7 +53,7 @@ namespace Content.Server.Abilities.Mime
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// How long it takes the mime to get their powers back
|
/// How long it takes the mime to get their powers back
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[DataField("vowCooldown", customTypeSerializer: typeof(TimeOffsetSerializer))]
|
[DataField("vowCooldown")]
|
||||||
public TimeSpan VowCooldown = TimeSpan.FromMinutes(5);
|
public TimeSpan VowCooldown = TimeSpan.FromMinutes(5);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -55,7 +55,7 @@ public sealed class MaterialStorageComponent : Component
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// How long the inserting animation will play
|
/// How long the inserting animation will play
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[DataField("insertionTime", customTypeSerializer: typeof(TimeOffsetSerializer))]
|
[DataField("insertionTime")]
|
||||||
public TimeSpan InsertionTime = TimeSpan.FromSeconds(0.79f); // 0.01 off for animation timing
|
public TimeSpan InsertionTime = TimeSpan.FromSeconds(0.79f); // 0.01 off for animation timing
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -70,6 +70,16 @@ public abstract class SharedMeleeWeaponSystem : EntitySystem
|
|||||||
SubscribeAllEvent<HeavyAttackEvent>(OnHeavyAttack);
|
SubscribeAllEvent<HeavyAttackEvent>(OnHeavyAttack);
|
||||||
SubscribeAllEvent<DisarmAttackEvent>(OnDisarmAttack);
|
SubscribeAllEvent<DisarmAttackEvent>(OnDisarmAttack);
|
||||||
SubscribeAllEvent<StopAttackEvent>(OnStopAttack);
|
SubscribeAllEvent<StopAttackEvent>(OnStopAttack);
|
||||||
|
|
||||||
|
#if DEBUG
|
||||||
|
SubscribeLocalEvent<MeleeWeaponComponent, MapInitEvent>(OnMapInit);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnMapInit(EntityUid uid, MeleeWeaponComponent component, MapInitEvent args)
|
||||||
|
{
|
||||||
|
if (component.NextAttack > TimeSpan.Zero)
|
||||||
|
Logger.Warning($"Initializing a map that contains an entity that is on cooldown. Entity: {ToPrettyString(uid)}");
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnMeleeSelected(EntityUid uid, MeleeWeaponComponent component, HandSelectedEvent args)
|
private void OnMeleeSelected(EntityUid uid, MeleeWeaponComponent component, HandSelectedEvent args)
|
||||||
@@ -80,6 +90,9 @@ public abstract class SharedMeleeWeaponSystem : EntitySystem
|
|||||||
if (!component.ResetOnHandSelected)
|
if (!component.ResetOnHandSelected)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
if (Paused(uid))
|
||||||
|
return;
|
||||||
|
|
||||||
// If someone swaps to this weapon then reset its cd.
|
// If someone swaps to this weapon then reset its cd.
|
||||||
var curTime = Timing.CurTime;
|
var curTime = Timing.CurTime;
|
||||||
var minimum = curTime + TimeSpan.FromSeconds(1 / component.AttackRate);
|
var minimum = curTime + TimeSpan.FromSeconds(1 / component.AttackRate);
|
||||||
|
|||||||
@@ -152,7 +152,8 @@ public abstract partial class SharedGunSystem
|
|||||||
{
|
{
|
||||||
// Reset shotting for cycling
|
// Reset shotting for cycling
|
||||||
if (Resolve(uid, ref gunComp, false) &&
|
if (Resolve(uid, ref gunComp, false) &&
|
||||||
gunComp is { FireRate: > 0f })
|
gunComp is { FireRate: > 0f } &&
|
||||||
|
!Paused(uid))
|
||||||
{
|
{
|
||||||
gunComp.NextFire = Timing.CurTime + TimeSpan.FromSeconds(1 / gunComp.FireRate);
|
gunComp.NextFire = Timing.CurTime + TimeSpan.FromSeconds(1 / gunComp.FireRate);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -64,13 +64,17 @@ public abstract partial class SharedGunSystem
|
|||||||
|
|
||||||
DebugTools.Assert((component.AvailableModes & fire) != 0x0);
|
DebugTools.Assert((component.AvailableModes & fire) != 0x0);
|
||||||
component.SelectedMode = fire;
|
component.SelectedMode = fire;
|
||||||
var curTime = Timing.CurTime;
|
|
||||||
var cooldown = TimeSpan.FromSeconds(InteractNextFire);
|
|
||||||
|
|
||||||
if (component.NextFire < curTime)
|
if (!Paused(uid))
|
||||||
component.NextFire = curTime + cooldown;
|
{
|
||||||
else
|
var curTime = Timing.CurTime;
|
||||||
component.NextFire += cooldown;
|
var cooldown = TimeSpan.FromSeconds(InteractNextFire);
|
||||||
|
|
||||||
|
if (component.NextFire < curTime)
|
||||||
|
component.NextFire = curTime + cooldown;
|
||||||
|
else
|
||||||
|
component.NextFire += cooldown;
|
||||||
|
}
|
||||||
|
|
||||||
Audio.PlayPredicted(component.SoundModeToggle, uid, user);
|
Audio.PlayPredicted(component.SoundModeToggle, uid, user);
|
||||||
Popup(Loc.GetString("gun-selected-mode", ("mode", GetLocSelector(fire))), uid, user);
|
Popup(Loc.GetString("gun-selected-mode", ("mode", GetLocSelector(fire))), uid, user);
|
||||||
|
|||||||
@@ -88,6 +88,16 @@ public abstract partial class SharedGunSystem : EntitySystem
|
|||||||
SubscribeLocalEvent<GunComponent, ExaminedEvent>(OnExamine);
|
SubscribeLocalEvent<GunComponent, ExaminedEvent>(OnExamine);
|
||||||
SubscribeLocalEvent<GunComponent, CycleModeEvent>(OnCycleMode);
|
SubscribeLocalEvent<GunComponent, CycleModeEvent>(OnCycleMode);
|
||||||
SubscribeLocalEvent<GunComponent, ComponentInit>(OnGunInit);
|
SubscribeLocalEvent<GunComponent, ComponentInit>(OnGunInit);
|
||||||
|
|
||||||
|
#if DEBUG
|
||||||
|
SubscribeLocalEvent<GunComponent, MapInitEvent>(OnMapInit);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnMapInit(EntityUid uid, GunComponent component, MapInitEvent args)
|
||||||
|
{
|
||||||
|
if (component.NextFire > TimeSpan.Zero)
|
||||||
|
Logger.Warning($"Initializing a map that contains an entity that is on cooldown. Entity: {ToPrettyString(uid)}");
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnGunInit(EntityUid uid, GunComponent component, ComponentInit args)
|
private void OnGunInit(EntityUid uid, GunComponent component, ComponentInit args)
|
||||||
|
|||||||
@@ -1055,8 +1055,6 @@ entities:
|
|||||||
- pos: -2.172831,4.5306726
|
- pos: -2.172831,4.5306726
|
||||||
parent: 179
|
parent: 179
|
||||||
type: Transform
|
type: Transform
|
||||||
- nextAttack: 384.7724706
|
|
||||||
type: MeleeWeapon
|
|
||||||
- uid: 148
|
- uid: 148
|
||||||
type: Ointment
|
type: Ointment
|
||||||
components:
|
components:
|
||||||
@@ -1687,8 +1685,6 @@ entities:
|
|||||||
- pos: -3.4579864,-1.9811735
|
- pos: -3.4579864,-1.9811735
|
||||||
parent: 179
|
parent: 179
|
||||||
type: Transform
|
type: Transform
|
||||||
- nextAttack: 582.1216812
|
|
||||||
type: MeleeWeapon
|
|
||||||
- uid: 186
|
- uid: 186
|
||||||
type: PowerCellMedium
|
type: PowerCellMedium
|
||||||
components:
|
components:
|
||||||
@@ -2617,16 +2613,12 @@ entities:
|
|||||||
- pos: -0.11783123,4.753312
|
- pos: -0.11783123,4.753312
|
||||||
parent: 179
|
parent: 179
|
||||||
type: Transform
|
type: Transform
|
||||||
- nextAttack: 244.2972008
|
|
||||||
type: MeleeWeapon
|
|
||||||
- uid: 328
|
- uid: 328
|
||||||
type: MopItem
|
type: MopItem
|
||||||
components:
|
components:
|
||||||
- pos: 7.6382103,16.08618
|
- pos: 7.6382103,16.08618
|
||||||
parent: 179
|
parent: 179
|
||||||
type: Transform
|
type: Transform
|
||||||
- nextAttack: 3088.5283222
|
|
||||||
type: MeleeWeapon
|
|
||||||
- solutions:
|
- solutions:
|
||||||
absorbed:
|
absorbed:
|
||||||
temperature: 293.15
|
temperature: 293.15
|
||||||
@@ -2728,8 +2720,6 @@ entities:
|
|||||||
- pos: 0.6895334,4.7183027
|
- pos: 0.6895334,4.7183027
|
||||||
parent: 179
|
parent: 179
|
||||||
type: Transform
|
type: Transform
|
||||||
- nextAttack: 247.8805212
|
|
||||||
type: MeleeWeapon
|
|
||||||
- uid: 344
|
- uid: 344
|
||||||
type: ClothingHeadHatWelding
|
type: ClothingHeadHatWelding
|
||||||
components:
|
components:
|
||||||
@@ -2838,8 +2828,6 @@ entities:
|
|||||||
- pos: -1.6207478,4.3951616
|
- pos: -1.6207478,4.3951616
|
||||||
parent: 179
|
parent: 179
|
||||||
type: Transform
|
type: Transform
|
||||||
- nextAttack: 232.4472496
|
|
||||||
type: MeleeWeapon
|
|
||||||
- uid: 360
|
- uid: 360
|
||||||
type: PowerCellMedium
|
type: PowerCellMedium
|
||||||
components:
|
components:
|
||||||
@@ -2973,8 +2961,6 @@ entities:
|
|||||||
- pos: -3.277628,-2.15838
|
- pos: -3.277628,-2.15838
|
||||||
parent: 179
|
parent: 179
|
||||||
type: Transform
|
type: Transform
|
||||||
- nextAttack: 578.7883598
|
|
||||||
type: MeleeWeapon
|
|
||||||
- uid: 382
|
- uid: 382
|
||||||
type: SheetSteel
|
type: SheetSteel
|
||||||
components:
|
components:
|
||||||
@@ -3357,8 +3343,6 @@ entities:
|
|||||||
- pos: -1.235331,4.739151
|
- pos: -1.235331,4.739151
|
||||||
parent: 179
|
parent: 179
|
||||||
type: Transform
|
type: Transform
|
||||||
- nextAttack: 385.5557994
|
|
||||||
type: MeleeWeapon
|
|
||||||
- uid: 432
|
- uid: 432
|
||||||
type: ChemicalPayload
|
type: ChemicalPayload
|
||||||
components:
|
components:
|
||||||
@@ -3377,8 +3361,6 @@ entities:
|
|||||||
- pos: -3.1734612,-2.6066077
|
- pos: -3.1734612,-2.6066077
|
||||||
parent: 179
|
parent: 179
|
||||||
type: Transform
|
type: Transform
|
||||||
- nextAttack: 577.9550312
|
|
||||||
type: MeleeWeapon
|
|
||||||
- uid: 435
|
- uid: 435
|
||||||
type: ModularGrenade
|
type: ModularGrenade
|
||||||
components:
|
components:
|
||||||
@@ -5099,8 +5081,6 @@ entities:
|
|||||||
- pos: 1.1246341,7.500063
|
- pos: 1.1246341,7.500063
|
||||||
parent: 179
|
parent: 179
|
||||||
type: Transform
|
type: Transform
|
||||||
- nextAttack: 669.0197422
|
|
||||||
type: MeleeWeapon
|
|
||||||
- uid: 673
|
- uid: 673
|
||||||
type: Poweredlight
|
type: Poweredlight
|
||||||
components:
|
components:
|
||||||
@@ -7191,13 +7171,11 @@ entities:
|
|||||||
parent: 179
|
parent: 179
|
||||||
type: Transform
|
type: Transform
|
||||||
- uid: 956
|
- uid: 956
|
||||||
type: EmergencyOxygenTank
|
type: EmergencyOxygenTankFilled
|
||||||
components:
|
components:
|
||||||
- pos: -10.505015,6.711994
|
- pos: -10.505015,6.711994
|
||||||
parent: 179
|
parent: 179
|
||||||
type: Transform
|
type: Transform
|
||||||
- nextAttack: 396.1132382
|
|
||||||
type: MeleeWeapon
|
|
||||||
- uid: 957
|
- uid: 957
|
||||||
type: AlwaysPoweredLightLED
|
type: AlwaysPoweredLightLED
|
||||||
components:
|
components:
|
||||||
|
|||||||
Reference in New Issue
Block a user