// World Zone created on a chunk, and expended after public WorldZone(WorldChunk chunk, WorldChunkComputed.WorldChunkZone zone) { this.randomInt = (int)Random.Range(1f, 100f); this.randomColor = new Color(Random.Range(0f, 1f), Random.Range(0f, 1f), Random.Range(0f, 1f)); this.type = zone.type; this.isMainGround = false; this.isDeleted = false; if (zone.IsOnChunkBorder()) { this.state = WorldZoneStates.Created; this.requireZoneState = (chunk.requireState >= ChunkStates.Merged) ? WorldZoneStates.Merged : WorldZoneStates.Created; /* * for (int e = 0; e < Coord.directions.Length; e++) { * Direction direction = Coord.directions [e]; * Coord directionCoord = chunk.coord.GetDirection (direction); * if (zone.isDirectionChunkBorder [direction]) { * this.missingChunks.Add (directionCoord); * } * }*/ } else { this.state = WorldZoneStates.Merged; this.requireZoneState = WorldZoneStates.Merged; } // Have chunk border this.chunks.Add(chunk.coord); // ref to this zone this.chunkZones[chunk.coord] = new List <WorldChunkComputed.WorldChunkZone>(); this.chunkZones [chunk.coord].Add(zone); // Add a ref to it }
// This is called for already existing zone but not completely merge public void UpdateState(WorldZoneStates state) { if (this.requireZoneState < WorldZoneStates.Merged) { this.requireZoneState = WorldZoneStates.Merged; /*for (int missingChunk_idx = 0; missingChunk_idx < this.missingChunks.Count; missingChunk_idx++) { * MapEndless.instance.MergeOrCreateZones(this.missingChunks[missingChunk_idx]); * }*/ } }
// Main Ground public WorldZone(WorldZoneTypes type) { this.type = type; this.isMainGround = true; // Main Ground ! this.isDeleted = false; this.state = WorldZoneStates.Merged; this.requireZoneState = WorldZoneStates.Merged; this.randomInt = 0; this.randomColor = new Color(1f, 245f / 255f, 0f); // yellow }
// Result of all region zone-merging public void OnMergeCompleted() { this.state = WorldZoneStates.Merged; this.requireZoneState = WorldZoneStates.Merged; if (this.isMainGround) { return; // stop } for (int chunk_idx = 0; chunk_idx < this.chunks.Count; chunk_idx++) { WorldChunk chunk = MapEndless.instance.worldChunks [this.chunks [chunk_idx]]; MapDisplay.instance.UpdateChunkDisplay(chunk); // Reload display for all chunk on this zone chunk.TestMerged(MapEngine.instance.worldChunkSetting); } }