[Bug] [#433] Actually fix fuzzy stranger text

This commit is contained in:
Nick 2022-12-12 19:45:40 -05:00
parent 6926cebe3c
commit 58b89b6862
2 changed files with 30 additions and 1 deletions

View File

@ -616,7 +616,7 @@ namespace NewHorizons.Builder.Props
// #433 fuzzy stranger text
if (info.arcInfo.Any(x => x.type == PropModule.NomaiTextArcInfo.NomaiTextArcType.Stranger))
{
StreamingHandler.SetUpStreaming(_ghostArcPrefabs.First(), sector);
StreamingHandler.SetUpStreaming(AstroObject.Name.RingWorld, sector);
}
return nomaiWallText;

View File

@ -20,6 +20,23 @@ namespace NewHorizons.Handlers
_sectorCache.Clear();
}
public static void SetUpStreaming(AstroObject.Name name, Sector sector)
{
var group = GetStreamingGroup(name);
sector.OnOccupantEnterSector += _ =>
{
group.LoadRequiredAssets();
};
sector.OnOccupantExitSector += _ =>
{
if (!sector.ContainsAnyOccupants(DynamicOccupant.Player | DynamicOccupant.Probe))
{
group.UnloadRequiredAssets();
}
};
}
/// <summary>
/// makes it so that this object's streaming stuff will be connected to the given sector
/// </summary>
@ -111,5 +128,17 @@ namespace NewHorizons.Handlers
return true;
return false;
}
public static StreamingGroup GetStreamingGroup(AstroObject.Name name)
{
if (name == AstroObject.Name.CaveTwin || name == AstroObject.Name.TowerTwin)
{
return GameObject.Find("FocalBody/StreamingGroup_HGT").GetComponent<StreamingGroup>();
}
else
{
return Locator.GetAstroObject(name)?.GetComponentInChildren<StreamingGroup>();
}
}
}
}