Пример #1
0
        public static void DestroyLogger()
        {
            // Unsubbing from events
            MhwHelper.OnMissionStart -= OnMissionStart;
            MhwHelper.OnMissionEnd   -= OnMissionEnd;

            if (StatObject.Instance != null)
            {
                StatObject.Clear();
                StatObject.Exists = false;
                Log.WriteLine("StatLogger Disabled!");
            }
        }
Пример #2
0
        } = null;                                                       // A dummy to store the last logged DataObject
        public static void InitLogger()
        {
            if (StatObject.Exists)
            {
                return;        // If a StatObject already exists, do nothing
            }
            StatObject.Init(); // Initializing the StatObject

            // Subscribing to events
            MhwHelper.OnMissionStart += OnMissionStart;
            MhwHelper.OnMissionEnd   += OnMissionEnd;

            StatObject.Exists = true;             // Setting a flag to tell other places the Object Exists
            StatObject.Clear();                   // Safety Measures
            StatObject.Instance.Location = "WIP"; // TODO: Somehow get the Location into this :thinkingEmoji:
            LastStamp = 0;
            Log.WriteLine("StatLogger Enabled!");
        }
Пример #3
0
        private static void OnMissionEnd()
        {
            if (!StatObject.Exists)
            {
                return; // More Safety measures
            }
            MissionInProgress = false;

            string dir = "data";

            Directory.CreateDirectory(dir); // Create the dir if it does not exist yet

            if (LastStamp != 0)
            {
                JsonSerialization.WriteToJsonFile <StatObject>($"{dir}\\{LastStamp}.json", StatObject.Instance, false);
                Log.WriteLine("Stat Logging Stopped!");
            }
            else
            {
                Log.WriteLine("Stat Logging Aborted!");
            }

            StatObject.Clear(); // Clearing the object so it'll be empty when the next mission starts
        }