Exemplo n.º 1
0
        internal static void Pull(ModdedSaveData data)
        {
            extendedActorData.Clear();
            foreach (var mod in data.segments)
            {
                Debug.Log($"mod {mod.modid} has {mod.extendedData.Count} extended actor datas");
                foreach (var extendedDataTree in mod.extendedData)
                {
                    switch (extendedDataTree.idType)
                    {
                    case ExtendedDataTree.IdentifierType.ACTOR:
                        var list = ExtendedDataUtils.GetPieceForMod(mod.modid, GetDataForActor(extendedDataTree.identifier)).DataList;
                        foreach (var h in extendedDataTree.dataPiece.DataList)
                        {
                            list.Add(h);
                        }
                        break;

                    default:
                        throw new NotImplementedException();
                    }
                }
            }
        }
Exemplo n.º 2
0
        internal static CompoundDataPiece GetDataForCurrentMod(CompoundDataPiece piece)
        {
            var strin = SRMod.GetCurrentMod().ModInfo.Id;

            return(ExtendedDataUtils.GetPieceForMod(strin, piece));
        }
Exemplo n.º 3
0
        internal static void OnRegisterActor(GameModel model, long actorId, GameObject gameObject, bool skipNotify)
        {
            if (Identifiable.GetId(gameObject) == Identifiable.Id.NONE)
            {
                return;
            }

            var actorIdentifier = DataIdentifier.GetActorIdentifier(actorId);

            if (preparedData.TryGetValue(actorIdentifier, out var pdata))
            {
                var data = pdata.Data;
                foreach (var saveInfoPair in SaveRegistry.modToSaveInfo)
                {
                    if (data.HasPiece(saveInfoPair.Key.ModInfo.Id))
                    {
                        saveInfoPair.Value.OnExtendedActorDataLoaded(model.actors[actorId], gameObject, ExtendedDataUtils.GetPieceForMod(saveInfoPair.Key.ModInfo.Id, data));
                    }
                }
                ApplyDataToGameObject(gameObject, data);
                preparedData.Remove(actorIdentifier);
            }
        }
Exemplo n.º 4
0
        internal static void OnRegisterActor(GameModel model, long actorId, GameObject gameObject, bool skipNotify)
        {
            if (Identifiable.GetId(gameObject) == Identifiable.Id.NONE)
            {
                return;
            }

            if (IsRegistered(actorId))
            {
                foreach (var saveInfoPair in SaveRegistry.modToSaveInfo)
                {
                    if (extendedActorData[actorId].HasPiece(saveInfoPair.Key.ModInfo.Id))
                    {
                        saveInfoPair.Value.OnExtendedActorDataLoaded(model.actors[actorId], gameObject, ExtendedDataUtils.GetPieceForMod(saveInfoPair.Key.ModInfo.Id, extendedActorData[actorId]));
                    }
                }

                foreach (var participant in gameObject.GetComponentsInChildren <ExtendedData.Participant>())
                {
                    if (!ValidateParticipant(participant, (extendedActorData[actorId])))
                    {
                        InitParticipant(participant, (extendedActorData[actorId]));
                    }
                }

                foreach (var participant in gameObject.GetComponentsInChildren <ExtendedData.Participant>())
                {
                    try
                    {
                        SetParticipant(participant, (extendedActorData[actorId]));
                    }
                    catch (InvalidOperationException)
                    {
                        Debug.Log($"Yipes! seems like {participant.GetType()} isn't initialized!");
                        // a bit gross hack but it'll help when mods add new participants to things that already have actor data stored
                        InitParticipant(participant, (extendedActorData[actorId]));
                        SetParticipant(participant, (extendedActorData[actorId]));
                    }
                }
            }
            else
            {
                var participants = gameObject.GetComponents <ExtendedData.Participant>();
                if (participants != null && participants.Length > 0)
                {
                    RegisterExtendedActorData(actorId, gameObject, skipNotify);
                }
            }
        }