Job scheduling will be broken down into the following pieces:
Job data object
An ongoing job queue
Progress tracking for each job in job queue
Job Data Object
This will represent a single job. Each job must have (at least) the following items:
Associated plot/building
Begin DateTime (game time corrected)
Projected end DateTime (game time corrected)
Progress float
When scheduling a job you will:
Create the Job Data Object
Assign it the appropriate plot/building
Assign it the game time corrected DateTime.Now
Assign it the game time corrected Begin DateTime + TimeSpan for job as the Projected end DateTime
Assign it's progress level a value of 0f
Ongoing Job Queue
For every job in the job queue, which itself will be a mutable List, you must do the following:
(Outside of loop) store game time corrected DateTime.Now
Compare current game time to game corrected Projected end DateTime of Job using DateTime.CompareTo
If current game time is ≤ 0 when compared to game corrected Projected end DateTime of Job, then remove Job from Job Queue and flag it as completed
Progress Tracking for Each Job in Job Queue
Get progress from the difference of (current game time - Begin DateTime for Job) and (game time corrected Projected end DateTime for Job - Begin DateTime for Job) via TotalDays or TotalHours method of corresponding TimeSpans.
This will not be necessary for already completed Jobs.
Job Scheduling
Job scheduling will be broken down into the following pieces:
Job Data Object
This will represent a single job. Each job must have (at least) the following items:
When scheduling a job you will:
Ongoing Job Queue
For every job in the job queue, which itself will be a mutable List, you must do the following:
Progress Tracking for Each Job in Job Queue
Get progress from the difference of (current game time - Begin DateTime for Job) and (game time corrected Projected end DateTime for Job - Begin DateTime for Job) via TotalDays or TotalHours method of corresponding TimeSpans.
This will not be necessary for already completed Jobs.
Reference