Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adjustment of time definitions to account for non-standard system scales. #5

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 10 additions & 8 deletions Snacks/GUI/SnackAppView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,11 @@ protected double DaysPerYear
{
get
{
if (GameSettings.KERBIN_TIME)
return 426.08f;
else
return 365f;
//if (GameSettings.KERBIN_TIME)
// return 426.08f;
//else
// return 365f;
return (KSPUtil.dateTimeFormatter.Year / KSPUtil.dateTimeFormatter.Day);
}
}

Expand All @@ -62,10 +63,11 @@ double HoursPerDay
{
get
{
if (GameSettings.KERBIN_TIME)
return 6f;
else
return 24f;
//if (GameSettings.KERBIN_TIME)
// return 6f;
//else
// return 24f;
return (KSPUtil.dateTimeFormatter.Day / KSPUtil.dateTimeFormatter.Hour);
}
}

Expand Down
9 changes: 5 additions & 4 deletions Snacks/LifeSupport/SnackController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -417,10 +417,11 @@ public void GameSettingsApplied()
{
// snackFrequency = 5;
//Seconds per day = 6 * 60 * 60 = 21600
if (GameSettings.KERBIN_TIME)
snackFrequency = (6 * 3600) / SnacksProperties.MealsPerDay;
else
snackFrequency = (24 * 3600) / SnacksProperties.MealsPerDay;
//if (GameSettings.KERBIN_TIME)
// snackFrequency = (6 * 3600) / SnacksProperties.MealsPerDay;
//else
// snackFrequency = (24 * 3600) / SnacksProperties.MealsPerDay;
snackFrequency = ((KSPUtil.dateTimeFormatter.Day) / SnacksProperties.MealsPerDay);

//Make sure that the penalties know about the update
foreach (ISnacksPenalty handler in penaltyHandlers)
Expand Down
9 changes: 5 additions & 4 deletions Snacks/Settings/SnacksProperties.cs
Original file line number Diff line number Diff line change
Expand Up @@ -239,10 +239,11 @@ public static int NapTime
return 120;

case FaintTime.OneDay:
if (GameSettings.KERBIN_TIME)
return 360;
else
return 1440;
//if (GameSettings.KERBIN_TIME)
// return 360;
//else
// return 1440;
return KSPUtil.dateTimeFormatter.Day;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
return KSPUtil.dateTimeFormatter.Day;
return KSPUtil.dateTimeFormatter.Day / 10;

The previous numbers look to be a tenth of a Day, could use a var here

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This may need author input; the series of settings are in order of increasing duration in minutes, with the change intended to fill in for a whole day. I'm not sure what you mean about a tenth of a day?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry mate I got my maths wrong, its not a fraction of a day like I thought - too many thoughts, not enough brain cells

}
}
}
Expand Down
13 changes: 8 additions & 5 deletions Snacks/Utilities/WindowUtils.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/**
/**
* WindowUtils.cs
*
* Thunder Aerospace Corporation's library for the Kerbal Space Program, by Taranis Elsu
Expand Down Expand Up @@ -36,10 +36,13 @@ namespace Snacks
{
public static class WindowUtils
{
const double SECONDS_PER_MINUTE = 60.0;
const double MINUTES_PER_HOUR = 60.0;
static double HOURS_PER_DAY = (GameSettings.KERBIN_TIME) ? 6.0 : 24.0;
public static double SECONDS_PER_DAY = SECONDS_PER_MINUTE*MINUTES_PER_HOUR*HOURS_PER_DAY;
public static double SECONDS_PER_MINUTE => KSPUtil.dateTimeFormatter.Minute;

public static double MINUTES_PER_HOUR => KSPUtil.dateTimeFormatter.Hour / KSPUtil.dateTimeFormatter.Minute;

public static double HOURS_PER_DAY => KSPUtil.dateTimeFormatter.Day / KSPUtil.dateTimeFormatter.Hour; // (GameSettings.KERBIN_TIME) ? 6.0 : 24.0;

public static double SECONDS_PER_DAY = KSPUtil.dateTimeFormatter.Day; // SECONDS_PER_MINUTE*MINUTES_PER_HOUR*HOURS_PER_DAY;

public static double ToDegrees(double radians)
{
Expand Down