Last active
July 18, 2021 09:57
-
-
Save ronyx69/47eed7c522b5fcbc055a974b19e87fc5 to your computer and use it in GitHub Desktop.
Reads the prop buffer and generates a script to set it. Intended for reading/setting props for buildings in the asset editor. Generated example below the actual script.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// You must place the exact amount of props (any kind of props anywhere) before running the prop set script, otherwise it will not work properly. | |
// Generate a script to place props, located in local addons folder. | |
var s = "PropInstance[] nb = new PropInstance[65536];\n\n"; | |
var buffer = PropManager.instance.m_props.m_buffer; | |
for(var i = 0; i < buffer.Length; i++) if (buffer[i].m_flags!=0) { | |
s = s + "nb[" + i + "].Angle = " + buffer[i].Angle + "f;\n"; | |
s = s + "nb[" + i + "].Blocked = " + buffer[i].Blocked.ToString().ToLower() + ";\n"; | |
s = s + "nb[" + i + "].FixedHeight = " + buffer[i].FixedHeight.ToString().ToLower() + ";\n"; | |
s = s + "nb[" + i + "].Hidden = " + buffer[i].Hidden.ToString().ToLower() + ";\n"; | |
s = s + "nb[" + i + "].Info = PrefabCollection<PropInfo>.FindLoaded(\"" + buffer[i].Info.name + "\");\n"; | |
s = s + "nb[" + i + "].Position = new Vector3(" + buffer[i].Position.x + "f, " + buffer[i].Position.y + "f, " + buffer[i].Position.z + "f);\n"; | |
s = s + "nb[" + i + "].Single = " + buffer[i].Single.ToString().ToLower() + ";\n"; | |
s = s + "nb[" + i + "].m_angle = " + buffer[i].m_angle + ";\n"; | |
s = s + "nb[" + i + "].m_flags = " + buffer[i].m_flags + ";\n"; | |
s = s + "nb[" + i + "].m_infoIndex = " + buffer[i].m_infoIndex + ";\n"; | |
s = s + "nb[" + i + "].m_nextGridProp = " + buffer[i].m_nextGridProp + ";\n"; | |
s = s + "nb[" + i + "].m_posX = " + buffer[i].m_posX + ";\n"; | |
s = s + "nb[" + i + "].m_posY = " + buffer[i].m_posY + ";\n"; | |
s = s + "nb[" + i + "].m_posZ = " + buffer[i].m_posZ + ";\n"; | |
s = s + "\n"; } s = s + "PropManager.instance.m_props.m_buffer = nb;"; | |
var path = Path.Combine(ColossalFramework.IO.DataLocation.addonsPath, "Props.cs"); File.WriteAllText(path, s); | |
// GENERATED EXAMPLE | |
// The amount of props in the script must be placed before running the script. | |
PropInstance[] nb = new PropInstance[65536]; | |
nb[2836].Angle = 4.441833f; | |
nb[2836].Blocked = false; | |
nb[2836].FixedHeight = true; | |
nb[2836].Hidden = false; | |
nb[2836].Info = PrefabCollection<PropInfo>.FindLoaded("Cargo container"); | |
nb[2836].Position = new Vector3(4.169312f, 75.65625f, 6.196289f); | |
nb[2836].Single = true; | |
nb[2836].m_angle = 46330; | |
nb[2836].m_flags = 49; | |
nb[2836].m_infoIndex = 111; | |
nb[2836].m_nextGridProp = 0; | |
nb[2836].m_posX = 253; | |
nb[2836].m_posY = 4842; | |
nb[2836].m_posZ = 376; | |
nb[2852].Angle = 4.764736f; | |
nb[2852].Blocked = false; | |
nb[2852].FixedHeight = true; | |
nb[2852].Hidden = false; | |
nb[2852].Info = PrefabCollection<PropInfo>.FindLoaded("Cargo container"); | |
nb[2852].Position = new Vector3(0.3295898f, 71.09375f, 12.78809f); | |
nb[2852].Single = true; | |
nb[2852].m_angle = 49698; | |
nb[2852].m_flags = 49; | |
nb[2852].m_infoIndex = 111; | |
nb[2852].m_nextGridProp = 2836; | |
nb[2852].m_posX = 20; | |
nb[2852].m_posY = 4550; | |
nb[2852].m_posZ = 776; | |
nb[17784].Angle = 5.698547f; | |
nb[17784].Blocked = false; | |
nb[17784].FixedHeight = true; | |
nb[17784].Hidden = false; | |
nb[17784].Info = PrefabCollection<PropInfo>.FindLoaded("Barrels"); | |
nb[17784].Position = new Vector3(-3.262939f, 77.1875f, 1.203003f); | |
nb[17784].Single = true; | |
nb[17784].m_angle = 59438; | |
nb[17784].m_flags = 49; | |
nb[17784].m_infoIndex = 52; | |
nb[17784].m_nextGridProp = 65090; | |
nb[17784].m_posX = -198; | |
nb[17784].m_posY = 4940; | |
nb[17784].m_posZ = 73; | |
PropManager.instance.m_props.m_buffer = nb; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment