Starting implement deserialize migration

This commit is contained in:
Absolutely disgusting
2025-10-23 19:11:17 +04:00
parent 4d6aee63fb
commit c9c37113d3
7 changed files with 48 additions and 11 deletions
+28
View File
@@ -0,0 +1,28 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace _2DGAMELIB
{
public static class ObjExtensions
{
static readonly Dictionary<string, string> KeyMap = new()
{
["咳"] = "Cough"
};
public static void MigrateKeys(this Obj obj)
{
var newDict = new OrderedDictionary<string, Difs>();
foreach (var key in obj.Keys)
{
var newKey = KeyMap.TryGetValue(key, out var mapped) ? mapped : key;
newDict.Add(newKey, obj.Difss[key]);
}
obj.Difss = newDict;
}
}
}
+5 -4
View File
@@ -13,7 +13,6 @@ namespace _2DGAMELIB
private static double s0;
public static Color Reverse(this Color c)
{
return Color.FromArgb(c.A, 255 - c.R, 255 - c.G, 255 - c.B);
@@ -159,10 +158,12 @@ namespace _2DGAMELIB
public static Obj ObjLoad(this byte[] bd)
{
return bd.Load<byte[]>().ToDeserialObject<Obj>().SetDefaultR();
}
Obj obj = bd.Load<byte[]>().ToDeserialObject<Obj>().SetDefaultR();
return obj;
}
public static bool Lot(this double p)
public static bool Lot(this double p)
{
return RNG.XS.NextDouble() < p;
}
+5
View File
@@ -6,4 +6,9 @@
<PropertyGroup>
<ActiveDebugProfile>SlaveMatrix</ActiveDebugProfile>
</PropertyGroup>
<ItemGroup>
<EmbeddedResource Update="Properties\Resources.resx">
<SubType>Designer</SubType>
</EmbeddedResource>
</ItemGroup>
</Project>
@@ -2,7 +2,7 @@ using _2DGAMELIB;
namespace SlaveMatrix
{
public class 咳 : Ele
public class Cough : Ele
{
public Par X0Y0_咳基;
@@ -346,10 +346,10 @@ namespace SlaveMatrix
}
}
public 咳(double DisUnit, 配色指定 配色指定, 体配色 体配色, Med Med, 咳D e)
public Cough(double DisUnit, 配色指定 配色指定, 体配色 体配色, Med Med, 咳D e)
{
ThisType = GetType();
本体 = new Difs(Sta.胴体["咳"]);
本体 = new Difs(Sta.胴体["Cough"]);
Pars pars = 本体[0][0];
X0Y0_咳基 = pars["咳基"].ToPar();
X0Y0_雫1 = pars["雫1"].ToPar();
@@ -25,7 +25,7 @@ namespace SlaveMatrix
public override Ele GetEle(double DisUnit, Med Med, 体配色 体配色)
{
return new 咳(DisUnit, 配色指定, 体配色, Med, this);
return new Cough(DisUnit, 配色指定, 体配色, Med, this);
}
}
}
+2 -2
View File
@@ -120,7 +120,7 @@ namespace SlaveMatrix
public 性器精液_人 口精液;
public 咳 咳;
public Cough 咳;
public 呼気 呼気;
@@ -4009,7 +4009,7 @@ namespace SlaveMatrix
涎右.SetHitFalse();
口精液 = 頭.口_接続.GetEle<性器精液_人>();
口精液.SetHitFalse();
咳 = 頭.口_接続.GetEle<咳>();
咳 = 頭.口_接続.GetEle<Cough>();
咳.SetHitFalse();
呼気 = 頭.口_接続.GetEle<呼気>();
呼気.SetHitFalse();
+4 -1
View File
@@ -1084,7 +1084,10 @@ namespace SlaveMatrix
static Sta()
{
胴体 = Resources.胴体.ObjLoad();
var obj = Resources.胴体.ObjLoad();
obj.MigrateKeys();
胴体 = obj;
//胴体.SaveExMod("C:\\Users\\dave\\Documents\\胴体");
//Ser.ToJson(胴体, "C:\\Users\\dave\\Documents\\胴体.json");
//胴体 = Ser.UnJson<Obj>("C:\\Users\\dave\\Documents\\胴体.json");