Alternative SpriteComponent.CopyFrom() fix (#3705)

This commit is contained in:
Leon Friedrich
2023-01-16 19:34:38 +13:00
committed by GitHub
parent 525e1d56c1
commit d79ad9717b
2 changed files with 14 additions and 9 deletions

View File

@@ -304,11 +304,8 @@ namespace Robust.Client.GameObjects
void ISerializationHooks.AfterDeserialization()
{
// Please somebody burn this to the ground
// Fix prototype reload trying to update tree on deserialization dummy instances.
if (!Owner.IsValid())
return;
// Please somebody burn this to the ground. There is so much spaghetti.
IoCManager.InjectDependencies(this);
{
@@ -1404,7 +1401,7 @@ namespace Robust.Client.GameObjects
private void QueueUpdateRenderTree()
{
if (TreeUpdateQueued || entities?.EventBus == null)
if (TreeUpdateQueued || !Owner.IsValid())
return;
// TODO whenever sprite comp gets ECS'd , just make this a direct method call.
@@ -1414,7 +1411,7 @@ namespace Robust.Client.GameObjects
private void QueueUpdateIsInert()
{
if (_inertUpdateQueued || entities?.EventBus == null)
if (_inertUpdateQueued || !Owner.IsValid())
return;
// TODO whenever sprite comp gets ECS'd , just make this a direct method call.

View File

@@ -1,4 +1,3 @@
using System;
using System.Collections.Generic;
using JetBrains.Annotations;
using Robust.Client.ComponentTrees;
@@ -21,7 +20,6 @@ namespace Robust.Client.GameObjects
[Dependency] private readonly IEyeManager _eyeManager = default!;
[Dependency] private readonly IConfigurationManager _cfg = default!;
[Dependency] private readonly SpriteTreeSystem _treeSystem = default!;
[Dependency] private readonly TransformSystem _transform = default!;
private readonly Queue<SpriteComponent> _inertUpdateQueue = new();
private HashSet<SpriteComponent> _manualUpdate = new();
@@ -34,9 +32,16 @@ namespace Robust.Client.GameObjects
_proto.PrototypesReloaded += OnPrototypesReloaded;
SubscribeLocalEvent<SpriteComponent, SpriteUpdateInertEvent>(QueueUpdateInert);
SubscribeLocalEvent<SpriteComponent, ComponentInit>(OnInit);
_cfg.OnValueChanged(CVars.RenderSpriteDirectionBias, OnBiasChanged, true);
}
private void OnInit(EntityUid uid, SpriteComponent component, ComponentInit args)
{
// I'm not 100% this is needed, but I CBF with this ATM. Somebody kill server sprite component please.
QueueUpdateInert(uid, component);
}
public override void Shutdown()
{
base.Shutdown();
@@ -50,6 +55,9 @@ namespace Robust.Client.GameObjects
}
private void QueueUpdateInert(EntityUid uid, SpriteComponent sprite, ref SpriteUpdateInertEvent ev)
=> QueueUpdateInert(uid, sprite);
public void QueueUpdateInert(EntityUid uid, SpriteComponent sprite)
{
if (sprite._inertUpdateQueued)
return;