@@ -48,7 +48,7 @@ public void OnEnable() {
4848 [ HarmonyPrefix ]
4949 [ HarmonyPatch ( typeof ( BuildingUnlockingService ) , "Unlocked" ) ]
5050 static bool BuildingUnlocker ( ref bool __result ) {
51- if ( ! creativeModeEnabled || ! disableScienceCost . Value ) {
51+ if ( ! ( creativeModeEnabled && disableScienceCost . Value ) ) {
5252 return true ;
5353 }
5454 __result = true ;
@@ -61,7 +61,7 @@ static bool BuildingUnlocker(ref bool __result) {
6161 [ HarmonyPrefix ]
6262 [ HarmonyPatch ( typeof ( BuildingPlacer ) , "Place" ) ]
6363 static bool PlaceInstantly ( BlockObject prefab ) {
64- if ( ! creativeModeEnabled || enableInstantBuilding . Value ) {
64+ if ( creativeModeEnabled && enableInstantBuilding . Value ) {
6565 Building component = prefab . GetComponent < Building > ( ) ;
6666 component . PlaceFinished = true ;
6767 }
@@ -126,12 +126,14 @@ static void HideOldMapEditorTool(ToolGroup ____toolGroup, ref bool __result) {
126126 */
127127 [ HarmonyPostfix ]
128128 [ HarmonyPatch ( typeof ( OptionsBox ) , "GetPanel" ) ]
129- static void AddCreativeModeToggle ( ref VisualElement __result ) {
129+ static void AddCreativeModeToggle ( ref VisualElement __result , OptionsBox __instance ) {
130130 VisualElement root = __result . Children ( ) . First ( ) ;
131131 IEnumerable < string > buttonStyle = root . Children ( ) . First ( ) . GetClasses ( ) ;
132132
133- Button button = CreateButton ( "Toggle Creative Mode" , buttonStyle ) ;
134- button . clicked += ToggleCreativeMode ;
133+ string text = "Toggle Creative Mode " + ( creativeModeEnabled ? "Off" : "On" ) ;
134+ Button button = CreateButton ( text , buttonStyle ) ;
135+ OptionsBox optionsBox = __instance ;
136+ button . clicked += ( ) => ToggleCreativeMode ( __instance ) ;
135137 root . Insert ( 4 , button ) ;
136138 }
137139
@@ -147,8 +149,9 @@ private static Button CreateButton(string name, IEnumerable<string> styles) {
147149 return button ;
148150 }
149151
150- public static void ToggleCreativeMode ( ) {
152+ public static void ToggleCreativeMode ( OptionsBox optionsBox ) {
151153 creativeModeEnabled = ! creativeModeEnabled ;
154+ optionsBox . ResumeClicked ( ) ;
152155 }
153156 }
154157}
0 commit comments