Exemplo n.º 1
0
        void RecreateVisibilityZones()
        {
            RemoveVisibilityZones();

              if (EngineTerrain == null)
            return;

              int iCount = _terrainConfig.OverallSectorCount;
              int iCountX = _terrainConfig._sectorCount.Width;
              int iCountY = _terrainConfig._sectorCount.Height;
              int iZoneCount = iCountX * iCountY;

              _visibilityZones = new TerrainVisibilityZoneShape[iZoneCount];
            //      bool bCallAddToScene = this.ParentLayer != null;
              int i = 0;
              int x, y;
              for (y = 0; y < iCountY; y++)
            for (x = 0; x < iCountX; x++, i++)
            {
              TerrainVisibilityZoneShape zone = new TerrainVisibilityZoneShape(this, x,y);
              _visibilityZones[i] = zone;

              // re-use ID
              if (_cachedSectorIDs != null && i < _cachedSectorIDs.Length)
            zone.LocalID = _cachedSectorIDs[i];

              zone.DebugColor = Color.DarkGreen;
              zone.ShapeVirtualCounter++;
              zone.VisibilityOwnerMeshShape = this;
              zone.ParentLayer = this.ParentLayer;
              zone.OnAddedToScene();

              if (_savedZoneBoxes!=null && _savedZoneBoxes.Length==iZoneCount)
              {
            zone.SetSectorBoundingBox(_savedZoneBoxes[i]);
              }
              else
            zone.UpdateSectorBoundingBox();
            }

              // connect zones
              for (y = 0; y < iCountY; y++)
            for (x = 0; x < iCountX; x++, i++)
            {
              TerrainVisibilityZoneShape zone = GetZone(x, y);
              // GetZone handles zones out of range and AddNeighborZone only adds if !=null
              zone.AddNeighborZone(GetZone(x - 1, y));
              zone.AddNeighborZone(GetZone(x + 1, y));
              zone.AddNeighborZone(GetZone(x, y - 1));
              zone.AddNeighborZone(GetZone(x, y + 1));
            }
              EditorManager.VisibilityBuilder.Dirty = true;
        }
 public SetSectorPropertyAction(TerrainVisibilityZoneShape sector, string propertyName, object newValue)
     : base(sector, propertyName, newValue)
 {
     _sector = sector;
 }
 public SetSectorPropertyAction(TerrainVisibilityZoneShape sector, string propertyName, object newValue)
     : base(sector, propertyName, newValue)
 {
     _sector = sector;
 }