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

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;
}
}
}

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,9 +158,11 @@ 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)
{
return RNG.XS.NextDouble() < p;

View File

@@ -6,4 +6,9 @@
<PropertyGroup>
<ActiveDebugProfile>SlaveMatrix</ActiveDebugProfile>
</PropertyGroup>
<ItemGroup>
<EmbeddedResource Update="Properties\Resources.resx">
<SubType>Designer</SubType>
</EmbeddedResource>
</ItemGroup>
</Project>

View File

@@ -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();

View File

@@ -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);
}
}
}

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();

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");