Skip to content

Instantly share code, notes, and snippets.

@Jon889
Created May 21, 2015 20:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Jon889/e7cb72addcaf7150ebdc to your computer and use it in GitHub Desktop.
Save Jon889/e7cb72addcaf7150ebdc to your computer and use it in GitHub Desktop.
Draggable runways and taxiways
using ICities;
using ColossalFramework;
using ColossalFramework.Globalization;
using ColossalFramework.IO;
using ColossalFramework.UI;
using ColossalFramework.Steamworks;
using UnityEngine;
using System;
using System.Collections;
using System.Reflection;
using System.Collections.Generic;
using ColossalFramework.Plugins;
namespace MediumOWR
{
public class MediumOWRMod : IUserMod
{
public string Name
{
get { return "Runways and Taxiways"; }
}
public string Description
{
get { return "Adds draggable runways and taxiways to the game."; }
}
}
public class MediumOWRLoader : LoadingExtensionBase
{
public override void OnCreated(ILoading loading)
{
InitMod();
}
public override void OnLevelLoaded(LoadMode mode)
{
base.OnLevelLoaded(mode);
if (mode == LoadMode.LoadGame || mode == LoadMode.NewGame)
{
InitMod();
}
}
private void ShowNetwork(String name, String desc, GeneratedScrollPanel panel)
{
var netInfo = PrefabCollection<NetInfo>.FindLoaded(name);
Locale locale = (Locale)typeof(LocaleManager).GetField("m_Locale", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(SingletonLite<LocaleManager>.instance);
locale.AddLocalizedString(new Locale.Key() { m_Identifier = "NET_TITLE", m_Key = name }, name);
locale.AddLocalizedString(new Locale.Key() { m_Identifier = "NET_DESC", m_Key = name }, desc);
typeof(GeneratedScrollPanel).GetMethod("CreateAssetItem", BindingFlags.NonPublic | BindingFlags.Instance).Invoke(panel, new object[] { netInfo });
}
private void InitMod()
{
PublicTransportPanel ptp = GameObject.Find("PublicTransportPlanePanel").GetComponent<PublicTransportPanel>();
ShowNetwork("Airplane Runway", "Runway", ptp);
ShowNetwork("Airplane Taxiway", "Taxiway", ptp);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment