Changeset 299 for binary-improvements/MapRendering
- Timestamp:
- Dec 14, 2016, 7:47:05 PM (8 years ago)
- Location:
- binary-improvements/MapRendering
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
binary-improvements/MapRendering/API.cs
r291 r299 16 16 } 17 17 18 public override void GameShutdown () { 19 AllocsFixes.MapRendering.MapRendering.Shutdown (); 20 } 21 18 22 public override void CalcChunkColorsDone (Chunk _chunk) { 19 23 AllocsFixes.MapRendering.MapRendering.RenderSingleChunk (_chunk); -
binary-improvements/MapRendering/MapRendering/MapRendering.cs
r269 r299 25 25 private MapRenderBlockBuffer[] zoomLevelBuffers; 26 26 private Dictionary<Vector2i, Color32[]> dirtyChunks = new Dictionary<Vector2i, Color32[]> (); 27 private System.Timers.Timer chunkSaveTimer = new System.Timers.Timer (500);28 27 private bool renderingFullMap = false; 29 28 public static bool renderingEnabled = true; 30 29 private MicroStopwatch msw = new MicroStopwatch (); 31 30 private AllocsFixes.FileCache.MapTileCache cache = new AllocsFixes.FileCache.MapTileCache (Constants.MAP_BLOCK_SIZE); 31 private float renderTimeout = float.MaxValue; 32 private Coroutine renderCoroutineRef; 32 33 33 34 public static AllocsFixes.FileCache.MapTileCache GetTileCache() { … … 51 52 } 52 53 53 chunkSaveTimer.AutoReset = false; 54 chunkSaveTimer.Elapsed += new System.Timers.ElapsedEventHandler (TimedRendering); 54 renderCoroutineRef = ThreadManager.StartCoroutine (renderCoroutine ()); 55 } 56 57 public static void Shutdown () 58 { 59 if (Instance.renderCoroutineRef != null) { 60 ThreadManager.StopCoroutine (Instance.renderCoroutineRef); 61 Instance.renderCoroutineRef = null; 62 } 55 63 } 56 64 … … 75 83 Instance.dirtyChunks [cPos2] = realColors; 76 84 //Log.Out ("Add Dirty: " + cPos2); 77 Instance.chunkSaveTimer.Stop ();78 Instance.chunkSaveTimer.Start ();79 85 } 80 86 } … … 177 183 } 178 184 179 private void TimedRendering (object source, System.Timers.ElapsedEventArgs e) 180 { 181 lock (lockObject) { 182 RenderDirtyChunks (); 183 if (dirtyChunks.Count > 0) 184 Instance.chunkSaveTimer.Start (); 185 private System.Collections.IEnumerator renderCoroutine () { 186 while (true) { 187 lock (lockObject) { 188 if (dirtyChunks.Count > 0 && renderTimeout == float.MaxValue) { 189 renderTimeout = Time.time + 0.5f; 190 } 191 if (Time.time > renderTimeout || dirtyChunks.Count > 200) { 192 RenderDirtyChunks (); 193 } 194 } 195 yield return new WaitForSeconds (0.2f); 185 196 } 186 197 } -
binary-improvements/MapRendering/ModInfo.xml
r297 r299 5 5 <Description value="Render the game map to image map tiles as it is uncovered" /> 6 6 <Author value="Christian 'Alloc' Illy" /> 7 <Version value="1 8" />7 <Version value="19" /> 8 8 <Website value="http://7dtd.illy.bz" /> 9 9 </ModInfo>
Note:
See TracChangeset
for help on using the changeset viewer.