public LightingManager(IGameContext gameContext,
                               IGameProperties gameProperties,
                               IMeshManager meshManager,
                               IMaterialManager materialManager,
                               ITextureManager textureManager,
                               IRenderManager renderManager,
                               CameraManager cameraManager,
                               LightStore lightStore,
                               ILightManager lightManager,
                               TimeManager timeManager)
        {
            this.gameContext    = gameContext;
            this.gameProperties = gameProperties;
            this.meshManager    = meshManager;
            this.textureManager = textureManager;
            this.renderManager  = renderManager;
            this.cameraManager  = cameraManager;
            this.lightStore     = lightStore;
            this.lightManager   = lightManager;
            this.timeManager    = timeManager;
            skySphereMesh       = meshManager.CreateMesh(ObjParser.LoadObj("meshes/skysphere.obj").MeshData);
            skyMaterial         = materialManager.CreateMaterial("data/skybox.json");
            noiseTexture        = textureManager.LoadTexture("textures/noise_512.png");

            skyMaterial.SetTexture("cloudsTex", noiseTexture);
        }
Exemplo n.º 2
0
 public LightScheduleService(ILogger <LightScheduleService> logger, IOptionsMonitor <HueShiftOptions> appOptionsDelegate, ILightManager lightManager, ILightScheduleWorker lightScheduler)
 {
     this.logger             = logger;
     this.appOptionsDelegate = appOptionsDelegate;
     this.lightManager       = lightManager;
     this.lightScheduler     = lightScheduler;
 }
Exemplo n.º 3
0
        public void Reset()
        {
            EditorSceneManager.NewScene(NewSceneSetup.EmptyScene);
            mockMesher           = new MockMesher(mockGetComponent);
            mockMesher.CullFaces = true;//by default mesher is dependent on neighbour, as only the naive mesher is not
            mockProvider         = new MockProvider();
            mockComponentStorage = new Dictionary <Vector3Int, MockChunkComponent>();
            mockPlayChunkID      = Vector3Int.zero;
            mockLightManager     = Substitute.For <ILightManager>();
            mockLightManager.CreateGenerationJob(Arg.Any <Vector3Int>())
            .Returns(args =>
            {
                return(new BasicFunctionJob <LightmapGenerationJobResult>(() => new LightmapGenerationJobResult()));
            });

            mockManager = Substitute.For <IChunkManager>();
            mockManager.GetChunkComponent(Arg.Any <Vector3Int>())
            .Returns(args =>
            {
                var chunkId = (Vector3Int)args[0];
                return(mockGetComponent(chunkId));
            });
            mockManager.GetManhattanDistanceFromPlayer(Arg.Any <Vector3Int>())
            .Returns(args => {
                var chunkId = (Vector3Int)args[0];
                return(MockGetPriorityOfChunk(chunkId));
            });
            worldLimits = new WorldSizeLimits(false, 0);
            worldLimits.Initalise();
            mockManager.WorldLimits.Returns(worldLimits);
        }
Exemplo n.º 4
0
 public AutoLightScheduler(ILogger <AutoLightScheduler> logger, IOptionsMonitor <HueShiftOptions> appOptionsDelegate, IOptionsMonitor <CustomScheduleOptions> scheduleOptionsDelegate,
                           ILightManager lightManager, IEnumerable <IScheduleProvider> scheduleProviders)
 {
     this.mode               = HueShiftMode.Auto;
     this.logger             = logger;
     this.appOptionsDelegate = appOptionsDelegate;
     this.scheduleProvider   = scheduleProviders.First(x => x.Mode() == this.mode);
     this.lightManager       = lightManager;
 }
Exemplo n.º 5
0
 // Additional constructor to allow dependency injection
 public BuildingController(string id, ILightManager iLightManager, IFireAlarmManager iFireAlarmManager, IDoorManager iDoorManager, IWebService iWebService, IEmailService iEmailService)
 {
     buildingID       = id.ToLower();
     lightManager     = iLightManager;
     doorManager      = iDoorManager;
     fireAlarmManager = iFireAlarmManager;
     webservice       = iWebService;
     emailService     = iEmailService;
 }
Exemplo n.º 6
0
        public void Initialise(IVoxelTypeManager voxelTypeManager, IChunkManager chunkManager, IHeightMapProvider heightMapProvider)
        {
            var lm = new LightManager();

            lm.Parallel = parallel;
            lm.MaxChunksGeneratedPerUpdate = MaxChunksGeneratedPerUpdate;
            lm.MaxLightUpdates             = MaxPropPerUpdate;
            lightManager = lm;
            lightManager.Initialise(voxelTypeManager, chunkManager, heightMapProvider);
        }
Exemplo n.º 7
0
        protected Tile(TileState state, RectangleF rect)
        {
            _resourceManager = IoCManager.Resolve<IResourceManager>();
            _lightManager = IoCManager.Resolve<ILightManager>();

            tileState = state;

            bounds = rect;

            Sprite = _resourceManager.GetSprite("space_texture");
            Sprite.SetPosition(Position.X, Position.Y);
        }
Exemplo n.º 8
0
        protected Tile(TileState state, RectangleF rect)
        {
            _resourceManager = IoCManager.Resolve <IResourceManager>();
            _lightManager    = IoCManager.Resolve <ILightManager>();

            tileState = state;

            bounds = rect;

            Sprite = _resourceManager.GetSprite("space_texture");
            Sprite.SetPosition(Position.X, Position.Y);
        }
Exemplo n.º 9
0
        public BuildingController(string id, ILightManager iLightManager, IFireAlarmManager iFireAlarmManager,
                                  IDoorManager iDoorManager, IWebService iWebService, IEmailService iEmailService)
        {
            string idLower = id.ToLower();

            buildingID   = idLower;
            currentState = "out of hours";
            lightManager = iLightManager;
            fireAlarm    = iFireAlarmManager;
            doorManager  = iDoorManager;
            webService   = iWebService;
            emailService = iEmailService;
        }
Exemplo n.º 10
0
        /// <summary>
        /// Initializes a new instance of the <see cref="DrawingManager"/> class.
        /// </summary>
        /// <param name="rw">The <see cref="RenderWindow"/>.</param>
        public DrawingManager(RenderWindow rw)
        {
            BackgroundColor = Color.Black;

            // Create the objects
            _sb = new RoundedSpriteBatch();
            _lightManager = CreateLightManager();
            _refractionManager = CreateRefractionManager();

            // Set up the sprite used to draw the light map
            _drawBufferToWindowSprite = new SFML.Graphics.Sprite
            {
                Color = Color.White,
                Rotation = 0,
                Scale = Vector2.One,
                Origin = Vector2.Zero,
                Position = Vector2.Zero
            };

            // Set the RenderWindow
            RenderWindow = rw;
        }
        //(L3R1)
        public BuildingController(string id, ILightManager iLightManager,
                                  IFireAlarmManager iFireAlarmManager,
                                  IDoorManager iDoorManager, IWebService iWebService,
                                  IEmailService iEmailService)
        {
            checkIdIsWithinLimits(id);

            this.buildingID        = id.ToLower();
            this._lightManager     = iLightManager;
            this._fireAlarmManager = iFireAlarmManager;
            this._doorManager      = iDoorManager;
            this._webService       = iWebService;
            this._emailService     = iEmailService;

            this.currentState = STATE_OUT_OF_HOURS; //(L1R2)

            ThrowExcpetionIfAnObjectIsNull();       //(L3R1)

            ThrowExceptionStateInvalid();           //(L2R3)

            ThrowExceptionIfIdIsNull(id);           // (L1R1)
        }
Exemplo n.º 12
0
        /// <summary>
        /// Initializes a new instance of the <see cref="DrawingManager"/> class.
        /// </summary>
        /// <param name="rw">The <see cref="RenderWindow"/>.</param>
        public DrawingManager(RenderWindow rw)
        {
            BackgroundColor = Color.Black;

            // Create the objects
            _sb                = new RoundedSpriteBatch();
            _lightManager      = CreateLightManager();
            _refractionManager = CreateRefractionManager();

            // Set up the sprite used to draw the light map
            _drawBufferToWindowSprite = new SFML.Graphics.Sprite
            {
                Color    = Color.White,
                Rotation = 0,
                Scale    = Vector2.One,
                Origin   = Vector2.Zero,
                Position = Vector2.Zero
            };

            // Set the RenderWindow
            RenderWindow = rw;
        }
Exemplo n.º 13
0
        public MapManager(IResourceManager resourceManager, ILightManager lightManager,
                          ICollisionManager collisionManager)
        {
            _resourceManager  = resourceManager;
            _lightManager     = lightManager;
            _collisionManager = collisionManager;
            _mapHeight        = 256;
            _mapWidth         = 256;
            Init();

            _cardinalList = new List <Vector2D>
            {
                new Vector2D(0, 0),
                new Vector2D(0, 1),
                new Vector2D(0, -1),
                new Vector2D(1, 0),
                new Vector2D(-1, 0),
                new Vector2D(1, 1),
                new Vector2D(-1, -1),
                new Vector2D(-1, 1),
                new Vector2D(1, -1)
            };
        }
Exemplo n.º 14
0
        public MapManager(IResourceManager resourceManager, ILightManager lightManager,
                          ICollisionManager collisionManager)
        {
            _resourceManager = resourceManager;
            _lightManager = lightManager;
            _collisionManager = collisionManager;
            _mapHeight = 256;
            _mapWidth = 256;
            Init();

            _cardinalList = new List<Vector2D>
                                {
                                    new Vector2D(0, 0),
                                    new Vector2D(0, 1),
                                    new Vector2D(0, -1),
                                    new Vector2D(1, 0),
                                    new Vector2D(-1, 0),
                                    new Vector2D(1, 1),
                                    new Vector2D(-1, -1),
                                    new Vector2D(-1, 1),
                                    new Vector2D(1, -1)
                                };
        }
Exemplo n.º 15
0
        public ChunkPipelineManager(IChunkProvider chunkProvider,
                                    IChunkMesher chunkMesher,
                                    IChunkManager chunkManager,
                                    int maxDataPerUpdate,
                                    int maxMeshPerUpdate,
                                    int maxCollisionPerUpdate,
                                    bool structureGen          = false,
                                    int maxStructurePerUpdate  = 200,
                                    ILightManager lightManager = null)
        {
            getChunkComponent  = chunkManager.GetChunkComponent;
            this.chunkProvider = chunkProvider;
            this.chunkMesher   = chunkMesher;
            GenerateStructures = structureGen;
            worldLimits        = chunkManager.WorldLimits;

            bool lighting = lightManager != null;

            bool meshDependentOnNeighbours = chunkMesher.CullFaces || lighting;

            Func <Vector3Int, float> priorityFunc = chunkManager.GetManhattanDistanceFromPlayer;

            int i = 0;

            var ScheduledForData = new PrioritizedBufferStage("ScheduledForData", i++,
                                                              this, chunkManager.GetManhattanDistanceFromPlayer);

            stages.Add(ScheduledForData);

            var GeneratingData = new GenerateTerrainStage(
                "GeneratingTerrain", i++, this, maxDataPerUpdate);

            stages.Add(GeneratingData);

            TerrainDataStage   = i;
            OwnStructuresStage = i;

            if (structureGen)
            {
                ///Wait until all neighbours including diagonal ones have their terrain data
                var waitForNeighbourTerrain = new WaitForNeighboursStage(
                    "WaitForNeighbourTerrain", i++, this, true);
                stages.Add(waitForNeighbourTerrain);

                var scheduledForStructures = new PrioritizedBufferStage(
                    "ScheduledForStructures", i++, this, priorityFunc);
                stages.Add(scheduledForStructures);

                var generatingStructures = new GenerateStructuresStage(
                    "GeneratingStructures", i++, this, maxStructurePerUpdate);
                stages.Add(generatingStructures);

                ///At this point the chunk has generated all of its own structures.
                OwnStructuresStage = i;
                if (lighting)
                {
                    PreLightGenWaitStage = i;//This is the wait stage before lighting
                }
                var waitingForAllNeighboursToHaveStructures = new WaitForNeighboursStage(
                    "WaitForNeighbourStructures", i++, this, true);

                stages.Add(waitingForAllNeighboursToHaveStructures);
            }


            if (lighting)
            {
                if (!structureGen)
                {
                    PreLightGenWaitStage = i;
                    ///If structures are not generated, need a separate wait for neighbours.
                    ///Otherwise, the wait at the end of the structure generation is sufficient.
                    var waitingForNeighboursForLighting = new WaitForNeighboursStage(
                        "WaitForNeighboursPreLights", i++, this, false
                        );
                    stages.Add(waitingForNeighboursForLighting);
                }

                var scheduledForLighting = new PrioritizedBufferStage(
                    "ScheduledForLights", i++, this, priorityFunc);
                stages.Add(scheduledForLighting);

                var generatingLights = new GenerateLightsStage("GeneratingLights",
                                                               i++, this, lightManager.MaxChunksGeneratedPerUpdate, lightManager);
                stages.Add(generatingLights);
            }

            ///Passthrough stage to set chunkdata fully generated flag
            var preFullyGeneratedStage = new PassThroughApplyFunctionStage("PreFullGenerated", i++, this,
                                                                           (chunkId) =>
            {
                var chunkData = getChunkComponent(chunkId).Data;
                if (chunkData.FullyGenerated)
                {
                    var stageData = chunkStageMap.TryGetValue(chunkId, out var tmp) ? tmp : null;
                    Debug.LogError($"Chunk data for {chunkId} was listed as fully generated before reaching the fully generated stage!");
                }
                //The chunk is now fully generated, after having received both voxels and lighting.
                chunkData.FullyGenerated = true;
            });

            stages.Add(preFullyGeneratedStage);

            FullyGeneratedStage = i;

            if (meshDependentOnNeighbours)
            {
                /// If mesh is dependent on neighbour chunks, add a waiting stage
                /// to wait until the neighbours of a chunk have their data before
                /// moving that chunk onwards through the pipeline. Diagonals are included
                /// in the neighbourhood if structureGen is on.
                stages.Add(new WaitForNeighboursStage("WaitForNeighboursPreMesh", i++,
                                                      this, includeDiagonals: structureGen));
            }
            else
            {
                ///Otherwise, the chunk can move onwards freely
                stages.Add(new PassThroughStage("GotAllData", i++, this));
            }


            var ScheduledForMesh = new PrioritizedBufferStage("ScheduledForMesh", i++,
                                                              this, priorityFunc);

            stages.Add(ScheduledForMesh);

            var GeneratingMesh = new GenerateMeshStage("GeneratingMesh", i++,
                                                       this, maxMeshPerUpdate);

            stages.Add(GeneratingMesh);


            RenderedStage = i;
            stages.Add(new PassThroughStage("GotMesh", i++, this));

            var ScheduledForCollisionMesh = new PrioritizedBufferStage(
                "ScheduledForCollisionMesh", i++, this, priorityFunc);

            stages.Add(ScheduledForCollisionMesh);

            var ApplyingCollisionMesh = new ApplyCollisionMeshStage(
                "ApplyingCollisionMesh", i++, this, maxCollisionPerUpdate);

            stages.Add(ApplyingCollisionMesh);

            //Final stage
            CompleteStage = i;
            stages.Add(new PassThroughStage("Complete", i++, this));


            foreach (var stage in stages)
            {
                stage.Initialise();
            }
        }
Exemplo n.º 16
0
 public void Setup(ILightManager lightManager, IGameManager gameManager)
 {
     _lightManager = lightManager;
     _gameManager  = gameManager;
 }
Exemplo n.º 17
0
 public GameManager(ILightManager lightManager)
 {
     _lightManager = lightManager;
 }
        ILightManager GetMockLightManager()
        {
            ILightManager stubLightManager = Substitute.For <ILightManager>();

            return(stubLightManager);
        }
Exemplo n.º 19
0
 public GenerateLightsStage(string name, int order, IChunkPipeline pipeline, int maxInStage, ILightManager lightManager) : base(name, order, pipeline, maxInStage)
 {
     this.lightManager = lightManager;
 }