TheLacus wrote: ↑Sun May 06, 2018 1:29 pm
Now that i read the code again, i see there is also LocationRect but in Daggerfall world units so providing access to CityNavigation.WorldToScenePosition() from UpdateLocation() may also be an alternative.
Using the CityNavigation component is actually quite clever, as it exposes a lot of this information in an easy to use way. I wasn't sure what you meant by providing access from UpdateLocation(). Did you mean using an event or something? Let me know and I'm happy to work in with your requirements.
In the interim, I've added a new method to StreamingWorld called GetCurrentCityNavigation() that will return CityNavigation component for town object inside player's current location tile (if any). It will return null if player not inside a location tile.
So you should be able to use:
Code: Select all
CityNavigation cityNavigation = GameManager.Instance.StreamingWorld.GetCurrentCityNavigation();
// Do stuff
With a CityNavigation reference, you can use the public method WorldToScenePosition() to calcuate any world position back to scene space relative to the actual location itself. Use refineY=true to sample the actual terrain height under that world position coord. CityNavigation also exposes a couple of useful properties such as the dimensions of the town itself. All you'd need is the town origin from world rect and a reference to CityNavigation and you should be able to compute very precisely the town area.
Keep in mind that WorldToScenePosition() is very slightly expensive (more so when using refineY=true). It's not the sort of thing you want to use every frame, but should be OK for scene setup and placement.
Let me know if anything else I can do to help.