From fe3b681c66fc4c7cb87a40c6f2a4a902ba5981ba Mon Sep 17 00:00:00 2001 From: AbdulmanovAI Date: Wed, 29 Oct 2025 16:24:54 +0400 Subject: [PATCH 1/2] Load save fix --- SlaveMatrix/SlaveMatrix/GameClasses/EleD.cs | 25 ++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/SlaveMatrix/SlaveMatrix/GameClasses/EleD.cs b/SlaveMatrix/SlaveMatrix/GameClasses/EleD.cs index 0d2cc25..412084d 100644 --- a/SlaveMatrix/SlaveMatrix/GameClasses/EleD.cs +++ b/SlaveMatrix/SlaveMatrix/GameClasses/EleD.cs @@ -1,8 +1,9 @@ +using _2DGAMELIB; using System; using System.Collections.Generic; using System.Linq; using System.Reflection; -using _2DGAMELIB; +using System.Runtime.Serialization; namespace SlaveMatrix { @@ -73,11 +74,29 @@ namespace SlaveMatrix public double 濃度 = 1.0; - //TODO this broke loading saves + //TODO this broke loading saves [NonSerialized] public Type ThisType; - public virtual Ele GetEle(double DisUnit, Med Med, 体配色 体配色) + // Храним только имя типа (можно AQN) + [OptionalField] private string _thisTypeName; + + [OnSerializing] + private void OnSerializing(StreamingContext _) + { + _thisTypeName = ThisType?.AssemblyQualifiedName + ?? GetType().AssemblyQualifiedName; + } + + [OnDeserialized] + private void OnDeserialized(StreamingContext _) + { + ThisType = _thisTypeName != null + ? Type.GetType(_thisTypeName, throwOnError: false) ?? GetType() + : GetType(); + } + + public virtual Ele GetEle(double DisUnit, Med Med, 体配色 体配色) { return null; } From 00aa9998c758827ba3a9559187e6517ed4590b2f Mon Sep 17 00:00:00 2001 From: AbdulmanovAI Date: Wed, 29 Oct 2025 16:38:42 +0400 Subject: [PATCH 2/2] Simplify load fix --- SlaveMatrix/SlaveMatrix/GameClasses/EleD.cs | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/SlaveMatrix/SlaveMatrix/GameClasses/EleD.cs b/SlaveMatrix/SlaveMatrix/GameClasses/EleD.cs index 412084d..c487813 100644 --- a/SlaveMatrix/SlaveMatrix/GameClasses/EleD.cs +++ b/SlaveMatrix/SlaveMatrix/GameClasses/EleD.cs @@ -78,23 +78,15 @@ namespace SlaveMatrix [NonSerialized] public Type ThisType; - // Храним только имя типа (можно AQN) - [OptionalField] private string _thisTypeName; + //Some how fixes saves (thx GPT) - [OnSerializing] - private void OnSerializing(StreamingContext _) - { - _thisTypeName = ThisType?.AssemblyQualifiedName - ?? GetType().AssemblyQualifiedName; - } + //So how I am understend it (description) + //This Type is empty on deserialization because Type is not serializable + //We need just init it after deserialization [OnDeserialized] - private void OnDeserialized(StreamingContext _) - { - ThisType = _thisTypeName != null - ? Type.GetType(_thisTypeName, throwOnError: false) ?? GetType() - : GetType(); - } + private void OnDeserialized(StreamingContext _) => ThisType = GetType(); + public virtual Ele GetEle(double DisUnit, Med Med, 体配色 体配色) {