private static IDChangePair DissolveBase <T>(string content, uint offset) where T : GameDataBlockBase <T> { try { var setting = GameDataSettingBase; var block = JsonConvert.DeserializeObject <T>(content, setting); if (GameDataBlockBase <T> .HasBlock(block.persistentID)) { throw new InvalidDataException($"Data already exist for ID: {block.persistentID} ({typeof(T).Name})"); } var change = new IDChangePair() { Previous = block.persistentID, New = offset }; block.persistentID = change.New; GameDataBlockBase <T> .AddBlock((T)block, -1); return(change); } catch (Exception e) { MelonLogger.Log(e.ToString()); return(default);
public void AddBlock(T block) { var existingBlock = GameDataBlockBase <T> .GetBlock(block.persistentID); if (existingBlock != null) { CopyProperties(block, existingBlock); Logger.Warning($"Replaced Block: {existingBlock.persistentID}, {existingBlock.name}"); return; } GameDataBlockBase <T> .AddBlock(block, -1); Logger.Log($"Added Block: {block.persistentID}, {block.name}"); }