Content fixes for timeoffsets (#15934)

This commit is contained in:
metalgearsloth
2023-05-01 14:49:25 +10:00
committed by GitHub
parent 2cf883b56a
commit d51d74d934
18 changed files with 53 additions and 63 deletions

View File

@@ -52,7 +52,7 @@ public abstract partial class SharedGunSystem : EntitySystem
[Dependency] protected readonly SharedAudioSystem Audio = default!;
[Dependency] private readonly SharedGravitySystem _gravity = default!;
[Dependency] protected readonly SharedProjectileSystem Projectiles = default!;
[Dependency] protected readonly SharedTransformSystem Transform = default!;
[Dependency] protected readonly SharedTransformSystem TransformSystem = default!;
protected ISawmill Sawmill = default!;
@@ -85,7 +85,7 @@ public abstract partial class SharedGunSystem : EntitySystem
SubscribeLocalEvent<GunComponent, GetVerbsEvent<AlternativeVerb>>(OnAltVerb);
SubscribeLocalEvent<GunComponent, ExaminedEvent>(OnExamine);
SubscribeLocalEvent<GunComponent, CycleModeEvent>(OnCycleMode);
SubscribeLocalEvent<GunComponent, ComponentInit>(OnGunInit);
SubscribeLocalEvent<GunComponent, EntityUnpausedEvent>(OnGunUnpaused);
#if DEBUG
SubscribeLocalEvent<GunComponent, MapInitEvent>(OnMapInit);
@@ -93,14 +93,16 @@ public abstract partial class SharedGunSystem : EntitySystem
private void OnMapInit(EntityUid uid, GunComponent component, MapInitEvent args)
{
if (component.NextFire > TimeSpan.Zero)
if (component.NextFire > Timing.CurTime)
Logger.Warning($"Initializing a map that contains an entity that is on cooldown. Entity: {ToPrettyString(uid)}");
DebugTools.Assert((component.AvailableModes & component.SelectedMode) != 0x0);
#endif
}
private void OnGunInit(EntityUid uid, GunComponent component, ComponentInit args)
private void OnGunUnpaused(EntityUid uid, GunComponent component, ref EntityUnpausedEvent args)
{
DebugTools.Assert((component.AvailableModes & component.SelectedMode) != 0x0);
component.NextFire += args.PausedTime;
}
private void OnGunMeleeAttempt(EntityUid uid, GunComponent component, ref MeleeAttackAttemptEvent args)
@@ -378,8 +380,8 @@ public abstract partial class SharedGunSystem : EntitySystem
public void CauseImpulse(EntityCoordinates fromCoordinates, EntityCoordinates toCoordinates, EntityUid user, PhysicsComponent userPhysics)
{
var fromMap = fromCoordinates.ToMapPos(EntityManager, Transform);
var toMap = toCoordinates.ToMapPos(EntityManager, Transform);
var fromMap = fromCoordinates.ToMapPos(EntityManager, TransformSystem);
var toMap = toCoordinates.ToMapPos(EntityManager, TransformSystem);
var shotDirection = (toMap - fromMap).Normalized;
const float impulseStrength = 25.0f;