Skip to content

Commit b86e11f

Browse files
committed
2.2.0.1
1 parent de331bb commit b86e11f

File tree

8 files changed

+609
-482
lines changed

8 files changed

+609
-482
lines changed

GalacticScale2/DSP_Plugins.GalacticScale.csproj

Lines changed: 454 additions & 454 deletions
Large diffs are not rendered by default.

GalacticScale2/Scripts/GalacticScale2.0/Init.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -119,10 +119,10 @@ public static void Init()
119119
{
120120
if (File.Exists(Path.Combine(AssemblyPath, "icon.png")))
121121
{
122-
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();
122+
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();
123123
File.Delete(Path.Combine(AssemblyPath, "icon.png"));
124-
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.";
125-
}
124+
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";
125+
}
126126

127127
// Warn("Start");
128128
if (Directory.Exists(OldDataDir) && !Directory.Exists(DataDir))

GalacticScale2/Scripts/GalacticScale2.0/Logging/ConsoleSplash.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public static void ConsoleSplash()
2727
Bootstrap.Debug("┌─────────────────────────────────────────────────────────────────────────┐"); // Failsafe if BCE not present
2828
Bootstrap.Debug("│ ╔═╗┌─┐┬ ┌─┐┌─┐┌┬┐┬┌─┐ ╔═╗┌─┐┌─┐┬ ┌─┐ │");
2929
Bootstrap.Debug("│ ║ ╦├─┤│ ├─┤│ │ ││ ╚═╗│ ├─┤│ ├┤ │");
30-
Bootstrap.Debug("│ ╚═╝┴ ┴┴─┘┴ ┴└─┘ ┴ ┴└─┘ ╚═╝└─┘┴ ┴┴─┘└─┘ Version " + Version + " Initializing │");
30+
Bootstrap.Debug("│ ╚═╝┴ ┴┴─┘┴ ┴└─┘ ┴ ┴└─┘ ╚═╝└─┘┴ ┴┴─┘└─┘ Version " + Version + " Initializing │");
3131
Bootstrap.Debug("└─────────────────────────────────────────────────────────────────────────┘");
3232
}
3333
}

GalacticScale2/Scripts/GalacticScale2.0/Models/Themes/GSTheme.cs

Lines changed: 53 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -477,7 +477,7 @@ public GSTheme Clone()
477477
public ThemeProto ToProto()
478478
{
479479
if (PlanetType != EPlanetType.Gas) AmbientSettings.ToTheme(this);
480-
return new ThemeProto
480+
var tp = new ThemeProto
481481
{
482482
name = Name,
483483
Name = Name,
@@ -514,15 +514,17 @@ public ThemeProto ToProto()
514514
SFXPath = SFXPath,
515515
SFXVolume = SFXVolume,
516516
CullingRadius = CullingRadius,
517-
terrainMat = new Material[] {terrainMat},
518-
oceanMat = new Material[] {oceanMat},
519-
atmosMat = new Material[] {atmosMat},
520-
thumbMat = new Material[] {thumbMat},
521-
minimapMat = new Material[] {minimapMat},
522-
ambientDesc = new AmbientDesc[] {ambientDesc},
523-
ambientSfx = new AudioClip[] {ambientSfx},
517+
524518
ID = LDBThemeId
525519
};
520+
if (terrainMat != null) tp.terrainMat = new Material[] { terrainMat };
521+
if (oceanMat != null) tp.oceanMat = new Material[] { oceanMat };
522+
if (atmosMat != null) tp.atmosMat = new Material[] { atmosMat };
523+
if (thumbMat != null) tp.thumbMat = new Material[] { thumbMat };
524+
if (minimapMat != null) tp.minimapMat = new Material[] { minimapMat };
525+
if (ambientDesc != null) tp.ambientDesc = new AmbientDesc[] { ambientDesc };
526+
if (ambientSfx != null) tp.ambientSfx = new AudioClip[] { ambientSfx };
527+
return tp;
526528
}
527529

528530
public int AddToThemeProtoSet()
@@ -555,7 +557,7 @@ public int UpdateThemeProtoSet()
555557

556558
private bool CreateMaterial(GSMaterialSettings settings, out Material material)
557559
{
558-
//GS2.Log("Start|" + Name);
560+
GS2.Log("Start|" + Name);
559561
var materialType = "terrain";
560562
if (settings == oceanMaterial) materialType = "ocean";
561563

@@ -570,33 +572,56 @@ private bool CreateMaterial(GSMaterialSettings settings, out Material material)
570572
//GS2.Log("Not Copying From Another Theme");
571573
Material tempMat;
572574
if (settings.Path == null)
575+
{
573576
//GS2.Log("Creating Material from MaterialPath Resource @ " + MaterialPath + materialType);
574-
tempMat = Resources.Load<Material>(MaterialPath + materialType);
577+
//tempMat = Resources.Load<Material>(MaterialPath + materialType);
578+
var matArray = Utils.ResourcesLoadArray<Material>(this.MaterialPath + materialType, "{0}-{1}", true);
579+
if (matArray != null) tempMat = matArray[0];
580+
else tempMat = null;
581+
GS2.Log((tempMat == null).ToString());
582+
}
575583
else
584+
{
576585
//GS2.Log("Creating Material from Settings Defined Resource @ " + settings.Path);
577-
tempMat = Resources.Load<Material>(settings.Path);
586+
//tempMat = Resources.Load<Material>(settings.Path);
587+
var matArray = Utils.ResourcesLoadArray<Material>(settings.Path, "{0}-{1}", true);
588+
if (matArray != null) tempMat = matArray[0];
589+
else tempMat = null;
590+
GS2.Log((tempMat == null).ToString());
591+
}
578592
if (tempMat != null)
593+
{
579594
//GS2.Log("Creating Material");
580595
material = Object.Instantiate(tempMat);
596+
}
581597
else
582-
// GS2.Log("Failed to Create Material|" + Name);
583-
material = Resources.Load<Material>(MaterialPath + materialType);
598+
{
599+
//GS2.Log("Failed to Create Material|" + Name);
600+
//material = Resources.Load<Material>(MaterialPath + materialType);
601+
var matArray = Utils.ResourcesLoadArray<Material>(this.MaterialPath + materialType, "{0}-{1}", true);
602+
if (matArray != null) material = matArray[0];
603+
else material = null;
604+
}
584605
}
585606
else
586607
{
587-
//GS2.Log($"Copying {materialType} from Theme: {settings.CopyFrom}");
608+
GS2.Log($"Copying {materialType} from Theme: {settings.CopyFrom}");
588609
var copyFrom = settings.CopyFrom.Split('.');
589610
if (copyFrom.Length != 2 || copyFrom[0] == null || copyFrom[0] == "" || copyFrom[1] == null || copyFrom[1] == "")
590611
{
591612
GS2.Error("Copyfrom Parameter for Theme Material cannot be parsed. Please ensure it is in the format ThemeName.terrainMat etc");
592-
material = Resources.Load<Material>(MaterialPath + materialType);
613+
// material = Resources.Load<Material>(MaterialPath + materialType);
614+
var matArray = Utils.ResourcesLoadArray<Material>(this.MaterialPath + materialType, "{0}-{1}", true);
615+
if (matArray != null) material = matArray[0];
616+
else material = null;
593617
}
594618
else
595619
{
596620
//GS2.Warn($"Copying {Name} {materialType} material from Theme {settings.CopyFrom}");
597621
var materialBaseTheme = GSSettings.ThemeLibrary.Find(copyFrom[0]);
598622
var materialName = copyFrom[1];
599623
material = Object.Instantiate((Material)typeof(GSTheme).GetField(materialName).GetValue(materialBaseTheme));
624+
//material = Utils.ResourcesLoadArray<Material>(this.MaterialPath + materialType, "{0}-{1}", true)[0];
600625
}
601626
}
602627

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

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

620645
if (tex == null)
621-
GS2.Error("Texture not found");
646+
GS2.Error("Texture not found, or method not implemented");
622647
else
623-
//GS2.Log("Assigning Texture");
624-
material.SetTexture(name, tex);
648+
GS2.Log("Assigning Texture");
649+
material.SetTexture(name, tex);
625650
}
626-
651+
//GS2.Warn($"Material null? {material == null}");
627652
return false;
628653
}
629654

@@ -646,14 +671,19 @@ public void InitMaterials()
646671
{
647672
if (AmbientSettings.ResourcePath != null && AmbientSettings.ResourcePath != "")
648673
//GS2.Log("Loading AmbientDesc from AmbientSettings.ResourcePath" + AmbientSettings.ResourcePath);
649-
Resources.Load<AmbientDesc>(AmbientSettings.ResourcePath);
674+
//Resources.Load<AmbientDesc>(AmbientSettings.ResourcePath);
675+
ambientDesc = Utils.ResourcesLoadArray<AmbientDesc>(AmbientSettings.ResourcePath, "{0}-{1}", true)[0];
650676
else if (ambient == null)
651677
//GS2.Log("Loading AmbientDesc from MaterialPath = " + MaterialPath + "ambient");
652-
ambientDesc = Resources.Load<AmbientDesc>(MaterialPath + "ambient");
678+
//ambientDesc = Resources.Load<AmbientDesc>(MaterialPath + "ambient");
679+
ambientDesc = Utils.ResourcesLoadArray<AmbientDesc>(this.MaterialPath + "ambient", "{0}-{1}", true)[0];
680+
681+
653682
else
654683
//GS2.Log("Loading AmbientDesc from base theme = "+ambient);
655684
ambientDesc = GSSettings.ThemeLibrary.Find(ambient).ambientDesc;
656-
ambientSfx = Resources.Load<AudioClip>(SFXPath);
685+
//ambientSfx = Resources.Load<AudioClip>(SFXPath);
686+
ambientSfx = Utils.ResourcesLoadArray<AudioClip>(this.SFXPath, "{0}-{1}", true)[0];
657687
}
658688

659689
initialized = true;

GalacticScale2/Scripts/GalacticScale2.0/Patches/-Debug/Debug.cs

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,70 @@
11
using HarmonyLib;
2+
using System;
3+
using System.Collections.Generic;
4+
using UnityEngine;
25

36
namespace GalacticScale
47

58
{
69
public class PatchOnWhatever
710
{
11+
[HarmonyPrefix, HarmonyPatch(typeof(ThemeProto), "Preload")]
12+
public static bool Preload(ref ThemeProto __instance)
13+
{
14+
__instance.displayName = __instance.DisplayName.Translate();
15+
__instance.terrainMat = Utils.ResourcesLoadArray<Material>(__instance.MaterialPath + "terrain", "{0}-{1}", true);
16+
__instance.oceanMat = Utils.ResourcesLoadArray<Material>(__instance.MaterialPath + "ocean", "{0}-{1}", true);
17+
__instance.atmosMat = Utils.ResourcesLoadArray<Material>(__instance.MaterialPath + "atmosphere", "{0}-{1}", true);
18+
__instance.lowMat = Utils.ResourcesLoadArray<Material>(__instance.MaterialPath + "low", "{0}-{1}", true);
19+
__instance.thumbMat = Utils.ResourcesLoadArray<Material>(__instance.MaterialPath + "thumb", "{0}-{1}", true);
20+
__instance.minimapMat = Utils.ResourcesLoadArray<Material>(__instance.MaterialPath + "minimap", "{0}-{1}", true);
21+
__instance.ambientDesc = Utils.ResourcesLoadArray<AmbientDesc>(__instance.MaterialPath + "ambient", "{0}-{1}", true);
22+
__instance.ambientSfx = Utils.ResourcesLoadArray<AudioClip>(__instance.SFXPath, "{0}-{1}", true);
23+
if (__instance.RareSettings.Length != __instance.RareVeins.Length * 4)
24+
{
25+
Debug.LogError("稀有矿物数组长度有误 " + __instance.displayName);
26+
}
27+
return false;
28+
}
29+
30+
//[HarmonyPrefix, HarmonyPatch(typeof(CommonUtils), "ResourcesLoadArray")]
31+
//public static bool ResourcesLoadArray<T>(ref T[] __result, string path, string format, bool emptyNull) where T : UnityEngine.Object
32+
//{
33+
// List<T> list = new List<T>();
34+
35+
// T t = Resources.Load<T>(path);
36+
// if (t == null)
37+
// {
38+
// GS2.Log("Resource returned null, exiting");
39+
// __result = null;
40+
// return false;
41+
// }
42+
// GS2.Log("Resource loaded");
43+
// int num = 0;
44+
// if (t != null)
45+
// {
46+
// list.Add(t);
47+
// num = 1;
48+
// }
49+
// do
50+
// {
51+
// t = Resources.Load<T>(string.Format(format, path, num));
52+
// if (t == null || ((num == 1 || num == 2) && list.Contains(t)))
53+
// {
54+
// break;
55+
// }
56+
// list.Add(t);
57+
// num++;
58+
// }
59+
// while (num < 1024);
60+
// if (emptyNull && list.Count == 0)
61+
// {
62+
// __result = null;
63+
// return false;
64+
// }
65+
// __result = list.ToArray();
66+
// return false;
67+
//}
868
//[HarmonyPatch(typeof(WorkerThreadExecutor), "InserterPartExecute")]
969
//[HarmonyPrefix]
1070
//public static bool InserterPartExecute(ref WorkerThreadExecutor __instance)

GalacticScale2/Scripts/GalacticScale2.0/Patches/PlanetModelingManager/ModelingPlanetCoroutine.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ public partial class PatchOnPlanetModelingManager
88
[HarmonyPatch(typeof(PlanetModelingManager), "ModelingPlanetCoroutine")]
99
public static bool ModelingPlanetCoroutine()
1010
{
11+
if (GS2.IsMenuDemo || GS2.Vanilla) return true;
1112
// GS2.Log("ModelingPlanetCoroutine");
1213
Modeler.ModelingCoroutine();
1314
return false;

GalacticScale2/Scripts/GalacticScale2.0/Planet Generation/Modeler.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ public static void ModelingCoroutine()
180180
{
181181
planetData = planetModQueue[0];
182182
planetModQueue.RemoveAt(0);
183-
Log($"Modelling {planetData.name}");
183+
Log($"Modelling {planetData.name} - {GetGSPlanet(planetData).Theme}");
184184
}
185185

186186
if (planetData != null)

GalacticScale2/Scripts/GalacticScale2.0/Utils/Utils.cs

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,42 @@ public static string Serialize(object value, bool pretty = true)
2424
return fsJsonPrinter.PrettyJson(data);
2525
}
2626

27+
public static T[] ResourcesLoadArray<T>(string path, string format, bool emptyNull) where T : UnityEngine.Object
28+
{
29+
30+
List<T> list = new List<T>();
31+
32+
T t = Resources.Load<T>(path);
33+
if (t == null)
34+
{
35+
//GS2.Log("Resource returned null, exiting");
36+
return null;
37+
}
38+
//GS2.Log("Resource loaded");
39+
int num = 0;
40+
if (t != null)
41+
{
42+
list.Add(t);
43+
num = 1;
44+
}
45+
do
46+
{
47+
t = Resources.Load<T>(string.Format(format, path, num));
48+
if (t == null || ((num == 1 || num == 2) && list.Contains(t)))
49+
{
50+
break;
51+
}
52+
list.Add(t);
53+
num++;
54+
}
55+
while (num < 1024);
56+
if (emptyNull && list.Count == 0)
57+
{
58+
return null;
59+
}
60+
return list.ToArray();
61+
}
62+
2763
public static VectorLF3 PolarToCartesian(double p, double theta, double phi)
2864
{
2965
var x = p * Math.Sin(phi) * Math.Cos(theta);

0 commit comments

Comments
 (0)