mirror of
https://github.com/Outer-Wilds-New-Horizons/new-horizons.git
synced 2025-12-11 20:15:44 +01:00
added mirror status to spiral cache and fixed bugs with loading cache
This commit is contained in:
parent
c03938a1ab
commit
bf2043a80b
@ -626,6 +626,7 @@ namespace NewHorizons.Builder.Props
|
|||||||
public MVector3[] skeletonPoints;
|
public MVector3[] skeletonPoints;
|
||||||
public MVector3 position;
|
public MVector3 position;
|
||||||
public float zRotation;
|
public float zRotation;
|
||||||
|
public bool mirrored;
|
||||||
}
|
}
|
||||||
|
|
||||||
internal static void RefreshArcs(NomaiWallText nomaiWallText, GameObject conversationZone, PropModule.NomaiTextInfo info, NewHorizonsBody nhBody, string cacheKey)
|
internal static void RefreshArcs(NomaiWallText nomaiWallText, GameObject conversationZone, PropModule.NomaiTextInfo info, NewHorizonsBody nhBody, string cacheKey)
|
||||||
@ -671,6 +672,7 @@ namespace NewHorizons.Builder.Props
|
|||||||
var skeletonPoints = cachedData[i].skeletonPoints.Select(mv => (Vector3)mv).ToArray();
|
var skeletonPoints = cachedData[i].skeletonPoints.Select(mv => (Vector3)mv).ToArray();
|
||||||
arcReadFromCache = NomaiTextArcBuilder.BuildSpiralGameObject(skeletonPoints, cachedData[i].mesh);
|
arcReadFromCache = NomaiTextArcBuilder.BuildSpiralGameObject(skeletonPoints, cachedData[i].mesh);
|
||||||
arcReadFromCache.transform.parent = arranger.transform;
|
arcReadFromCache.transform.parent = arranger.transform;
|
||||||
|
arcReadFromCache.transform.localScale = new Vector3(cachedData[i].mirrored? -1 : 1, 1, 1);
|
||||||
arcReadFromCache.transform.localPosition = cachedData[i].position;
|
arcReadFromCache.transform.localPosition = cachedData[i].position;
|
||||||
arcReadFromCache.transform.localEulerAngles = new Vector3(0, 0, cachedData[i].zRotation);
|
arcReadFromCache.transform.localEulerAngles = new Vector3(0, 0, cachedData[i].zRotation);
|
||||||
}
|
}
|
||||||
@ -727,7 +729,8 @@ namespace NewHorizons.Builder.Props
|
|||||||
mesh = spiralManipulator.GetComponent<MeshFilter>().sharedMesh, // TODO: create a serializable version of Mesh and pass this: spiralManipulator.GetComponent<MeshFilter>().mesh
|
mesh = spiralManipulator.GetComponent<MeshFilter>().sharedMesh, // TODO: create a serializable version of Mesh and pass this: spiralManipulator.GetComponent<MeshFilter>().mesh
|
||||||
skeletonPoints = spiralManipulator.NomaiTextLine._points.Select(v => (MVector3)v).ToArray(),
|
skeletonPoints = spiralManipulator.NomaiTextLine._points.Select(v => (MVector3)v).ToArray(),
|
||||||
position = spiralManipulator.transform.localPosition,
|
position = spiralManipulator.transform.localPosition,
|
||||||
zRotation = spiralManipulator.transform.localEulerAngles.z
|
zRotation = spiralManipulator.transform.localEulerAngles.z,
|
||||||
|
mirrored = spiralManipulator.transform.localScale.x < 0
|
||||||
}).ToArray();
|
}).ToArray();
|
||||||
|
|
||||||
nhBody.Cache.Set(cacheKey, cacheData);
|
nhBody.Cache.Set(cacheKey, cacheData);
|
||||||
|
|||||||
@ -17,23 +17,20 @@ namespace NewHorizons.Utility
|
|||||||
public Cache(IModBehaviour mod, string cacheFilePath)
|
public Cache(IModBehaviour mod, string cacheFilePath)
|
||||||
{
|
{
|
||||||
this.mod = mod;
|
this.mod = mod;
|
||||||
|
this.filepath = cacheFilePath;
|
||||||
filepath = cacheFilePath;
|
var fullPath = mod.ModHelper.Manifest.ModFolderPath + cacheFilePath;
|
||||||
|
|
||||||
var json = File.ReadAllText(mod.ModHelper.Manifest.ModFolderPath + cacheFilePath);
|
if (!File.Exists(fullPath))
|
||||||
data = JsonConvert.DeserializeObject<Dictionary<string, string>>(json);
|
|
||||||
// the above is exactly the same thing that the below does, but the below for some reason always returns null. no clue why
|
|
||||||
// data = mod.ModHelper.Storage.Load<Dictionary<string, string>>(filepath);
|
|
||||||
|
|
||||||
if (data == null)
|
|
||||||
{
|
{
|
||||||
Logger.LogWarning("Failed to load cache! Cache path: " + cacheFilePath);
|
Logger.LogWarning("Cache file not found! Cache path: " + cacheFilePath);
|
||||||
data = new Dictionary<string, string>();
|
data = new Dictionary<string, string>();
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Logger.LogWarning("CACHE DEBUG: Cache path: " + cacheFilePath);
|
var json = File.ReadAllText(fullPath);
|
||||||
Logger.LogWarning("CACHE DEBUG: Loaded cache == null? " + (data == null));
|
data = JsonConvert.DeserializeObject<Dictionary<string, string>>(json);
|
||||||
Logger.LogWarning("CACHE DEBUG: Loaded cache keys: " + String.Join(",", data?.Keys ?? new Dictionary<string, string>().Keys));
|
// the code above does exactly the same thing that the code below does, but the below for some reason always returns null. no clue why
|
||||||
|
// data = mod.ModHelper.Storage.Load<Dictionary<string, string>>(filepath);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void WriteToFile()
|
public void WriteToFile()
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
using NewHorizons.External.Configs;
|
using NewHorizons.External.Configs;
|
||||||
using OWML.Common;
|
using OWML.Common;
|
||||||
|
using System;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
namespace NewHorizons.Utility
|
namespace NewHorizons.Utility
|
||||||
@ -33,8 +34,16 @@ namespace NewHorizons.Utility
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var pathWithoutExtension = RelativePath.Substring(0, RelativePath.LastIndexOf('.'));
|
try
|
||||||
Cache = new Cache(Mod, pathWithoutExtension+".nhcache");
|
{
|
||||||
|
var pathWithoutExtension = RelativePath.Substring(0, RelativePath.LastIndexOf('.'));
|
||||||
|
Cache = new Cache(Mod, pathWithoutExtension+".nhcache");
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
Logger.LogError("Cache failed to load: " + e.Message);
|
||||||
|
Cache = null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void UnloadCache(bool writeBeforeUnload=false)
|
public void UnloadCache(bool writeBeforeUnload=false)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user