Skip to content

Commit

Permalink
2.2.0.1
Browse files Browse the repository at this point in the history
  • Loading branch information
innominata committed Sep 17, 2021
1 parent de331bb commit b86e11f
Show file tree
Hide file tree
Showing 8 changed files with 609 additions and 482 deletions.
908 changes: 454 additions & 454 deletions GalacticScale2/DSP_Plugins.GalacticScale.csproj

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions GalacticScale2/Scripts/GalacticScale2.0/Init.cs
Original file line number Diff line number Diff line change
Expand Up @@ -119,10 +119,10 @@ public static void Init()
{
if (File.Exists(Path.Combine(AssemblyPath, "icon.png")))
{
updateMessage += "Update Detected. Please do not save over existing saves \r\nuntil you are sure you can load saves saved with this version!\r\nPlease note the settings panel is under construction, and missing options will reappear in future updates\r\nPlease Click GS2 Help and click the link to join our community on discord for preview builds and to help shape the mod going forward".Translate();
updateMessage += "Update Detected. Please do not save over existing saves \r\nuntil you are sure you can load saves saved with this version!\r\nPlease Click GS2 Help and click the link to join our community on discord for preview builds and to help shape the mod going forward".Translate();
File.Delete(Path.Combine(AssemblyPath, "icon.png"));
updateMessage += "\r\nPLEASE NOTE: This update includes changes to the planet grid system to bring 200 radius planets in line with vanilla. THIS WILL BREAK 200 SIZED PLANETS. Roll back to the previous version if you have a current game.";
}
updateMessage += "The latest DSP update has added additional planet themes which are yet to be included in GS2. \r\nI'm working on getting them added to the GS2 themeset, as well as implementing their new subtheme system";
}

// Warn("Start");
if (Directory.Exists(OldDataDir) && !Directory.Exists(DataDir))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public static void ConsoleSplash()
Bootstrap.Debug("┌─────────────────────────────────────────────────────────────────────────┐"); // Failsafe if BCE not present
Bootstrap.Debug("│ ╔═╗┌─┐┬ ┌─┐┌─┐┌┬┐┬┌─┐ ╔═╗┌─┐┌─┐┬ ┌─┐ │");
Bootstrap.Debug("│ ║ ╦├─┤│ ├─┤│ │ ││ ╚═╗│ ├─┤│ ├┤ │");
Bootstrap.Debug("│ ╚═╝┴ ┴┴─┘┴ ┴└─┘ ┴ ┴└─┘ ╚═╝└─┘┴ ┴┴─┘└─┘ Version " + Version + " Initializing │");
Bootstrap.Debug("│ ╚═╝┴ ┴┴─┘┴ ┴└─┘ ┴ ┴└─┘ ╚═╝└─┘┴ ┴┴─┘└─┘ Version " + Version + " Initializing │");
Bootstrap.Debug("└─────────────────────────────────────────────────────────────────────────┘");
}
}
Expand Down
76 changes: 53 additions & 23 deletions GalacticScale2/Scripts/GalacticScale2.0/Models/Themes/GSTheme.cs
Original file line number Diff line number Diff line change
Expand Up @@ -477,7 +477,7 @@ public GSTheme Clone()
public ThemeProto ToProto()
{
if (PlanetType != EPlanetType.Gas) AmbientSettings.ToTheme(this);
return new ThemeProto
var tp = new ThemeProto
{
name = Name,
Name = Name,
Expand Down Expand Up @@ -514,15 +514,17 @@ public ThemeProto ToProto()
SFXPath = SFXPath,
SFXVolume = SFXVolume,
CullingRadius = CullingRadius,
terrainMat = new Material[] {terrainMat},
oceanMat = new Material[] {oceanMat},
atmosMat = new Material[] {atmosMat},
thumbMat = new Material[] {thumbMat},
minimapMat = new Material[] {minimapMat},
ambientDesc = new AmbientDesc[] {ambientDesc},
ambientSfx = new AudioClip[] {ambientSfx},

ID = LDBThemeId
};
if (terrainMat != null) tp.terrainMat = new Material[] { terrainMat };
if (oceanMat != null) tp.oceanMat = new Material[] { oceanMat };
if (atmosMat != null) tp.atmosMat = new Material[] { atmosMat };
if (thumbMat != null) tp.thumbMat = new Material[] { thumbMat };
if (minimapMat != null) tp.minimapMat = new Material[] { minimapMat };
if (ambientDesc != null) tp.ambientDesc = new AmbientDesc[] { ambientDesc };
if (ambientSfx != null) tp.ambientSfx = new AudioClip[] { ambientSfx };
return tp;
}

public int AddToThemeProtoSet()
Expand Down Expand Up @@ -555,7 +557,7 @@ public int UpdateThemeProtoSet()

private bool CreateMaterial(GSMaterialSettings settings, out Material material)
{
//GS2.Log("Start|" + Name);
GS2.Log("Start|" + Name);
var materialType = "terrain";
if (settings == oceanMaterial) materialType = "ocean";

Expand All @@ -570,33 +572,56 @@ private bool CreateMaterial(GSMaterialSettings settings, out Material material)
//GS2.Log("Not Copying From Another Theme");
Material tempMat;
if (settings.Path == null)
{
//GS2.Log("Creating Material from MaterialPath Resource @ " + MaterialPath + materialType);
tempMat = Resources.Load<Material>(MaterialPath + materialType);
//tempMat = Resources.Load<Material>(MaterialPath + materialType);
var matArray = Utils.ResourcesLoadArray<Material>(this.MaterialPath + materialType, "{0}-{1}", true);
if (matArray != null) tempMat = matArray[0];
else tempMat = null;
GS2.Log((tempMat == null).ToString());
}
else
{
//GS2.Log("Creating Material from Settings Defined Resource @ " + settings.Path);
tempMat = Resources.Load<Material>(settings.Path);
//tempMat = Resources.Load<Material>(settings.Path);
var matArray = Utils.ResourcesLoadArray<Material>(settings.Path, "{0}-{1}", true);
if (matArray != null) tempMat = matArray[0];
else tempMat = null;
GS2.Log((tempMat == null).ToString());
}
if (tempMat != null)
{
//GS2.Log("Creating Material");
material = Object.Instantiate(tempMat);
}
else
// GS2.Log("Failed to Create Material|" + Name);
material = Resources.Load<Material>(MaterialPath + materialType);
{
//GS2.Log("Failed to Create Material|" + Name);
//material = Resources.Load<Material>(MaterialPath + materialType);
var matArray = Utils.ResourcesLoadArray<Material>(this.MaterialPath + materialType, "{0}-{1}", true);
if (matArray != null) material = matArray[0];
else material = null;
}
}
else
{
//GS2.Log($"Copying {materialType} from Theme: {settings.CopyFrom}");
GS2.Log($"Copying {materialType} from Theme: {settings.CopyFrom}");
var copyFrom = settings.CopyFrom.Split('.');
if (copyFrom.Length != 2 || copyFrom[0] == null || copyFrom[0] == "" || copyFrom[1] == null || copyFrom[1] == "")
{
GS2.Error("Copyfrom Parameter for Theme Material cannot be parsed. Please ensure it is in the format ThemeName.terrainMat etc");
material = Resources.Load<Material>(MaterialPath + materialType);
// material = Resources.Load<Material>(MaterialPath + materialType);
var matArray = Utils.ResourcesLoadArray<Material>(this.MaterialPath + materialType, "{0}-{1}", true);
if (matArray != null) material = matArray[0];
else material = null;
}
else
{
//GS2.Warn($"Copying {Name} {materialType} material from Theme {settings.CopyFrom}");
var materialBaseTheme = GSSettings.ThemeLibrary.Find(copyFrom[0]);
var materialName = copyFrom[1];
material = Object.Instantiate((Material)typeof(GSTheme).GetField(materialName).GetValue(materialBaseTheme));
//material = Utils.ResourcesLoadArray<Material>(this.MaterialPath + materialType, "{0}-{1}", true)[0];
}
}

Expand All @@ -607,7 +632,7 @@ private bool CreateMaterial(GSMaterialSettings settings, out Material material)
var location = value[0];
var path = value[1];
var name = kvp.Key;
//GS2.Log("Setting Texture " + name + " from " + location + " / " + path);
GS2.Log("Setting Texture " + name + " from " + location + " / " + path);
Texture tex = null;
if (location == "GS2") tex = Utils.GetTextureFromBundle(path);

Expand All @@ -618,12 +643,12 @@ private bool CreateMaterial(GSMaterialSettings settings, out Material material)
if (location == "BUNDLE") tex = Utils.GetTextureFromExternalBundle(path);

if (tex == null)
GS2.Error("Texture not found");
GS2.Error("Texture not found, or method not implemented");
else
//GS2.Log("Assigning Texture");
material.SetTexture(name, tex);
GS2.Log("Assigning Texture");
material.SetTexture(name, tex);
}

//GS2.Warn($"Material null? {material == null}");
return false;
}

Expand All @@ -646,14 +671,19 @@ public void InitMaterials()
{
if (AmbientSettings.ResourcePath != null && AmbientSettings.ResourcePath != "")
//GS2.Log("Loading AmbientDesc from AmbientSettings.ResourcePath" + AmbientSettings.ResourcePath);
Resources.Load<AmbientDesc>(AmbientSettings.ResourcePath);
//Resources.Load<AmbientDesc>(AmbientSettings.ResourcePath);
ambientDesc = Utils.ResourcesLoadArray<AmbientDesc>(AmbientSettings.ResourcePath, "{0}-{1}", true)[0];
else if (ambient == null)
//GS2.Log("Loading AmbientDesc from MaterialPath = " + MaterialPath + "ambient");
ambientDesc = Resources.Load<AmbientDesc>(MaterialPath + "ambient");
//ambientDesc = Resources.Load<AmbientDesc>(MaterialPath + "ambient");
ambientDesc = Utils.ResourcesLoadArray<AmbientDesc>(this.MaterialPath + "ambient", "{0}-{1}", true)[0];


else
//GS2.Log("Loading AmbientDesc from base theme = "+ambient);
ambientDesc = GSSettings.ThemeLibrary.Find(ambient).ambientDesc;
ambientSfx = Resources.Load<AudioClip>(SFXPath);
//ambientSfx = Resources.Load<AudioClip>(SFXPath);
ambientSfx = Utils.ResourcesLoadArray<AudioClip>(this.SFXPath, "{0}-{1}", true)[0];
}

initialized = true;
Expand Down
60 changes: 60 additions & 0 deletions GalacticScale2/Scripts/GalacticScale2.0/Patches/-Debug/Debug.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,70 @@
using HarmonyLib;
using System;
using System.Collections.Generic;
using UnityEngine;

namespace GalacticScale

{
public class PatchOnWhatever
{
[HarmonyPrefix, HarmonyPatch(typeof(ThemeProto), "Preload")]
public static bool Preload(ref ThemeProto __instance)
{
__instance.displayName = __instance.DisplayName.Translate();
__instance.terrainMat = Utils.ResourcesLoadArray<Material>(__instance.MaterialPath + "terrain", "{0}-{1}", true);
__instance.oceanMat = Utils.ResourcesLoadArray<Material>(__instance.MaterialPath + "ocean", "{0}-{1}", true);
__instance.atmosMat = Utils.ResourcesLoadArray<Material>(__instance.MaterialPath + "atmosphere", "{0}-{1}", true);
__instance.lowMat = Utils.ResourcesLoadArray<Material>(__instance.MaterialPath + "low", "{0}-{1}", true);
__instance.thumbMat = Utils.ResourcesLoadArray<Material>(__instance.MaterialPath + "thumb", "{0}-{1}", true);
__instance.minimapMat = Utils.ResourcesLoadArray<Material>(__instance.MaterialPath + "minimap", "{0}-{1}", true);
__instance.ambientDesc = Utils.ResourcesLoadArray<AmbientDesc>(__instance.MaterialPath + "ambient", "{0}-{1}", true);
__instance.ambientSfx = Utils.ResourcesLoadArray<AudioClip>(__instance.SFXPath, "{0}-{1}", true);
if (__instance.RareSettings.Length != __instance.RareVeins.Length * 4)
{
Debug.LogError("稀有矿物数组长度有误 " + __instance.displayName);
}
return false;
}

//[HarmonyPrefix, HarmonyPatch(typeof(CommonUtils), "ResourcesLoadArray")]
//public static bool ResourcesLoadArray<T>(ref T[] __result, string path, string format, bool emptyNull) where T : UnityEngine.Object
//{
// List<T> list = new List<T>();

// T t = Resources.Load<T>(path);
// if (t == null)
// {
// GS2.Log("Resource returned null, exiting");
// __result = null;
// return false;
// }
// GS2.Log("Resource loaded");
// int num = 0;
// if (t != null)
// {
// list.Add(t);
// num = 1;
// }
// do
// {
// t = Resources.Load<T>(string.Format(format, path, num));
// if (t == null || ((num == 1 || num == 2) && list.Contains(t)))
// {
// break;
// }
// list.Add(t);
// num++;
// }
// while (num < 1024);
// if (emptyNull && list.Count == 0)
// {
// __result = null;
// return false;
// }
// __result = list.ToArray();
// return false;
//}
//[HarmonyPatch(typeof(WorkerThreadExecutor), "InserterPartExecute")]
//[HarmonyPrefix]
//public static bool InserterPartExecute(ref WorkerThreadExecutor __instance)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ public partial class PatchOnPlanetModelingManager
[HarmonyPatch(typeof(PlanetModelingManager), "ModelingPlanetCoroutine")]
public static bool ModelingPlanetCoroutine()
{
if (GS2.IsMenuDemo || GS2.Vanilla) return true;
// GS2.Log("ModelingPlanetCoroutine");
Modeler.ModelingCoroutine();
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ public static void ModelingCoroutine()
{
planetData = planetModQueue[0];
planetModQueue.RemoveAt(0);
Log($"Modelling {planetData.name}");
Log($"Modelling {planetData.name} - {GetGSPlanet(planetData).Theme}");
}

if (planetData != null)
Expand Down
36 changes: 36 additions & 0 deletions GalacticScale2/Scripts/GalacticScale2.0/Utils/Utils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,42 @@ public static string Serialize(object value, bool pretty = true)
return fsJsonPrinter.PrettyJson(data);
}

public static T[] ResourcesLoadArray<T>(string path, string format, bool emptyNull) where T : UnityEngine.Object
{

List<T> list = new List<T>();

T t = Resources.Load<T>(path);
if (t == null)
{
//GS2.Log("Resource returned null, exiting");
return null;
}
//GS2.Log("Resource loaded");
int num = 0;
if (t != null)
{
list.Add(t);
num = 1;
}
do
{
t = Resources.Load<T>(string.Format(format, path, num));
if (t == null || ((num == 1 || num == 2) && list.Contains(t)))
{
break;
}
list.Add(t);
num++;
}
while (num < 1024);
if (emptyNull && list.Count == 0)
{
return null;
}
return list.ToArray();
}

public static VectorLF3 PolarToCartesian(double p, double theta, double phi)
{
var x = p * Math.Sin(phi) * Math.Cos(theta);
Expand Down

0 comments on commit b86e11f

Please sign in to comment.