public bool AllowReference(Reference reference, XYZ position) { if (LinkInstance == null) { return(false); } if (ClassFilters == null) { Document linkedDoc = LinkInstance.GetLinkDocument(); Element element = linkedDoc.GetElement(reference.LinkedElementId); return(TargetTypes.Contains(element.GetType())); } else { foreach (var ClassFilter in ClassFilters) { if (ClassFilter.AllowReference(reference, position)) { return(true); } } return(false); } }
private void BackColorSupport_AddingChildControl(object sender, ChildControlListAddingEventArgs e) { try { if (TargetTypes == null) { // 如果控件的类型存在于过滤表中,则忽略 if (FiltrateTypes.Contains(e.Control.GetType())) { e.IsCancel = true; return; } else { // 给控件赋予事件 AddEvents(e.Control); } } else { if (TargetTypes.Contains(e.Control.GetType())) { // 给控件赋予事件 AddEvents(e.Control); } else { e.IsCancel = true; return; } } } catch { } }
public bool AllowElement(Element element) { if (IsLinkInstance) { LinkInstance = element as RevitLinkInstance; return(LinkInstance != null); } else { if (ClassFilters == null) { return(TargetTypes.Contains(element.GetType())); } else { foreach (var ClassFilter in ClassFilters) { if (ClassFilter.AllowElement(element)) { return(true); } } return(false); } } }
private void ValidateItemTargetType() { if (!TargetTypes.Contains(InnerItem.TargetType)) { InnerItem.SetError("TargetType", "TargetType must be selected".Localize(), true); } else { InnerItem.ClearError("TargetType"); } }
public override GridOccupant[] FindTargets(GridOccupant wielder, Vector2Int direction, Grid.Grid grid) { var path = CalculatePath(wielder, direction, grid); if (!path.IsLastNodeTarget) { return(null); } var targets = path.Travelled.Last().Occupants.Where(it => TargetTypes.Contains(it.Type)); return(targets as GridOccupant[] ?? targets.ToArray()); }
public override bool CanTarget(GridOccupant target, GridOccupant wielder, Grid.Grid grid) { var direction = target.Position - wielder.Position; if (!direction.IsCardinal() || direction.CardinalMagnitude() > 1) { return(false); } var node = new Grid.Grid.Node(); if (grid.TryGetNodeAt(wielder.Position, ref node)) { return(node.Occupants.Any(it => TargetTypes.Contains(it.Type))); } return(false); }
// public override Grid.Grid.Node[] FindTargets(Grid.Grid.Node wielder, Grid.Grid grid) // { // var neighbours = grid.GetNeighbours(wielder); // // // todo(chris) consider optimising as this will be used by every mellee enemy on the grid // return neighbours.Where(node => node.Occupants.Any(it => it.Tags.Intersect(TargetTypes).Any())).ToArray(); // } // todo(chris) shouldnt this only find targets in direction?? public override GridOccupant[] FindTargets(GridOccupant wielder, Vector2Int direction, Grid.Grid grid) { var node = new Grid.Grid.Node(); if (grid.TryGetNodeAt(wielder.Position, ref node)) { var neighbours = grid.GetNeighbours(node); var targets = new List <GridOccupant>(); foreach (var neighbour in neighbours) { var validOccupants = neighbour.Occupants.Where(it => TargetTypes.Contains(it.Type)); targets.AddRange(validOccupants); } return(targets.ToArray()); } return(null); }
public PathDetails CalculatePath(GridOccupant wielder, Vector2Int direction, Grid.Grid grid) { PathDetails path = new PathDetails { Travelled = new List <Grid.Grid.Node>(), IsLastNodeTarget = false }; var normalised = direction.CardinalNormalise(); var magnitude = projectile.Range; var node = new Grid.Grid.Node(); for (int i = 1; i <= magnitude; i++) { if (grid.TryGetNodeAt(wielder.Position + i * normalised, ref node)) { path.Travelled.Add(node); // if we have hit something that has a type then weve eiher hit something we cant move though // or weve hit our target if (node.Occupants.Any(it => it.Type != null)) { path.IsLastNodeTarget = node.Occupants.Any(it => it.Type != null && TargetTypes.Contains(it.Type)); break; } // todo(chris) add back in when we implement penetration // else // { // var targetOccupants = node.Occupants.Where(it => TargetTypes.Contains(it.Type)); // // var gridOccupants = targetOccupants as GridOccupant[] ?? targetOccupants.ToArray(); // // // occupant isnt a target so cant go through // if (gridOccupants.Length == 0) // { // break; // } // // path.Hits.Add(node); // // var penetrating = gridOccupants.Where(occupant => projectile.PenitrationTags.Contains(occupant.Type)); // // var penetratingArray = penetrating as GridOccupant[] ?? penetrating.ToArray(); // // // cant penetrate target to this will be as far as we go // if (penetratingArray.Length == 0) // { // break; // } // // // if we cant penetrate all then we are done // if (remainingDepth <= penetratingArray.Length) // { // break; // } // // // continue; // } } else { break; } } if (path.IsLastNodeTarget && path.Travelled.Count == 0) { path = new PathDetails { Travelled = new List <Grid.Grid.Node>(), IsLastNodeTarget = false }; } else { path.Travelled.RemoveAt(0); } return(path); }