Remove update from DeviceLinkSystem (#37152)
The tick updates were purely used to decrease the invoke counter once per tick. Now instead we just calculate the effective counter value with some trivial math on the tick number. This completely removes the need for an update function. The relative tick is not stored to map files. If we really need this, we can add a TickOffsetSerializer (similar to TimeOffsetSerializer), but I doubt it matters.
This commit is contained in:
committed by
GitHub
parent
e6040d1b25
commit
81cbb31425
@@ -20,23 +20,6 @@ public sealed class DeviceLinkSystem : SharedDeviceLinkSystem
|
||||
SubscribeLocalEvent<DeviceLinkSourceComponent, NewLinkEvent>(OnNewLink);
|
||||
}
|
||||
|
||||
public override void Update(float frameTime)
|
||||
{
|
||||
var query = EntityQueryEnumerator<DeviceLinkSinkComponent>();
|
||||
|
||||
while (query.MoveNext(out var component))
|
||||
{
|
||||
if (component.InvokeLimit < 1)
|
||||
{
|
||||
component.InvokeCounter = 0;
|
||||
continue;
|
||||
}
|
||||
|
||||
if(component.InvokeCounter > 0)
|
||||
component.InvokeCounter--;
|
||||
}
|
||||
}
|
||||
|
||||
#region Sending & Receiving
|
||||
public override void InvokePort(EntityUid uid, string port, NetworkPayload? data = null, DeviceLinkSourceComponent? sourceComponent = null)
|
||||
{
|
||||
@@ -67,16 +50,17 @@ public sealed class DeviceLinkSystem : SharedDeviceLinkSystem
|
||||
if (!Resolve(sink, ref sink.Comp))
|
||||
return;
|
||||
|
||||
if (sink.Comp.InvokeCounter > sink.Comp.InvokeLimit)
|
||||
var invokeCounter = GetEffectiveInvokeCounter(sink.Comp);
|
||||
if (invokeCounter > sink.Comp.InvokeLimit)
|
||||
{
|
||||
sink.Comp.InvokeCounter = 0;
|
||||
SetInvokeCounter(sink.Comp, 0);
|
||||
var args = new DeviceLinkOverloadedEvent();
|
||||
RaiseLocalEvent(sink, ref args);
|
||||
RemoveAllFromSink(sink, sink.Comp);
|
||||
return;
|
||||
}
|
||||
|
||||
sink.Comp.InvokeCounter++;
|
||||
SetInvokeCounter(sink.Comp, invokeCounter + 1);
|
||||
|
||||
//Just skip using device networking if the source or the sink doesn't support it
|
||||
if (!HasComp<DeviceNetworkComponent>(source) || !TryComp<DeviceNetworkComponent>(sink, out var sinkNetwork))
|
||||
|
||||
Reference in New Issue
Block a user