//Event Handler //--------------------------------------------------------------------------- public void Handle_PlayerLeaveChunk(IEvent _event) { GSW.RestartTimer(); //Interpret Event E_Player_LeaveChunk LeaveChunk = (_event as E_Player_LeaveChunk); AreaRect TempArea = m_CoverArea; TempArea.Move(LeaveChunk.Offset); int i, j = 0; ChunkInWorld SpawnLoc; for (i = TempArea.left; i <= TempArea.right; ++i) { for (j = TempArea.bottom; j <= TempArea.top; ++j) { SpawnLoc = new ChunkInWorld(new Vector2Int(i, j), m_World); m_WorldEntity.Spawn(SpawnLoc); m_CoveredLoc.Remove(SpawnLoc.Value); } } //remove not covered chunk foreach (var uncoverd in m_CoveredLoc) { m_WorldEntity.Remove(new ChunkInWorld(uncoverd, m_World)); } //update cover area SetCoverArea(TempArea); }
private void Start() { m_World = Locator <IWorld> .GetService(); //Compute Current Location m_CurLoc = new BlockLocation(transform.position, m_World); m_PreChunkLoc = m_CurLoc.ChunkInWorld.Value; m_PreSecLoc = m_CurLoc.SecInWorld.Value; //make event cache m_Cache_EChunkChange = new E_Player_LeaveChunk(Vector2Int.zero); }