Content fixes for timeoffsets (#15934)
This commit is contained in:
@@ -158,7 +158,7 @@ public sealed partial class GunSystem : SharedGunSystem
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Define target coordinates relative to gun entity, so that network latency on moving grids doesn't fuck up the target location.
|
// Define target coordinates relative to gun entity, so that network latency on moving grids doesn't fuck up the target location.
|
||||||
var coordinates = EntityCoordinates.FromMap(entity, mousePos, Transform, EntityManager);
|
var coordinates = EntityCoordinates.FromMap(entity, mousePos, TransformSystem, EntityManager);
|
||||||
|
|
||||||
Sawmill.Debug($"Sending shoot request tick {Timing.CurTick} / {Timing.CurTime}");
|
Sawmill.Debug($"Sending shoot request tick {Timing.CurTick} / {Timing.CurTime}");
|
||||||
|
|
||||||
@@ -175,7 +175,7 @@ public sealed partial class GunSystem : SharedGunSystem
|
|||||||
// Rather than splitting client / server for every ammo provider it's easier
|
// Rather than splitting client / server for every ammo provider it's easier
|
||||||
// to just delete the spawned entities. This is for programmer sanity despite the wasted perf.
|
// to just delete the spawned entities. This is for programmer sanity despite the wasted perf.
|
||||||
// This also means any ammo specific stuff can be grabbed as necessary.
|
// This also means any ammo specific stuff can be grabbed as necessary.
|
||||||
var direction = fromCoordinates.ToMapPos(EntityManager, Transform) - toCoordinates.ToMapPos(EntityManager, Transform);
|
var direction = fromCoordinates.ToMapPos(EntityManager, TransformSystem) - toCoordinates.ToMapPos(EntityManager, TransformSystem);
|
||||||
|
|
||||||
foreach (var (ent, shootable) in ammo)
|
foreach (var (ent, shootable) in ammo)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ using System.Collections.Generic;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Content.Shared.Coordinates;
|
using Content.Shared.Coordinates;
|
||||||
|
using Content.Shared.Sound.Components;
|
||||||
using NUnit.Framework;
|
using NUnit.Framework;
|
||||||
using Robust.Shared.GameObjects;
|
using Robust.Shared.GameObjects;
|
||||||
using Robust.Shared.IoC;
|
using Robust.Shared.IoC;
|
||||||
@@ -18,6 +19,7 @@ using Robust.Shared.Serialization.Markdown.Mapping;
|
|||||||
using Robust.Shared.Serialization.Markdown.Validation;
|
using Robust.Shared.Serialization.Markdown.Validation;
|
||||||
using Robust.Shared.Serialization.Markdown.Value;
|
using Robust.Shared.Serialization.Markdown.Value;
|
||||||
using Robust.Shared.Serialization.TypeSerializers.Interfaces;
|
using Robust.Shared.Serialization.TypeSerializers.Interfaces;
|
||||||
|
using Robust.Shared.Timing;
|
||||||
|
|
||||||
namespace Content.IntegrationTests.Tests;
|
namespace Content.IntegrationTests.Tests;
|
||||||
|
|
||||||
@@ -166,16 +168,19 @@ public sealed class PrototypeSaveTest
|
|||||||
foreach (var prototype in prototypes)
|
foreach (var prototype in prototypes)
|
||||||
{
|
{
|
||||||
uid = entityMan.SpawnEntity(prototype.ID, testLocation);
|
uid = entityMan.SpawnEntity(prototype.ID, testLocation);
|
||||||
server.RunTicks(1);
|
|
||||||
|
|
||||||
// get default prototype data
|
// get default prototype data
|
||||||
Dictionary<string, MappingDataNode> protoData = new();
|
Dictionary<string, MappingDataNode> protoData = new();
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
context.WritingReadingPrototypes = true;
|
||||||
|
|
||||||
foreach (var (compType, comp) in prototype.Components)
|
foreach (var (compType, comp) in prototype.Components)
|
||||||
{
|
{
|
||||||
protoData.Add(compType, seriMan.WriteValueAs<MappingDataNode>(comp.Component.GetType(), comp.Component, alwaysWrite:true, context: context));
|
protoData.Add(compType, seriMan.WriteValueAs<MappingDataNode>(comp.Component.GetType(), comp.Component, alwaysWrite: true, context: context));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
context.WritingReadingPrototypes = false;
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
@@ -239,6 +244,7 @@ public sealed class PrototypeSaveTest
|
|||||||
ITypeSerializer<EntityUid, ValueDataNode>
|
ITypeSerializer<EntityUid, ValueDataNode>
|
||||||
{
|
{
|
||||||
public SerializationManager.SerializerProvider SerializerProvider { get; }
|
public SerializationManager.SerializerProvider SerializerProvider { get; }
|
||||||
|
public bool WritingReadingPrototypes { get; set; }
|
||||||
|
|
||||||
public TestEntityUidContext()
|
public TestEntityUidContext()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -175,7 +175,9 @@ public sealed class TileAtmosCollectionSerializer : ITypeSerializer<Dictionary<V
|
|||||||
public readonly Dictionary<int, uint> Data = new();
|
public readonly Dictionary<int, uint> Data = new();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void CopyTo(ISerializationManager serializationManager, Dictionary<Vector2i, TileAtmosphere> source, ref Dictionary<Vector2i, TileAtmosphere> target, SerializationHookContext hookCtx,
|
public void CopyTo(ISerializationManager serializationManager, Dictionary<Vector2i, TileAtmosphere> source, ref Dictionary<Vector2i, TileAtmosphere> target,
|
||||||
|
IDependencyCollection dependencies,
|
||||||
|
SerializationHookContext hookCtx,
|
||||||
ISerializationContext? context = null)
|
ISerializationContext? context = null)
|
||||||
{
|
{
|
||||||
target.Clear();
|
target.Clear();
|
||||||
|
|||||||
@@ -21,5 +21,5 @@ public sealed class AutoRechargeComponent : Component
|
|||||||
/// The time when the next charge will be added
|
/// The time when the next charge will be added
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[DataField("nextChargeTime", customTypeSerializer: typeof(TimeOffsetSerializer))]
|
[DataField("nextChargeTime", customTypeSerializer: typeof(TimeOffsetSerializer))]
|
||||||
public TimeSpan NextChargeTime = TimeSpan.MaxValue;
|
public TimeSpan NextChargeTime;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,7 +15,6 @@ public sealed class SolutionPurgeSystem : EntitySystem
|
|||||||
base.Initialize();
|
base.Initialize();
|
||||||
|
|
||||||
SubscribeLocalEvent<SolutionPurgeComponent, EntityUnpausedEvent>(OnUnpaused);
|
SubscribeLocalEvent<SolutionPurgeComponent, EntityUnpausedEvent>(OnUnpaused);
|
||||||
SubscribeLocalEvent<SolutionPurgeComponent, MapInitEvent>(OnMapInit);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Update(float frameTime)
|
public override void Update(float frameTime)
|
||||||
@@ -39,10 +38,4 @@ public sealed class SolutionPurgeSystem : EntitySystem
|
|||||||
{
|
{
|
||||||
comp.NextPurgeTime += args.PausedTime;
|
comp.NextPurgeTime += args.PausedTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnMapInit(EntityUid uid, SolutionPurgeComponent comp, MapInitEvent args)
|
|
||||||
{
|
|
||||||
if (comp.NextPurgeTime < _timing.CurTime)
|
|
||||||
comp.NextPurgeTime = _timing.CurTime;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -45,7 +45,6 @@ public sealed class SmokeSystem : EntitySystem
|
|||||||
{
|
{
|
||||||
base.Initialize();
|
base.Initialize();
|
||||||
SubscribeLocalEvent<SmokeComponent, EntityUnpausedEvent>(OnSmokeUnpaused);
|
SubscribeLocalEvent<SmokeComponent, EntityUnpausedEvent>(OnSmokeUnpaused);
|
||||||
SubscribeLocalEvent<SmokeComponent, MapInitEvent>(OnSmokeMapInit);
|
|
||||||
SubscribeLocalEvent<SmokeComponent, ReactionAttemptEvent>(OnReactionAttempt);
|
SubscribeLocalEvent<SmokeComponent, ReactionAttemptEvent>(OnReactionAttempt);
|
||||||
SubscribeLocalEvent<SmokeComponent, SpreadNeighborsEvent>(OnSmokeSpread);
|
SubscribeLocalEvent<SmokeComponent, SpreadNeighborsEvent>(OnSmokeSpread);
|
||||||
SubscribeLocalEvent<SmokeDissipateSpawnComponent, TimedDespawnEvent>(OnSmokeDissipate);
|
SubscribeLocalEvent<SmokeDissipateSpawnComponent, TimedDespawnEvent>(OnSmokeDissipate);
|
||||||
@@ -166,11 +165,6 @@ public sealed class SmokeSystem : EntitySystem
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnSmokeMapInit(EntityUid uid, SmokeComponent component, MapInitEvent args)
|
|
||||||
{
|
|
||||||
component.NextReact = _timing.CurTime;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void OnSmokeUnpaused(EntityUid uid, SmokeComponent component, ref EntityUnpausedEvent args)
|
private void OnSmokeUnpaused(EntityUid uid, SmokeComponent component, ref EntityUnpausedEvent args)
|
||||||
{
|
{
|
||||||
component.NextReact += args.PausedTime;
|
component.NextReact += args.PausedTime;
|
||||||
|
|||||||
@@ -85,6 +85,7 @@ public sealed class NPCBlackboardSerializer : ITypeReader<NPCBlackboard, Mapping
|
|||||||
ISerializationManager serializationManager,
|
ISerializationManager serializationManager,
|
||||||
NPCBlackboard source,
|
NPCBlackboard source,
|
||||||
ref NPCBlackboard target,
|
ref NPCBlackboard target,
|
||||||
|
IDependencyCollection dependencies,
|
||||||
SerializationHookContext hookCtx,
|
SerializationHookContext hookCtx,
|
||||||
ISerializationContext? context = null)
|
ISerializationContext? context = null)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -22,7 +22,6 @@ public sealed class ProximityBeeperSystem : EntitySystem
|
|||||||
public override void Initialize()
|
public override void Initialize()
|
||||||
{
|
{
|
||||||
SubscribeLocalEvent<ProximityBeeperComponent, UseInHandEvent>(OnUseInHand);
|
SubscribeLocalEvent<ProximityBeeperComponent, UseInHandEvent>(OnUseInHand);
|
||||||
SubscribeLocalEvent<ProximityBeeperComponent, MapInitEvent>(OnInit);
|
|
||||||
SubscribeLocalEvent<ProximityBeeperComponent, EntityUnpausedEvent>(OnUnpaused);
|
SubscribeLocalEvent<ProximityBeeperComponent, EntityUnpausedEvent>(OnUnpaused);
|
||||||
SubscribeLocalEvent<ProximityBeeperComponent, PowerCellSlotEmptyEvent>(OnPowerCellSlotEmpty);
|
SubscribeLocalEvent<ProximityBeeperComponent, PowerCellSlotEmptyEvent>(OnPowerCellSlotEmpty);
|
||||||
}
|
}
|
||||||
@@ -34,12 +33,6 @@ public sealed class ProximityBeeperSystem : EntitySystem
|
|||||||
args.Handled = TryToggle(uid, component, args.User);
|
args.Handled = TryToggle(uid, component, args.User);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnInit(EntityUid uid, ProximityBeeperComponent component, MapInitEvent args)
|
|
||||||
{
|
|
||||||
if (component.NextBeepTime < _timing.CurTime)
|
|
||||||
component.NextBeepTime = _timing.CurTime;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void OnUnpaused(EntityUid uid, ProximityBeeperComponent component, ref EntityUnpausedEvent args)
|
private void OnUnpaused(EntityUid uid, ProximityBeeperComponent component, ref EntityUnpausedEvent args)
|
||||||
{
|
{
|
||||||
component.NextBeepTime += args.PausedTime;
|
component.NextBeepTime += args.PausedTime;
|
||||||
|
|||||||
@@ -42,7 +42,6 @@ public sealed class PowerCellSystem : SharedPowerCellSystem
|
|||||||
|
|
||||||
SubscribeLocalEvent<PowerCellComponent, ExaminedEvent>(OnCellExamined);
|
SubscribeLocalEvent<PowerCellComponent, ExaminedEvent>(OnCellExamined);
|
||||||
|
|
||||||
SubscribeLocalEvent<PowerCellDrawComponent, MapInitEvent>(OnMapInit);
|
|
||||||
SubscribeLocalEvent<PowerCellDrawComponent, EntityUnpausedEvent>(OnUnpaused);
|
SubscribeLocalEvent<PowerCellDrawComponent, EntityUnpausedEvent>(OnUnpaused);
|
||||||
|
|
||||||
// funny
|
// funny
|
||||||
@@ -136,12 +135,6 @@ public sealed class PowerCellSystem : SharedPowerCellSystem
|
|||||||
RaiseLocalEvent(uid, ref ev);
|
RaiseLocalEvent(uid, ref ev);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnMapInit(EntityUid uid, PowerCellDrawComponent component, MapInitEvent args)
|
|
||||||
{
|
|
||||||
if (component.NextUpdateTime < _timing.CurTime)
|
|
||||||
component.NextUpdateTime = _timing.CurTime;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void OnUnpaused(EntityUid uid, PowerCellDrawComponent component, ref EntityUnpausedEvent args)
|
private void OnUnpaused(EntityUid uid, PowerCellDrawComponent component, ref EntityUnpausedEvent args)
|
||||||
{
|
{
|
||||||
component.NextUpdateTime += args.PausedTime;
|
component.NextUpdateTime += args.PausedTime;
|
||||||
|
|||||||
@@ -44,7 +44,6 @@ public sealed class ThrusterSystem : EntitySystem
|
|||||||
SubscribeLocalEvent<ThrusterComponent, ActivateInWorldEvent>(OnActivateThruster);
|
SubscribeLocalEvent<ThrusterComponent, ActivateInWorldEvent>(OnActivateThruster);
|
||||||
SubscribeLocalEvent<ThrusterComponent, ComponentInit>(OnThrusterInit);
|
SubscribeLocalEvent<ThrusterComponent, ComponentInit>(OnThrusterInit);
|
||||||
SubscribeLocalEvent<ThrusterComponent, ComponentShutdown>(OnThrusterShutdown);
|
SubscribeLocalEvent<ThrusterComponent, ComponentShutdown>(OnThrusterShutdown);
|
||||||
SubscribeLocalEvent<ThrusterComponent, MapInitEvent>(OnThrusterMapInit);
|
|
||||||
SubscribeLocalEvent<ThrusterComponent, PowerChangedEvent>(OnPowerChange);
|
SubscribeLocalEvent<ThrusterComponent, PowerChangedEvent>(OnPowerChange);
|
||||||
SubscribeLocalEvent<ThrusterComponent, AnchorStateChangedEvent>(OnAnchorChange);
|
SubscribeLocalEvent<ThrusterComponent, AnchorStateChangedEvent>(OnAnchorChange);
|
||||||
SubscribeLocalEvent<ThrusterComponent, ReAnchorEvent>(OnThrusterReAnchor);
|
SubscribeLocalEvent<ThrusterComponent, ReAnchorEvent>(OnThrusterReAnchor);
|
||||||
@@ -201,12 +200,6 @@ public sealed class ThrusterSystem : EntitySystem
|
|||||||
EnableThruster(uid, component);
|
EnableThruster(uid, component);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnThrusterMapInit(EntityUid uid, ThrusterComponent component, MapInitEvent args)
|
|
||||||
{
|
|
||||||
if (component.NextFire < _timing.CurTime)
|
|
||||||
component.NextFire = _timing.CurTime;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void OnThrusterInit(EntityUid uid, ThrusterComponent component, ComponentInit args)
|
private void OnThrusterInit(EntityUid uid, ThrusterComponent component, ComponentInit args)
|
||||||
{
|
{
|
||||||
_ambient.SetAmbience(uid, false);
|
_ambient.SetAmbience(uid, false);
|
||||||
|
|||||||
@@ -36,7 +36,6 @@ public sealed class SpreaderSystem : EntitySystem
|
|||||||
{
|
{
|
||||||
SubscribeLocalEvent<AirtightChanged>(OnAirtightChanged);
|
SubscribeLocalEvent<AirtightChanged>(OnAirtightChanged);
|
||||||
SubscribeLocalEvent<GridInitializeEvent>(OnGridInit);
|
SubscribeLocalEvent<GridInitializeEvent>(OnGridInit);
|
||||||
SubscribeLocalEvent<SpreaderGridComponent, MapInitEvent>(OnSpreaderGridMapInit);
|
|
||||||
|
|
||||||
SubscribeLocalEvent<SpreaderGridComponent, EntityUnpausedEvent>(OnGridUnpaused);
|
SubscribeLocalEvent<SpreaderGridComponent, EntityUnpausedEvent>(OnGridUnpaused);
|
||||||
|
|
||||||
@@ -44,11 +43,6 @@ public sealed class SpreaderSystem : EntitySystem
|
|||||||
_prototype.PrototypesReloaded += OnPrototypeReload;
|
_prototype.PrototypesReloaded += OnPrototypeReload;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnSpreaderGridMapInit(EntityUid uid, SpreaderGridComponent component, MapInitEvent args)
|
|
||||||
{
|
|
||||||
component.NextUpdate = _timing.CurTime;
|
|
||||||
}
|
|
||||||
|
|
||||||
public override void Shutdown()
|
public override void Shutdown()
|
||||||
{
|
{
|
||||||
base.Shutdown();
|
base.Shutdown();
|
||||||
|
|||||||
@@ -93,8 +93,8 @@ public sealed partial class GunSystem : SharedGunSystem
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var fromMap = fromCoordinates.ToMap(EntityManager, Transform);
|
var fromMap = fromCoordinates.ToMap(EntityManager, TransformSystem);
|
||||||
var toMap = toCoordinates.ToMapPos(EntityManager, Transform);
|
var toMap = toCoordinates.ToMapPos(EntityManager, TransformSystem);
|
||||||
var mapDirection = toMap - fromMap.Position;
|
var mapDirection = toMap - fromMap.Position;
|
||||||
var mapAngle = mapDirection.ToAngle();
|
var mapAngle = mapDirection.ToAngle();
|
||||||
var angle = GetRecoilAngle(Timing.CurTime, gun, mapDirection.ToAngle());
|
var angle = GetRecoilAngle(Timing.CurTime, gun, mapDirection.ToAngle());
|
||||||
@@ -299,7 +299,7 @@ public sealed partial class GunSystem : SharedGunSystem
|
|||||||
Projectiles.SetShooter(projectile, user.Value);
|
Projectiles.SetShooter(projectile, user.Value);
|
||||||
}
|
}
|
||||||
|
|
||||||
Transform.SetWorldRotation(uid, direction.ToWorldAngle());
|
TransformSystem.SetWorldRotation(uid, direction.ToWorldAngle());
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -398,10 +398,10 @@ public sealed partial class GunSystem : SharedGunSystem
|
|||||||
|
|
||||||
if (xformQuery.TryGetComponent(gridUid, out var gridXform))
|
if (xformQuery.TryGetComponent(gridUid, out var gridXform))
|
||||||
{
|
{
|
||||||
var (_, gridRot, gridInvMatrix) = Transform.GetWorldPositionRotationInvMatrix(gridUid.Value, xformQuery);
|
var (_, gridRot, gridInvMatrix) = TransformSystem.GetWorldPositionRotationInvMatrix(gridUid.Value, xformQuery);
|
||||||
|
|
||||||
fromCoordinates = new EntityCoordinates(gridUid.Value,
|
fromCoordinates = new EntityCoordinates(gridUid.Value,
|
||||||
gridInvMatrix.Transform(fromCoordinates.ToMapPos(EntityManager, Transform)));
|
gridInvMatrix.Transform(fromCoordinates.ToMapPos(EntityManager, TransformSystem)));
|
||||||
|
|
||||||
// Use the fallback angle I guess?
|
// Use the fallback angle I guess?
|
||||||
angle -= gridRot;
|
angle -= gridRot;
|
||||||
|
|||||||
@@ -85,7 +85,7 @@ public sealed class AnomalyComponent : Component
|
|||||||
/// The time at which the next artifact pulse will occur.
|
/// The time at which the next artifact pulse will occur.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[DataField("nextPulseTime", customTypeSerializer: typeof(TimeOffsetSerializer)), ViewVariables(VVAccess.ReadWrite)]
|
[DataField("nextPulseTime", customTypeSerializer: typeof(TimeOffsetSerializer)), ViewVariables(VVAccess.ReadWrite)]
|
||||||
public TimeSpan NextPulseTime = TimeSpan.MaxValue;
|
public TimeSpan NextPulseTime = TimeSpan.Zero;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The minimum interval between pulses.
|
/// The minimum interval between pulses.
|
||||||
|
|||||||
@@ -41,6 +41,7 @@ public sealed class StaminaSystem : EntitySystem
|
|||||||
public override void Initialize()
|
public override void Initialize()
|
||||||
{
|
{
|
||||||
base.Initialize();
|
base.Initialize();
|
||||||
|
SubscribeLocalEvent<StaminaComponent, EntityUnpausedEvent>(OnStamUnpaused);
|
||||||
SubscribeLocalEvent<StaminaComponent, ComponentStartup>(OnStartup);
|
SubscribeLocalEvent<StaminaComponent, ComponentStartup>(OnStartup);
|
||||||
SubscribeLocalEvent<StaminaComponent, ComponentShutdown>(OnShutdown);
|
SubscribeLocalEvent<StaminaComponent, ComponentShutdown>(OnShutdown);
|
||||||
SubscribeLocalEvent<StaminaComponent, ComponentGetState>(OnStamGetState);
|
SubscribeLocalEvent<StaminaComponent, ComponentGetState>(OnStamGetState);
|
||||||
@@ -51,6 +52,11 @@ public sealed class StaminaSystem : EntitySystem
|
|||||||
SubscribeLocalEvent<StaminaDamageOnHitComponent, MeleeHitEvent>(OnHit);
|
SubscribeLocalEvent<StaminaDamageOnHitComponent, MeleeHitEvent>(OnHit);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void OnStamUnpaused(EntityUid uid, StaminaComponent component, ref EntityUnpausedEvent args)
|
||||||
|
{
|
||||||
|
component.NextUpdate += args.PausedTime;
|
||||||
|
}
|
||||||
|
|
||||||
private void OnStamGetState(EntityUid uid, StaminaComponent component, ref ComponentGetState args)
|
private void OnStamGetState(EntityUid uid, StaminaComponent component, ref ComponentGetState args)
|
||||||
{
|
{
|
||||||
args.State = new StaminaComponentState()
|
args.State = new StaminaComponentState()
|
||||||
@@ -206,7 +212,7 @@ public sealed class StaminaSystem : EntitySystem
|
|||||||
{
|
{
|
||||||
if (!args.OurFixture.ID.Equals(CollideFixture)) return;
|
if (!args.OurFixture.ID.Equals(CollideFixture)) return;
|
||||||
|
|
||||||
TakeStaminaDamage(args.OtherFixture.Body.Owner, component.Damage, source:args.OurFixture.Body.Owner);
|
TakeStaminaDamage(args.OtherEntity, component.Damage, source:args.OurEntity);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void SetStaminaAlert(EntityUid uid, StaminaComponent? component = null)
|
private void SetStaminaAlert(EntityUid uid, StaminaComponent? component = null)
|
||||||
|
|||||||
@@ -17,6 +17,6 @@ public sealed class EmitSoundOnCollideComponent : BaseEmitSoundComponent
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// To avoid sound spam add a cooldown to it.
|
/// To avoid sound spam add a cooldown to it.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[ViewVariables(VVAccess.ReadWrite), DataField("nextSound", customTypeSerializer:typeof(TimeOffsetSerializer))]
|
[ViewVariables(VVAccess.ReadWrite), DataField("nextSound", customTypeSerializer: typeof(TimeOffsetSerializer))]
|
||||||
public TimeSpan NextSound;
|
public TimeSpan NextSound = TimeSpan.FromSeconds(0.2);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -39,6 +39,8 @@ public abstract class SharedEmitSoundSystem : EntitySystem
|
|||||||
SubscribeLocalEvent<EmitSoundOnActivateComponent, ActivateInWorldEvent>(OnEmitSoundOnActivateInWorld);
|
SubscribeLocalEvent<EmitSoundOnActivateComponent, ActivateInWorldEvent>(OnEmitSoundOnActivateInWorld);
|
||||||
SubscribeLocalEvent<EmitSoundOnPickupComponent, GotEquippedHandEvent>(OnEmitSoundOnPickup);
|
SubscribeLocalEvent<EmitSoundOnPickupComponent, GotEquippedHandEvent>(OnEmitSoundOnPickup);
|
||||||
SubscribeLocalEvent<EmitSoundOnDropComponent, DroppedEvent>(OnEmitSoundOnDrop);
|
SubscribeLocalEvent<EmitSoundOnDropComponent, DroppedEvent>(OnEmitSoundOnDrop);
|
||||||
|
|
||||||
|
SubscribeLocalEvent<EmitSoundOnCollideComponent, EntityUnpausedEvent>(OnEmitSoundUnpaused);
|
||||||
SubscribeLocalEvent<EmitSoundOnCollideComponent, StartCollideEvent>(OnEmitSoundOnCollide);
|
SubscribeLocalEvent<EmitSoundOnCollideComponent, StartCollideEvent>(OnEmitSoundOnCollide);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -112,6 +114,11 @@ public abstract class SharedEmitSoundSystem : EntitySystem
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void OnEmitSoundUnpaused(EntityUid uid, EmitSoundOnCollideComponent component, ref EntityUnpausedEvent args)
|
||||||
|
{
|
||||||
|
component.NextSound += args.PausedTime;
|
||||||
|
}
|
||||||
|
|
||||||
private void OnEmitSoundOnCollide(EntityUid uid, EmitSoundOnCollideComponent component, ref StartCollideEvent args)
|
private void OnEmitSoundOnCollide(EntityUid uid, EmitSoundOnCollideComponent component, ref StartCollideEvent args)
|
||||||
{
|
{
|
||||||
if (!args.OurFixture.Hard ||
|
if (!args.OurFixture.Hard ||
|
||||||
|
|||||||
@@ -59,6 +59,7 @@ public abstract class SharedMeleeWeaponSystem : EntitySystem
|
|||||||
base.Initialize();
|
base.Initialize();
|
||||||
Sawmill = Logger.GetSawmill("melee");
|
Sawmill = Logger.GetSawmill("melee");
|
||||||
|
|
||||||
|
SubscribeLocalEvent<MeleeWeaponComponent, EntityUnpausedEvent>(OnMeleeUnpaused);
|
||||||
SubscribeLocalEvent<MeleeWeaponComponent, ComponentGetState>(OnGetState);
|
SubscribeLocalEvent<MeleeWeaponComponent, ComponentGetState>(OnGetState);
|
||||||
SubscribeLocalEvent<MeleeWeaponComponent, ComponentHandleState>(OnHandleState);
|
SubscribeLocalEvent<MeleeWeaponComponent, ComponentHandleState>(OnHandleState);
|
||||||
SubscribeLocalEvent<MeleeWeaponComponent, HandDeselectedEvent>(OnMeleeDropped);
|
SubscribeLocalEvent<MeleeWeaponComponent, HandDeselectedEvent>(OnMeleeDropped);
|
||||||
@@ -77,11 +78,16 @@ public abstract class SharedMeleeWeaponSystem : EntitySystem
|
|||||||
|
|
||||||
private void OnMapInit(EntityUid uid, MeleeWeaponComponent component, MapInitEvent args)
|
private void OnMapInit(EntityUid uid, MeleeWeaponComponent component, MapInitEvent args)
|
||||||
{
|
{
|
||||||
if (component.NextAttack > TimeSpan.Zero)
|
if (component.NextAttack > Timing.CurTime)
|
||||||
Logger.Warning($"Initializing a map that contains an entity that is on cooldown. Entity: {ToPrettyString(uid)}");
|
Logger.Warning($"Initializing a map that contains an entity that is on cooldown. Entity: {ToPrettyString(uid)}");
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void OnMeleeUnpaused(EntityUid uid, MeleeWeaponComponent component, ref EntityUnpausedEvent args)
|
||||||
|
{
|
||||||
|
component.NextAttack += args.PausedTime;
|
||||||
|
}
|
||||||
|
|
||||||
private void OnMeleeSelected(EntityUid uid, MeleeWeaponComponent component, HandSelectedEvent args)
|
private void OnMeleeSelected(EntityUid uid, MeleeWeaponComponent component, HandSelectedEvent args)
|
||||||
{
|
{
|
||||||
if (component.AttackRate.Equals(0f))
|
if (component.AttackRate.Equals(0f))
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ public abstract partial class SharedGunSystem : EntitySystem
|
|||||||
[Dependency] protected readonly SharedAudioSystem Audio = default!;
|
[Dependency] protected readonly SharedAudioSystem Audio = default!;
|
||||||
[Dependency] private readonly SharedGravitySystem _gravity = default!;
|
[Dependency] private readonly SharedGravitySystem _gravity = default!;
|
||||||
[Dependency] protected readonly SharedProjectileSystem Projectiles = default!;
|
[Dependency] protected readonly SharedProjectileSystem Projectiles = default!;
|
||||||
[Dependency] protected readonly SharedTransformSystem Transform = default!;
|
[Dependency] protected readonly SharedTransformSystem TransformSystem = default!;
|
||||||
|
|
||||||
protected ISawmill Sawmill = default!;
|
protected ISawmill Sawmill = default!;
|
||||||
|
|
||||||
@@ -85,7 +85,7 @@ public abstract partial class SharedGunSystem : EntitySystem
|
|||||||
SubscribeLocalEvent<GunComponent, GetVerbsEvent<AlternativeVerb>>(OnAltVerb);
|
SubscribeLocalEvent<GunComponent, GetVerbsEvent<AlternativeVerb>>(OnAltVerb);
|
||||||
SubscribeLocalEvent<GunComponent, ExaminedEvent>(OnExamine);
|
SubscribeLocalEvent<GunComponent, ExaminedEvent>(OnExamine);
|
||||||
SubscribeLocalEvent<GunComponent, CycleModeEvent>(OnCycleMode);
|
SubscribeLocalEvent<GunComponent, CycleModeEvent>(OnCycleMode);
|
||||||
SubscribeLocalEvent<GunComponent, ComponentInit>(OnGunInit);
|
SubscribeLocalEvent<GunComponent, EntityUnpausedEvent>(OnGunUnpaused);
|
||||||
|
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
SubscribeLocalEvent<GunComponent, MapInitEvent>(OnMapInit);
|
SubscribeLocalEvent<GunComponent, MapInitEvent>(OnMapInit);
|
||||||
@@ -93,14 +93,16 @@ public abstract partial class SharedGunSystem : EntitySystem
|
|||||||
|
|
||||||
private void OnMapInit(EntityUid uid, GunComponent component, MapInitEvent args)
|
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)}");
|
Logger.Warning($"Initializing a map that contains an entity that is on cooldown. Entity: {ToPrettyString(uid)}");
|
||||||
|
|
||||||
|
DebugTools.Assert((component.AvailableModes & component.SelectedMode) != 0x0);
|
||||||
#endif
|
#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)
|
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)
|
public void CauseImpulse(EntityCoordinates fromCoordinates, EntityCoordinates toCoordinates, EntityUid user, PhysicsComponent userPhysics)
|
||||||
{
|
{
|
||||||
var fromMap = fromCoordinates.ToMapPos(EntityManager, Transform);
|
var fromMap = fromCoordinates.ToMapPos(EntityManager, TransformSystem);
|
||||||
var toMap = toCoordinates.ToMapPos(EntityManager, Transform);
|
var toMap = toCoordinates.ToMapPos(EntityManager, TransformSystem);
|
||||||
var shotDirection = (toMap - fromMap).Normalized;
|
var shotDirection = (toMap - fromMap).Normalized;
|
||||||
|
|
||||||
const float impulseStrength = 25.0f;
|
const float impulseStrength = 25.0f;
|
||||||
|
|||||||
Reference in New Issue
Block a user