void OnEnable() { Application.logMessageReceived += HandleLog; godModeEnabled = false; Instance = this; componentEnabled = false; }
public override int Traverse() { float total = 0f; for (int i = 0; i < chances.Count; i++) { total += chances[i]; } float roll = Random.Range(0, total); float originalRoll = roll; for (int i = 0; i < chances.Count; i++) { roll -= chances[i]; if (roll <= 0) { TaskManager.Instance.setNode(outputKnobs[i]); if (PrintRandomRolls) { DevConsoleScript.Print("Total weight: " + total + ", Random roll: " + originalRoll + ", Connection index: " + i); } return(-1); } } // This might be possible due to floating point inaccuracies TaskManager.Instance.setNode(outputKnobs[chances.Count - 1]); //Debug.LogWarning("Something went wrong with the roulette. Double check the entered floats!"); return(-1); }
void Disable() { componentEnabled = false; Application.logMessageReceived -= HandleLog; Instance = null; }