Im looking for information and resources for working with terrain, but I can't seem to find much in the docs. Can anyone point me towards either docs or other plugins that deal with looking up and or manipulating terrain features, monuments, and resource zones (sulfur, HQM, metal, stone, etc)?
Terrain documentation
Discussion in 'Rust Development' started by Jrodz, Aug 25, 2015.
-
-
Is it possible to at least read the terrain details to find and hold onto locations and values of things? The OnTerrainInitialized hook doesn't appear to take any arguments... is that correct? I was really hoping it would yield a map object or something that I could interrogate for info about the map.
Do you know if monuments and landscape features (like caves) are entities? -
-
Just a note, I don't have the exact location but I was looking through the code that spawns monuments in the decompiled code a while back. From what I remember, the information is not stored in a way that can be retrieved (there isn't an array of monuments somewhere) but that said, the code that spawns them based on a map seed is out there. I suppose you could copy the function and alter it so it returns a list of rad town spawn locations for your seed.
Either way, I'm very interested in this because I have several plugins I've authored that would benefit from this information. Roads and rad towns is my main interest, but anything else would be really nice to have. -
Most of the terrain data can be read, I'd recommend using a disassembler to browse the Assembly-CSharp.dll and have a look at the classes starting with Terrain and UnityEngine.TerrainData (Unity - Scripting API:)
Changing the terrain however is not possible as both the server and client generate their own terrain, so basically you could spawn monuments and such, they would not physically be there on the client as those are spawned by the generator and changing the generator has no use as the client uses its own which you can not alter without modding your client.
As far as it goes for like reading monuments, you can use the FindObjectsOfType<>() method to do this, I'd recommend to read them when the server has just started and store them somewhere if you'd want to get the information per command as FindObjectsOfType is a bit slow. -
What data type are monuments? Do you have that somewhere?
-
[DOUBLEPOST=1440652148][/DOUBLEPOST]You can also use MonumentInfo to get only the monuments:
Code:var gameobjects = UnityEngine.Object.FindObjectsOfType<MonumentInfo>(); Puts($"Found {gameobjects.Length} gameobjects on the map."); foreach (var go in gameobjects) Puts($"Found monument {go.name} at {go.transform.position}");
Last edited by a moderator: Aug 27, 2015 -
Wow guys... thanks for all the info! This more than puts me on the path to success!