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

@ -201,25 +201,38 @@ namespace NewHorizons.Builder.ShipLog
navMatrix[y][x] = currentNav[y][x];
astroIdToNavIndex.Add(currentNav[y][x].GetID(), new [] {y, x});
}
}
}
}
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;
GameObject newMapModeGO = CreateMapModeGameObject(body, transformParent, layer, body.Config.ShipLog?.mapMode?.manualPosition);
ShipLogAstroObject newAstroObject = AddShipLogAstroObject(newMapModeGO, body, greyScaleMaterial, layer);
MakeDetails(body, newMapModeGO.transform, greyScaleMaterial);
Vector2 navigationPosition = body.Config.ShipLog?.mapMode?.manualNavigationPosition;
navMatrix[(int) navigationPosition.y][(int) navigationPosition.x] = newAstroObject;
}
if (Main.Instance.CurrentStarSystem == "SolarSystem")
{
foreach (NewHorizonsBody body in Main.BodyDict["SolarSystem"].Where(ShipLogHandler.IsVanillaBody))
// Sometimes they got other names idk
var name = body.Config.Name.Replace(" ", "");
var existingBody = AstroObjectLocator.GetAstroObject(body.Config.Name);
if (existingBody != null)
{
GameObject gameObject = GameObject.Find(ShipLogHandler.PAN_ROOT_PATH + "/" + body.Config.Name.Replace(" ", ""));
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);
ShipLogAstroObject newAstroObject = AddShipLogAstroObject(newMapModeGO, body, greyScaleMaterial, layer);
MakeDetails(body, newMapModeGO.transform, greyScaleMaterial);
Vector2 navigationPosition = body.Config.ShipLog?.mapMode?.manualNavigationPosition;
navMatrix[(int)navigationPosition.y][(int)navigationPosition.x] = newAstroObject;
}
else if (Main.Instance.CurrentStarSystem == "SolarSystem")
{
GameObject gameObject = GameObject.Find(ShipLogHandler.PAN_ROOT_PATH + "/" + name);
if (body.Config.Destroy || (body.Config.ShipLog?.mapMode?.remove ?? false))
{
ShipLogAstroObject astroObject = gameObject.GetComponent<ShipLogAstroObject>();
@ -232,7 +245,7 @@ namespace NewHorizons.Builder.ShipLog
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);
}
@ -247,11 +260,11 @@ namespace NewHorizons.Builder.ShipLog
if (body.Config.ShipLog?.mapMode?.manualNavigationPosition != null)
{
Vector2 navigationPosition = body.Config.ShipLog?.mapMode?.manualNavigationPosition;
navMatrix[(int) navigationPosition.y][(int) navigationPosition.x] = gameObject.GetComponent<ShipLogAstroObject>();
navMatrix[(int)navigationPosition.y][(int)navigationPosition.x] = gameObject.GetComponent<ShipLogAstroObject>();
}
if (body.Config.ShipLog?.mapMode?.scale != null)
{
gameObject.transform.localScale = Vector3.one * body.Config.ShipLog.mapMode.scale;
gameObject.transform.localScale = Vector3.one * body.Config.ShipLog.mapMode.scale;
}
}
}

View File

@ -180,7 +180,15 @@ namespace NewHorizons.Builder.ShipLog
{
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)
{
var existingBody = AstroObjectLocator.GetAstroObject(body.Config.Name);
if (existingBody != null && existingBody.GetAstroObjectName() != AstroObject.Name.CustomString)
return true;
return vanillaBodies.Contains(body.Config.Name.Replace(" ", ""));
}