Beispiel #1
0
 public ChunkCache(Game game)
     : base(game)
 {
     m_logger = MainEngine.GetEngineInstance().GetLogger("ChunkCache");
     Debug.Assert(game != null);
     var graphicsDevice = game.GraphicsDevice;
     Debug.Assert(ViewRange < CacheRange);
     Debug.Assert(graphicsDevice != null);
     Blocks = new Block[CacheSizeInBlocks * CacheSizeInBlocks * CacheSizeInBlocks];
     m_lightingEngine = new CellularLighting<Block>(Blocks, BlockIndexByWorldPosition, Chunk.SizeInBlocks, GetChunkByWorldPosition);
     m_vertexBuilder = new VertexBuilder<Block>(Blocks, BlockIndexByWorldPosition, graphicsDevice);
     m_chunkStorage = new SparseArray3D<Chunk>(CacheRange * 2 + 1, CacheRange * 2 + 1);
     m_cacheCenterPosition = new Vector4();
     m_eventSinkImpl = new EventSinkImpl ();
     m_eventSinkImpl.AddHandler<Vector3Args>(EventConstants.PlayerPositionUpdated, OnUpdateCachePosition);
     m_startUpState = StartUpState.NotStarted;
     m_processingQueue = new Queue<Chunk>();
     m_EditQueue = new ConcurrentQueue<WorldEdit>();
     #if DEBUG
     StateStatistics = new Dictionary<ChunkState, int> // init. the debug stastics.
                                {
                                    {ChunkState.AwaitingGenerate, 0},
                                    {ChunkState.Generating, 0},
                                    {ChunkState.AwaitingLighting, 0},
                                    {ChunkState.Lighting, 0},
                                    {ChunkState.AwaitingBuild, 0},
                                    {ChunkState.Building, 0},
                                    {ChunkState.Ready, 0},
                                    {ChunkState.AwaitingRemoval, 0},
                                };
     #endif
 }
Beispiel #2
0
 public Camera(float aspectRatio)
 {
     World = Matrix.Identity;
     Projection = Matrix.CreatePerspectiveFieldOfView(ViewAngle, aspectRatio, NearPlaneDistance, FarPlaneDistance);
     m_eventSinkImpl = new EventSinkImpl();
     m_eventSinkImpl.AddHandler<Vector2Args>(EventConstants.ScreenSizeUpdated, OnUpdateScreenSize);
     m_eventSinkImpl.AddHandler<Vector3Args>(EventConstants.ViewUpdated, OnUpdateTarget);
     m_eventSinkImpl.AddHandler<Vector3Args>(EventConstants.PlayerPositionUpdated, OnUpdatePosition);
      //   m_eventSinkImpl.AddHandler<Vector3Args>(EventConstants.ModalScreenPushed, OnUpdatePosition);
 }
Beispiel #3
0
 public Player(Block[] blocks, MappingFunctionVector3 mappingFunction)
 {
     FlyingEnabled = true;
     m_blocks = blocks;
     m_mappingFunction = mappingFunction;
     Equipable = new Shovel();
     m_eventSinkImpl = new EventSinkImpl();
     m_eventSinkImpl.AddHandler<Vector2Args>(EventConstants.MousePositionUpdated, OnMouseUpdated);
     m_eventSinkImpl.AddHandler<KeyArgs>(EventConstants.KeyDown, OnKeyDown);
     m_eventSinkImpl.AddHandler<KeyArgs>(EventConstants.KeyUp, OnKeyUp);
     m_eventSinkImpl.AddHandler<MouseButtonArgs>(EventConstants.LeftMouseDown, OnLeftMouseDown);
     m_eventSinkImpl.AddHandler<MouseButtonArgs>(EventConstants.LeftMouseUp, OnLeftMouseUp);
     m_eventSinkImpl.AddHandler<MouseButtonArgs>(EventConstants.RightMouseDown, OnRightMouseDown);
     m_eventSinkImpl.AddHandler<MouseButtonArgs>(EventConstants.RightMouseUp, OnRightMouseUp);
     EventsFired = new[]
     {
         EventConstants.PlayerPositionUpdated,
         EventConstants.ViewUpdated
     };
     m_eventSourceImpl = new EventSource(EventsFired, true);
 }