Ejemplo n.º 1
0
 /// <summary>
 /// GameSaveData Constructor
 /// </summary>
 public GameStateData()
 {
     playerSave = new PlayerSaveData();
     cameraSave = new CameraSaveData();
     levelState = Level.m_Level.GetLevelState();
     enemyState = EnemyStateControl.m_EnemyStateControl.EnemyState();
     npcState = NPCStateControl.m_NPCStateControl.NPCState();
 }
Ejemplo n.º 2
0
    private bool Load(IReader reader)
    {
        string a = reader.ReadKleiString();

        Debug.Assert(a == "world");
        Deserializer deserializer = new Deserializer(reader);
        SaveFileRoot saveFileRoot = new SaveFileRoot();

        deserializer.Deserialize(saveFileRoot);
        SaveGame.GameInfo gameInfo = GameInfo;
        if (gameInfo.saveMajorVersion != 7)
        {
            SaveGame.GameInfo gameInfo2 = GameInfo;
            if (gameInfo2.saveMinorVersion >= 8)
            {
                goto IL_00f7;
            }
        }
        if (saveFileRoot.requiredMods != null)
        {
            saveFileRoot.active_mods = new List <Label>();
            foreach (ModInfo requiredMod in saveFileRoot.requiredMods)
            {
                ModInfo current = requiredMod;
                saveFileRoot.active_mods.Add(new Label
                {
                    id      = current.assetID,
                    version = current.lastModifiedTime,
                    distribution_platform = Label.DistributionPlatform.Steam,
                    title = current.description
                });
            }
            saveFileRoot.requiredMods.Clear();
        }
        goto IL_00f7;
IL_00f7:
        KMod.Manager modManager = Global.Instance.modManager;
        modManager.Load(Content.LayerableFiles);
        if (!modManager.MatchFootprint(saveFileRoot.active_mods, Content.LayerableFiles | Content.Strings | Content.DLL | Content.Translation | Content.Animation))
        {
            DebugUtil.LogWarningArgs("Mod footprint of save file doesn't match current mod configuration");
        }
        Global.Instance.modManager.SendMetricsEvent();
        string text = saveFileRoot.worldID;

        if (text == null)
        {
            try
            {
                text = CustomGameSettings.Instance.GetCurrentQualitySetting(CustomGameSettingConfigs.World).id;
            }
            catch
            {
                text = "worlds/SandstoneDefault";
            }
        }
        Game.worldID = text;
        worldGen     = new WorldGen(text, null);
        Game.LoadSettings(deserializer);
        GridSettings.Reset(saveFileRoot.WidthInCells, saveFileRoot.HeightInCells);
        Singleton <KBatchedAnimUpdater> .Instance.InitializeGrid();

        Sim.SIM_Initialize(Sim.DLL_MessageHandler);
        SimMessages.CreateSimElementsTable(ElementLoader.elements);
        SimMessages.CreateDiseaseTable();
        byte[]     bytes   = saveFileRoot.streamed["Sim"];
        FastReader reader2 = new FastReader(bytes);

        if (Sim.Load(reader2) != 0)
        {
            DebugUtil.LogWarningArgs("\n--- Error loading save ---\nSimDLL found bad data\n");
            Sim.Shutdown();
            return(false);
        }
        SceneInitializer.Instance.PostLoadPrefabs();
        mustRestartOnFail = true;
        if (!saveManager.Load(reader))
        {
            Sim.Shutdown();
            DebugUtil.LogWarningArgs("\n--- Error loading save ---\n");
            SetActiveSaveFilePath(null);
            return(false);
        }
        Grid.Visible = saveFileRoot.streamed["GridVisible"];
        if (saveFileRoot.streamed.ContainsKey("GridSpawnable"))
        {
            Grid.Spawnable = saveFileRoot.streamed["GridSpawnable"];
        }
        Grid.Damage = BytesToFloat(saveFileRoot.streamed["GridDamage"]);
        Game.Instance.Load(deserializer);
        FastReader reader3 = new FastReader(saveFileRoot.streamed["Camera"]);

        CameraSaveData.Load(reader3);
        return(true);
    }
Ejemplo n.º 3
0
 /// <summary>
 /// Load Camera from CameraSave
 /// </summary>
 /// <param name="c">CameraSave</param>
 private void LoadCamera(CameraSaveData c)
 {
     MainCamera.m_MainCamera.SetPosition(
         new Vector3(c.posX, c.posY, c.posZ)
     );
 }