From b750ba73295702bd3d98e09d0a89085cd2dc0e6a Mon Sep 17 00:00:00 2001 From: Tobias Meuser Date: Thu, 26 Nov 2020 20:14:35 +0100 Subject: [PATCH] Updated time behavior --- src/RealTime/Config/RealTimeConfig.cs | 10 +++++----- src/RealTime/Core/RealTimeMod.cs | 2 ++ src/RealTime/Pandemic/PandemicManager.cs | 4 ++-- src/RealTime/Simulation/TimeAdjustment.cs | 6 +++--- 4 files changed, 12 insertions(+), 10 deletions(-) mode change 100644 => 100755 src/RealTime/Simulation/TimeAdjustment.cs diff --git a/src/RealTime/Config/RealTimeConfig.cs b/src/RealTime/Config/RealTimeConfig.cs index b802baf..60901c4 100755 --- a/src/RealTime/Config/RealTimeConfig.cs +++ b/src/RealTime/Config/RealTimeConfig.cs @@ -15,7 +15,7 @@ namespace RealTime.Config public sealed class RealTimeConfig : IConfiguration { /// The storage ID for the configuration objects. - public const string StorageId = "RealTimeConfiguration"; + public const string StorageId = "PandemicConfiguration"; private const int LatestVersion = 4; @@ -110,7 +110,7 @@ namespace RealTime.Config /// at night. All buildings higher than this value will not switch the lights off. /// [ConfigItem("1General", "1Other", 4)] - [ConfigItemSlider(0, 100f, 5f, ValueType = SliderValueType.Default)] + [ConfigItemSlider(0, 100, 5, ValueType = SliderValueType.Default)] public float SwitchOffLightsMaxHeight { get; set; } /// Gets or sets a value indicating whether a citizen can abandon a journey when being too long in @@ -161,12 +161,12 @@ namespace RealTime.Config /// Gets or sets the indoor transmission probability. [ConfigItem("DiseaseProperties", 1)] - [ConfigItemSlider(0f, 100f, 1f, ValueType = SliderValueType.Percentage)] + [ConfigItemSlider(0, 100, 1, ValueType = SliderValueType.Percentage)] public uint IndoorDiseaseTransmissionProbability { get; set; } /// Gets or sets the outdoor transmission probability. [ConfigItem("DiseaseProperties", 2)] - [ConfigItemSlider(0f, 100f, 1f, ValueType = SliderValueType.Percentage)] + [ConfigItemSlider(0, 100, 1, ValueType = SliderValueType.Percentage)] public uint OutdoorDiseaseTransmissionProbability { get; set; } /// Gets or sets the transmission range. @@ -176,7 +176,7 @@ namespace RealTime.Config /// Gets or sets the ratio of initial infections. [ConfigItem("DiseaseProperties", 4)] - [ConfigItemSlider(0f, 100, 1, ValueType = SliderValueType.Percentage)] + [ConfigItemSlider(0, 100, 1, ValueType = SliderValueType.Percentage)] public float DiseaseStartInfectionRatio { get; set; } /// diff --git a/src/RealTime/Core/RealTimeMod.cs b/src/RealTime/Core/RealTimeMod.cs index a7c1307..0ce35c1 100755 --- a/src/RealTime/Core/RealTimeMod.cs +++ b/src/RealTime/Core/RealTimeMod.cs @@ -152,6 +152,8 @@ namespace RealTime.Core { CheckCompatibility(compatibility); } + + configProvider.SaveDefaultConfiguration(); } /// diff --git a/src/RealTime/Pandemic/PandemicManager.cs b/src/RealTime/Pandemic/PandemicManager.cs index 940132f..30cd679 100755 --- a/src/RealTime/Pandemic/PandemicManager.cs +++ b/src/RealTime/Pandemic/PandemicManager.cs @@ -124,7 +124,7 @@ namespace RealTime.Pandemic { if (activeInfections.ContainsKey(citizenID)) { - long infectedTime = activeInfections[citizenID] - (currentDateTime.Ticks / 10000); + long infectedTime = (currentDateTime.Ticks / 10000) - activeInfections[citizenID]; double infectedTimeInDays = infectedTime / 1000.0 / 3600.0 / 24.0; if (Config.StartInfection <= infectedTimeInDays && infectedTimeInDays <= Config.EndInfection) { @@ -183,7 +183,7 @@ namespace RealTime.Pandemic if (CitizenProxy.IsSick(ref citizens[citizenID]) && activeInfections.ContainsKey(citizenID)) { - long infectedTime = activeInfections[citizenID] - (currentDateTime.Ticks / 10000); + long infectedTime = (currentDateTime.Ticks / 10000) - activeInfections[citizenID]; double infectedTimeInDays = infectedTime / 1000.0 / 3600.0 / 24.0; if (infectedTimeInDays > Config.DiseaseDuration) { diff --git a/src/RealTime/Simulation/TimeAdjustment.cs b/src/RealTime/Simulation/TimeAdjustment.cs old mode 100644 new mode 100755 index 184f0cb..b21ffe0 --- a/src/RealTime/Simulation/TimeAdjustment.cs +++ b/src/RealTime/Simulation/TimeAdjustment.cs @@ -1,4 +1,4 @@ -// Copyright (c) dymanoid. All rights reserved. +// Copyright (c) dymanoid. All rights reserved. namespace RealTime.Simulation { @@ -150,7 +150,7 @@ namespace RealTime.Simulation var originalDate = sm.m_ThreadingWrapper.simulationTime; sm.m_timePerFrame = useCustomTimePerFrame - ? new TimeSpan(24L * 3600L * 10_000_000L / framesPerDay) + ? new TimeSpan(24L * 3600L * 400_000_000L / framesPerDay) : vanillaTimePerFrame; SetGameDateTime(originalDate); @@ -164,4 +164,4 @@ namespace RealTime.Simulation return 1u << (int)(RealtimeSpeed - offset); } } -} \ No newline at end of file +} -- GitLab