1
Fork 0
mirror of https://github.com/thegeneralist01/Scene-Manager-DevRepo synced 2026-01-11 23:50:29 +01:00

Initial commit

This commit is contained in:
Rich Dunne 2021-01-10 08:41:27 -07:00
parent f494dd7a84
commit b66a97fef8

View file

@ -0,0 +1,54 @@
using Rage;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace SceneManager
{
// The only reason this class should change is to modify how settings are validated
internal class SettingsValidator
{
internal static void ValidateWaypointSettings()
{
if (Settings.CollectorRadius > 50 || Settings.CollectorRadius < 1)
{
Settings.CollectorRadius = 1;
Game.LogTrivial($"Invalid value for CollectorRadius in user settings, resetting to default.");
}
if (Settings.SpeedZoneRadius > 200 || Settings.SpeedZoneRadius < 5)
{
Settings.SpeedZoneRadius = 5;
Game.LogTrivial($"Invalid value for SpeedZoneRadius in user settings, resetting to default.");
}
if (Settings.CollectorRadius > Settings.SpeedZoneRadius)
{
Settings.CollectorRadius = 1;
Settings.SpeedZoneRadius = 5;
Game.LogTrivial($"CollectorRadius is greater than SpeedZoneRadius in user settings, resetting to defaults.");
}
if (Settings.WaypointSpeed > 100 || Settings.WaypointSpeed < 5)
{
Settings.WaypointSpeed = 5;
Game.LogTrivial($"Invalid value for WaypointSpeed in user settings, resetting to default.");
}
}
internal static void ValidateBarrierSettings(InitializationFile ini)
{
foreach (string displayName in ini.GetKeyNames("Barriers"))
{
var model = new Model(ini.ReadString("Barriers", displayName.Trim()));
if (model.IsValid)
{
Settings.Barriers.Add(displayName, model);
}
else
{
Game.LogTrivial($"{model.Name} is not valid.");
}
}
}
}
}