示例#1
0
 /// <summary>
 /// Triggers the event or adds it to the delayedTriggerEvents it if it has a delay
 /// </summary>
 private void TryTriggerEvent(MissionPrefab.TriggerEvent trigger)
 {
     if (trigger.CampaignOnly && GameMain.GameSession?.Campaign == null)
     {
         return;
     }
     if (trigger.Delay > 0)
     {
         if (!delayedTriggerEvents.Any(t => t.TriggerEvent == trigger))
         {
             delayedTriggerEvents.Add(new DelayedTriggerEvent(trigger, trigger.Delay));
         }
     }
     else
     {
         TriggerEvent(trigger);
     }
 }
示例#2
0
        /// <summary>
        /// Triggers the event immediately, ignoring any delays
        /// </summary>
        private void TriggerEvent(MissionPrefab.TriggerEvent trigger)
        {
            if (trigger.CampaignOnly && GameMain.GameSession?.Campaign == null)
            {
                return;
            }
            var eventPrefab = EventSet.GetAllEventPrefabs().Find(p => p.Identifier.Equals(trigger.EventIdentifier, StringComparison.OrdinalIgnoreCase));

            if (eventPrefab == null)
            {
                DebugConsole.ThrowError($"Mission \"{Name}\" failed to trigger an event (couldn't find an event with the identifier \"{trigger.EventIdentifier}\").");
                return;
            }
            if (GameMain.GameSession?.EventManager != null)
            {
                var newEvent = eventPrefab.CreateInstance();
                GameMain.GameSession.EventManager.ActiveEvents.Add(newEvent);
                newEvent.Init(true);
            }
        }
示例#3
0
 public DelayedTriggerEvent(MissionPrefab.TriggerEvent triggerEvent, float delay)
 {
     TriggerEvent = triggerEvent;
     Delay        = delay;
 }