Skip to content
Merged
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
13 changes: 13 additions & 0 deletions .idea/.idea.PatchManager/.idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions .idea/.idea.PatchManager/.idea/.name

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion .idea/.idea.PatchManager/.idea/projectSettingsUpdater.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Runtime/PatchManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ public void Awake()
ModuleManager.Register(typeof(PartsModule));
ModuleManager.Register(typeof(ResourcesModule));
ModuleManager.Register(typeof(ScienceModule));
ModuleManager.Register(typeof(PlanetsModule));
Logging.Initialize(SWLogger);
foreach (var module in ModuleManager.Modules)
{
Expand Down
8 changes: 8 additions & 0 deletions Runtime/Planets.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions Runtime/Planets/Modifiables.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

28 changes: 28 additions & 0 deletions Runtime/Planets/Modifiables/AtmosphereOverrideModifiable.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
using PatchManager.SassyPatching;
using PatchManager.SassyPatching.Modifiables;
using PatchManager.Planets.Selectables;

namespace PatchManager.Planets.Modifiables
{
public class AtmosphereOverrideModifiable : JTokenModifiable
{
private AtmosphereOverrideSelectable _atmosphereOverrideSelectable;

/// <summary>
/// Creates a new <see cref="GalaxyModifiable"/> for the given <see cref="GalaxyModifiable"/>.
/// </summary>
/// <param name="selectable">The selectable to modify.</param>
public AtmosphereOverrideModifiable(AtmosphereOverrideSelectable selectable) : base(selectable.AtmosphereOverrideObject, selectable.SetModified) => _atmosphereOverrideSelectable = selectable;

/// <inheritdoc/>
public override void Set(DataValue dataValue)
{
if (dataValue.IsDeletion)
{
_atmosphereOverrideSelectable.SetDeleted();
return;
}
base.Set(dataValue);
}
}
}
11 changes: 11 additions & 0 deletions Runtime/Planets/Modifiables/AtmosphereOverrideModifiable.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

28 changes: 28 additions & 0 deletions Runtime/Planets/Modifiables/CelestialBodyModifiable.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
using PatchManager.SassyPatching;
using PatchManager.SassyPatching.Modifiables;
using PatchManager.Planets.Selectables;

namespace PatchManager.Planets.Modifiables
{
public class CelestialBodyModifiable : JTokenModifiable
{
private CelestialBodySelectable _celestialBodySelectable;

/// <summary>
/// Creates a new <see cref="CelestialBodyModifiable"/> for the given <see cref="CelestialBodyModifiable"/>.
/// </summary>
/// <param name="selectable">The selectable to modify.</param>
public CelestialBodyModifiable(CelestialBodySelectable selectable) : base(selectable.DataObject, selectable.SetModified) => _celestialBodySelectable = selectable;

/// <inheritdoc/>
public override void Set(DataValue dataValue)
{
if (dataValue.IsDeletion)
{
_celestialBodySelectable.SetDeleted();
return;
}
base.Set(dataValue);
}
}
}
11 changes: 11 additions & 0 deletions Runtime/Planets/Modifiables/CelestialBodyModifiable.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

28 changes: 28 additions & 0 deletions Runtime/Planets/Modifiables/GalaxyModifiable.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
using PatchManager.SassyPatching;
using PatchManager.SassyPatching.Modifiables;
using PatchManager.Planets.Selectables;

namespace PatchManager.Planets.Modifiables
{
public class GalaxyModifiable : JTokenModifiable
{
private GalaxySelectable _galaxySelectable;

/// <summary>
/// Creates a new <see cref="GalaxyModifiable"/> for the given <see cref="GalaxyModifiable"/>.
/// </summary>
/// <param name="selectable">The selectable to modify.</param>
public GalaxyModifiable(GalaxySelectable selectable) : base(selectable.GalaxyObject, selectable.SetModified) => _galaxySelectable = selectable;

/// <inheritdoc/>
public override void Set(DataValue dataValue)
{
if (dataValue.IsDeletion)
{
_galaxySelectable.SetDeleted();
return;
}
base.Set(dataValue);
}
}
}
11 changes: 11 additions & 0 deletions Runtime/Planets/Modifiables/GalaxyModifiable.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

28 changes: 28 additions & 0 deletions Runtime/Planets/Modifiables/VolumeCloudOverrideModifiable.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
using PatchManager.SassyPatching;
using PatchManager.SassyPatching.Modifiables;
using PatchManager.Planets.Selectables;

namespace PatchManager.Planets.Modifiables
{
public class VolumeCloudOverrideModifiable : JTokenModifiable
{
private readonly VolumeCloudSelectable _volumeCloudSelectable;

/// <summary>
/// Creates a new <see cref="GalaxyModifiable"/> for the given <see cref="GalaxyModifiable"/>.
/// </summary>
/// <param name="selectable">The selectable to modify.</param>
public VolumeCloudOverrideModifiable(VolumeCloudSelectable selectable) : base(selectable.VolumeCloudOverrideObject, selectable.SetModified) => _volumeCloudSelectable = selectable;

/// <inheritdoc/>
public override void Set(DataValue dataValue)
{
if (dataValue.IsDeletion)
{
_volumeCloudSelectable.SetDeleted();
return;
}
base.Set(dataValue);
}
}
}
11 changes: 11 additions & 0 deletions Runtime/Planets/Modifiables/VolumeCloudOverrideModifiable.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 15 additions & 0 deletions Runtime/Planets/OverrideManager.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
using System.Collections.Generic;
using JetBrains.Annotations;
using PatchManager.Planets.Overrides;

namespace PatchManager.Planets
{
[PublicAPI]
public static class OverrideManager
{
public static Dictionary<string, AtmosphereOverride> AtmosphereOverrides = new();
public static Dictionary<string, double> Scales = new();
public static Dictionary<string, VolumeCloudConfigurationOverride> VolumeCloudOverrides = new();
}
}

11 changes: 11 additions & 0 deletions Runtime/Planets/OverrideManager.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions Runtime/Planets/Overrides.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

87 changes: 87 additions & 0 deletions Runtime/Planets/Overrides/AtmosphereOverride.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
using JetBrains.Annotations;
using KSP.Game;
using KSP.Rendering;
using UnityEngine;

namespace PatchManager.Planets.Overrides
{
[PublicAPI]
[UsedImplicitly]
public struct AtmosphereOverride : IOverride<AtmosphereModel>
{
public string PlanetName;
public bool? IsGasGiant;
public Vector2? Exposure;
public float? SunAngleRadius;
public float? SunZenithAngle;
public Vector3? SolarIrradiance;
public float? SunDirectionExposureModifier;
public float? TransmittanceTint;
public float? NoonColorStrength;
public float? SunsetColorStrength;
public float? ColorTransitionScale;
public float? BottomRadius;
public float? AtmosphereHeight;
public Color? GroundAlbedo;
public Vector3? RayleighScattering;
public float? RayleighScatteringScale;
public float? RayleighExponentialDistribution;
public Vector3? MieScattering;
public float? MieScatteringScale;
public float? MieAnistropy;
public float? MieExponentialDistribution;
public float? AbsorptionScale;
public Vector3? Absorption;
public float? AbsorptionMaxDensity;
public Vector2? AbsorptionHeightMinMax;
[CanBeNull] public string TransmittanceTexture;
[CanBeNull] public string IrradianceTexture;
[CanBeNull] public string ScatteringTexture;

public void ApplyTo(AtmosphereModel atmosphereModel)
{
if (IsGasGiant.HasValue) atmosphereModel.IsGasGiant = IsGasGiant.Value;
if (Exposure.HasValue) atmosphereModel.Exposure = Exposure.Value;
if (SunAngleRadius.HasValue) atmosphereModel.SunAngleRadius = SunAngleRadius.Value;
if (SunZenithAngle.HasValue) atmosphereModel.SunZenithAngle = SunZenithAngle.Value;
if (SolarIrradiance.HasValue) atmosphereModel.SolarIrradiance = SolarIrradiance.Value;
if (SunDirectionExposureModifier.HasValue)
atmosphereModel.SunDirectionExposureModifier = SunDirectionExposureModifier.Value;
if (TransmittanceTint.HasValue) atmosphereModel.TransmittanceTint = TransmittanceTint.Value;
if (NoonColorStrength.HasValue) atmosphereModel.NoonColorStrengh = NoonColorStrength.Value;
if (SunsetColorStrength.HasValue) atmosphereModel.SunsetColorStrengh = SunsetColorStrength.Value;
if (ColorTransitionScale.HasValue) atmosphereModel.ColorTransitionScale = ColorTransitionScale.Value;
if (BottomRadius.HasValue) atmosphereModel.BottomRadius = BottomRadius.Value;
if (AtmosphereHeight.HasValue) atmosphereModel.AtmosphereHeight = AtmosphereHeight.Value;
if (GroundAlbedo.HasValue) atmosphereModel.GroundAlbedo = GroundAlbedo.Value;
if (RayleighScattering.HasValue) atmosphereModel.RayleighScattering = RayleighScattering.Value;
if (RayleighScatteringScale.HasValue) atmosphereModel.RayleighScatteringScale = RayleighScatteringScale.Value;
if (RayleighExponentialDistribution.HasValue)
atmosphereModel.RayleighExponentialDistribution = RayleighExponentialDistribution.Value;
if (MieScattering.HasValue) atmosphereModel.MieScattering = MieScattering.Value;
if (MieScatteringScale.HasValue) atmosphereModel.MieScatteringScale = MieScatteringScale.Value;
if (MieAnistropy.HasValue) atmosphereModel.MieAnisotropy = MieAnistropy.Value;
if (MieExponentialDistribution.HasValue)
atmosphereModel.MieExponentialDistribution = MieExponentialDistribution.Value;
if (AbsorptionScale.HasValue) atmosphereModel.AbsorptionScale = AbsorptionScale.Value;
if (Absorption.HasValue) atmosphereModel.Absorption = Absorption.Value;
if (AbsorptionHeightMinMax.HasValue) atmosphereModel.AbsorptionHeightMinMax = AbsorptionHeightMinMax.Value;
if (!string.IsNullOrEmpty(TransmittanceTexture))
{
GameManager.Instance.Assets.TryLoad<Texture2D>(TransmittanceTexture,
asset => atmosphereModel.TransmittanceTexture = asset);
}
if (!string.IsNullOrEmpty(IrradianceTexture))
{
GameManager.Instance.Assets.TryLoad<Texture2D>(IrradianceTexture,
asset => atmosphereModel.IrradianceTexture = asset);
}
if (!string.IsNullOrEmpty(ScatteringTexture))
{
GameManager.Instance.Assets.TryLoad<Texture3D>(ScatteringTexture,
asset => atmosphereModel.ScatteringTexture = asset);
}
}
}
}

11 changes: 11 additions & 0 deletions Runtime/Planets/Overrides/AtmosphereOverride.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading