Fix anomaly vessels not generating points (#14137)
This commit is contained in:
parent
6b381f7304
commit
9ed3127ed5
|
|
@ -88,10 +88,7 @@ public sealed partial class AnomalySystem
|
|||
private void OnVesselGetPointsPerSecond(EntityUid uid, AnomalyVesselComponent component, ref ResearchServerGetPointsPerSecondEvent args)
|
||||
{
|
||||
if (!this.IsPowered(uid, EntityManager) || component.Anomaly is not {} anomaly)
|
||||
{
|
||||
args.Points = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
args.Points += (int) (GetAnomalyPointValue(anomaly) * component.PointMultiplier);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ public sealed partial class ResearchSystem
|
|||
{
|
||||
private void InitializeClient()
|
||||
{
|
||||
SubscribeLocalEvent<ResearchClientComponent, ComponentStartup>(OnClientStartup);
|
||||
SubscribeLocalEvent<ResearchClientComponent, MapInitEvent>(OnClientMapInit);
|
||||
SubscribeLocalEvent<ResearchClientComponent, ComponentShutdown>(OnClientShutdown);
|
||||
SubscribeLocalEvent<ResearchClientComponent, BoundUIOpenedEvent>(OnClientUIOpen);
|
||||
SubscribeLocalEvent<ResearchClientComponent, ConsoleServerSyncMessage>(OnConsoleSync);
|
||||
|
|
@ -26,12 +26,11 @@ public sealed partial class ResearchSystem
|
|||
|
||||
private void OnClientSelected(EntityUid uid, ResearchClientComponent component, ResearchClientServerSelectedMessage args)
|
||||
{
|
||||
var server = GetServerById(args.ServerId);
|
||||
if (server == null)
|
||||
if (!TryGetServerById(args.ServerId, out var serveruid, out var serverComponent))
|
||||
return;
|
||||
|
||||
UnregisterClient(uid, clientComponent: component);
|
||||
RegisterClient(uid, server.Owner, component, server);
|
||||
UnregisterClient(uid, component);
|
||||
RegisterClient(uid, serveruid.Value, component, serverComponent);
|
||||
}
|
||||
|
||||
private void OnClientDeselected(EntityUid uid, ResearchClientComponent component, ResearchClientServerDeselectedMessage args)
|
||||
|
|
@ -66,7 +65,7 @@ public sealed partial class ResearchSystem
|
|||
UpdateClientInterface(uid, component);
|
||||
}
|
||||
|
||||
private void OnClientStartup(EntityUid uid, ResearchClientComponent component, ComponentStartup args)
|
||||
private void OnClientMapInit(EntityUid uid, ResearchClientComponent component, MapInitEvent args)
|
||||
{
|
||||
var allServers = EntityQuery<ResearchServerComponent>(true).ToArray();
|
||||
if (allServers.Length > 0)
|
||||
|
|
|
|||
|
|
@ -140,7 +140,7 @@ public sealed partial class ResearchSystem
|
|||
if (!CanRun(uid))
|
||||
return points;
|
||||
|
||||
var ev = new ResearchServerGetPointsPerSecondEvent(component.Owner, points);
|
||||
var ev = new ResearchServerGetPointsPerSecondEvent(uid, points);
|
||||
foreach (var client in component.Clients)
|
||||
{
|
||||
RaiseLocalEvent(client, ref ev);
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
using Content.Shared.Research.Components;
|
||||
using Content.Shared.Research.Systems;
|
||||
|
|
@ -28,16 +29,22 @@ namespace Content.Server.Research.Systems
|
|||
/// Gets a server based on it's unique numeric id.
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <param name="serverUid"></param>
|
||||
/// <param name="serverComponent"></param>
|
||||
/// <returns></returns>
|
||||
public ResearchServerComponent? GetServerById(int id)
|
||||
public bool TryGetServerById(int id, [NotNullWhen(true)] out EntityUid? serverUid, [NotNullWhen(true)] out ResearchServerComponent? serverComponent)
|
||||
{
|
||||
serverUid = null;
|
||||
serverComponent = null;
|
||||
foreach (var server in EntityQuery<ResearchServerComponent>())
|
||||
{
|
||||
if (server.Id == id)
|
||||
return server;
|
||||
if (server.Id != id)
|
||||
continue;
|
||||
serverUid = server.Owner;
|
||||
serverComponent = server;
|
||||
return true;
|
||||
}
|
||||
|
||||
return null;
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
|
|||
Loading…
Reference in New Issue