mirror of
https://github.com/Outer-Wilds-New-Horizons/new-horizons.git
synced 2025-12-11 20:15:44 +01:00
73 lines
3.0 KiB
C#
73 lines
3.0 KiB
C#
using NewHorizons.Utility;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
|
|
namespace NewHorizons.External
|
|
{
|
|
public class PlanetConfig : IPlanetConfig
|
|
{
|
|
public string Name { get; set; }
|
|
public bool Destroy { get; set; }
|
|
public MVector3 SpawnPoint { get; set; }
|
|
public BaseModule Base { get; set; }
|
|
public AtmosphereModule Atmosphere { get; set; }
|
|
public OrbitModule Orbit { get; set; }
|
|
public RingModule Ring { get; set; }
|
|
public HeightMapModule HeightMap { get; set; }
|
|
public ProcGenModule ProcGen { get; set; }
|
|
public AsteroidBeltModule AsteroidBelt { get; set; }
|
|
public SpawnModule Spawn { get; set; }
|
|
|
|
public PlanetConfig(Dictionary<string, object> dict)
|
|
{
|
|
// Always have to have a base module and orbit module
|
|
Base = new BaseModule();
|
|
Orbit = new OrbitModule();
|
|
|
|
if (dict == null) return;
|
|
|
|
foreach (var item in dict)
|
|
{
|
|
switch(item.Key)
|
|
{
|
|
case "Base":
|
|
Base.Build(item.Value as Dictionary<string, object>);
|
|
break;
|
|
case "Orbit":
|
|
Orbit.Build(item.Value as Dictionary<string, object>);
|
|
break;
|
|
case "Atmosphere":
|
|
Atmosphere = new AtmosphereModule();
|
|
Atmosphere.Build(item.Value as Dictionary<string, object>);
|
|
break;
|
|
case "Ring":
|
|
Ring = new RingModule();
|
|
Ring.Build(item.Value as Dictionary<string, object>);
|
|
break;
|
|
case "HeightMap":
|
|
HeightMap = new HeightMapModule();
|
|
HeightMap.Build(item.Value as Dictionary<string, object>);
|
|
break;
|
|
case "ProcGen":
|
|
ProcGen = new ProcGenModule();
|
|
ProcGen.Build(item.Value as Dictionary<string, object>);
|
|
break;
|
|
case "AsteroidBelt":
|
|
AsteroidBelt = new AsteroidBeltModule();
|
|
AsteroidBelt.Build(item.Value as Dictionary<string, object>);
|
|
break;
|
|
case "Spawn":
|
|
Spawn = new SpawnModule();
|
|
Spawn.Build(item.Value as Dictionary<string, object>);
|
|
break;
|
|
default:
|
|
var property = typeof(PlanetConfig).GetProperty(item.Key, System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Instance);
|
|
if (property != null) property.SetValue(this, Convert.ChangeType(item.Value, property.PropertyType));
|
|
else Logger.LogError($"{item.Key} {item.Value} is not valid. Is your config formatted correctly?");
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|