Skip to content

Instantly share code, notes, and snippets.

Avatar

Ronyx69 ronyx69

View GitHub Profile
@ronyx69
ronyx69 / TransparentSelectors.cs
Last active Sep 13, 2020
Source code of the transparent selectors mod.
View TransparentSelectors.cs
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 Jan 10, 2020
Replace lane props on networks in the asset editor.
View ReplaceLaneProps.cs
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 Sep 13, 2020
Network segment and node reorder scripts. Refreshes UI automatically.
View Network_SegmentNode_Reorder.cs
// Network segment and node reorder scripts. Refreshes UI automatically.
// SEGMENTS
var asset = ToolsModifierControl.toolController.m_editPrefabInfo as NetInfo;
@ronyx69
ronyx69 / PropIlluminationRange.cs
Created Mar 21, 2018
Changes the times when a prop is illuminated.
View PropIlluminationRange.cs
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);
@ronyx69
ronyx69 / Flag_Script.cs
Last active Aug 26, 2020
Script for saving Flag shader params in props. (Added modless shader parameter saving method by boformer.)
View Flag_Script.cs
// The script will not work properly if you have no texture imported.
//
// The vertex paint of the mesh controls the amount of movement:
// white means no movement and black means maximum movement.
//
// If you're using multiple "flag" textures in one prop, (like vanilla flags)
// the flag must be entirely black and everything else should be white,
// and you can't use the strength variable, otherwise the UV mapping will break.
// The flag should be UV mapped onto the flag on the bottom right of the texture.
@ronyx69
ronyx69 / ShaderChange_Rotors.cs
Last active Aug 17, 2020
Change the shader of a prop, building, or building sub mesh to rotors in asset editor. Also deletes LOD.
View ShaderChange_Rotors.cs
// Rotors Shader
// Also deletes LOD.
// Prop
var shader = Shader.Find("Custom/Vehicles/Vehicle/Rotors");
var asset = ToolsModifierControl.toolController.m_editPrefabInfo as PropInfo;
if(asset.m_material != null) asset.m_material.shader = shader;
@ronyx69
ronyx69 / NetworkElevationRenamer.cs
Created Dec 27, 2019
Renames elevations based on the name of the loaded asset.
View NetworkElevationRenamer.cs
// Renames elevations, to fix the game adding 0 or 1 to the elevation names, so that they can be kept consistent when updating a network multiple times.
// Do not run on a newly created network, it must be saved with the final name it should have, loaded again, and only then run this script.
var asset = ToolsModifierControl.toolController.m_editPrefabInfo as NetInfo;
var ai = (asset.m_netAI as TrainTrackAI); // change this to RoadAI or something else if necessary.
if(ai.m_elevatedInfo != null) ai.m_elevatedInfo.name = ai.m_info.name.Substring(0, ai.m_info.name.Length-6) + " E";
if(ai.m_bridgeInfo != null) ai.m_bridgeInfo.name = ai.m_info.name.Substring(0, ai.m_info.name.Length-6) + " B";
if(ai.m_slopeInfo != null) ai.m_slopeInfo.name = ai.m_info.name.Substring(0, ai.m_info.name.Length-6) + " S";
if(ai.m_tunnelInfo != null) ai.m_tunnelInfo.name = ai.m_info.name.Substring(0, ai.m_info.name.Length-6) + " T";
@ronyx69
ronyx69 / Relight.cs
Last active May 2, 2020
Source code for Relight mod. Rebalanced and customizable lighting and tonemapping. UI / saving and preset system by Simon Royer. Shadow bias change by saki7. Shadow smoothing change by TPB.
View Relight.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ICities;
using UnityEngine;
using System.Reflection;
using System.Runtime.InteropServices;
using System.Threading;
using System.Xml.Serialization;
@ronyx69
ronyx69 / Thirty_Fifteen_Curb.cs
Last active Mar 31, 2020
Attempts to find all -30cm roads and lifts them to -15cm. Doesn't work for LOD. Also updates all segments (therefore lanes too) so vehicles jump up to the new height.
View Thirty_Fifteen_Curb.cs
var networks = Resources.FindObjectsOfTypeAll<NetInfo>();
for(uint i = 0; i < networks.Length; i++)
{
var network = networks[i];
if(network == null) continue;
if(network.m_netAI == null) continue;
if(network.m_netAI.GetType().Name != "RoadAI" &&
network.m_netAI.GetType().Name != "RoadBridgeAI" &&
network.m_netAI.GetType().Name != "RoadTunnelAI") continue;
{
@ronyx69
ronyx69 / Railway_StationTrackTagger.cs
Last active Jan 20, 2020
Tag station tracks for usage in Railway track replacer UI.
View Railway_StationTrackTagger.cs
var stationTrackType = "r69rwst-double"; // The type of station track:
// r69rwst-double (normal double station track)
// r69rwst-edouble (elevated double station track)
// r69rwst-single2 (single station track - two sided boarding)
// r69rwst-single1 (single station track - left sided boarding)
// r69rwst-singler (single station track - right sided boarding)
// r69rwst-esingle2 (elevated single station track - two sided boarding (shinkansen only afaik))
// r69rwst-esinglel (elevated single station track - left sided boarding)
You can’t perform that action at this time.