-
Notifications
You must be signed in to change notification settings - Fork 225
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #677 from tiltedphoques/revert/calendarSync
Revert: calendar sync
- Loading branch information
Showing
20 changed files
with
156 additions
and
301 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
|
||
#include <Structs/TimeModel.h> | ||
|
||
const int cDayLengthArray[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; | ||
|
||
int TimeModel::GetNumerOfDaysByMonthIndex(int aIndex) | ||
{ | ||
if (aIndex < 12) | ||
{ | ||
return cDayLengthArray[aIndex]; | ||
} | ||
|
||
return 0; | ||
} | ||
|
||
void TimeModel::Update(uint64_t aDelta) | ||
{ | ||
float deltaSeconds = static_cast<float>(aDelta) / 1000.f; | ||
Time += (deltaSeconds * (TimeScale * 0.00027777778f)); | ||
|
||
if (Time > 24.f) | ||
{ | ||
int maxDays = GetNumerOfDaysByMonthIndex(Month); | ||
|
||
while (Time > 24.f) | ||
{ | ||
Time = Time + -24.f; | ||
Day++; | ||
} | ||
|
||
if (Day > maxDays) | ||
{ | ||
Month++; | ||
Day = Day - maxDays; | ||
|
||
if (Month > 12) | ||
{ | ||
Month = Month + -12; | ||
Year++; | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#pragma once | ||
|
||
#include <cstdint> | ||
|
||
struct TimeModel | ||
{ | ||
// Default time: 01/01/01 at 12:00 | ||
float TimeScale = 20.f; | ||
float Time = 12.f; | ||
int Year = 1; | ||
int Month = 1; | ||
int Day = 1; | ||
|
||
void Update(uint64_t aDelta); | ||
[[nodiscard]] static int GetNumerOfDaysByMonthIndex(int index); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.