Skip to content

Commit

Permalink
fucking containers strike again
Browse files Browse the repository at this point in the history
  • Loading branch information
ElectroJr committed Jan 17, 2025
1 parent 0f5e025 commit c508f7e
Showing 1 changed file with 16 additions and 6 deletions.
22 changes: 16 additions & 6 deletions Robust.Shared/EntitySerialization/EntityDeserializer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using System.Diagnostics.CodeAnalysis;
using System.Globalization;
using System.Linq;
using System.Runtime.Serialization;
using JetBrains.Annotations;
using Robust.Shared.EntitySerialization.Components;
using Robust.Shared.EntitySerialization.Systems;
Expand Down Expand Up @@ -630,9 +631,6 @@ private void LoadEntity(
// Finally, copy over the entity specific information
foreach (var (name, data) in _components)
{
if (proto != null && proto.Components.ContainsKey(name))
continue;

CurrentComponent = name;

var compReg = _factory.GetRegistration(name);
Expand All @@ -642,6 +640,19 @@ private void LoadEntity(
var newComponent = (IComponent) _seriMan.Read(compReg.Type, data, this)!;

// TODO ECS remove this when everything has been ECSd
if (newComponent is ISerializationHooks)
{
// Some components depend on Component.Owner being correctly set after serialization
// E.g., ContainerManagerComponent
// So we have this jank edge case.
// I hate this.
existing = _factory.GetComponent(compReg);
EntMan.AddComponent(uid, existing);
_seriMan.CopyTo(newComponent, ref existing, this, notNullableOverride: true);
continue;
}

// TODO ECS also remove this
_deps.InjectDependencies(newComponent);

EntMan.AddComponent(uid, newComponent);
Expand All @@ -650,9 +661,8 @@ private void LoadEntity(

// TODO ENTITY SERIALIZATION
// Copy directly into the existing object
// Not doing this yet, because its modifying the method significantly and I'm scared turning over this
// rock will reveal a lot of bugs. So leaving that to a future PR. I.e., creating "temp" here just
// unnecessarily slows everything down.
// I'm scared turning over this rock will reveal a lot of bugs. So leaving that to a future PR.
// I.e., creating "temp" here just unnecessarily slows everything down.
var temp = (IComponent) _seriMan.Read(compReg.Type, data, this)!;

_seriMan.CopyTo(temp, ref existing, this, notNullableOverride: true);
Expand Down

0 comments on commit c508f7e

Please sign in to comment.