mirror of
https://github.com/Outer-Wilds-New-Horizons/new-horizons.git
synced 2025-12-11 20:15:44 +01:00
Change texture load for ship log
This commit is contained in:
parent
d2a223cefb
commit
8b253ed6a0
@ -15,7 +15,7 @@ namespace NewHorizons.Builder.ShipLog
|
|||||||
public static class EntryLocationBuilder
|
public static class EntryLocationBuilder
|
||||||
{
|
{
|
||||||
private static readonly List<ShipLogEntryLocation> _locationsToInitialize = new List<ShipLogEntryLocation>();
|
private static readonly List<ShipLogEntryLocation> _locationsToInitialize = new List<ShipLogEntryLocation>();
|
||||||
public static void Make(GameObject go, Sector sector, PropModule.EntryLocationInfo info, IModHelper mod)
|
public static void Make(GameObject go, Sector sector, PropModule.EntryLocationInfo info, IModBehaviour mod)
|
||||||
{
|
{
|
||||||
GameObject entryLocationGameObject = new GameObject("Entry Location (" + info.id + ")");
|
GameObject entryLocationGameObject = new GameObject("Entry Location (" + info.id + ")");
|
||||||
entryLocationGameObject.SetActive(false);
|
entryLocationGameObject.SetActive(false);
|
||||||
|
|||||||
@ -63,7 +63,7 @@ namespace NewHorizons.Builder.ShipLog
|
|||||||
return ShipLogHandler.GetNameFromAstroID(id) ?? id;
|
return ShipLogHandler.GetNameFromAstroID(id) ?? id;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static GameObject CreateImage(GameObject nodeGO, IModAssets assets, Texture2D texture, string name, int layer)
|
private static GameObject CreateImage(GameObject nodeGO, Texture2D texture, string name, int layer)
|
||||||
{
|
{
|
||||||
GameObject newImageGO = new GameObject(name);
|
GameObject newImageGO = new GameObject(name);
|
||||||
newImageGO.layer = layer;
|
newImageGO.layer = layer;
|
||||||
@ -113,14 +113,14 @@ namespace NewHorizons.Builder.ShipLog
|
|||||||
string imagePath = body.Config.ShipLog?.mapMode?.revealedSprite;
|
string imagePath = body.Config.ShipLog?.mapMode?.revealedSprite;
|
||||||
string outlinePath = body.Config.ShipLog?.mapMode?.outlineSprite;
|
string outlinePath = body.Config.ShipLog?.mapMode?.outlineSprite;
|
||||||
|
|
||||||
if (imagePath != null) image = body.Mod.Assets.GetTexture(imagePath);
|
if (imagePath != null) image = ImageUtilities.GetTexture(body.Mod, imagePath);
|
||||||
else image = AutoGenerateMapModePicture(body);
|
else image = AutoGenerateMapModePicture(body);
|
||||||
|
|
||||||
if (outlinePath != null) outline = body.Mod.Assets.GetTexture(outlinePath);
|
if (outlinePath != null) outline = ImageUtilities.GetTexture(body.Mod, outlinePath);
|
||||||
else outline = ImageUtilities.MakeOutline(image, Color.white, 10);
|
else outline = ImageUtilities.MakeOutline(image, Color.white, 10);
|
||||||
|
|
||||||
astroObject._imageObj = CreateImage(gameObject, body.Mod.Assets, image, body.Config.Name + " Revealed", layer);
|
astroObject._imageObj = CreateImage(gameObject, image, body.Config.Name + " Revealed", layer);
|
||||||
astroObject._outlineObj = CreateImage(gameObject, body.Mod.Assets, outline, body.Config.Name + " Outline", layer);
|
astroObject._outlineObj = CreateImage(gameObject, outline, body.Config.Name + " Outline", layer);
|
||||||
if (ShipLogHandler.BodyHasEntries(body))
|
if (ShipLogHandler.BodyHasEntries(body))
|
||||||
{
|
{
|
||||||
Image revealedImage = astroObject._imageObj.GetComponent<Image>();
|
Image revealedImage = astroObject._imageObj.GetComponent<Image>();
|
||||||
@ -157,14 +157,14 @@ namespace NewHorizons.Builder.ShipLog
|
|||||||
string imagePath = info.revealedSprite;
|
string imagePath = info.revealedSprite;
|
||||||
string outlinePath = info.outlineSprite;
|
string outlinePath = info.outlineSprite;
|
||||||
|
|
||||||
if (imagePath != null) image = body.Mod.Assets.GetTexture(imagePath);
|
if (imagePath != null) image = ImageUtilities.GetTexture(body.Mod, imagePath);
|
||||||
else image = AutoGenerateMapModePicture(body);
|
else image = AutoGenerateMapModePicture(body);
|
||||||
|
|
||||||
if (outlinePath != null) outline = body.Mod.Assets.GetTexture(outlinePath);
|
if (outlinePath != null) outline = ImageUtilities.GetTexture(body.Mod, outlinePath);
|
||||||
else outline = ImageUtilities.MakeOutline(image, Color.white, 10);
|
else outline = ImageUtilities.MakeOutline(image, Color.white, 10);
|
||||||
|
|
||||||
Image revealedImage = CreateImage(detailGameObject, body.Mod.Assets, image, "Detail Revealed", parent.gameObject.layer).GetComponent<Image>();
|
Image revealedImage = CreateImage(detailGameObject, image, "Detail Revealed", parent.gameObject.layer).GetComponent<Image>();
|
||||||
Image outlineImage = CreateImage(detailGameObject, body.Mod.Assets, outline, "Detail Outline", parent.gameObject.layer).GetComponent<Image>();
|
Image outlineImage = CreateImage(detailGameObject, outline, "Detail Outline", parent.gameObject.layer).GetComponent<Image>();
|
||||||
|
|
||||||
ShipLogDetail detail = detailGameObject.AddComponent<ShipLogDetail>();
|
ShipLogDetail detail = detailGameObject.AddComponent<ShipLogDetail>();
|
||||||
detail.Init(info, revealedImage, outlineImage, greyScaleMaterial);
|
detail.Init(info, revealedImage, outlineImage, greyScaleMaterial);
|
||||||
@ -500,9 +500,9 @@ namespace NewHorizons.Builder.ShipLog
|
|||||||
{
|
{
|
||||||
Texture2D texture;
|
Texture2D texture;
|
||||||
|
|
||||||
if(body.Config.Star != null) texture = Main.Instance.ModHelper.Assets.GetTexture("AssetBundle/DefaultMapModeStar.png");
|
if(body.Config.Star != null) texture = ImageUtilities.GetTexture(Main.Instance, "AssetBundle/DefaultMapModeStar.png");
|
||||||
else if(body.Config.Atmosphere != null) texture = Main.Instance.ModHelper.Assets.GetTexture("AssetBundle/DefaultMapModNoAtmo.png");
|
else if(body.Config.Atmosphere != null) texture = ImageUtilities.GetTexture(Main.Instance, "AssetBundle/DefaultMapModNoAtmo.png");
|
||||||
else texture = Main.Instance.ModHelper.Assets.GetTexture("AssetBundle/DefaultMapModePlanet.png");
|
else texture = ImageUtilities.GetTexture(Main.Instance, "AssetBundle/DefaultMapModePlanet.png");
|
||||||
|
|
||||||
var color = GetDominantPlanetColor(body);
|
var color = GetDominantPlanetColor(body);
|
||||||
var darkColor = new Color(color.r / 3f, color.g / 3f, color.b / 3f);
|
var darkColor = new Color(color.r / 3f, color.g / 3f, color.b / 3f);
|
||||||
@ -529,7 +529,7 @@ namespace NewHorizons.Builder.ShipLog
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var texture = body.Mod.Assets.GetTexture(body.Config.HeightMap.TextureMap);
|
var texture = ImageUtilities.GetTexture(body.Mod, body.Config.HeightMap.TextureMap);
|
||||||
var landColor = ImageUtilities.GetAverageColor(texture);
|
var landColor = ImageUtilities.GetAverageColor(texture);
|
||||||
if (landColor != null) return landColor;
|
if (landColor != null) return landColor;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -14,7 +14,7 @@ namespace NewHorizons.Builder.ShipLog
|
|||||||
{
|
{
|
||||||
public static class RevealBuilder
|
public static class RevealBuilder
|
||||||
{
|
{
|
||||||
public static void Make(GameObject go, Sector sector, PropModule.RevealInfo info, IModHelper mod)
|
public static void Make(GameObject go, Sector sector, PropModule.RevealInfo info, IModBehaviour mod)
|
||||||
{
|
{
|
||||||
GameObject newRevealGO = MakeGameObject(go, sector, info, mod);
|
GameObject newRevealGO = MakeGameObject(go, sector, info, mod);
|
||||||
switch (info.revealOn.ToLower())
|
switch (info.revealOn.ToLower())
|
||||||
@ -44,7 +44,7 @@ namespace NewHorizons.Builder.ShipLog
|
|||||||
return newShape;
|
return newShape;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static GameObject MakeGameObject(GameObject go, Sector sector, PropModule.RevealInfo info, IModHelper mod)
|
private static GameObject MakeGameObject(GameObject go, Sector sector, PropModule.RevealInfo info, IModBehaviour mod)
|
||||||
{
|
{
|
||||||
GameObject revealTriggerVolume = new GameObject("Reveal Volume (" + info.revealOn + ")");
|
GameObject revealTriggerVolume = new GameObject("Reveal Volume (" + info.revealOn + ")");
|
||||||
revealTriggerVolume.SetActive(false);
|
revealTriggerVolume.SetActive(false);
|
||||||
@ -53,7 +53,7 @@ namespace NewHorizons.Builder.ShipLog
|
|||||||
return revealTriggerVolume;
|
return revealTriggerVolume;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void MakeTrigger(GameObject go, Sector sector, PropModule.RevealInfo info, IModHelper mod)
|
private static void MakeTrigger(GameObject go, Sector sector, PropModule.RevealInfo info, IModBehaviour mod)
|
||||||
{
|
{
|
||||||
SphereShape newShape = MakeShape(go, info, Shape.CollisionMode.Volume);
|
SphereShape newShape = MakeShape(go, info, Shape.CollisionMode.Volume);
|
||||||
OWTriggerVolume newVolume = go.AddComponent<OWTriggerVolume>();
|
OWTriggerVolume newVolume = go.AddComponent<OWTriggerVolume>();
|
||||||
@ -62,7 +62,7 @@ namespace NewHorizons.Builder.ShipLog
|
|||||||
volume._factIDs = info.reveals;
|
volume._factIDs = info.reveals;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void MakeObservable(GameObject go, Sector sector, PropModule.RevealInfo info, IModHelper mod)
|
private static void MakeObservable(GameObject go, Sector sector, PropModule.RevealInfo info, IModBehaviour mod)
|
||||||
{
|
{
|
||||||
go.layer = LayerMask.NameToLayer("Interactible");
|
go.layer = LayerMask.NameToLayer("Interactible");
|
||||||
SphereCollider newSphere = go.AddComponent<SphereCollider>();
|
SphereCollider newSphere = go.AddComponent<SphereCollider>();
|
||||||
@ -76,7 +76,7 @@ namespace NewHorizons.Builder.ShipLog
|
|||||||
newObserveTrigger._disableColliderOnRevealFact = true;
|
newObserveTrigger._disableColliderOnRevealFact = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void MakeSnapshot(GameObject go, Sector sector, PropModule.RevealInfo info, IModHelper mod)
|
private static void MakeSnapshot(GameObject go, Sector sector, PropModule.RevealInfo info, IModBehaviour mod)
|
||||||
{
|
{
|
||||||
SphereShape newShape = MakeShape(go, info, Shape.CollisionMode.Manual);
|
SphereShape newShape = MakeShape(go, info, Shape.CollisionMode.Manual);
|
||||||
ShapeVisibilityTracker newTracker = go.AddComponent<ShapeVisibilityTracker>();
|
ShapeVisibilityTracker newTracker = go.AddComponent<ShapeVisibilityTracker>();
|
||||||
|
|||||||
@ -58,7 +58,7 @@ namespace NewHorizons.Builder.ShipLog
|
|||||||
public static void AddBodyToShipLog(ShipLogManager manager, NewHorizonsBody body)
|
public static void AddBodyToShipLog(ShipLogManager manager, NewHorizonsBody body)
|
||||||
{
|
{
|
||||||
string systemName = body.Config.StarSystem;
|
string systemName = body.Config.StarSystem;
|
||||||
XElement astroBodyFile = XElement.Load(body.Mod.Manifest.ModFolderPath + "/" + body.Config.ShipLog.xmlFile);
|
XElement astroBodyFile = XElement.Load(body.Mod.ModHelper.Manifest.ModFolderPath + "/" + body.Config.ShipLog.xmlFile);
|
||||||
XElement astroBodyId = astroBodyFile.Element("ID");
|
XElement astroBodyId = astroBodyFile.Element("ID");
|
||||||
if (astroBodyId == null)
|
if (astroBodyId == null)
|
||||||
{
|
{
|
||||||
@ -208,7 +208,7 @@ namespace NewHorizons.Builder.ShipLog
|
|||||||
string relativePath = body.Config.ShipLog.spriteFolder + "/" + entryId + ".png";
|
string relativePath = body.Config.ShipLog.spriteFolder + "/" + entryId + ".png";
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Texture2D newTexture = body.Mod.Assets.GetTexture(relativePath);
|
Texture2D newTexture = ImageUtilities.GetTexture(body.Mod, relativePath);
|
||||||
Rect rect = new Rect(0, 0, newTexture.width, newTexture.height);
|
Rect rect = new Rect(0, 0, newTexture.width, newTexture.height);
|
||||||
Vector2 pivot = new Vector2(newTexture.width / 2, newTexture.height / 2);
|
Vector2 pivot = new Vector2(newTexture.width / 2, newTexture.height / 2);
|
||||||
return Sprite.Create(newTexture, rect, pivot);
|
return Sprite.Create(newTexture, rect, pivot);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user