Exemplo n.º 1
0
    public static void Save(string save_name)
    {
        if (SaveGame.m_State != SaveGame.State.None)
        {
            Debug.LogWarning("Can't save, state = " + SaveGame.m_State.ToString());
            return;
        }
        if (GreenHellGame.Instance.IsGamescom())
        {
            return;
        }
        if (!ReplTools.IsPlayingAlone() && !ReplTools.AmIMaster())
        {
            SaveGame.SaveCoop();
            return;
        }
        Debug.Log("SAVE - " + save_name);
        SaveGame.m_State = SaveGame.State.Save;
        HUDSaving.Get().Activate();
        SaveGame.SetupObjects();
        SaveGame.m_IVals.Clear();
        SaveGame.m_SVals.Clear();
        SaveGame.m_FVals.Clear();
        SaveGame.m_BVals.Clear();
        foreach (ISaveLoad saveLoad in SaveGame.m_Objects)
        {
            saveLoad.Save();
        }
        BinaryFormatter binaryFormatter = new BinaryFormatter();
        MemoryStream    memoryStream    = new MemoryStream();

        binaryFormatter.Serialize(memoryStream, GreenHellGame.s_GameVersion);
        binaryFormatter.Serialize(memoryStream, GreenHellGame.Instance.m_GameMode);
        long num = DateTime.Now.ToBinary();

        binaryFormatter.Serialize(memoryStream, num);
        int ivalue = StatsManager.Get().GetStatistic(Enums.Event.DaysSurvived).IValue;

        binaryFormatter.Serialize(memoryStream, ivalue);
        int activePresetType = (int)DifficultySettings.GetActivePresetType();

        binaryFormatter.Serialize(memoryStream, activePresetType);
        binaryFormatter.Serialize(memoryStream, MainLevel.Instance.m_Tutorial);
        bool flag = Player.Get().IsDead();

        binaryFormatter.Serialize(memoryStream, flag);
        binaryFormatter.Serialize(memoryStream, ReplicatedSessionState.Get() != null && ReplicatedSessionState.Get().m_PlayedCoop);
        Stream     serializationStream = memoryStream;
        P2PSession instance            = P2PSession.Instance;

        binaryFormatter.Serialize(serializationStream, ((instance != null) ? instance.GetSessionId() : null) ?? "");
        binaryFormatter.Serialize(memoryStream, SaveGame.m_IVals);
        binaryFormatter.Serialize(memoryStream, SaveGame.m_SVals);
        binaryFormatter.Serialize(memoryStream, SaveGame.m_FVals);
        binaryFormatter.Serialize(memoryStream, SaveGame.m_BVals);
        DebugUtils.Assert(GreenHellGame.Instance.m_RemoteStorage.FileWrite(save_name, memoryStream.GetBuffer()), "SaveGame - remote storage write failed", true, DebugUtils.AssertType.Info);
        memoryStream.Close();
        SaveGame.SaveScreenshot(save_name);
        SaveGame.m_State = SaveGame.State.None;
    }
Exemplo n.º 2
0
    public Injury AddInjury(InjuryType type, InjuryPlace place, BIWoundSlot slot, InjuryState state, int poison_level = 0, Injury parent_injury = null, DamageInfo damage_info = null)
    {
        if (!slot || PlayerConditionModule.Get().GetParameterLossBlocked())
        {
            return(null);
        }
        if (DifficultySettings.GetActivePresetType() == DifficultySettings.PresetType.Tourist && !MainLevel.Instance.m_Tutorial)
        {
            return(null);
        }
        if (type == InjuryType.Leech && this.GetAllInjuries(type).Count == 0 && PlayerSanityModule.Get())
        {
            PlayerSanityModule.Get().ResetEventCooldown(PlayerSanityModule.SanityEventType.Leech);
        }
        Debug.Log("AddInjury");
        Injury injury = new Injury(type, place, slot, state, poison_level, parent_injury, damage_info);

        this.m_Injuries.Add(injury);
        this.OnAddInjury(type);
        return(injury);
    }