From 61dd9204d2570c16dd59aa34f606442594b16066 Mon Sep 17 00:00:00 2001 From: VMSolidus Date: Fri, 8 Nov 2024 15:00:31 -0500 Subject: [PATCH 1/2] Update TraitSystem.Functions.cs --- Content.Server/Traits/TraitSystem.Functions.cs | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/Content.Server/Traits/TraitSystem.Functions.cs b/Content.Server/Traits/TraitSystem.Functions.cs index 7cf02b6310a..c18e5923bb1 100644 --- a/Content.Server/Traits/TraitSystem.Functions.cs +++ b/Content.Server/Traits/TraitSystem.Functions.cs @@ -25,14 +25,11 @@ public override void OnPlayerSpawn(EntityUid uid, IEntityManager entityManager, ISerializationManager serializationManager) { - foreach (var (name, data) in Components) + foreach (var (_, data) in Components) { - var component = (Component) factory.GetComponent(name); - var temp = (object) component; - serializationManager.CopyTo(data.Component, ref temp); - entityManager.RemoveComponent(uid, temp!.GetType()); - entityManager.AddComponent(uid, (Component) temp, true); + var comp = (Component) serializationManager.CreateCopy(data.Component, notNullableOverride: true); + entityManager.AddComponent(uid, comp, true); } } } @@ -52,11 +49,13 @@ public override void OnPlayerSpawn(EntityUid uid, IEntityManager entityManager, ISerializationManager serializationManager) { - foreach (var (name, _) in Components) + foreach (var entry in Components.Values) { - var component = (Component) factory.GetComponent(name); + if (entityManager.HasComponent(uid, entry.Component.GetType())) + continue; - entityManager.AddComponent(uid, component, true); + var comp = (Component) serializationManager.CreateCopy(entry.Component, notNullableOverride: true); + entityManager.AddComponent(uid, comp, false); } } } From 07fd38b5f590316e0acd2c5534404e3044aeba32 Mon Sep 17 00:00:00 2001 From: VMSolidus Date: Fri, 8 Nov 2024 15:03:32 -0500 Subject: [PATCH 2/2] Update TraitSystem.Functions.cs --- Content.Server/Traits/TraitSystem.Functions.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Content.Server/Traits/TraitSystem.Functions.cs b/Content.Server/Traits/TraitSystem.Functions.cs index c18e5923bb1..528cb4f9183 100644 --- a/Content.Server/Traits/TraitSystem.Functions.cs +++ b/Content.Server/Traits/TraitSystem.Functions.cs @@ -27,8 +27,8 @@ public override void OnPlayerSpawn(EntityUid uid, { foreach (var (_, data) in Components) { - var comp = (Component) serializationManager.CreateCopy(data.Component, notNullableOverride: true); + comp.Owner = uid; entityManager.AddComponent(uid, comp, true); } } @@ -55,7 +55,8 @@ public override void OnPlayerSpawn(EntityUid uid, continue; var comp = (Component) serializationManager.CreateCopy(entry.Component, notNullableOverride: true); - entityManager.AddComponent(uid, comp, false); + comp.Owner = uid; + entityManager.AddComponent(uid, comp); } } }