Remove 700 usages of Component.Owner (#21100)
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
using Content.Server.Power.EntitySystems;
|
||||
using Content.Shared.Research.Components;
|
||||
using Robust.Server.Player;
|
||||
@@ -58,9 +57,15 @@ public sealed partial class ResearchSystem
|
||||
|
||||
private void OnClientMapInit(EntityUid uid, ResearchClientComponent component, MapInitEvent args)
|
||||
{
|
||||
var allServers = EntityQuery<ResearchServerComponent>(true).ToArray();
|
||||
if (allServers.Length > 0)
|
||||
RegisterClient(uid, allServers[0].Owner, component, allServers[0]);
|
||||
var allServers = new List<Entity<ResearchServerComponent>>();
|
||||
var query = AllEntityQuery<ResearchServerComponent>();
|
||||
while (query.MoveNext(out var serverUid, out var serverComp))
|
||||
{
|
||||
allServers.Add((serverUid, serverComp));
|
||||
}
|
||||
|
||||
if (allServers.Count > 0)
|
||||
RegisterClient(uid, allServers[0], component, allServers[0]);
|
||||
}
|
||||
|
||||
private void OnClientShutdown(EntityUid uid, ResearchClientComponent component, ComponentShutdown args)
|
||||
|
||||
@@ -11,14 +11,14 @@ public sealed partial class ResearchSystem
|
||||
SubscribeLocalEvent<ResearchPointSourceComponent, ResearchServerGetPointsPerSecondEvent>(OnGetPointsPerSecond);
|
||||
}
|
||||
|
||||
private void OnGetPointsPerSecond(EntityUid uid, ResearchPointSourceComponent component, ref ResearchServerGetPointsPerSecondEvent args)
|
||||
private void OnGetPointsPerSecond(Entity<ResearchPointSourceComponent> source, ref ResearchServerGetPointsPerSecondEvent args)
|
||||
{
|
||||
if (CanProduce(component))
|
||||
args.Points += component.PointsPerSecond;
|
||||
if (CanProduce(source))
|
||||
args.Points += source.Comp.PointsPerSecond;
|
||||
}
|
||||
|
||||
public bool CanProduce(ResearchPointSourceComponent component)
|
||||
public bool CanProduce(Entity<ResearchPointSourceComponent> source)
|
||||
{
|
||||
return component.Active && this.IsPowered(component.Owner, EntityManager);
|
||||
return source.Comp.Active && this.IsPowered(source, EntityManager);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -42,11 +42,13 @@ namespace Content.Server.Research.Systems
|
||||
{
|
||||
serverUid = null;
|
||||
serverComponent = null;
|
||||
foreach (var server in EntityQuery<ResearchServerComponent>())
|
||||
|
||||
var query = EntityQueryEnumerator<ResearchServerComponent>();
|
||||
while (query.MoveNext(out var uid, out var server))
|
||||
{
|
||||
if (server.Id != id)
|
||||
continue;
|
||||
serverUid = server.Owner;
|
||||
serverUid = uid;
|
||||
serverComponent = server;
|
||||
return true;
|
||||
}
|
||||
@@ -89,13 +91,14 @@ namespace Content.Server.Research.Systems
|
||||
|
||||
public override void Update(float frameTime)
|
||||
{
|
||||
foreach (var server in EntityQuery<ResearchServerComponent>())
|
||||
var query = EntityQueryEnumerator<ResearchServerComponent>();
|
||||
while (query.MoveNext(out var uid, out var server))
|
||||
{
|
||||
if (server.NextUpdateTime > _timing.CurTime)
|
||||
continue;
|
||||
server.NextUpdateTime = _timing.CurTime + server.ResearchConsoleUpdateTime;
|
||||
|
||||
UpdateServer(server.Owner, (int) server.ResearchConsoleUpdateTime.TotalSeconds, server);
|
||||
UpdateServer(uid, (int) server.ResearchConsoleUpdateTime.TotalSeconds, server);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user