Skip to content

Commit

Permalink
Add BymlObject for keeping original parameters intact during serializ…
Browse files Browse the repository at this point in the history
…ation
  • Loading branch information
KillzXGaming committed Nov 11, 2023
1 parent 199ffdc commit 270a301
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions Fushigi.Byml/Serializer/BymlObject.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Fushigi.Byml.Serializer
{
internal class BymlObject
{
public BymlHashTable HashTable;

public BymlObject(BymlHashTable bymlHashTable) {
this.HashTable = bymlHashTable;
}

public void Deserialize()
{
BymlSerialize.Deserialize(this, HashTable);
}

public void Serialize()
{
var hashTable = BymlSerialize.Serialize(this);
//Merge hash tables. Keep original params intact
foreach (var pair in hashTable.Pairs)
{
//Update or add any hash table params
if (HashTable.ContainsKey(pair.Name))
HashTable.SetNode(pair.Name, pair.Value);
else
HashTable.AddNode(pair.Id, pair.Value, pair.Name);
}
}
}
}

0 comments on commit 270a301

Please sign in to comment.