See https://community.simtropolis.com/forums/topic/73475-modding-tutorial-1-prop-remover/
Last active
January 4, 2023 05:51
-
-
Save boformer/45e3e2999d2f1aefb82048bc9cabe47c to your computer and use it in GitHub Desktop.
Cities: Skylines Modding Tutorial 1: Complete Source Code
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
using ICities; | |
namespace CityBeautifier | |
{ | |
public class CityBeautifierMod : IUserMod | |
{ | |
public string Name => "City Beautifier"; | |
public string Description => "Removes some ugly props"; | |
} | |
public class CityBeautifierLoading : ILoadingExtension | |
{ | |
// called when level loading begins | |
public void OnCreated(ILoading loading) | |
{ | |
} | |
// called when level is loaded | |
public void OnLevelLoaded(LoadMode mode) | |
{ | |
for (uint index = 0; index < PrefabCollection<BuildingInfo>.LoadedCount(); index++) | |
{ | |
// get the building prefab with the given index from the collection | |
BuildingInfo prefab = PrefabCollection<BuildingInfo>.GetLoaded(index); | |
// skip prefabs without props | |
if (prefab == null || prefab.m_props == null) continue; | |
for (int propIndex = 0; propIndex < prefab.m_props.Length; propIndex++) | |
{ | |
// get the prop item | |
BuildingInfo.Prop propItem = prefab.m_props[propIndex]; | |
// skip trees/undefined props etc. | |
if (propItem.m_prop == null) continue; | |
string propName = propItem.m_prop.name; | |
// check if the prop name equals one of the banned props | |
if (propName == "Billboard_big_variation" | |
|| propName == "Billboard_big_variation_01" | |
|| propName == "Billboard_big_variation_02" | |
|| propName == "Billboard_big_variation_04" | |
|| propName == "neon-yakisoba-noodles" | |
|| propName == "neon-burned-bean-coffee" | |
|| propName == "neon-morellos") | |
{ | |
// set the probability to zero to hide the props | |
propItem.m_probability = 0; | |
} | |
} | |
} | |
} | |
// called when unloading begins | |
public void OnLevelUnloading() | |
{ | |
} | |
// called when unloading finished | |
public void OnReleased() | |
{ | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment