Example #1
0
 public virtual void RunBuild(FilePath solution)
 {
     CakeContext.DotNetBuild(solution, c => {
         c.Configuration = Configuration;
         if (!string.IsNullOrEmpty(Platform))
         {
             c.Properties ["Platform"] = new [] { Platform }
         }
         ;
         if (Targets != null && Targets.Any())
         {
             foreach (var t in Targets)
             {
                 c.Targets.Add(t);
             }
         }
         if (Properties != null && Properties.Any())
         {
             foreach (var kvp in Properties)
             {
                 c.Properties.Add(kvp.Key, kvp.Value);
             }
         }
     });
 }
 public IEnumerable <ValidationResult> Validate(ValidationContext validationContext)
 {
     if (!Targets.Any())
     {
         yield return(new ValidationResult("Empty Targets", new[] { "Targets" }));
     }
 }
        protected override float TargetEvaluation()
        {
            if (character.SelectedConstruction != null && Targets.Any(t => character.SelectedConstruction == t && t.ConditionPercentage < 100))
            {
                // Don't stop fixing until done
                return(100);
            }
            int   otherFixers = HumanAIController.CountCrew(c => c != HumanAIController && c.ObjectiveManager.IsCurrentObjective <AIObjectiveRepairItems>() && !c.Character.IsIncapacitated, onlyBots: true);
            int   items       = Targets.Count;
            bool  anyFixers   = otherFixers > 0;
            float ratio       = anyFixers ? items / (float)otherFixers : 1;

            if (objectiveManager.CurrentOrder == this)
            {
                return(Targets.Sum(t => 100 - t.ConditionPercentage) * ratio);
            }
            else
            {
                if (anyFixers && (ratio <= 1 || otherFixers > 5 || otherFixers / (float)HumanAIController.CountCrew(onlyBots: true) > 0.75f))
                {
                    // Enough fixers
                    return(0);
                }
                if (RequireAdequateSkills)
                {
                    return(Targets.Sum(t => GetTargetPriority(t, character, RequiredSuccessFactor)) * ratio);
                }
                else
                {
                    return(Targets.Sum(t => 100 - t.ConditionPercentage) * ratio);
                }
            }
        }
Example #4
0
 /// <summary>
 /// Ensure that last target is selected if no other targets are selected</summary>
 internal void EnsureSelection()
 {
     if (Targets.Count > 0 && !Targets.Any(x => x.IsSelected))
     {
         Targets[Targets.Count - 1].IsSelected = true;
     }
 }
Example #5
0
        public override void RunBuild(FilePath solution)
        {
            if (!BuildsOnCurrentPlatform)
            {
                CakeContext.Information("Solution is not configured to build on this platform: {0}", SolutionPath);
                return;
            }

            CakeContext.MSBuild(solution, c => {
                c.Configuration   = Configuration;
                c.MSBuildPlatform = MSBuildPlatform;

                if (!string.IsNullOrEmpty(Platform))
                {
                    c.Properties["Platform"] = new[] { Platform }
                }
                ;

                if (Targets != null && Targets.Any())
                {
                    foreach (var t in Targets)
                    {
                        c.Targets.Add(t);
                    }
                }

                if (Properties != null && Properties.Any())
                {
                    foreach (var kvp in Properties)
                    {
                        c.Properties.Add(kvp.Key, kvp.Value);
                    }
                }
            });
        }
Example #6
0
    public override void OnInspectorGUI()
    {
        DrawDefaultInspector();
        DrawInspectorButtons(1);
        EditorGUILayout.Separator();
        using (new EditorGUILayout.HorizontalScope())
        {
            if (Targets.Any(rail => rail.GetComponent <RailView>() == null))
            {
                if (GUILayout.Button("Add Placeholder View"))
                {
                    foreach (var rail in Targets.Where(rail => rail.GetComponent <RailView>() == null))
                    {
                        rail.gameObject.AddComponent <RailView>();
                    }
                }
            }

            if (Targets.Any(rail => rail.GetComponent <RailCollider>() == null))
            {
                if (GUILayout.Button("Add Rail Collider"))
                {
                    foreach (var rail in Targets.Where(rail => rail.GetComponent <RailCollider>() == null))
                    {
                        rail.gameObject.AddComponent <RailCollider>();
                    }
                }
            }
        }
    }
Example #7
0
        /// <inheritdoc />
        public virtual bool HasTargets(IActor performer)
        {
            if (!Targets.Any())
            {
                return(true);
            }

            return(GetTargets(performer).Any());
        }
Example #8
0
            private void SetupDisablerButtonText()
            {
                if (SelectedTarget != null)
                {
                    var d3d9Path = Path.Combine(MEDirectories.ExecutableDirectory(SelectedTarget), @"d3d9.dll");
                    if (File.Exists(d3d9Path))
                    {
                        // See if it ME3Tweaks disabler or some other tool
                        var fi = new FileInspector(d3d9Path);
                        foreach (var sig in fi.GetSignatures())
                        {
                            foreach (var signChain in sig.AdditionalCertificates)
                            {
                                try
                                {
                                    var outStr = signChain.Subject.Substring(3); //remove CN=
                                    outStr = outStr.Substring(0, outStr.IndexOf(','));
                                    if (outStr == @"Michael Perez")              //My signing cert name
                                    {
                                        D3D9Status            = M3L.GetString(M3L.string_overlayDisablerInstalled);
                                        DisablerButtonText    = M3L.GetString(M3L.string_uninstallDisabler);
                                        DisablerButtonEnabled = true;
                                        return;
                                    }
                                }
                                catch
                                {
                                }
                            }
                        }

                        D3D9Status            = M3L.GetString(M3L.string_otherD3d9dllInstalledOverlayDisabled);
                        DisablerButtonText    = M3L.GetString(M3L.string_cannotUninstallOtherD3d9File);
                        DisablerButtonEnabled = false;
                        return;
                    }

                    DisablerButtonEnabled = true;
                    D3D9Status            = M3L.GetString(M3L.string_overlayDisablerNotInstalled);
                    DisablerButtonText    = M3L.GetString(M3L.string_installDisabler);
                }
                else
                {
                    DisablerButtonEnabled = false;
                    DisablerButtonText    = M3L.GetString(M3L.string_installDisabler);

                    if (Targets.Any())
                    {
                        D3D9Status = M3L.GetString(M3L.string_noTargetSelected);
                    }
                    else
                    {
                        D3D9Status = M3L.GetString(M3L.string_noOriginBasedGameTargets);
                    }
                }
            }
Example #9
0
        private void OK_Click(object sender, RoutedEventArgs e)
        {
            CurrentAnswer.Value = InputTextBox.Text;
            if (String.IsNullOrEmpty(CurrentAnswer.Value))
            {
                Rule newRule = GetNextRule(Targets.Peek());
                WorkWithNewRule(newRule);
            }
            else
            {
                Context.Add(new Property(CurrentAnswer.Key, CurrentAnswer.Value));
                Logger.Info(CurrentAnswer.Key + " - " + CurrentAnswer.Value + " : помещены в контекстный стек");
                Targets.Pop();
                Rule currentRule = GetNextRule(Targets.Peek());
                if (currentRule == null)
                {
                    Flag = true;
                }
                else if (GetNextVerifiableProperty(currentRule) != null)
                {
                    Targets.Push(GetNextVerifiableProperty(currentRule).Key);
                    Logger.Info(GetNextVerifiableProperty(currentRule).Key + " : помещена в стек целей");
                    CurrentAnswer.Key        = GetNextVerifiableProperty(currentRule).Key;
                    PropertyKeyLabel.Content = Char.ToUpper(CurrentAnswer.Key[0]) + CurrentAnswer.Key.Substring(1) + ":";
                    InputTextBox.Clear();
                }
                else
                {
                    Context.Add(new Property(currentRule.Target.Key, currentRule.Target.Value));
                    Logger.Info(currentRule.Target.Key + " - " + currentRule.Target.Value + " : сделан вывод");
                    Targets.Pop();
                    if (Targets.Any())
                    {
                        Rule newRule = GetNextRule(Targets.Peek());
                        WorkWithNewRule(newRule);
                    }
                    else
                    {
                        Flag = true;
                    }
                }
            }

            if (Flag)
            {
                if (Context.Select(x => x.Key).Contains(MainTarget))
                {
                    AnswerLabel.Content = MainTarget + " - " + Context.First(x => x.Key == MainTarget).Value;
                }
                else
                {
                    AnswerLabel.Content = "Ответа нет.";
                }
            }
        }
Example #10
0
 public bool ExistsTargetOrTerritoryById(int id)
 {
     if (Targets.Any(target => target.Id == id) || Territories.Any(territory => territory.Id == id))
     {
         return(true);
     }
     else
     {
         return(false);
     }
 }
Example #11
0
        /// <inheritdoc />
        public virtual IEnumerable <IHasStats> GetTargets(IActor performer)
        {
            if (Targets.Any())
            {
                //Describes who is performing the action and what is granting the action (Owner)
                var args = new SystemArgs(performer.CurrentLocation.World, null, 0, performer, Owner, Guid.Empty);
                return(Targets.SelectMany(t => t.Get(args)).Distinct());
            }

            return(new IHasStats[0]);
        }
Example #12
0
        //
        // win lose feedback
        //

        private BattleResult GetResult()
        {
            if (Player.HP <= 0)
            {
                return(BattleResult.Lose);
            }
            if (!Targets.Any() || Targets.All(t => t.HP <= 0))
            {
                return(BattleResult.Win);
            }
            return(BattleResult.Continue);
        }
Example #13
0
    bool HasMutlipleShaders()
    {
        if (MatEditor.targets.Length > 1)
        {
            return(Targets.Any(o => {
                var objMat = o as Material;
                return objMat != null && (Target != null && objMat.shader != Target.shader);
            }));
        }

        return(false);
    }
Example #14
0
        public IEnumerable <FightActor> GetAffectedActors()
        {
            if (m_customAffectedActors != null)
            {
                return(m_customAffectedActors);
            }

            if (Targets.Any(x => x is TargetTypeCriterion && ((TargetTypeCriterion)x).TargetType == SpellTargetType.SELF_ONLY) && !AffectedCells.Contains(Caster.Cell))
            {
                AffectedCells.Add(Caster.Cell);
            }

            return(Fight.GetAllFighters(AffectedCells).Where(entry => !entry.IsDead() && !entry.IsCarried() && IsValidTarget(entry)).ToArray());
        }
Example #15
0
        private void UpdateDropTarget()
        {
            PointerEventData cursor = new PointerEventData(EventSystem.current);

            cursor.position = Input.mousePosition;

            var Hits = GraphicRaycasterVA.Instance.LastResultList;

            var otherHits = Hits.Where(h => !Targets.Any(t => h.gameObject.transform.IsChildOf(t)));

            if (!otherHits.Any())
            {
                return;
            }

            DropTarget = otherHits.First().gameObject;
        }
Example #16
0
        public EraseStatement(IEnumerable <TargetDetails> targets, int keywordLineIndex)
        {
            if (targets == null)
            {
                throw new ArgumentNullException("targets");
            }
            if (keywordLineIndex < 0)
            {
                throw new ArgumentOutOfRangeException("keywordLineIndex");
            }

            Targets = targets.ToList().AsReadOnly();
            if (Targets.Any(t => t == null))
            {
                throw new ArgumentException("Encountered null reference in targets set");
            }
            KeywordLineIndex = keywordLineIndex;
        }
Example #17
0
        public void Publish(IDataContainer dataContainer)
        {
            if (!Targets.Any())
            {
                dataContainer.Dispose();
                return;
            }

            if (Targets.Count > 1)
            {
                for (var i = 0; i < Targets.Count - 1; i++)
                {
                    var dataContainerCopy = dataContainer.Copy();
                    Targets[i].Process(dataContainerCopy);
                }
            }

            Targets.Last().Process(dataContainer);
        }
Example #18
0
        public void SetNeuralNetwork(NeuralNetwork nn)
        {
            #region Validate

            if (nn == null)
            {
                throw new ArgumentNullException(nameof(nn));
            }

            if (TrainingSet == null || TrainingSet.Length == 0)
            {
                throw new InvalidOperationException("Input values aren't set!");
            }

            if (Targets == null || Targets.Length == 0)
            {
                throw new InvalidOperationException("Target values aren't set!");
            }

            if (TrainingSet.Length != Targets.Length)
            {
                throw new InvalidOperationException("Count of input values don't equal count of target values!");
            }

            var inputLayer = nn.Layers[0];
            if (TrainingSet.Any(s => s.Length != inputLayer))
            {
                throw new ArgumentException("Count of inputs of the neural network don't equal count of values of the training set", nameof(nn));
            }

            var outputLayer = nn.Layers[nn.Layers.Length - 1];
            if (Targets.Any(t => t.Length != outputLayer))
            {
                throw new ArgumentException("Count of outputs of the neural network don't equal count of targets", nameof(nn));
            }

            #endregion

            _nn         = nn;
            _totalSteps = 0;
            _totalError = 1d;
        }
Example #19
0
        public async Task RunAsync()
        {
            if (Targets.Any(t => t.ToLower() == "all"))
            {
                Targets = BuildContext.Default.Config.ProductNames;
            }

            var bt  = new Bullseye.Targets();
            var cmd = this;

            var productBuildTargets = new List <string>();

            foreach (var target in Targets)
            {
                var product = target;
                var ctx     = new BuildContext();
                ctx.SetCommand(this);

                bt.Add(
                    FindPackageTarget.NameWith(product),
                    async() => await FindPackageTarget.RunAsync(ctx, product));

                bt.Add(
                    FetchPackageTarget.NameWith(product),
                    Bullseye.Targets.DependsOn(FindPackageTarget.NameWith(product)),
                    async() => await FetchPackageTarget.RunAsync(ctx));

                productBuildTargets.Add(FetchPackageTarget.NameWith(product));
            }

            try
            {
                await bt.RunWithoutExitingAsync(productBuildTargets);
            }
            catch
            {
                // We swallow exceptions here, BullsEye prints them
                // TODO: use overload "messageOnly"
            }
        }
 private bool IsExistingIndex(int index)
 {
     return(Targets.Any(t => t.id == index));
 }
Example #21
0
 protected override float TargetEvaluation() => Targets.Any() ? (objectiveManager.CurrentOrder == this ? AIObjectiveManager.OrderPriority : AIObjectiveManager.RunPriority - 1) : 0;
Example #22
0
 private bool CoordinatIsEqualToTarget(Kordinat newKordinat)
 {
     return(Targets.Any(t => t.Kordinater.X == newKordinat.X && t.Kordinater.Y == newKordinat.Y));
 }
Example #23
0
        public async Task RunAsync()
        {
            if (Targets.Any(t => t.ToLower() == "containers"))
            {
                var items = await ArtifactsApi.ListNamedContainers();

                await Console.Out.WriteLineAsync(Environment.NewLine + "Branches:");

                await Console.Out.WriteLineAsync(string.Join(
                                                     Environment.NewLine,
                                                     items
                                                     .Where(itm => itm.IsBranch)
                                                     .Select(itm => "  " + itm.Name)
                                                     ));

                await Console.Out.WriteLineAsync(Environment.NewLine + "Versions:");

                await Console.Out.WriteLineAsync(string.Join(
                                                     Environment.NewLine,
                                                     items
                                                     .Where(itm => itm.IsVersion)
                                                     .Select(itm => "  " + itm.Name)
                                                     ));

                await Console.Out.WriteLineAsync(Environment.NewLine + "Aliases:");

                await Console.Out.WriteLineAsync(string.Join(
                                                     Environment.NewLine,
                                                     items
                                                     .Where(itm => itm.IsAlias)
                                                     .Select(itm => "  " + itm.Name)
                                                     ));

                return;
            }

            if (string.IsNullOrWhiteSpace(ContainerId))
            {
                await Console.Out.WriteLineAsync(
                    $"ERROR(s):{Environment.NewLine}" +
                    MagicStrings.Errors.NeedCidWhenTargetSpecified);

                return;
            }

            if (Targets.Any(t => t.ToLower() == "all"))
            {
                Targets = BuildContext.Default.Config.ProductNames;
            }

            foreach (var target in Targets)
            {
                if (!ForceSwitch && !BuildContext.Default.Config.ProductNames.Any(t => t.ToLower() == target))
                {
                    throw new InvalidDataException($"Invalid product '{target}'");
                }

                await Console.Out.WriteLineAsync(Environment.NewLine +
                                                 $"Discovering '{target}' in '{ContainerId}' ...");

                var items = await ArtifactsApi.FindArtifact(target, filter =>
                {
                    filter.ContainerId = ContainerId;
                    filter.Bitness     = Bitness;
                });

                await Console.Out.WriteLineAsync(string.Join(
                                                     Environment.NewLine,
                                                     items.Select(itm => "  " + itm.FileName + Environment.NewLine + "  " + itm.Url + Environment.NewLine)
                                                     ));
            }
        }
Example #24
0
 public bool IsValid <T>(T evt) where T : ISerializableEvent
 {
     return(Targets.Any(obj => evt.GetType() == obj.EventType.GetTypeFromCached() && obj.Target == (evt as ISerializableEvent).Source));
 }
        public override void OnPreTargetMembersGUI()
        {
            var refMaterial = Material;
            var mixedPreset = Targets.Any(target => (target as DeformableTerrainMaterial).PresetName != refMaterial.PresetName);

            using (new InspectorGUI.IndentScope((InspectorGUI.IndentScope.Level > 0 ? -1 : 0))) {
                var resetButtonWidth = EditorGUIUtility.singleLineHeight;
                var rect             = EditorGUILayout.GetControlRect();
                var totalRectWidth   = rect.width;

                var availablePresets = DeformableTerrainMaterial.GetAvailablePresets().ToArray();
                var presetIndex      = FindPresetIndex(availablePresets,
                                                       refMaterial.PresetName);
                var invalidPreset = presetIndex < 0;
                EditorGUI.showMixedValue = mixedPreset || invalidPreset;
                if (invalidPreset)
                {
                    InspectorGUI.WarningLabel($"Material preset name {refMaterial.PresetName} doesn't exist in the material presets library.");
                }

                rect.width = EditorGUIUtility.labelWidth;
                EditorGUI.PrefixLabel(rect, GUI.MakeLabel("Preset"), InspectorEditor.Skin.Label);

                rect.x    += rect.width;
                rect.width = totalRectWidth - EditorGUIUtility.labelWidth - resetButtonWidth;
                EditorGUI.BeginChangeCheck();
                var newPresetIndex = EditorGUI.Popup(rect, Mathf.Max(presetIndex, 0), availablePresets, InspectorEditor.Skin.Popup);
                if (EditorGUI.EndChangeCheck() && invalidPreset)
                {
                    invalidPreset = false;
                }
                EditorGUI.showMixedValue = false;

                rect.x    += rect.width;
                rect.width = resetButtonWidth;
                var resetButtonPressed = InspectorGUI.Button(rect,
                                                             MiscIcon.ResetDefault,
                                                             !invalidPreset,
                                                             $"Reset values to default for preset: {refMaterial.PresetName}",
                                                             0.9f);

                if (!invalidPreset &&
                    newPresetIndex != presetIndex &&
                    EditorUtility.DisplayDialog("Library preset -> " + availablePresets[newPresetIndex],
                                                $"Change preset from {refMaterial.PresetName} to {availablePresets[ newPresetIndex ]}?\n" +
                                                "All current values will be overwritten.",
                                                "Yes", "No"))
                {
                    foreach (var material in GetTargets <DeformableTerrainMaterial>())
                    {
                        material.SetPresetNameAndUpdateValues(availablePresets[newPresetIndex]);
                    }
                }

                if (resetButtonPressed &&
                    EditorUtility.DisplayDialog("Reset values to default",
                                                $"Reset preset {refMaterial.PresetName} to default?",
                                                "Yes", "No"))
                {
                    foreach (var material in GetTargets <DeformableTerrainMaterial>())
                    {
                        material.ResetToPresetDefault();
                    }
                }

                InspectorGUI.Separator();
            }
        }
 protected override float TargetEvaluation() => Targets.Any() ? AIObjectiveManager.RunPriority - 1 : 0;
Example #27
0
        public string this[string propertyName]
        {
            get
            {
                try
                {
                    string validationResult = String.Empty;
                    if (ValidationEnabled)
                    {
                        switch (propertyName)
                        {
                        case "TaskConveyor":
                            if (TaskConveyor != EnumSimpleCommandConveyorTask.Move &&
                                TaskConveyor != EnumSimpleCommandConveyorTask.Create &&
                                TaskConveyor != EnumSimpleCommandConveyorTask.Delete)
                            {
                                validationResult = ResourceReader.GetString("ERR_TASK");
                            }
                            RaisePropertyChanged("Source");
                            break;

                        case "MaterialStr":
                            if (TaskConveyor == EnumSimpleCommandConveyorTask.Create)
                            {
                                if (Material.HasValue && _warehouse.DBService.FindMaterial(Material.Value) != null)
                                {
                                    validationResult = ResourceReader.GetString("ERR_MATERIALEXISTS");
                                }
                            }
                            else
                            {
                                if (!Material.HasValue || Material <= 0)
                                {
                                    validationResult = ResourceReader.GetString("ERR_MATERIALNOTVALID");
                                }
                                else if (_warehouse.DBService.FindMaterial(Material.Value) == null)
                                {
                                    validationResult = ResourceReader.GetString("ERR_MATERIALUNKNOWN");
                                }
                            }
                            break;

                        case "Source":
                            if (Sources != null && !Sources.Any(p => p == Source))
                            {
                                validationResult = ResourceReader.GetString("ERR_LOCATION");
                            }
                            if (TaskConveyor == EnumSimpleCommandConveyorTask.Create ||
                                TaskConveyor == EnumSimpleCommandConveyorTask.Delete)
                            {
                                Target = Source;
                            }
                            break;

                        case "Target":
                            if (Targets != null && !Targets.Any(p => p == Target))
                            {
                                validationResult = ResourceReader.GetString("ERR_LOCATION");
                            }
                            if (TaskConveyor == EnumSimpleCommandConveyorTask.Create ||
                                TaskConveyor == EnumSimpleCommandConveyorTask.Delete)
                            {
                                Source = Target;
                            }
                            break;
                        }
                    }
                    Validator.AddOrUpdate(propertyName, validationResult == String.Empty);
                    AllPropertiesValid = Validator.IsValid();
                    return(validationResult);
                }
                catch (Exception e)
                {
                    _warehouse.AddEvent(Database.Event.EnumSeverity.Error, Database.Event.EnumType.Exception,
                                        string.Format("{0}.{1}: {2}", this.GetType().Name, (new StackTrace()).GetFrame(0).GetMethod().Name, e.Message));
                    Validator.AddOrUpdate(propertyName, false);
                    AllPropertiesValid = Validator.IsValid();
                    return(ResourceReader.GetString("ERR_EXCEPTION"));
                }
            }
        }
Example #28
0
        /// <summary>
        ///   Return the best possible target (based on current target, distance and low value first)
        /// </summary>
        /// <param name="currentTarget"></param>
        /// <param name="distance"></param>
        /// <param name="lowValueFirst"></param>
        /// <returns></returns>
        public EntityCache GetBestTarget(EntityCache currentTarget, double distance, bool lowValueFirst)
        {
            // Is our current target a warp scrambling priority target?
            if (currentTarget != null && PriorityTargets.Any(pt => pt.Id == currentTarget.Id && pt.IsWarpScramblingMe))
            {
                return(currentTarget);
            }

            // Get the closest warp scrambling priority target
            var target = PriorityTargets.OrderBy(OrderByLowestHealth()).ThenBy(t => t.Distance).FirstOrDefault(pt => pt.Distance < distance && pt.IsWarpScramblingMe && Targets.Any(t => t.Id == pt.Id));

            if (target != null)
            {
                return(target);
            }

            // Is our current target any other priority target?
            if (currentTarget != null && PriorityTargets.Any(pt => pt.Id == currentTarget.Id))
            {
                return(currentTarget);
            }

            // Get the closest priority target
            target = PriorityTargets.OrderBy(OrderByLowestHealth()).ThenBy(t => t.Distance).FirstOrDefault(pt => pt.Distance < distance && Targets.Any(t => t.Id == pt.Id));
            if (target != null)
            {
                return(target);
            }

            // Do we have a target?
            if (currentTarget != null)
            {
                return(currentTarget);
            }

            // Get all entity targets
            var targets = Targets.Where(e => e.CategoryId == (int)CategoryID.Entity && e.IsNpc && !e.IsContainer && e.GroupId != (int)Group.LargeCollidableStructure);

            // Get the closest high value target
            var highValueTarget = targets.Where(t => t.TargetValue.HasValue && t.Distance < distance).OrderByDescending(t => t.TargetValue.Value).ThenBy(OrderByLowestHealth()).ThenBy(t => t.Distance).FirstOrDefault();
            // Get the closest low value target
            var lowValueTarget = targets.Where(t => !t.TargetValue.HasValue && t.Distance < distance).OrderBy(OrderByLowestHealth()).ThenBy(t => t.Distance).FirstOrDefault();

            if (lowValueFirst && lowValueTarget != null)
            {
                return(lowValueTarget);
            }
            if (!lowValueFirst && highValueTarget != null)
            {
                return(highValueTarget);
            }

            // Return either one or the other
            return(lowValueTarget ?? highValueTarget);
        }
Example #29
0
        public async Task RunAsync()
        {
            if (Targets.Any(t => t.ToLower() == "all"))
            {
                Targets = BuildContext.Default.Config.ProductNames;
            }

            var bt  = new Bullseye.Targets();
            var cmd = this;

            bt.Add(
                BuildBeatPackageCompilerTarget.Name,
                async() => await BuildBeatPackageCompilerTarget.RunAsync(BuildContext.Default));

            var productBuildTargets = new List <string>();

            bool addSignTarget = false;

            if (!CertPass.IsEmpty() && File.Exists(CertFile))
            {
                // Let's try value as file name first, then as env var
                var password = CertPass;

                try
                { password = await File.ReadAllTextAsync(CertPass); }
                catch
                { password = Environment.GetEnvironmentVariable(password); }

                if (!password.IsEmpty())
                {
                    CertPass      = password;
                    addSignTarget = true;
                }
            }

            foreach (var target in Targets)
            {
                var ctx = new BuildContext();
                ctx.SetCommand(this);

                bt.Add(
                    FindPackageTarget.NameWith(target),
                    async() => await FindPackageTarget.RunAsync(ctx, target));

                bt.Add(
                    FetchPackageTarget.NameWith(target),
                    Bullseye.Targets.DependsOn(FindPackageTarget.NameWith(target)),
                    async() => await FetchPackageTarget.RunAsync(ctx));

                bt.Add(
                    UnpackPackageTarget.NameWith(target),
                    Bullseye.Targets.DependsOn(FetchPackageTarget.NameWith(target)),
                    async() => await UnpackPackageTarget.RunAsync(ctx));

                // sign individual binaries
                if (addSignTarget)
                {
                    ctx.SetCertificate(CertFile, CertPass);
                }

                if (addSignTarget)
                {
                    bt.Add(
                        SignProductBinariesTarget.NameWith(target),
                        Bullseye.Targets.DependsOn(UnpackPackageTarget.NameWith(target)),
                        async() => await SignProductBinariesTarget.RunAsync(ctx));
                }
                else
                {
                    bt.Add(
                        SignProductBinariesTarget.NameWith(target),
                        Bullseye.Targets.DependsOn(UnpackPackageTarget.NameWith(target)),
                        () => Console.WriteLine("Skipping digital signature for product binaries"));
                }

                bt.Add(
                    CompileMsiTarget.NameWith(target),
                    Bullseye.Targets.DependsOn(
                        BuildBeatPackageCompilerTarget.Name,
                        SignProductBinariesTarget.NameWith(target)),
                    async() => await CompileMsiTarget.RunAsync(ctx));

                // sign final .msi
                if (addSignTarget)
                {
                    bt.Add(
                        SignMsiPackageTarget.NameWith(target),
                        Bullseye.Targets.DependsOn(CompileMsiTarget.NameWith(target)),
                        async() => await SignMsiPackageTarget.RunAsync(ctx));
                }
                else
                {
                    bt.Add(
                        SignMsiPackageTarget.NameWith(target),
                        Bullseye.Targets.DependsOn(CompileMsiTarget.NameWith(target)),
                        () => Console.WriteLine("Skipping digital signature for MSI package"));
                }

                bt.Add(
                    BuildInstallerTarget.NameWith(target),
                    Bullseye.Targets.DependsOn(SignMsiPackageTarget.NameWith(target)),
                    async() => await BuildInstallerTarget.RunAsync(ctx));

                productBuildTargets.Add(BuildInstallerTarget.NameWith(target));
            }

            try
            {
                await bt.RunWithoutExitingAsync(productBuildTargets);
            }
            catch
            {
                // We swallow exceptions here, BullsEye prints them
                // TODO: use overload "messageOnly"
            }
        }
Example #30
0
 protected override float TargetEvaluation() =>
 // If any target is visible -> 100 priority
 Targets.Any(t => t == character.CurrentHull || HumanAIController.VisibleHulls.Contains(t)) ? 100 :
 // Else based on the fire severity
 Targets.Sum(t => GetFireSeverity(t) * 100);