예제 #1
0
        /// <see cref="ITerrainObjectType.CheckTerrainObjectIntersections"/>
        public RCSet <RCIntVector> CheckTerrainObjectIntersections(IMapAccess map, RCIntVector position)
        {
            if (map == null)
            {
                throw new ArgumentNullException("map");
            }
            if (position == RCIntVector.Undefined)
            {
                throw new ArgumentNullException("position");
            }

            RCSet <RCIntVector> retList = new RCSet <RCIntVector>();

            for (int quadX = 0; quadX < this.quadraticSize.X; quadX++)
            {
                for (int quadY = 0; quadY < this.quadraticSize.Y; quadY++)
                {
                    RCIntVector relQuadCoords = new RCIntVector(quadX, quadY);
                    RCIntVector absQuadCoords = position + relQuadCoords;
                    if (absQuadCoords.X >= 0 && absQuadCoords.X < map.Size.X &&
                        absQuadCoords.Y >= 0 && absQuadCoords.Y < map.Size.Y)
                    {
                        /// Check intersection with other terrain object at the current quadratic tile.
                        ITerrainObject objToCheck = map.GetQuadTile(absQuadCoords).TerrainObject;
                        if (objToCheck != null && !this.IsExcluded(relQuadCoords) && objToCheck.GetQuadTile(absQuadCoords - objToCheck.MapCoords) != null)
                        {
                            retList.Add(relQuadCoords);
                        }
                    }
                }
            }
            return(retList);
        }
예제 #2
0
 /// <summary>
 /// Detaches the given terrain object from the map structure.
 /// </summary>
 /// <param name="terrainObj">The terrain object to be detached.</param>
 /// <exception cref="InvalidOperationException">If the given terrain object was not attached to this map.</exception>
 public void DetachTerrainObject(ITerrainObject terrainObj)
 {
     if (!this.terrainObjects.Remove(terrainObj))
     {
         throw new InvalidOperationException("The given terrain object was not attached to this map!");
     }
     for (int x = 0; x < terrainObj.Type.QuadraticSize.X; x++)
     {
         for (int y = 0; y < terrainObj.Type.QuadraticSize.Y; y++)
         {
             IQuadTile quadTile = terrainObj.GetQuadTile(new RCIntVector(x, y));
             if (quadTile != null)
             {
                 QuadTile quadTileObj = this.mapStructure.GetQuadTile(quadTile.MapCoords);
                 quadTileObj.DetachTerrainObject();
             }
         }
     }
 }
예제 #3
0
 /// <summary>
 /// Adds the given terrain object and all of its cutting quadratic tiles into the update lists.
 /// </summary>
 /// <param name="terrainObj">The terrain object to add.</param>
 /// <param name="terrainObjUpdateList">The terrain object update list.</param>
 /// <param name="quadTileUpdateList">The quadratic update list.</param>
 private void AddTerrainObjectToUpdate(ITerrainObject terrainObj, RCSet <ITerrainObject> terrainObjUpdateList, RCSet <IQuadTile> quadTileUpdateList)
 {
     if (terrainObj != null && terrainObjUpdateList.Add(terrainObj))
     {
         for (int col = 0; col < terrainObj.Type.QuadraticSize.X; col++)
         {
             for (int row = 0; row < terrainObj.Type.QuadraticSize.Y; row++)
             {
                 IQuadTile quadTileToUpdate = terrainObj.GetQuadTile(new RCIntVector(col, row));
                 if (quadTileToUpdate != null &&
                     (this.fowCacheMatrix.GetFullFowFlagsAtQuadTile(quadTileToUpdate.MapCoords) != FOWTileFlagsEnum.None ||
                      this.fowCacheMatrix.GetPartialFowFlagsAtQuadTile(quadTileToUpdate.MapCoords) != FOWTileFlagsEnum.None))
                 {
                     quadTileUpdateList.Add(quadTileToUpdate);
                 }
             }
         }
     }
 }