internal static void Push(ModdedSaveData data) { foreach (var actorData in GetAllData(SceneContext.Instance.GameModel)) { foreach (CompoundDataPiece modPiece in actorData.Value.DataList) { var mod = SRModLoader.GetMod(modPiece.key); var seg = data.GetSegmentForMod(mod); var newCompound = new CompoundDataPiece("root"); foreach (var dat in modPiece.DataList) { newCompound.DataList.Add(dat); } seg.extendedData.Add(new ExtendedDataTree() { dataPiece = newCompound, longIdentifier = actorData.Key.longID, stringIdentifier = actorData.Key.stringID ?? "", idType = ExtendedDataTree.IdentifierType.ACTOR }); } } foreach (var pair in worldSaveData) { SaveRegistry.GetSaveInfo(pair.Key).WorldDataSave(pair.Value); if (pair.Value.DataList.Count > 0) { data.GetSegmentForMod(pair.Key).extendedWorldData = pair.Value; } } }
private static void PullAmmoData(ModdedSaveData data, Game game) { foreach (var ammo in AmmoDataUtils.GetAllAmmoData(game)) { var modsInThis = new HashSet <SRMod>(ammo.Select((x) => ModdedIDRegistry.IsModdedID(x.id) ? ModdedIDRegistry.ModForID(x.id) : null)); var belongingMod = AmmoIdentifier.TryGetIdentifier(ammo, game, out var id) ? AmmoIdentifier.GetModForIdentifier(id) : null; modsInThis.Add(belongingMod); modsInThis.Remove(null); foreach (var mod in modsInThis) { if (mod == null) { continue; } if (AmmoIdentifier.TryGetIdentifier(ammo, game, out var identifier)) { var segment = data.GetSegmentForMod(mod); segment.customAmmo[identifier] = AmmoDataUtils.RipOutWhere(ammo, (x) => mod == belongingMod?ModdedIDRegistry.ModForID(x.id) == null:ModdedIDRegistry.ModForID(x.id) == mod, false); } else { Debug.LogError("Unknown ammo identifier, skipping..."); } } } }
private static void PullTertiaryData(ModdedSaveData data, Game game) { foreach (var mod in ModPlayerData.FindAllModsWithData(game.player)) { var segment = data.GetSegmentForMod(mod); segment.playerData.Pull(game.player, mod); } PediaDataBuffer buf = new PediaDataBuffer(game.pedia); foreach (var mod in ModPediaData.FindAllModsWithData(buf)) { var segment = data.GetSegmentForMod(mod); segment.pediaData.Pull(buf, mod); } foreach (var mod in ModWorldData.FindAllModsWithData(game.world)) { var segment = data.GetSegmentForMod(mod); segment.worldData.Pull(game.world, mod); } }
internal static void Push(ModdedSaveData data) { foreach (var actorData in extendedActorData) { foreach (CompoundDataPiece modPiece in actorData.Value.DataList) { var mod = SRModLoader.GetMod(modPiece.key); var seg = data.GetSegmentForMod(mod); var newCompound = new CompoundDataPiece("root"); foreach (var dat in modPiece.DataList) { newCompound.DataList.Add(dat); } seg.extendedData.Add(new ExtendedDataTree() { dataPiece = newCompound, identifier = actorData.Key, idType = ExtendedDataTree.IdentifierType.ACTOR }); } } }
public static void PullModdedData(GameV09 game) { data.segments.Clear(); data.ammoDataEntries.Clear(); foreach (var actor in game.actors.Where((x) => SaveRegistry.IsCustom(x))) { var segment = data.GetSegmentForMod(SaveRegistry.ModForData(actor)); segment.identifiableData.Add(new IdentifiedData() { data = actor, dataID = new DataIdentifier() { longID = actor.actorId, stringID = "", Type = IdentifierType.ACTOR } }); } foreach (var gadget in game.world.placedGadgets.Where((x) => SaveRegistry.IsCustom(x.Value))) { var segment = data.GetSegmentForMod(SaveRegistry.ModForData(gadget.Value)); segment.identifiableData.Add(new IdentifiedData() { data = gadget.Value, dataID = new DataIdentifier() { longID = 0, stringID = gadget.Key, Type = IdentifierType.GADGET } }); } foreach (var mod in ModPlayerData.FindAllModsWithData(game.player)) { var segment = data.GetSegmentForMod(mod); segment.playerData.Pull(game.player, mod); } PediaDataBuffer buf = new PediaDataBuffer(game.pedia); foreach (var mod in ModPediaData.FindAllModsWithData(buf)) { var segment = data.GetSegmentForMod(mod); segment.pediaData.Pull(buf, mod); } foreach (var ammo in AmmoDataUtils.GetAllAmmoData(game).Where((x) => AmmoDataUtils.HasCustomData(x))) { var modsInThis = new HashSet <SRMod>(ammo.Select((x) => SaveRegistry.IsCustom(x.id) ? SaveRegistry.ModForID(x.id) : null)); modsInThis.Remove(null); foreach (var mod in modsInThis) { if (mod == null) { continue; } if (AmmoIdentifier.TryGetIdentifier(ammo, game, out var identifier)) { var segment = data.GetSegmentForMod(mod); segment.customAmmo[identifier] = AmmoDataUtils.RipOutWhere(ammo, (x) => SaveRegistry.ModForID(x.id) == mod, false); } else { throw new Exception("OH GOD ITS HAPPENING"); } } } ExtendedData.Push(data); PersistentAmmoManager.SyncAll(); PersistentAmmoManager.Push(data); }
private static void PullFullData(ModdedSaveData data, Game game) { foreach (var actor in game.actors.Where((x) => SaveRegistry.IsCustom(x))) { var segment = data.GetSegmentForMod(SaveRegistry.ModForData(actor)); segment.identifiableData.Add(new IdentifiedData() { data = actor, dataID = new DataIdentifier() { longID = actor.actorId, stringID = "", Type = IdentifierType.ACTOR } }); } foreach (var plot in game.ranch.plots.Where(x => ModdedStringRegistry.IsValidString(x.id) && (SaveRegistry.IsCustom(x) || ModdedStringRegistry.IsModdedString(x.id)))) { var segment = data.GetSegmentForMod(SaveRegistry.ModForData(plot) is SRMod mod ? mod : ModdedStringRegistry.GetModForModdedString(plot.id)); segment.identifiableData.Add(new IdentifiedData() { data = plot, dataID = new DataIdentifier() { longID = 0, stringID = plot.id, Type = IdentifierType.LANDPLOT } }); } void GetStringIndexedModdedData <T>(Dictionary <string, T> source, Func <KeyValuePair <string, T>, DataIdentifier> dataIdentifier) where T : PersistedDataSet { foreach (var pair in source.Where(x => ModdedStringRegistry.IsValidString(x.Key) && (SaveRegistry.IsCustom(x.Value) || ModdedStringRegistry.IsModdedString(x.Key)))) { var segment = data.GetSegmentForMod(SaveRegistry.ModForData(pair.Value) ?? ModdedStringRegistry.GetModForModdedString(pair.Key)); segment.identifiableData.Add(new IdentifiedData() { data = pair.Value, dataID = dataIdentifier(pair) }); } } GetStringIndexedModdedData(game.world.placedGadgets, (gadget) => new DataIdentifier() { longID = 0, stringID = gadget.Key, Type = IdentifierType.GADGET }); GetStringIndexedModdedData(game.world.gordos, (gordo) => new DataIdentifier() { longID = 0, stringID = gordo.Key, Type = IdentifierType.GORDO }); GetStringIndexedModdedData(game.world.treasurePods, (pod) => new DataIdentifier() { longID = 0, stringID = pod.Key, Type = IdentifierType.TREASUREPOD }); foreach (var v in game.world.offers.Where(x => ModdedIDRegistry.IsModdedID(x.Key) || ExchangeOfferRegistry.IsCustom(x.Value))) { var segment = data.GetSegmentForMod(SaveRegistry.ModForData(v.Value) ?? ExchangeOfferRegistry.GetModForData(v.Value)); segment.identifiableData.Add(new IdentifiedData() { data = v.Value, dataID = new DataIdentifier() { Type = IdentifierType.EXCHANGEOFFER, longID = (int)v.Key } }); } }