private async Task <Dictionary <AssetId, HashSet <AssetId> > > ComputeReferences() { var dependencyManager = Session.DependencyManager; var references = new Dictionary <AssetId, HashSet <AssetId> >(); var ids = (await Manager.ComputeReferencedAssets()).ToList(); foreach (var id in ids) { var referencedAsset = Session.GetAssetById(id); if (referencedAsset == null) { continue; } var dependencies = dependencyManager.ComputeDependencies(referencedAsset.AssetItem.Id, AssetDependencySearchOptions.Out | AssetDependencySearchOptions.Recursive, ContentLinkType.Reference); if (dependencies != null) { var entry = references.GetOrCreateValue(referencedAsset.Id); entry.Add(referencedAsset.Id); foreach (var dependency in dependencies.LinksOut) { entry = references.GetOrCreateValue(dependency.Item.Id); entry.Add(referencedAsset.Id); } } } return(references); }
private void AddMonthData(RoomRecord data, int month) { var monthData = _monthRoomRecord.GetOrCreateValue(month); if (!monthData.Contains(data)) { monthData.Add(data); } }
public override CmlScriptValue GetIndirectValue(string id) { return(indirect_values.GetOrCreateValue(id, delegate() { return (context.GetEngine().GetGlobalLibrary() .CreateScriptValue(id, host_argument) ?? this_argument.GetIndirectValue(id)); })); }
public VariableInstance CompileVariableInstance(CmlContext context) { CmlScriptRequest request = InitializeRequest(context); ILValue il_value = GetExpression().GetValue().GetILValue(); Type expression_type = il_value.GetValueType(); CmlScriptValue_Argument value_argument = request.AddPrimaryArgument( new CmlScriptValue_Argument_Single_Placeholder(expression_type) ); CmlScriptDefinition_Link definition = definitions.GetOrCreateValue(request.GetSignature(), delegate() { return(new CmlScriptDefinition_Link( expression_type, "CmlLink[" + stored_text + "]", il_value.CanStore().IfTrue(() => GetType().CreateDynamicMethodDelegate <Process <object, object, object> >( "CmlLink_Store[" + stored_text + "]", new ILAssign(il_value, value_argument.GetILValue()) ) ), il_value.CanLoad().IfTrue(() => GetType().CreateDynamicMethodDelegate <Operation <object, object, object, object> >( "CmlLink_Load[" + stored_text + "]", new ILReturn(il_value) ) ) )); }); return(definition.CreateVariableInstance(request)); }
public CmlScriptValue GetParentOfTypeValue(Type type) { return(parent_of_type_arguments.GetOrCreateValue(type, delegate() { return GetTargetInfo().GetParentOfType(type) .IfNotNull(p => AddSecondaryArgument(new CmlScriptValue_Argument_Single_Constant(p))); })); }
private static void RegisterElementInWindow([NotNull] FrameworkElement element) { var window = Window.GetWindow(element); if (window == null) { return; } // First unregister element from previous window, if any UnregisterElementFromWindow(element); ElementToWindowLookup.Add(element, window); var elements = WindowToElementsLookup.GetOrCreateValue(window, _ => { // DragEnter is needed to ensure the data type is reset immediately when a drag operation starts, otherwise it would reuse the previous one for a while. window.GiveFeedback += OnGiveFeedback; window.PreviewDragEnter += OnDragOver; window.PreviewDragOver += OnDragOver; window.Closed += OnWindowClosed; return(new HashSet <FrameworkElement>()); }); elements.Add(element); }
internal void Initialize() { var commandGroups = new Dictionary <string, List <ModelNodeCommandWrapper> >(); foreach (var node in combinedNodes) { 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(string.Format("Inconsistent combine mode among command {0}", commandGroup.Key)); } var shouldCombine = mode != CombineMode.DoNotCombine && (mode == CombineMode.AlwaysCombine || commandGroup.Value.Count == combinedNodes.Count); if (shouldCombine) { var command = new CombinedNodeCommandWrapper(ServiceProvider, commandGroup.Key, Path, Owner.Identifier, commandGroup.Value); AddCommand(command); } } if (!HasList || HasDictionary) { var commonChildren = GetCommonChildren(); GenerateChildren(commonChildren); } else { var allChildren = GetAllChildrenByValue(); if (allChildren != null) { // TODO: Disable list children for now - they need to be improved a lot (resulting combinaison is very random, especially for list of ints //GenerateListChildren(allChildren); } } 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(); }
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(); }
public CmlScriptValue InsertRepresentationValue(string id) { return(insert_representation_values.GetOrCreateValue(id, delegate() { return context.GetUnitSpace() .IfNotNull(s => s.GetRepresentation(id)) .IfNotNull(r => AddSecondaryArgument(new CmlScriptValue_Argument_Single_Constant(r))); })); }
public EditProperty GetElement(int index) { EnsureContents(false); return(elements_by_index.GetOrCreateValue(index, i => new EditPropertyArrayElement(GetTarget(), GetVariable(), i) ) .GetProperty()); }
public void CollectionExtensions_IDictionary_GetOrCreateValue_AddsValueIfNotContainedInDictionary() { // Arrange IDictionary <string, string> dictionary = new Dictionary <string, string>(); // Act var result = dictionary.GetOrCreateValue("blah", () => "yo"); // Assert Assert.AreEqual("yo", result); }
public EditorGUIView GetEditorGUIView(T item, SerializedObject serialized_object) { if (gui_views.Count >= MAXIMUM_NUMBER_INSTANCES) { gui_views.Clear(); } return(gui_views.GetOrCreateValue( serialized_object, o => new EditorGUIView(CreateRootEditorGUIElement(new EditTarget(o)).InitilizeAndGet()) )); }
public EditorSceneElement GetEditorSceneElement(T item, SerializedObject serialized_object) { if (scene_elements.Count >= MAXIMUM_NUMBER_INSTANCES) { scene_elements.Clear(); } return(scene_elements.GetOrCreateValue( serialized_object, o => CreateRootEditorSceneElement(new EditTarget(o)).InitilizeAndGet() )); }
private void Update() { Camera camera = GetComponent <Camera>(); foreach (ScreenTouch screen_touch in ScreenInput.GetScreenTouchs()) { world_presses.GetOrCreateValue(screen_touch.id, () => new WorldPress(this)) .UpdatePosition(camera.ScreenToWorldPlanarPoint(screen_touch.position), update_id); } world_presses.Reduce(p => p.Value.Update(update_id)); update_id++; }
public void should_add_null_as_value() { var target = new Dictionary <int, string?> { { 1, "one" }, { 2, "two" } }; // --act var actual = target.GetOrCreateValue(3, () => null); // ----assert actual.Should().BeNull(); target[3].Should().BeNull(); }
private void Initialize(bool isUpdating) { var commandGroups = new Dictionary <string, List <ModelNodeCommandWrapper> >(); foreach (var node in combinedNodes) { 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(string.Format("Inconsistent combine mode among command {0}", commandGroup.Key)); } var shouldCombine = mode != CombineMode.DoNotCombine && (mode == CombineMode.AlwaysCombine || commandGroup.Value.Count == combinedNodes.Count); if (shouldCombine) { var command = new CombinedNodeCommandWrapper(ServiceProvider, commandGroup.Key, Path, Owner.Identifier, commandGroup.Value); AddCommand(command); } } if (!HasList || HasDictionary) { var commonChildren = GetCommonChildren(); GenerateChildren(commonChildren, isUpdating); } else { var allChildren = GetAllChildrenByValue(); if (allChildren != null) { GenerateListChildren(allChildren, isUpdating); } } if (Owner.ObservableViewModelService != null) { var data = Owner.ObservableViewModelService.RequestAssociatedData(this, isUpdating); SetValue(ref associatedData, data, "AssociatedData"); } CheckDynamicMemberConsistency(); }
private void CreateTerrain(TextureGenerator textureGenerator) { // for now just render a cube so we have a point of reference var height = 45; var heightmap = CalculateRandomHeightmap(_width + 1, _height + 1, height); var terrain = new TextureMeshDescriptionBuilder(); var vertices = new List <VertexPositionColorTexture>(); for (int y = 0; y < _height; y++) { for (int x = 0; x < _width; x++) { // add a quad per cell var xCoord = x * CellSize; var zCoord = y * CellSize; var bbox = new BoundingBox(new Vector3(xCoord, 0, zCoord), new Vector3(xCoord + CellSize, 0, zCoord + CellSize)); vertices.AddRange(new[] { new VertexPositionColorTexture(new Vector3(bbox.Max.X, heightmap[x + 1, y], bbox.Min.Z), Color.White, new Vector2(heightmap[x + 1, y] / (float)height)), new VertexPositionColorTexture(new Vector3(bbox.Min.X, heightmap[x, y + 1], bbox.Max.Z), Color.White, new Vector2(heightmap[x, y + 1] / (float)height)), new VertexPositionColorTexture(new Vector3(bbox.Min.X, heightmap[x, y], bbox.Min.Z), Color.White, new Vector2(heightmap[x, y] / (float)height)), new VertexPositionColorTexture(new Vector3(bbox.Min.X, heightmap[x, y + 1], bbox.Max.Z), Color.White, new Vector2(heightmap[x, y + 1] / (float)height)), new VertexPositionColorTexture(new Vector3(bbox.Max.X, heightmap[x + 1, y], bbox.Min.Z), Color.White, new Vector2(heightmap[x + 1, y] / (float)height)), new VertexPositionColorTexture(new Vector3(bbox.Max.X, heightmap[x + 1, y + 1], bbox.Max.Z), Color.White, new Vector2(heightmap[x + 1, y + 1] / (float)height)) }); } } terrain.AddVertices(vertices); _terrain = _renderContext.MeshCreator.CreateMesh(terrain); var terrainTex = _textureCache.GetOrCreateValue("terrain", key => textureGenerator.CreateTerrainTexture()); _terrainBrush = new TextureBrush(terrainTex); }
public void SubscribeToChangeOf <TProperty>( Expression <Func <TProperty> > propertyGetterExpression, EventHandler handler) { if (handler is null) { throw new ArgumentNullException(nameof(handler)); } var propertyName = GetPropertyName(propertyGetterExpression); var handlers = _propertyChangedSubscriptionsDictionary.GetOrCreateValue(propertyName); handlers.Add(handler); }
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))); }
private void RegisterElement() { if (AssociatedObject != null) { List <FrameworkElement> list = ElementGroups.GetOrCreateValue(GroupName); list.Add(AssociatedObject); if (SynchronizeWidth) { WidthChanged(AssociatedObject, EventArgs.Empty); } if (SynchronizeHeight) { HeightChanged(AssociatedObject, EventArgs.Empty); } } }
private void Grow(GraphNodeNavigatorVisit <T> parent, T node) { if (closed_set.Contains(node) == false) { double total_distance = parent.GetTentativeTotalDistance(node); GraphNodeNavigatorVisit <T> visit = open_set.GetOrCreateValue(node, n => GraphNodeNavigatorVisit <T> .CreateNormal(n, goal.CalculateHeuristicCostEstimate(n)) ); if (visit.Update(parent, total_distance)) { AddVisit(visit); } } }
public FunctionInstance CompileFunctionInstance(CmlContext context) { CmlScriptRequest request = InitializeRequest(context); CmlScriptDefinition_Function definition = definitions.GetOrCreateValue(request.GetSignature(), delegate() { string name = "CmlFunction[" + GetFunctionParameters() + stored_text + "]"; return(new CmlScriptDefinition_Function( name, GetFunctionParameters().IfNotNull(p => p.GetParameterTypes()), GetType().CreateDynamicMethodDelegate <Process <object, object, object> >( name, GetLambda().GetILStatement() ) )); }); return(definition.CreateFunctionInstance(request)); }
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); } } }
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); } } }
static public InputDevice_Keyboard GetKeyboard(int device_index) { return(KEYBOARDS.GetOrCreateValue(device_index, i => new InputDevice_Keyboard(i))); }
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); } }
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 override CmlScriptValue GetIndirectValue(string id) { return(indirect_values.GetOrCreateValue(id, delegate() { return global.GetIndirectValue(id, host); })); }
private TextStyle GetVsHighlighterAttributes([NotNull] string highlighterAttributeId) { lock (_vsAttributesByName) return(_vsAttributesByName.GetOrCreateValue(highlighterAttributeId, GetVsHighlighterAttributesNoCache)); }
public Process <object, TyonContext> FetchPrefabPusher(string tyon_data) { return(prefab_pushers.GetOrCreateValue(tyon_data, () => this.CompilePushToSystemObject(tyon_data, TyonHydrationMode.Permissive))); }
public TyonObject FetchPrefabTyonObject(string tyon_data) { return(prefab_tyon_objects.GetOrCreateValue(tyon_data, () => TyonObject.DOMify(tyon_data))); }
static public InputDevice_Joystick GetJoystick(int device_index) { return(JOYSTICKS.GetOrCreateValue(device_index, i => new InputDevice_Joystick(i))); }
public void AddPayRecord(PayRecord payRecord) { _dayPayData.GetOrCreateValue(payRecord.PayTime.Day).Add(payRecord); _payDatas.Add(payRecord); }
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) { } } } }
public Subsystem GetSubsystemInstance(Type type) { return(subsystems.GetOrCreateValue(type, t => SubsystemExtensions_Resource.LoadSubsystemResource(t))); }