private IEnumerator AddWidgetToBomb(KMWidget widget1, KMWidget widget2) { var modwidget = widget1.GetComponent <ModWidget>(); var startWidget = widget2.GetComponent <ModWidget>(); if (modwidget == null) { modwidget = widget1.gameObject.AddComponent <ModWidget>(); } if (startWidget == null && Settings.EnableStartTime) { startWidget = widget2.gameObject.AddComponent <ModWidget>(); } var generators = FindObjectsOfType <WidgetGenerator>(); DebugLog($"{generators.Length} Widget Generators found"); while (generators.Length == 0) { yield return(null); generators = FindObjectsOfType <WidgetGenerator>(); DebugLog($"{generators.Length} Widget Generators found"); } foreach (var g in generators) { if (modwidget == null) { break; } DebugLog("Adding required widget"); if (!g.RequiredWidgets.Contains(modwidget)) { g.RequiredWidgets.Add(modwidget); } if (!g.RequiredWidgets.Contains(startWidget) && Settings.EnableStartTime) { g.RequiredWidgets.Add(startWidget); } } yield break; }
public static IEnumerator AddWidgetToBomb(KMWidget widget) { DebugLog("Started AddWidgetToBomb"); var modwidget = widget.GetComponent <ModWidget>(); DebugLog("Tried to Get Modwidget"); if (modwidget == null) { DebugLog("Modwidget not defined. Creating it now."); modwidget = widget.gameObject.AddComponent <ModWidget>(); } DebugLog("Definitely have mod widget"); var generators = Object.FindObjectsOfType <WidgetGenerator>(); DebugLog($"{generators.Length} Widget Generators found"); while (generators.Length == 0) { yield return(null); generators = Object.FindObjectsOfType <WidgetGenerator>(); DebugLog($"{generators.Length} Widget Generators found"); } foreach (var g in generators) { if (modwidget == null) { break; } DebugLog("Adding required widget"); if (!g.RequiredWidgets.Contains(modwidget)) { g.RequiredWidgets.Add(modwidget); } } yield break; }