Fix more issues with vanilla bodies

This commit is contained in:
Nick J. Connors 2022-02-21 02:47:39 -05:00
parent e51fa7d7d2
commit 65694f2666
3 changed files with 43 additions and 18 deletions

View File

@ -204,22 +204,35 @@ namespace NewHorizons.Builder.ShipLog
} }
} }
foreach (NewHorizonsBody body in bodies.Where(b => ShipLogHandler.IsVanillaBody(b) == false)) foreach(NewHorizonsBody body in bodies)
{ {
if (body.Config.ShipLog == null) continue; if (body.Config.ShipLog?.mapMode?.manualNavigationPosition == null) continue;
// Sometimes they got other names idk
var name = body.Config.Name.Replace(" ", "");
var existingBody = AstroObjectLocator.GetAstroObject(body.Config.Name);
if (existingBody != null)
{
var astroName = existingBody.GetAstroObjectName();
if (astroName == AstroObject.Name.RingWorld) name = "InvisiblePlanet";
else if (astroName != AstroObject.Name.CustomString) name = astroName.ToString();
}
// Should probably also just fix the IsVanilla method
var isVanilla = ShipLogHandler.IsVanillaBody(body);
Logger.Log($"The name: {name} is vanilla? {isVanilla}");
if (!isVanilla)
{
GameObject newMapModeGO = CreateMapModeGameObject(body, transformParent, layer, body.Config.ShipLog?.mapMode?.manualPosition); GameObject newMapModeGO = CreateMapModeGameObject(body, transformParent, layer, body.Config.ShipLog?.mapMode?.manualPosition);
ShipLogAstroObject newAstroObject = AddShipLogAstroObject(newMapModeGO, body, greyScaleMaterial, layer); ShipLogAstroObject newAstroObject = AddShipLogAstroObject(newMapModeGO, body, greyScaleMaterial, layer);
MakeDetails(body, newMapModeGO.transform, greyScaleMaterial); MakeDetails(body, newMapModeGO.transform, greyScaleMaterial);
Vector2 navigationPosition = body.Config.ShipLog?.mapMode?.manualNavigationPosition; Vector2 navigationPosition = body.Config.ShipLog?.mapMode?.manualNavigationPosition;
navMatrix[(int)navigationPosition.y][(int)navigationPosition.x] = newAstroObject; navMatrix[(int)navigationPosition.y][(int)navigationPosition.x] = newAstroObject;
} }
else if (Main.Instance.CurrentStarSystem == "SolarSystem")
if (Main.Instance.CurrentStarSystem == "SolarSystem")
{ {
foreach (NewHorizonsBody body in Main.BodyDict["SolarSystem"].Where(ShipLogHandler.IsVanillaBody)) GameObject gameObject = GameObject.Find(ShipLogHandler.PAN_ROOT_PATH + "/" + name);
{
GameObject gameObject = GameObject.Find(ShipLogHandler.PAN_ROOT_PATH + "/" + body.Config.Name.Replace(" ", ""));
if (body.Config.Destroy || (body.Config.ShipLog?.mapMode?.remove ?? false)) if (body.Config.Destroy || (body.Config.ShipLog?.mapMode?.remove ?? false))
{ {
ShipLogAstroObject astroObject = gameObject.GetComponent<ShipLogAstroObject>(); ShipLogAstroObject astroObject = gameObject.GetComponent<ShipLogAstroObject>();
@ -232,7 +245,7 @@ namespace NewHorizons.Builder.ShipLog
GameObject.Find(ShipLogHandler.PAN_ROOT_PATH + "/" + "SandFunnel").SetActive(false); GameObject.Find(ShipLogHandler.PAN_ROOT_PATH + "/" + "SandFunnel").SetActive(false);
} }
} }
else if(body.Config.Name == "SandFunnel") else if (name == "SandFunnel")
{ {
GameObject.Find(ShipLogHandler.PAN_ROOT_PATH + "/" + "SandFunnel").SetActive(false); GameObject.Find(ShipLogHandler.PAN_ROOT_PATH + "/" + "SandFunnel").SetActive(false);
} }

View File

@ -180,7 +180,15 @@ namespace NewHorizons.Builder.ShipLog
{ {
if (_entryIdToRawName.ContainsKey(entry._id)) if (_entryIdToRawName.ContainsKey(entry._id))
{ {
entry._curiosity = _rawNameToCuriosityName[_entryIdToRawName[entry._id]]; var raw = _entryIdToRawName[entry._id];
if (_rawNameToCuriosityName.ContainsKey(raw))
{
entry._curiosity = _rawNameToCuriosityName[raw];
}
else
{
Logger.LogError($"Couldn't find {raw}. Did you define the curiosity in a json config? Because you have to.");
}
} }
} }

View File

@ -34,6 +34,10 @@ namespace NewHorizons.Builder.Handlers
public static bool IsVanillaBody(NewHorizonsBody body) public static bool IsVanillaBody(NewHorizonsBody body)
{ {
var existingBody = AstroObjectLocator.GetAstroObject(body.Config.Name);
if (existingBody != null && existingBody.GetAstroObjectName() != AstroObject.Name.CustomString)
return true;
return vanillaBodies.Contains(body.Config.Name.Replace(" ", "")); return vanillaBodies.Contains(body.Config.Name.Replace(" ", ""));
} }