コード例 #1
0
 private static void Postfix(LG_LayerType layer,
                             string mainObjective,
                             WardenObjectiveDataBlock data,
                             eWardenSubObjectiveStatus sub,
                             bool visible          = true,
                             bool isAdditionalHelp = false)
 {
     Watch.Current?.UpdateMainObjective(mainObjective);
     Log.Debug($"Got new objective! - {mainObjective}");
 }
コード例 #2
0
        internal bool ShouldFire_Internal(LG_LayerType layerType, WardenObjectiveDataBlock objectiveData)
        {
            bool shouldFire = false;

            if (IsRequiresAllFilter)
            {
                shouldFire  = true;
                shouldFire &= ShouldFire_LayerCheck(layerType);
                shouldFire &= ShouldFire_User(shouldFire, objectiveData);
            }
            else
            {
                shouldFire |= ShouldFire_LayerCheck(layerType);
                shouldFire |= ShouldFire_User(shouldFire, objectiveData);
            }

            return(shouldFire);
        }
コード例 #3
0
        internal static CustomExpHandlerBase[] FireAllGlobalHandler(LG_Layer layer, WardenObjectiveDataBlock objectiveData)
        {
            var handlerList = new HandlerList();

            foreach (var handler in _GlobalHandlers)
            {
                if (!_AllowedGlobalHandlers.Any(x => !string.IsNullOrEmpty(handler.GUID) && x.Equals(handler.GUID, StringComparison.OrdinalIgnoreCase)))
                {
                    continue;
                }

                var handlerInstance = FireHandlerByContainer(handler, layer, objectiveData, isGlobalHandler: true);

                if (handlerInstance != null)
                {
                    handlerList.Add(handlerInstance);
                }
            }

            return(handlerList.ToArray());
        }
コード例 #4
0
        internal void Setup(LG_Layer layer, WardenObjectiveDataBlock objectiveData, bool isGlobalHandler)
        {
            Layer         = layer;
            LayerType     = layer.m_type;
            ObjectiveData = objectiveData;

            IsDefaultObjective = Enum.IsDefined(typeof(eWardenObjectiveType), ObjectiveData.Type);
            IsGlobalHandler    = isGlobalHandler;

            var activeExpedition = RundownManager.ActiveExpedition;

            switch (LayerType)
            {
            case LG_LayerType.MainLayer:
                LayerData = activeExpedition.MainLayerData;
                break;

            case LG_LayerType.SecondaryLayer:
                LayerData = activeExpedition.SecondaryLayerData;
                break;

            case LG_LayerType.ThirdLayer:
                LayerData = activeExpedition.ThirdLayerData;
                break;
            }

            var data = RundownManager.GetActiveExpeditionData();

            CurrentExpeditionTier  = data.tier;
            CurrentExpeditionIndex = data.expeditionIndex;

            Builder         = new BuilderProxy(this);
            WinConditions   = new WinConditionProxy(this);
            ObjectiveStatus = new ObjectiveStatusProxy(this);


            var buildDone      = new Action(BuildDone);
            var elevatorArrive = new Action(ElevatorArrive);
            var levelSuccess   = new Action(OnExpeditionSuccess);
            var levelFail      = new Action(OnExpeditionFail);

            GlobalMessage.OnBuildDoneLate  += buildDone;
            GlobalMessage.OnElevatorArrive += elevatorArrive;

            GlobalMessage.OnLevelSuccess += levelSuccess;
            GlobalMessage.OnLevelFail    += levelFail;

            OnUnloadEvent += () =>
            {
                GlobalMessage.OnBuildDoneLate  -= buildDone;
                GlobalMessage.OnElevatorArrive -= elevatorArrive;

                GlobalMessage.OnLevelSuccess -= levelSuccess;
                GlobalMessage.OnLevelFail    -= levelFail;
            };

            OnSetupEvent?.Invoke();

            OnSetup();

            //Check WinCondition has been set after Setup
            if (!IsGlobalHandler && (!IsDefaultObjective && !ObjectiveStatus.Is))
            {
                Logger.Error("Every Custom Type Handler should set their ObjectiveStatus Update Behaviour Inside OnSetup()! Handler has been Unloaded!\n - typeID: {0}\n - handler {1}", (byte)ObjectiveData.Type, GetType().Name);
                UnloadSelf();
                return;
            }
        }
コード例 #5
0
 private bool ShouldFire_User(bool originalState, WardenObjectiveDataBlock objectiveData)
 {
     return(CustomFilter?.Invoke(objectiveData) ?? originalState);
 }
コード例 #6
0
        private static CustomExpHandlerBase FireHandlerByContainer(HandlerTypeContainer handlerContainer, LG_Layer layer, WardenObjectiveDataBlock objectiveData, bool isGlobalHandler = false)
        {
            if (handlerContainer.Setting == null)
            {
                return(null);
            }

            if (!handlerContainer.Setting.ShouldFire_Internal(layer.m_type, objectiveData))
            {
                return(null);
            }

            var handler = handlerContainer.CreateInstance();

            handler.Setup(layer, objectiveData, isGlobalHandler);
            handler.HandlerGUID = new Guid().ToString();

            _ActiveHandlers.Add(handler);

            return(handler);
        }
コード例 #7
0
 internal static CustomExpHandlerBase FireHandler(byte typeID, LG_Layer layer, WardenObjectiveDataBlock objectiveData)
 {
     if (_Handlers.TryGetValue(typeID, out var handler))
     {
         return(FireHandlerByContainer(handler, layer, objectiveData));
     }
     else
     {
         throw new ArgumentException($"typeID: {typeID} is not defined, Are you missing some plugin?");
     }
 }