public void Update(IQuadTreeMonitor <T> monitor, Bound previousRegion, Bound currentRegion) { // update the stored monitor for (int i = 0; i < _monitors.Length; ++i) { if (ReferenceEquals(_monitors[i].Monitor, monitor)) { _monitors[i].Region = currentRegion; break; } } // update the monitor for (int i = 0; i < _items.Length; ++i) { StoredItem item = _items[i]; bool containedPrevious = previousRegion.Contains(item.Position); bool containedCurrent = currentRegion.Contains(item.Position); // the monitor was previously interested but no longer is if (containedPrevious && containedCurrent == false) { monitor.OnExit(item.Item); } // the monitor was not previous interested but now is else if (containedPrevious == false && containedCurrent) { monitor.OnEnter(item.Item); } } }
public bool Add(T item) { if (Bound.Contains(item.Position)) { if (m_childs.Length == 0) { if (Depth < MaxDepth) { Subdivide(); } else { item.Node = this; ArrayEx.Add(ref m_items, ref m_items_size, item); return(true); } } for (int index = 0; index < m_childs.Length; index++) { if (m_childs[index].Add(item)) { return(true); } } } return(Parent?.Add(item) ?? false); }
/// <summary> /// 만약 Gfx의 rotate값이 0이 아닐 경우, RContains 함수가 정확합니다. 다만, 보시다시피, 비싼 계산을 요구합니다. /// </summary> /// <param name="p"></param> /// <returns></returns> public bool RContains(Point p) { Vector2 v = Method2D.PtV(p); Point RO = new Point(Pos.X + (ROrigin.X * Bound.Width) / Texture.Width, Pos.Y + (ROrigin.Y * Bound.Height) / Texture.Height); //실제 회전중심의 위치를 잡습니다. v = Vector2.Transform(v, Matrix2D.Rotate(RO, -Rotate)); return(Bound.Contains(Method2D.VtP(v))); }
public bool RContains(Point p)//만약 Gfx의 rotate값이 0이 아닐 경우, RContains 함수가 정확합니다. 다만, 보시다시피, 비싼 계산을 요구합니다. { Vector2 v = Method2D.PtV(p); Vector3 RO = new Vector3(Pos.X + (ROrigin.X * Bound.Width) / Texture.Width, Pos.Y + (ROrigin.Y * Bound.Height) / Texture.Height, 0); v = Vector2.Transform(v, Matrix.CreateTranslation(-RO) * Matrix.CreateRotationZ(-Rotate) * Matrix.CreateTranslation(RO)); return(Bound.Contains(Method2D.VtP(v))); }
public bool HandleMouseClick(Point coordinate) { if (Bound.Contains(coordinate)) { RealiseButton(); return(true); } return(false); }
public TileAttributes GetTileAttributes(Point point) { if (!Bound.Contains(point)) { throw new ArgumentException( string.Format("No tile exists at position {0}", point)); } return(tiles[point.x, point.y].Attributes); }
/// <summary> /// Adds all of the items inside of this node that are contained within the given region to /// the given collection. /// </summary> /// <param name="region">The area to collect objects from.</param> /// <param name="storage">Where to store the collected objects.</param> public void CollectInto(Bound region, ICollection <T> storage) { for (int i = 0; i < _items.Length; ++i) { StoredItem item = _items[i]; if (region.Contains(item.Position)) { storage.Add(item.Item); } } }
public override bool IsVisible(PointF point) { bool result = base.IsVisible(point); if (!result && Bound.Contains(point)) { Pen p = GetOutlinePen(); return(Path.IsOutlineVisible(point, p)); } return(result); }
public bool Update(T item) { if (ArrayEx.Contains(m_items, m_items_size, item)) { if (Bound.Contains(item.Position)) { return(true); } return(ArrayEx.Remove(m_items, ref m_items_size, item) && (Parent?.Add(item) ?? false)); } return(Add(item)); }
public override void Receive(Renderer render) { if (!Bound.Contains(new Vector2(render.bounds.center.x, render.bounds.center.z))) { return; } if (!Contains(render)) { m_lstGameObject.Add(render.gameObject); Quadtree.nReceivedCount++; } }
public void Add(IQuadTreeMonitor <T> monitor, Bound monitoredRegion) { _monitors.Add(new StoredMonitor(monitor, monitoredRegion)); // check to see if the monitor is interested in any of our stored items for (int i = 0; i < _items.Length; ++i) { StoredItem item = _items[i]; if (monitoredRegion.Contains(item.Position)) { monitor.OnEnter(item.Item); } } }
public void AddMesh(MTMeshHeader meshh) { if (mSubNode == null && Bound.Contains(meshh.Center)) { MeshID = meshh.MeshID; } else if (mSubNode != null) { for (int i = 0; i < 4; ++i) { mSubNode[i].AddMesh(meshh); } } }
public void AddMesh(MTMeshHeader meshh) { if (m_SubNodes == null && Bound.Contains(meshh.Center + Offset)) { MeshID = meshh.MeshID; } else if (m_SubNodes != null) { for (int i = 0; i < 4; ++i) { m_SubNodes[i].AddMesh(meshh); } } }
public override void Receive(IQtUserData userData) { if (!UQtAlgo.Intersects(Bound, userData)) { return; } if (Bound.Contains(new Vector2(userData.GetCenter().x, userData.GetCenter().z))) { _ownedObjects.Add(userData); } else { _affectedObjects.Add(userData); } }
public bool Contains(T item) { if (Bound.Contains(item.Position)) { if (m_childs.Length == 0) { return(ArrayEx.Contains(m_items, m_items_size, item)); } for (int index = 0; index < m_childs.Length; index++) { if (m_childs[index].Contains(item)) { return(true); } } } return(Parent?.Contains(item) ?? false); }
public override bool IsVisible(PointF point) { if (Bound.Contains(point)) { Pen p = Pen.Content; //线宽过小时不易选中,设置最小宽度为GraphicsTool.WidenWidth float minWdith = GraphicsTool.WidenWidth; float width = p.Width; if (p.Width < minWdith) { p.Width = minWdith; } bool b2 = Path.IsVisible(point); p.Width = width; return(b2); } return(false); }
public bool Remove(T item) { if (Bound.Contains(item.Position)) { if (m_childs.Length == 0 && ArrayEx.Remove(m_items, ref m_items_size, item)) { item.Node = null; return(true); } for (int index = 0; index < m_childs.Length; index++) { if (m_childs[index].Remove(item)) { return(true); } } } return(Parent?.Remove(item) ?? false); }
public void Remove(IQuadTreeMonitor <T> monitor, Bound monitoredRegion) { // remove the stored monitor for (int i = 0; i < _monitors.Length; ++i) { if (ReferenceEquals(_monitors[i].Monitor, monitor)) { _monitors.Remove(i); break; } } // remove all stored items from the monitor for (int i = 0; i < _items.Length; ++i) { StoredItem item = _items[i]; if (monitoredRegion.Contains(item.Position)) { monitor.OnExit(item.Item); } } }
// Damage the entity, Invoke by ColonyRunner.cs. see it ! // public virtual void OnDamaged(GameObject caster, float damge) // { // BaseData.m_Durability -= damge; // // if (BaseData.m_Durability < -0.001f) // BaseData.m_Durability = -0.001f; // // // for (int i = 0; i < m_Soldiers.Count; i++) // { // m_Soldiers[i].ProtectedEntityDamaged(this, caster, damge); // } // // } #region HELP_FUNC // private void SyncDura() // { // // Sync // CSMgCreator mgCreator = m_Creator as CSMgCreator; // if (mgCreator != null) // { // if (mgCreator.SimulatorMgr.ContainSimulator(ID)) // { // CSSimulator csf = mgCreator.SimulatorMgr.GetSimulator(ID); // csf.SyncHP(DuraPercent); // } // } // } public bool ContainPoint(Vector3 pos) { return(Bound.Contains(pos)); }
public bool Contains(Point p) { return(Bound.Contains(p)); }
public override bool IsHovering(Vector2 pos) { return(Bound.Contains(pos)); }
public bool Contains(REMOPoint p) { return(Bound.Contains(p.ToPoint())); }