mirror of
https://github.com/space-wizards/RobustToolbox.git
synced 2026-09-03 10:37:05 +02:00
* [Dependency] source generator No more reflection, no more codegen at runtime Also various changes to Roslyn helpers to make this easier to write. Requires all types with dependencies to be partial and not have readonly dependency fields. An analyzer enforces this at warning level, the previous injection strategies have remained in the code *for now* as a fallback. No fallback is available for [field: Dependency] properties, due to a Roslyn bug. Code Fixes exist. We love Roslyn * Apply dependencies generator changes to all code * Release notes * Preprocessor got hands * Handle nullable dependencies These are bad but gotta deal with it. * Apply suggestions from code review Co-authored-by: Moony <moony@hellomouse.net> * Fine, let's not use collection expressions --------- Co-authored-by: Moony <moony@hellomouse.net>
56 lines
1.4 KiB
C#
56 lines
1.4 KiB
C#
using System.Collections.Generic;
|
|
using Robust.Shared.GameObjects;
|
|
using Robust.Shared.IoC;
|
|
using Robust.Shared.Timing;
|
|
|
|
namespace Robust.Shared.Spawners;
|
|
|
|
public abstract partial class SharedTimedDespawnSystem : EntitySystem
|
|
{
|
|
[Dependency] private IGameTiming _timing = default!;
|
|
|
|
private readonly HashSet<EntityUid> _queuedDespawnEntities = new();
|
|
|
|
public override void Initialize()
|
|
{
|
|
base.Initialize();
|
|
UpdatesOutsidePrediction = true;
|
|
}
|
|
|
|
public override void Update(float frameTime)
|
|
{
|
|
base.Update(frameTime);
|
|
|
|
// AAAAAAAAAAAAAAAAAAAAAAAAAAA
|
|
// Client both needs to predict this, but also can't properly handle prediction resetting.
|
|
if (!_timing.IsFirstTimePredicted)
|
|
return;
|
|
|
|
_queuedDespawnEntities.Clear();
|
|
|
|
var query = EntityQueryEnumerator<TimedDespawnComponent>();
|
|
|
|
while (query.MoveNext(out var uid, out var comp))
|
|
{
|
|
comp.Lifetime -= frameTime;
|
|
|
|
if (!CanDelete(uid))
|
|
continue;
|
|
|
|
if (comp.Lifetime <= 0)
|
|
{
|
|
_queuedDespawnEntities.Add(uid);
|
|
}
|
|
}
|
|
|
|
foreach (var queued in _queuedDespawnEntities)
|
|
{
|
|
var ev = new TimedDespawnEvent();
|
|
RaiseLocalEvent(queued, ref ev);
|
|
QueueDel(queued);
|
|
}
|
|
}
|
|
|
|
protected abstract bool CanDelete(EntityUid uid);
|
|
}
|