private int GiveRandomAction(Effect item, EventType?eventType, int itemEffectBudget, bool isPositive = true, bool isAffectingGoodEntity = true) { EventType eventTypeSafe = eventType ?? (EventType)random.Next(1, Enum.GetValues(typeof(EventType)).Length); Action action = null; if (eventTypeSafe == EventType.ON_TICK) { int cooldown = random.Next(1, 1000); itemEffectBudget += itemEffectBudget * (cooldown - 500) / 500; action = new CooldownAction(item, GenerateRandomAction(item, 0, ref itemEffectBudget, isPositive, isAffectingGoodEntity), item, cooldown); } else if (eventTypeSafe == EventType.ON_ACTIVATION) { action = new CooldownAction(item, GenerateRandomAction(item, 0, ref itemEffectBudget, isPositive, isAffectingGoodEntity), item); } else { action = GenerateRandomAction(item, 0, ref itemEffectBudget, isPositive, isAffectingGoodEntity); } if (item.actions.ContainsKey(eventTypeSafe)) { item.actions[eventTypeSafe] = new MultiAction(item, action, item.actions[eventTypeSafe]); } else { item.actions.Add(eventTypeSafe, action); } return(itemEffectBudget); }
CooldownAction launchAction; // void Start() { turretAudio = GetComponent <AudioSource>(); scanAction = GetComponent <ScanAction>(); scanAction.OnEnded.AddListener(ScanEnded); shootAction = GetComponent <ShootAction>(); shootAction.OnEnded.AddListener(ShootEnded); // launchAction = GetComponent <LaunchAction>(); // }