internal void Initialize() { var commandGroups = new Dictionary<string, List<ModelNodeCommandWrapper>>(); foreach (var node in combinedNodes) { if (node.IsDisposed) throw new InvalidOperationException("One of the combined node is already disposed."); foreach (var command in node.Commands) { var list = commandGroups.GetOrCreateValue(command.Name); list.Add((ModelNodeCommandWrapper)command); } } foreach (var commandGroup in commandGroups) { var mode = commandGroup.Value.First().CombineMode; if (commandGroup.Value.Any(x => x.CombineMode != mode)) throw new InvalidOperationException($"Inconsistent combine mode among command {commandGroup.Key}"); var shouldCombine = mode != CombineMode.DoNotCombine && (mode == CombineMode.AlwaysCombine || commandGroup.Value.Count == combinedNodes.Count); if (shouldCombine) { var command = new CombinedNodeCommandWrapper(ServiceProvider, commandGroup.Key, commandGroup.Value); AddCommand(command); } } if (!HasList || HasDictionary) { var commonChildren = GetCommonChildren(); GenerateChildren(commonChildren); } else { var commonChildren = GetCommonChildrenInList(); if (commonChildren != null) { // TODO: Disable list children for now - they need to be improved a lot (resulting combinaison is very random, especially for list of ints GenerateChildren(commonChildren); } } foreach (var key in AssociatedData.Keys.ToList()) { RemoveAssociatedData(key); } // TODO: we add associatedData added to SingleObservableNode this way, but it's a bit dangerous. Maybe we should check that all combined nodes have this data entry, and all with the same value. foreach (var singleData in CombinedNodes.SelectMany(x => x.AssociatedData).Where(x => !AssociatedData.ContainsKey(x.Key))) { AddAssociatedData(singleData.Key, singleData.Value); } FinalizeChildrenInitialization(); CheckDynamicMemberConsistency(); }
private IEnumerable<KeyValuePair<string, List<SingleObservableNode>>> GetCommonChildren() { var allChildNodes = new Dictionary<string, List<SingleObservableNode>>(); foreach (var singleNode in CombinedNodes) { foreach (var observableNode in singleNode.Children) { var child = (SingleObservableNode)observableNode; var list = allChildNodes.GetOrCreateValue(child.Name); list.Add(child); } } return allChildNodes.Where(x => ShouldCombine(x.Value, CombinedNodes.Count, x.Key)); }
public void Reset() { foreach (var t in wf.Tasks) { t.ScheduledInstance = null; } Plan.Clear(); Wrappers = TaskScheduler.GenerateWrappers(wf); Estimations = TaskScheduler.MakeOverallEstimations(wf, Wrappers); if (!IgnoreNonUrgentTasks) { var additions = new Dictionary<int, List<ActiveEstimatedTask>>(); for (var i = 0; i < Estimations.Count; i++) { var ests = Estimations[i]; var busyEsts = ests.Where(e => { var busyNodes = e.Estimation.NodesTimings.Where(n => n.LaunchedTask != null).ToArray(); if (!busyNodes.Any()) { return false; } var maxUrgentTime = busyNodes.Max(n => n.LaunchedTask.IsUrgent ? n.LaunchedTask.Estimation.Result.Time : 0); return busyNodes.Any(n => !n.LaunchedTask.IsUrgent && n.LaunchedTask.Estimation.Result.Time > maxUrgentTime); }); foreach (var e in busyEsts.ToArray()) { additions.GetOrCreateValue(i, () => new List<ActiveEstimatedTask>()).Add(new ActiveEstimatedTask(e) { IgnoreNonUrgent = false }); } } foreach (var p in additions) { (Estimations[p.Key] as List<ActiveEstimatedTask>).AddRange(p.Value); } } }
private static void MonitorActors(DiaObject testunit, Dictionary<int, HashSet<ActorAttributeType>> unitAtts) { var existingAtts = unitAtts.GetOrCreateValue(testunit.ACDGuid, new HashSet<ActorAttributeType>()); var atts = Enum.GetValues(typeof (ActorAttributeType)).Cast<ActorAttributeType>().ToList(); foreach (var att in atts) { try { var attiResult = testunit.CommonData.GetAttribute<int>(att); var attfResult = testunit.CommonData.GetAttribute<float>(att); var hasValue = attiResult > 0 || !float.IsNaN(attfResult) && attfResult > 0; if (hasValue) { if (!existingAtts.Contains(att)) { Logger.Log("Unit {0} has gained {1} (i:{2} f:{3:00.00000})", testunit.Name, att.ToString(), attiResult, attfResult); existingAtts.Add(att); } } else { if (existingAtts.Contains(att)) { Logger.Log("Unit {0} has lost {1} (i:{2} f:{3:00.00000})", testunit.Name, att.ToString(), attiResult, attfResult); existingAtts.Remove(att); } } } catch (Exception) { } } var allpowers = Enum.GetValues(typeof (SNOPower)).Cast<SNOPower>().ToList(); var allBuffAttributes = Enum.GetValues(typeof (ActorAttributeType)).Cast<ActorAttributeType>().Where(a => a.ToString().Contains("Power")).ToList(); var checkpowers = new HashSet<SNOPower> { SNOPower.MonsterAffix_ReflectsDamage, SNOPower.MonsterAffix_ReflectsDamageCast, SNOPower.Monk_ExplodingPalm }; foreach (var power in allpowers) { foreach (var buffattr in allBuffAttributes) { try { if (testunit.CommonData.GetAttribute<int>(((int) power << 12) + ((int) buffattr & 0xFFF)) == 1) { Logger.Log("Unit {0} has {1} ({2})", testunit.Name, power, buffattr); } } catch (Exception) { } } } }
private static void StartTestHandler(object sender, RoutedEventArgs routedEventArgs) { try { var unitAtts = new Dictionary<int, HashSet<ActorAttributeType>>(); var unitLastDamage = new Dictionary<int, float>(); if (!ZetaDia.IsInGame) return; Worker.Start(() => { using (new MemoryHelper()) { Func<DiaUnit, bool> isValid = u => u != null && u.IsValid && u.CommonData != null && u.CommonData.IsValid && !u.CommonData.IsDisposed; var testunits = ZetaDia.Actors.GetActorsOfType<DiaUnit>().Where(u => isValid(u) && u.RActorGuid != ZetaDia.Me.RActorGuid).ToList(); if (!testunits.Any()) return false; var testunit = testunits.OrderBy(u => u.Distance).FirstOrDefault(); if (testunit == null || testunit.CommonData == null) { testunit = ZetaDia.Me; } //PowerBuff0VisualEffectNone (1) Power=MonsterAffix_ReflectsDamage //if(PowerBuff3VisualEffectNone (1) Power=MonsterAffix_ReflectsDamageCast) if (testunit.CommonData.GetAttribute<int>(((int) SNOPower.MonsterAffix_ReflectsDamageCast << 12) + ((int) ActorAttributeType.PowerBuff3VisualEffectNone & 0xFFF)) == 1) { Logger.Log("Unit {0} has has reflect buff", testunit.Name); } //var attrs = new HashSet<ActorAttributeType> //{ // ActorAttributeType.CustomTargetWeight, // ActorAttributeType.Hunter, // ActorAttributeType.PlatinumCapLastGain, //}; //foreach (var att in attrs) //{ // Logger.Log("Unit {0} attr {1} ival={2} fval={3}", testunit.Name, att, testunit.CommonData.GetAttribute<int>(att), testunit.CommonData.GetAttribute<float>(att)); //} var existingAtts = unitAtts.GetOrCreateValue(testunit.ACDGuid, new HashSet<ActorAttributeType>()); var atts = Enum.GetValues(typeof (ActorAttributeType)).Cast<ActorAttributeType>().ToList(); foreach (var att in atts) { //if (!att.ToString().ToLower().Contains("buff")) // continue; try { var attiResult = testunit.CommonData.GetAttribute<int>(att); var attfResult = testunit.CommonData.GetAttribute<float>(att); var hasValue = attiResult > 0 || !float.IsNaN(attfResult) && attfResult > 0; if (hasValue) { if (!existingAtts.Contains(att)) { Logger.Log("Unit {0} has gained {1} (i:{2} f:{3:00.00000})", testunit.Name, att.ToString(), attiResult, attfResult); existingAtts.Add(att); //if (att == ActorAttributeType.LastDamageACD) //{ // //var idmg = testunit.CommonData.GetAttribute<int>((attiResult << 12) + ((int) ActorAttributeType.LastDamageAmount & 0xFFF)); // //var fdmg = testunit.CommonData.GetAttribute<float>((attiResult << 12) + ((int) ActorAttributeType.LastDamageAmount & 0xFFF)); // //Logger.Log("DamageByUnit To LastACD {0} has gained {1} (i:{2} f:{3:00.00000})", testunit.Name, "LastDamageAmount", idmg, fdmg); // var idmg = ZetaDia.Me.CommonData.GetAttribute<int>((attiResult << 12) + ((int)ActorAttributeType.LastDamageAmount & 0xFFF)); // var fdmg = ZetaDia.Me.CommonData.GetAttribute<float>((attiResult << 12) + ((int)ActorAttributeType.LastDamageAmount & 0xFFF)); // Logger.Log("DamageToPlayer By Unit {0} has gained {1} (i:{2} f:{3:00.00000})", testunit.Name, "LastDamageAmount", idmg, fdmg); //} //foreach (var type in atts) //{ // //if (!att.ToString().ToLower().Contains("buff")) // // continue; // try // { // var ari = ZetaDia.Me.CommonData.GetAttribute<int>((testunit.ACDGuid << 12) + ((int)type & 0xFFF)); // var arf = ZetaDia.Me.CommonData.GetAttribute<float>((testunit.ACDGuid << 12) + ((int)type & 0xFFF)); // var hv = ari > 0 || !float.IsNaN(arf) && arf > 0; // if (hv) // { // Logger.Log("PlayerOffset {0} has gained {1} (i:{2} f:{3:00.00000})", testunit.Name, type.ToString(), ari, arf); // } // } // catch (Exception ex) // { // } //} } } else { if (existingAtts.Contains(att)) { Logger.Log("Unit {0} has lost {1} (i:{2} f:{3:00.00000})", testunit.Name, att.ToString(), attiResult, attfResult); existingAtts.Remove(att); } } } catch (Exception) { } } //if (testunit.CommonData.GetAttribute<int>(((int) SNOPower.MonsterAffix_ReflectsDamage << 12) + ((int) ActorAttributeType.PowerBuff0VisualEffectNone & 0xFFF)) == 1) //{ // Logger.Log("Unit {0} has reflect damage", testunit.Name); //} //MonsterAffix_ReflectsDamageCast var allpowers = Enum.GetValues(typeof (SNOPower)).Cast<SNOPower>().ToList(); var allBuffAttributes = Enum.GetValues(typeof(ActorAttributeType)).Cast<ActorAttributeType>().Where(a => a.ToString().StartsWith("PowerBuff")).ToList(); var checkpowers = new HashSet<SNOPower> { SNOPower.MonsterAffix_ReflectsDamage, SNOPower.MonsterAffix_ReflectsDamageCast, SNOPower.Monk_ExplodingPalm }; foreach (var power in allpowers) { foreach (var buffattr in allBuffAttributes) { try { if (testunit.CommonData.GetAttribute<int>(((int) power << 12) + ((int)buffattr & 0xFFF)) == 1) { Logger.Log("Unit {0} has {1} ({2})", testunit.Name, power, buffattr); } } catch (Exception) { } } //if (testunit.CommonData.GetAttribute<int>(((int) power << 12) + ((int) ActorAttributeType.PowerBuff0VisualEffect & 0xFFF)) == 1) // result = true; //if (testunit.CommonData.GetAttribute<int>(((int) power << 12) + ((int) ActorAttributeType.PowerBuff0VisualEffectNone & 0xFFF)) == 1) // result = true; //if (testunit.CommonData.GetAttribute<int>(((int) power << 12) + ((int) ActorAttributeType.PowerBuff0VisualEffectA & 0xFFF)) == 1) // result = true; //// Exploding Palm //if (testunit.CommonData.GetAttribute<int>(((int) power << 12) + ((int) ActorAttributeType.PowerBuff0VisualEffectB & 0xFFF)) == 1) // result = true; //if (testunit.CommonData.GetAttribute<int>(((int) power << 12) + ((int) ActorAttributeType.PowerBuff0VisualEffectC & 0xFFF)) == 1) // result = true; //if (testunit.CommonData.GetAttribute<int>(((int) power << 12) + ((int) ActorAttributeType.PowerBuff0VisualEffectD & 0xFFF)) == 1) // result = true; //if (testunit.CommonData.GetAttribute<int>(((int) power << 12) + ((int) ActorAttributeType.PowerBuff0VisualEffectE & 0xFFF)) == 1) // result = true; //if (testunit.CommonData.GetAttribute<int>(((int) power << 12) + ((int) ActorAttributeType.PowerBuff1VisualEffect & 0xFFF)) == 1) // result = true; //if (testunit.CommonData.GetAttribute<int>(((int) power << 12) + ((int) ActorAttributeType.PowerBuff1VisualEffectNone & 0xFFF)) == 1) // result = true; //if (testunit.CommonData.GetAttribute<int>(((int) power << 12) + ((int) ActorAttributeType.PowerBuff1VisualEffectA & 0xFFF)) == 1) // result = true; //if (testunit.CommonData.GetAttribute<int>(((int) power << 12) + ((int) ActorAttributeType.PowerBuff1VisualEffectB & 0xFFF)) == 1) // result = true; //if (testunit.CommonData.GetAttribute<int>(((int) power << 12) + ((int) ActorAttributeType.PowerBuff11VisualEffectC & 0xFFF)) == 1) // result = true; //if (testunit.CommonData.GetAttribute<int>(((int) power << 12) + ((int) ActorAttributeType.PowerBuff1VisualEffectD & 0xFFF)) == 1) // result = true; //if (testunit.CommonData.GetAttribute<int>(((int) power << 12) + ((int) ActorAttributeType.PowerBuff1VisualEffectE & 0xFFF)) == 1) // result = true; //if (testunit.CommonData.GetAttribute<int>(((int) power << 12) + ((int) ActorAttributeType.PowerBuff2VisualEffect & 0xFFF)) == 1) // result = true; //if (testunit.CommonData.GetAttribute<int>(((int) power << 12) + ((int) ActorAttributeType.PowerBuff2VisualEffectNone & 0xFFF)) == 1) // result = true; //if (testunit.CommonData.GetAttribute<int>(((int) power << 12) + ((int) ActorAttributeType.PowerBuff2VisualEffectA & 0xFFF)) == 1) // result = true; //if (testunit.CommonData.GetAttribute<int>(((int) power << 12) + ((int) ActorAttributeType.PowerBuff2VisualEffectB & 0xFFF)) == 1) // result = true; //if (testunit.CommonData.GetAttribute<int>(((int) power << 12) + ((int) ActorAttributeType.PowerBuff2VisualEffectC & 0xFFF)) == 1) // result = true; //if (testunit.CommonData.GetAttribute<int>(((int) power << 12) + ((int) ActorAttributeType.PowerBuff2VisualEffectD & 0xFFF)) == 1) // result = true; //if (testunit.CommonData.GetAttribute<int>(((int) power << 12) + ((int) ActorAttributeType.PowerBuff2VisualEffectE & 0xFFF)) == 1) // result = true; //if (testunit.CommonData.GetAttribute<int>(((int) power << 12) + ((int) ActorAttributeType.PowerBuff3VisualEffect & 0xFFF)) == 1) // result = true; //if (testunit.CommonData.GetAttribute<int>(((int) power << 12) + ((int) ActorAttributeType.PowerBuff3VisualEffectNone & 0xFFF)) == 1) // result = true; //if (testunit.CommonData.GetAttribute<int>(((int) power << 12) + ((int) ActorAttributeType.PowerBuff3VisualEffectA & 0xFFF)) == 1) // result = true; //if (testunit.CommonData.GetAttribute<int>(((int) power << 12) + ((int) ActorAttributeType.PowerBuff3VisualEffectB & 0xFFF)) == 1) // result = true; //if (testunit.CommonData.GetAttribute<int>(((int) power << 12) + ((int) ActorAttributeType.PowerBuff3VisualEffectC & 0xFFF)) == 1) // result = true; //if (testunit.CommonData.GetAttribute<int>(((int) power << 12) + ((int) ActorAttributeType.PowerBuff3VisualEffectD & 0xFFF)) == 1) // result = true; //if (testunit.CommonData.GetAttribute<int>(((int) power << 12) + ((int) ActorAttributeType.PowerBuff3VisualEffectE & 0xFFF)) == 1) // result = true; //if (testunit.CommonData.GetAttribute<int>(((int) power << 12) + ((int) ActorAttributeType.PowerBuff4VisualEffect & 0xFFF)) == 1) // result = true; //if (testunit.CommonData.GetAttribute<int>(((int) power << 12) + ((int) ActorAttributeType.PowerBuff4VisualEffectNone & 0xFFF)) == 1) // result = true; //if (testunit.CommonData.GetAttribute<int>(((int) power << 12) + ((int) ActorAttributeType.PowerBuff4VisualEffectA & 0xFFF)) == 1) // result = true; //if (testunit.CommonData.GetAttribute<int>(((int) power << 12) + ((int) ActorAttributeType.PowerBuff4VisualEffectB & 0xFFF)) == 1) // result = true; //if (testunit.CommonData.GetAttribute<int>(((int) power << 12) + ((int) ActorAttributeType.PowerBuff4VisualEffectC & 0xFFF)) == 1) // result = true; //if (testunit.CommonData.GetAttribute<int>(((int) power << 12) + ((int) ActorAttributeType.PowerBuff4VisualEffectD & 0xFFF)) == 1) // result = true; //if (testunit.CommonData.GetAttribute<int>(((int) power << 12) + ((int) ActorAttributeType.PowerBuff4VisualEffectE & 0xFFF)) == 1) // result = true; //if (testunit.CommonData.GetAttribute<int>(((int) power << 12) + ((int) ActorAttributeType.PowerBuff5VisualEffect & 0xFFF)) == 1) // result = true; //if (testunit.CommonData.GetAttribute<int>(((int) power << 12) + ((int) ActorAttributeType.PowerBuff5VisualEffectNone & 0xFFF)) == 1) // result = true; //if (testunit.CommonData.GetAttribute<int>(((int) power << 12) + ((int) ActorAttributeType.PowerBuff5VisualEffectA & 0xFFF)) == 1) // result = true; //if (testunit.CommonData.GetAttribute<int>(((int) power << 12) + ((int) ActorAttributeType.PowerBuff5VisualEffectB & 0xFFF)) == 1) // result = true; //if (testunit.CommonData.GetAttribute<int>(((int) power << 12) + ((int) ActorAttributeType.PowerBuff5VisualEffectC & 0xFFF)) == 1) // result = true; //if (testunit.CommonData.GetAttribute<int>(((int) power << 12) + ((int) ActorAttributeType.PowerBuff5VisualEffectD & 0xFFF)) == 1) // result = true; //if (testunit.CommonData.GetAttribute<int>(((int) power << 12) + ((int) ActorAttributeType.PowerBuff5VisualEffectE & 0xFFF)) == 1) // result = true; } //} //var atts = Enum.GetValues(typeof(ActorAttributeType)).Cast<ActorAttributeType>().ToList(); //var powers = Enum.GetValues(typeof(SNOPower)).Cast<SNOPower>().ToList(); //foreach (var att in atts) //{ // //if (!att.ToString().ToLower().Contains("buff")) // // continue; // try // { // var attResult = testunit.CommonData.GetAttribute<int>(att); // if (attResult > 0) // { // if (existingAtts.Contains(att)) // { // Logger.Log("Unit {0} has lost {1} ({2})", testunit.Name, att.ToString(), attResult); // existingAtts.Remove(att); // } // } // else // { // if (!existingAtts.Contains(att)) // { // Logger.Log("Unit {0} has gained {1} ({2})", testunit.Name, att.ToString(), attResult); // existingAtts.Add(att); // } // } // foreach (var power in powers) // { // try // { // var attPowerResult = testunit.CommonData.GetAttribute<int>(((int) power << 12) + ((int) att & 0xFFF)); // if (attPowerResult > 0) // { // if (existingAtts.Contains(att)) // { // Logger.Log("Unit {0} has lost {1} ({2}) Power={3}", testunit.Name, att.ToString(), attPowerResult, power); // existingAtts.Remove(att); // } // } // else // { // if (!existingAtts.Contains(att)) // { // Logger.Log("Unit {0} has gained {1} ({2}) Power={3}", testunit.Name, att.ToString(), attPowerResult, power); // existingAtts.Add(att); // } // } // } // catch (Exception) // { // } // } //foreach (var power in powers) //{ // var attIntPowerResult = testunit.CommonData.GetAttribute<int>(((int)power << 12) + ((int)att & 0xFFF)); //} //var attIntResult = testunit.CommonData.GetAttribute<int>(((int) debuffSNO << 12) + ((int) att & 0xFFF)); //if(attIntResult > 0) // Logger.Log("Unit {0} has {1}", testunit.Name, att.ToString()); // } // catch (Exception) // { // } //} } return false; }); //CacheManager.Start(); } catch (Exception ex) { Logger.LogError("Error Starting LazyCache: " + ex); } }