Skip to content

Instantly share code, notes, and snippets.

@ronyx69
ronyx69 / SetLaneProps.cs
Last active January 31, 2021 12:10
Script to set lane props for a network currently loaded in the asset editor. (for any elevation and lane) And another script which generates a script to set/edit lane props.
// Script to set lane props. Replaces all lane props!
var asset = ToolsModifierControl.toolController.m_editPrefabInfo as NetInfo; var ai = asset.m_netAI as RoadAI;
List<NetLaneProps.Prop>[] basic = new List<NetLaneProps.Prop>[asset.m_lanes.Length];
for (int i = 0; i < basic.Length; i++) basic[i] = new List<NetLaneProps.Prop>();
var elevatedLanes = 0;
if(ai.m_elevatedInfo != null) if(ai.m_elevatedInfo.m_lanes != null) if(ai.m_elevatedInfo.m_lanes.Length != 0) elevatedLanes = ai.m_elevatedInfo.m_lanes.Length;
List<NetLaneProps.Prop>[] elevated = new List<NetLaneProps.Prop>[elevatedLanes];
for (int i = 0; i < elevated.Length; i++) elevated[i] = new List<NetLaneProps.Prop>();
var bridgeLanes = 0;
if(ai.m_bridgeInfo != null) if(ai.m_bridgeInfo.m_lanes != null) if(ai.m_bridgeInfo.m_lanes.Length != 0) bridgeLanes = ai.m_bridgeInfo.m_lanes.Length;
@ronyx69
ronyx69 / ParkingSpaces_AssetEditor.cs
Last active December 4, 2020 09:32
Sets the amount, type, flags, direction and position of parking spaces for props. Not tested or researched.
// m_parkingSpaces
// Sets the amount, type, flags, direction and position of parking spaces for props.
// I haven't tested or researched this at all.
var asset = ToolsModifierControl.toolController.m_editPrefabInfo as PropInfo;
var parkingSpaces = 1; // amount of parking spaces
PropInfo.ParkingSpace[] temp = new PropInfo.ParkingSpace[parkingSpaces];
@ronyx69
ronyx69 / SpecialPlaces_AssetEditor.cs
Created November 16, 2017 15:02
Sets the amount, direction and position of sitting places for benches.
// m_specialPlaces (SittingDown)
// Sets the amount, direction and position of sitting places for benches.
var asset = ToolsModifierControl.toolController.m_editPrefabInfo as PropInfo;
var specialPlaces = 1; // amount of sitting positions
PropInfo.SpecialPlace[] temp = new PropInfo.SpecialPlace[specialPlaces];
@ronyx69
ronyx69 / PropVariations_AssetEditor.cs
Last active November 29, 2020 07:25
Sets amount of prop variations and calculates equal probability.
//----------------------------------------------------------------
// Prop Variation Amount Changer
//Set amount of prop variations.
//If you are increasing the amount, previous variations will be preserved.
//If decreasing, all variations will be removed!
var variations = 12; //CHANGE THIS
@ronyx69
ronyx69 / AnimUV_Buildings_AssetEditor.cs
Last active November 16, 2020 06:31
Scripts for using AnimUV shader on buildings and building sub meshes.
// Building (and Building Sub Mesh) Anim UV Scripts
// Create scrolling or multi-frame animations for buildings.
// Run in asset editor and see effects in real time.
// Ingame the building might require electricity to animate.
// No mods required, the changes save and load in vanilla.
@ronyx69
ronyx69 / NetworkList.cs
Last active November 15, 2020 23:21
Lists all networks in a text file.
var prefabNames = new List<string>();
for (uint i = 0; i < PrefabCollection<NetInfo>.LoadedCount(); i++)
{
var prefab = PrefabCollection<NetInfo>.GetLoaded(i);
if (prefab == null) continue;
Debug.Log(prefab);
prefabNames.Add(prefab.ToString());
}
prefabNames.Sort();
var s="\n";
@ronyx69
ronyx69 / TransparentSelectors.cs
Last active September 13, 2020 21:41
Source code of the transparent selectors mod.
using ColossalFramework.IO;
using ColossalFramework.UI;
using ICities;
using System;
using System.IO;
using System.Reflection;
using System.Xml.Serialization;
using UnityEngine;
namespace TransparentSelectors
@ronyx69
ronyx69 / ReplaceLaneProps.cs
Created January 10, 2020 21:12
Replace lane props on networks in the asset editor.
Action<string, string> ReplaceProp = (search, replace) =>
{
var replacementProp = PrefabCollection<PropInfo>.FindLoaded(replace);
for (uint i = 0; i < PrefabCollection<NetInfo>.LoadedCount(); i++)
{
var prefab = PrefabCollection<NetInfo>.GetLoaded(i);
if (prefab == null) continue;
if(prefab.m_lanes != null) foreach (var Lane in prefab.m_lanes)
{
@ronyx69
ronyx69 / Network_SegmentNode_Reorder.cs
Last active September 13, 2020 21:13
Network segment and node reorder scripts. Refreshes UI automatically.
// Network segment and node reorder scripts. Refreshes UI automatically.
// SEGMENTS
var asset = ToolsModifierControl.toolController.m_editPrefabInfo as NetInfo;
@ronyx69
ronyx69 / PropIlluminationRange.cs
Created March 21, 2018 13:59
Changes the times when a prop is illuminated.
var asset = ToolsModifierControl.toolController.m_editPrefabInfo as PropInfo;
var off = 15.0f; // amount of hours the light is turned off during the day (15 max) (0 means always on)
var random = 0.3f; // adds randomness to time lights turn on/off, if 0 then all lights turn on/off at the same time
asset.m_illuminationOffRange.x = 6*Convert.ToSingle(Math.Pow(Convert.ToDouble((6-off/2.5)/6), Convert.ToDouble(1/1.09)));
asset.m_illuminationOffRange.y = Mathf.Clamp(6*Convert.ToSingle(Math.Pow(Convert.ToDouble((6-off/2.5)/6), Convert.ToDouble(1/1.09)))-random, 0, 6);