/// <summary> /// Deserialization constructor /// </summary> /// <param name="character">The character for this training</param> /// <param name="serial">The serialization object for this training</param> /// <param name="isPaused">When true, the training is currently paused.</param> /// <param name="startTimeWhenPaused">Training starttime when the queue is actually paused. Indeed, in such case, CCP returns empty start and end time, so we compute a "what if we start now" scenario.</param> internal QueuedSkill(Character character, SerializableQueuedSkill serial, bool isPaused, ref DateTime startTimeWhenPaused) { m_owner = character; m_startSP = serial.StartSP; m_endSP = serial.EndSP; m_level = serial.Level; m_skill = character.Skills[serial.ID]; if (!isPaused) { // Not paused, we should trust CCP m_startTime = serial.StartTime; m_endTime = serial.EndTime; } else { // StartTime and EndTime were empty on the serialization object if the skill was paused // So we compute a "what if we start now" scenario m_startTime = startTimeWhenPaused; if (m_skill != null) { startTimeWhenPaused += m_skill.GetLeftTrainingTimeForLevelOnly(m_level); } m_endTime = startTimeWhenPaused; } }
/// <summary> /// Deserialization constructor. /// </summary> /// <param name="character">The character for this training</param> /// <param name="serial">The serialization object for this training</param> /// <param name="startTimeWhenPaused">Training starttime when the queue is actually paused. /// Indeed, in such case, CCP returns empty start and end time, so we compute a "what if we start now" scenario.</param> internal QueuedSkill(Character character, SerializableQueuedSkill serial, ref DateTime startTimeWhenPaused) { Owner = character; StartSP = serial.StartSP; EndSP = serial.EndSP; Level = serial.Level; Skill = character.Skills[serial.ID]; if (!serial.IsPaused) { // Not paused, we should trust CCP StartTime = serial.StartTime; EndTime = serial.EndTime; } else { // StartTime and EndTime were empty on the serialization object if the skill was paused // So we compute a "what if we start now" scenario StartTime = startTimeWhenPaused; if (Skill != null) { if (serial.Level <= Skill.Level + 1) { Skill.SkillPoints = StartSP; } startTimeWhenPaused += Skill.GetLeftTrainingTimeForLevelOnly(Level); } EndTime = startTimeWhenPaused; } }
/// <summary> /// Generates a deserialization object. /// </summary> /// <returns></returns> internal SerializableQueuedSkill Export() { var skill = new SerializableQueuedSkill { ID = (m_skill == null ? 0 : m_skill.ID), Level = m_level, StartSP = m_startSP, EndSP = m_endSP, }; // CCP's API indicates paused training with missing skill // start and end times. Mimicing them is ugly but necessary if (m_owner.IsTraining) { skill.StartTime = m_startTime; skill.EndTime = m_endTime; } return(skill); }
/// <summary> /// Generates a deserialization object. /// </summary> /// <returns></returns> internal SerializableQueuedSkill Export() { SerializableQueuedSkill skill = new SerializableQueuedSkill { ID = Skill?.ID ?? 0, Level = Level, StartSP = StartSP, EndSP = EndSP, }; // CCP's API indicates paused training skill with missing start and end times // Mimicing them is ugly but necessary if (!Owner.IsTraining) { return(skill); } skill.StartTime = StartTime; skill.EndTime = EndTime; return(skill); }