private void DeleteTargetCommand() { if (Targets.Contains(TargetsName)) { Targets.Remove(TargetsName); } }
protected override float TargetEvaluation() { if (Targets.None()) { return(100); } if (!objectiveManager.IsOrder(this)) { if (!character.IsMedic && HumanAIController.IsTrueForAnyCrewMember(c => c != HumanAIController && c.Character.IsMedic && !c.Character.IsUnconscious)) { // Don't do anything if there's a medic on board and we are not a medic return(100); } } float worstCondition = Targets.Min(t => GetVitalityFactor(t)); if (Targets.Contains(character)) { if (character.Bleeding > 10) { // Enforce the highest priority when bleeding out. worstCondition = 0; } // Boost the priority when wounded. worstCondition /= 2; } return(worstCondition); }
public override void AddItem(ICmObject obj) { if (!Targets.Contains(obj)) { AddItem(obj, LexEdStrings.ksUndoAddRef, LexEdStrings.ksRedoAddRef); } }
private void AddTargetCommand() { if (!Targets.Contains(TargetsName)) { Targets.Add(TargetsName); } }
//创建任务 protected Task CreateTask(TEnum type, TTarget target) { int enumIndex = Enum <TEnum> .Int(type); if (target == null) { return(null); } if (Targets.Contains(target)) { foreach (var item in AllTask) { if (item.Target == target) { return(item); } } return(null); } if (!ConfigData[enumIndex].Valid.Invoke(target)) { return(null); } var obj = new Task(); AllTask.Add(obj); Targets.Add(target); TypedTask[enumIndex].Add(obj); obj.Init(type, target, this); return(obj); }
public void AddTarget(ChainNode target, bool registerUndo = true) { if (target.HasDescendent(this)) { Debug.LogWarning("Not adding target because it would create a circular reference."); return; } if (Targets.Contains(target)) { return; } Targets.Add(target); if (registerUndo) { List <UndoItem> list = new List <UndoItem> { new RouterConnection(target, this, true) }; TargetAdded(this, target, list); UndoLord.Instance.Push(new UndoList(list)); } else { TargetAdded(this, target, null); } }
protected override void UpdateTargets(string tag, float range2) //modules, selectableTargets must be at z=0; { GameObject[] targets = GameObject.FindGameObjectsWithTag(tag); int count = targets.Length; SelectableTarget[] selectables = new SelectableTarget[count]; for (int i = 0; i < count; i++) { selectables[i] = targets[i].GetComponent <SelectableTarget>(); } for (int i = 0; i < count; i++) { if (selectables[i] == null) { targets[i] = targets[i].transform.parent.gameObject; selectables[i] = targets[i].GetComponent <SelectableTarget>(); } } if (combining) { count = 0; for (int i = 0; i < targets.Length; i++) { if (targets[i].GetComponent <CombineAction>().Combinable(part, up, down)) { selectables[count] = selectables[i]; targets[count++] = targets[i]; } } } for (int i = 0; i < count; i++) { if ((transform.position - targets[i].transform.position).sqrMagnitude <= range2) { if (!Targets.Contains(targets[i])) //add targets that newly came into range { if (!selectables[i].IsSelectable(PlayerInside, tag)) { continue; } Targets.Add(targets[i]); selectables[i].SetGlow(PlayerInside, true); } else if (!selectables[i].IsSelectable(PlayerInside, tag)) { Targets.Remove(targets[i]); } } else //out of range { if (Targets.Remove(targets[i])) //remove targets that went out of range { targets[i].GetComponent <SelectableTarget>().SetGlow(PlayerInside, false); } } } }
public override void Load(XmlNode originalNode) { string value = originalNode.GetValueAttributeValueFromChildElement(TargetName); if (!string.IsNullOrEmpty(value) && Targets.Contains(value)) { SelectedItem = value; } }
public bool Missed(Slot target) { // Maybe just return true here?? if (!Targets.Contains(target)) { throw new ArgumentException("Target was not a target of this move", "target"); } return(randomNumber > Accuracy(target)); }
private bool TryProgress(int value) { if (!Targets.Contains(value)) { return(false); } AddProgress(value); return(true); }
public async Task <bool> TryProgress(int value) { if (!Targets.Contains(value)) { return(false); } await AddProgressAsync(value); return(true); }
public int Accuracy(Slot target) { if (!Targets.Contains(target)) { throw new ArgumentException("Target was not a target of this move", "target"); } int effectiveStage = Math.Max(Math.Min(Slot.Pokemon.Stats.Stage(Statistic.Accuracy) - target.Pokemon.Stats.Stage(Statistic.Evasiveness), Statistics.MaxStage), Statistics.MinStage); return((int)AccuracyModifiers.Calculate(Move.Accuracy * Statistics.Multiplier(Statistic.Accuracy, effectiveStage))); }
/// <summary> /// 檢驗優惠券是否適用於指定訂單項目 /// </summary> /// <param name="orderItem">訂單項目</param> /// <param name="order">訂單</param> /// <returns>是否適用</returns> private protected virtual bool IsAvailable(IOrder order, IOrderItem orderItem) { if (orderItem is IOrderItem <TOrderItemIdentifier> item) { return(Targets.Contains(item.Id)); } if (Count.HasValue && Count == 0) { return(false); } return(false); }
public bool RemoveTarget(Card target) { if (Targets.Contains(target)) { int index = Targets.IndexOf(target); ToFrontFieldList.RemoveAt(index); ActionedList.RemoveAt(index); return(true); } else { return(false); } }
public async Task ReportProgress(int lot) { if (!Targets.Contains(lot)) { return; } AddProgress(lot); if (Completed) { await CheckMissionCompletedAsync(); } }
public async Task Progress(int lot) { if (!Targets.Contains(lot)) { return; } await AddProgressAsync(lot); if (await IsCompleteAsync()) { await CheckMissionCompleteAsync(); } }
public UndoItem RemoveTarget(ChainNode target, bool registerUndo) { if (!Targets.Contains(target)) { return(null); } Targets.Remove(target); TargetRemoved(this, target); if (registerUndo) { return(new RouterConnection(target, this, false)); } return(null); }
public async Task Progress(GameObject gameObject) { var component = gameObject.GetComponent <CollectibleComponent>(); if (!Targets.Contains((int)gameObject.Lot)) { return; } var shiftedId = component.CollectibleId + ((int)gameObject.Zone.ZoneId << 8); await AddProgressAsync(shiftedId); if (await IsCompleteAsync()) { await CheckMissionCompleteAsync(); } }
public void AddTarget(Step step) { if (Targets.Contains(step)) { return; } step.Timeline = Timeline; step.RemovalRequested += HandleStepRemovalRequested; step.MoveUpRequested += HandleStepMoveUpRequested; step.MoveDownRequested += HandleStepMoveDownRequested; step.DuplicationRequested += HandleStepDuplicationRequested; step.ReplacementRequested += HandleStepReplacementRequested; Targets.Add(step); TargetAdded(step); }
public void RemoveTarget(Step step) { if (!Targets.Contains(step)) { return; } step.Timeline = null; step.RemovalRequested -= HandleStepRemovalRequested; step.MoveUpRequested -= HandleStepMoveUpRequested; step.MoveDownRequested -= HandleStepMoveDownRequested; step.DuplicationRequested -= HandleStepDuplicationRequested; step.ReplacementRequested -= HandleStepReplacementRequested; Targets.Remove(step); TargetRemoved(step); }
RemoveTarget(Target target) { Guard.NotNull(target, nameof(target)); if (!Targets.Contains(target)) { throw new ArgumentException("Target not in graph", nameof(target)); } var requiring = Requiring(target).ToList(); foreach (var t in requiring) { RemoveDependency(target, t); } var required = Requiring(target).ToList(); foreach (var t in required) { RemoveDependency(t, target); } Targets.Remove(target); }
public async Task Progress(int id) { if (!Targets.Contains(id)) { return; } var progress = await GetProgressValuesAsync(); if (progress.Contains(id)) { return; } await AddProgressAsync(id); if (await IsCompleteAsync()) { await CheckMissionCompleteAsync(); } }
/// <summary> /// Constructs an instance with reasonable settings. /// </summary> /// <param name="targetGroups"> /// Specifies the targets to be included in the generated output code. /// </param> public ModelGeneratorSettings(params string[] targetGroups) { Covenant.Requires <ArgumentNullException>(targetGroups != null); foreach (var group in targetGroups) { if (string.IsNullOrEmpty(group)) { continue; } if (!Targets.Contains(group, StringComparer.InvariantCultureIgnoreCase)) { Targets.Add(group); } if (Targets.Count == 0) { throw new ArgumentException("At least one target group must be specified."); } } }
private void Update() { if (Selection != SelectionState.target) { return; } Cell cell = PhaseManager.MouseToCell(); if (cell == null) { return; } Fighter t = cell.unitInTile; if (t != null && Targets.Contains(t)) { Target = t; } PhaseManager.Crosshair.transform.position = (Vector2)Target.Position(); }
public int GetMarkedByEnemyCount(BaseUnit owner, TTarget target) { if (owner == null) { return(0); } if (target == null) { return(0); } if (!target.IsLive) { return(0); } if (!TargetUnits.ContainsKey(target)) { return(0); } bool ret = Targets.Contains(target); int count = 0; if (ret) { foreach (var item in TargetUnits[target]) { if (!item.IsLive) { continue; } if (owner.IsEnemy(item)) { count++; } } } return(count); }
public bool IsMarkedByEnemy(BaseUnit owner, TTarget target) { if (owner == null) { return(false); } if (target == null) { return(false); } if (!target.IsLive) { return(false); } if (!TargetUnits.ContainsKey(target)) { return(false); } bool ret = Targets.Contains(target); if (ret) { foreach (var item in TargetUnits[target]) { if (!item.IsLive) { continue; } if (owner.IsEnemy(item)) { return(true); } } return(false); } return(false); }
//转换任务 protected Task ConvertTask(TEnum type, Task objective) { var target = objective.Target; if (target == null) { return(null); } if (Targets.Contains(target)) { foreach (var item in AllTask) { if (item.Target == target) { return(item); } } return(null); } else { return(CreateTask(type, objective.Target)); } }
void CreateAuras(ref List <MissedTarget> missedTargets, ref List <IAura> auras, DynamicObject dynObj) { auras = AuraListPool.Obtain(); var allowDead = Spell.PersistsThroughDeath; // create AreaAura if (Spell.IsAreaAura) { if (dynObj != null || (CasterObject != null && (allowDead || !(CasterObject is Unit) || ((Unit)CasterObject).IsAlive))) { // AreaAura is created at the target location if it is a DynamicObject, else its applied to the caster var aaura = new AreaAura(dynObj ?? CasterObject, Spell); if (dynObj != null) { // also start the area aura auras.Add(aaura); } // else: Is coupled to an Aura instance } else { LogManager.GetCurrentClassLogger().Warn( "Tried to cast Spell {0} with invalid dynObj or Caster - dynObj: {1}, CasterObject: {2}, CasterUnit: {3}", Spell, dynObj, CasterObject, CasterUnit); } } // remove missed targets for (var i = m_auraApplicationInfos.Count - 1; i >= 0; i--) { var app = m_auraApplicationInfos[i]; if (!Targets.Contains(app.Target)) { m_auraApplicationInfos.RemoveAt(i); } } if (m_auraApplicationInfos.Count == 0) { return; } // create Aura-Handlers for (var i = 0; i < Handlers.Length; i++) { var spellHandler = Handlers[i]; if (spellHandler is ApplyAuraEffectHandler) { ((ApplyAuraEffectHandler)spellHandler).AddAuraHandlers(m_auraApplicationInfos); } } if (missedTargets == null) { missedTargets = CastMissListPool.Obtain(); } // apply all new Auras for (var i = 0; i < m_auraApplicationInfos.Count; i++) { var info = m_auraApplicationInfos[i]; var target = info.Target; if (!target.IsInContext) { continue; } if (info.Handlers == null || (!allowDead && !target.IsAlive)) { continue; } // check for immunities and resistances CastMissReason missReason; var hostile = Spell.IsHarmfulFor(CasterReference, target); if (!IsPassive && !Spell.IsPreventionDebuff && (missReason = CheckDebuffResist(target, Spell, CasterReference.Level, hostile)) != CastMissReason.None) { // debuff miss missedTargets.Add(new MissedTarget(target, missReason)); } else { // create aura var newAura = target.Auras.CreateAura(CasterReference, Spell, info.Handlers, TargetItem, !Spell.IsPreventionDebuff && !hostile); if (newAura != null) { // check for debuff and if the spell causes no threat we aren't put in combat if (!Spell.IsPreventionDebuff && !((Spell.AttributesExC & SpellAttributesExC.NoInitialAggro) != 0) && hostile && target.IsInWorld && target.IsAlive) { // force combat mode target.IsInCombat = true; if (target is NPC && CasterUnit != null) { ((NPC)target).ThreatCollection.AddNewIfNotExisted(CasterUnit); } } // add Aura now auras.Add(newAura); } } } //m_auraApplicationInfos.Clear(); //AuraAppListPool.Recycle(m_auraApplicationInfos); m_auraApplicationInfos = null; }
public async Task <int> OnExecuteAsync() { Exception error = default; try { NeedMono = !RuntimeInformation.IsOSPlatform(OSPlatform.Windows); TestFlagsNonParallel = "-parallel none -maxthreads 1 "; // TestFlagsNonParallel = "-parallel none -maxthreads 1 -preenumeratetheories "; TestFlagsParallel = ""; // Find the folder with the solution file BaseFolder = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); while (true) { if (Directory.Exists(Path.Combine(BaseFolder, ".git"))) { break; } BaseFolder = Path.GetDirectoryName(BaseFolder); if (BaseFolder == null) { throw new InvalidOperationException("Could not locate a solution file in the directory hierarchy"); } } ConsoleRunnerExe = Path.Combine(BaseFolder, "src", "xunit.v3.runner.console", "bin", ConfigurationText, "net472", "merged", "xunit.v3.runner.console.exe"); ConsoleRunner32Exe = Path.Combine(BaseFolder, "src", "xunit.v3.runner.console", "bin", ConfigurationText + "_x86", "net472", "merged", "xunit.v3.runner.console.x86.exe"); // Dependent folders PackageOutputFolder = Path.Combine(BaseFolder, "artifacts", "packages"); Directory.CreateDirectory(PackageOutputFolder); TestOutputFolder = Path.Combine(BaseFolder, "artifacts", "test"); Directory.CreateDirectory(TestOutputFolder); // Parse the targets var targetNames = Targets.Select(x => x.ToString()).ToList(); // Turn off test parallelization in CI, for more repeatable test timing if (Targets.Contains(BuildTarget.CI)) { TestFlagsParallel = TestFlagsNonParallel; } // Find target classes var targetCollection = new TargetCollection(); var targets = Assembly.GetExecutingAssembly() .ExportedTypes .Select(x => new { type = x, attr = x.GetCustomAttribute <TargetAttribute>() }) .Where(x => x.attr != null); foreach (var target in targets) { var method = target.type.GetRuntimeMethod("OnExecute", new[] { typeof(BuildContext) }); if (method == null) { targetCollection.Add(new Target(target.attr.TargetName, target.attr.DependentTargets)); } else { targetCollection.Add(new ActionTarget(target.attr.TargetName, target.attr.DependentTargets, async() => { var sw = Stopwatch.StartNew(); try { await(Task) method.Invoke(null, new[] { this }); } finally { if (Timing) { WriteLineColor(ConsoleColor.Cyan, $"TIMING: Target '{target.attr.TargetName}' took {sw.Elapsed}{Environment.NewLine}"); } } })); } } var swTotal = Stopwatch.StartNew(); // Let Bullseye run the target(s) await targetCollection.RunAsync(targetNames, SkipDependencies, dryRun : false, parallel : false, new NullLogger(), _ => false); WriteLineColor(ConsoleColor.Green, $"==> Build success! <=={Environment.NewLine}"); if (Timing) { WriteLineColor(ConsoleColor.Cyan, $"TIMING: Build took {swTotal.Elapsed}{Environment.NewLine}"); } return(0); } catch (Exception ex) { error = ex; while (error is TargetInvocationException || error is TargetFailedException) { error = error.InnerException; } } Console.WriteLine(); if (error is NonZeroExitCodeException nonZeroExit) { WriteLineColor(ConsoleColor.Red, "==> Build failed! <=="); return(nonZeroExit.ExitCode); } WriteLineColor(ConsoleColor.Red, $"==> Build failed! An unhandled exception was thrown <=="); Console.WriteLine(error.ToString()); return(-1); }
/// <summary> /// 檢驗此訂單是否可使用這個優惠券 /// </summary> /// <param name="order">訂單</param> /// <returns>是否可使用</returns> public override bool IsAvailable(IOrder order) { // 合併項目 Cashier.MergeOrderItem <TOrderItemIdentifier>(order); if (!base.IsAvailable(order) || order.TotalAmount < TargetAmount) { return(false); } foreach (var item in order.Items.Where(x => x is IOrderItem <TOrderItemIdentifier> _item && Targets.Contains(_item.Id))) { if (IsAvailable(order, item)) { return(true); } } return(false); }