Esempio n. 1
0
        internal Scene3D(
            Game game,
            InputMessageBuffer inputMessageBuffer,
            Func <Viewport> getViewport,
            ICameraController cameraController,
            WorldLighting lighting,
            int randomSeed,
            bool isDiagnosticScene = false)
            : this(game, getViewport, inputMessageBuffer, randomSeed, isDiagnosticScene, null, null)
        {
            _players = new List <Player>();
            _teams   = new List <Team>();

            // TODO: This is completely wrong.
            LocalPlayer = _players.FirstOrDefault();

            WaterAreas = AddDisposable(new WaterAreaCollection());
            Lighting   = lighting;

            Roads     = AddDisposable(new RoadCollection());
            Bridges   = Array.Empty <Bridge>();
            Waypoints = new WaypointCollection();
            Cameras   = new CameraCollection();

            CameraController = cameraController;
        }
Esempio n. 2
0
        private Scene3D(Game game, Func <Viewport> getViewport, InputMessageBuffer inputMessageBuffer, int randomSeed, bool isDiagnosticScene, MapFile mapFile, string mapPath)
        {
            Game = game;

            PlayerManager = new PlayerManager();

            Camera = new Camera(getViewport);

            SelectionGui = new SelectionGui();

            DebugOverlay = new DebugOverlay(this, game.ContentManager);

            Random = new Random(randomSeed);

            if (mapFile != null)
            {
                MapFile    = mapFile;
                Terrain    = AddDisposable(new Terrain.Terrain(mapFile, game.AssetStore.LoadContext));
                WaterAreas = AddDisposable(new WaterAreaCollection(mapFile.PolygonTriggers, mapFile.StandingWaterAreas, mapFile.StandingWaveAreas, game.AssetStore.LoadContext));
                Navigation = new Navigation.Navigation(mapFile.BlendTileData, Terrain.HeightMap);
            }

            RegisterInputHandler(_cameraInputMessageHandler = new CameraInputMessageHandler(), inputMessageBuffer);

            if (!isDiagnosticScene)
            {
                RegisterInputHandler(new SelectionMessageHandler(game.Selection), inputMessageBuffer);
                RegisterInputHandler(_orderGeneratorInputHandler = new OrderGeneratorInputHandler(game.OrderGenerator), inputMessageBuffer);
                RegisterInputHandler(_debugMessageHandler        = new DebugMessageHandler(DebugOverlay), inputMessageBuffer);
            }

            ParticleSystemManager = AddDisposable(new ParticleSystemManager(game.AssetStore.LoadContext));

            Radar = new Radar(this, game.AssetStore, mapPath);

            if (mapFile != null)
            {
                var borderWidth = mapFile.HeightMapData.BorderWidth * HeightMap.HorizontalScale;
                var width       = mapFile.HeightMapData.Width * HeightMap.HorizontalScale;
                var height      = mapFile.HeightMapData.Height * HeightMap.HorizontalScale;
                Quadtree = new Quadtree <GameObject>(new RectangleF(-borderWidth, -borderWidth, width, height));
            }

            GameContext = new GameContext(
                game.AssetStore.LoadContext,
                game.Audio,
                ParticleSystemManager,
                new ObjectCreationListManager(),
                Terrain,
                Navigation,
                Radar,
                Quadtree,
                this);

            GameObjects = AddDisposable(new GameObjectCollection(GameContext));

            GameContext.GameObjects = GameObjects;

            _orderGeneratorSystem = game.OrderGenerator;
        }
Esempio n. 3
0
        private Scene3D(Game game, Func <Viewport> getViewport, InputMessageBuffer inputMessageBuffer, int randomSeed, bool isDiagnosticScene, MapFile mapFile)
        {
            Camera = new Camera(getViewport);

            SelectionGui = new SelectionGui();

            DebugOverlay = new DebugOverlay(this, game.ContentManager);

            Random = new Random(randomSeed);

            if (mapFile != null)
            {
                MapFile    = mapFile;
                Terrain    = AddDisposable(new Terrain.Terrain(mapFile, game.AssetStore.LoadContext));
                WaterAreas = AddDisposable(new WaterAreaCollection(mapFile.PolygonTriggers, mapFile.StandingWaterAreas, mapFile.StandingWaveAreas, game.AssetStore.LoadContext));
                Navigation = new Navigation.Navigation(mapFile.BlendTileData, Terrain.HeightMap);
            }

            RegisterInputHandler(_cameraInputMessageHandler = new CameraInputMessageHandler(), inputMessageBuffer);

            if (!isDiagnosticScene)
            {
                RegisterInputHandler(new SelectionMessageHandler(game.Selection), inputMessageBuffer);
                RegisterInputHandler(_orderGeneratorInputHandler = new OrderGeneratorInputHandler(game.OrderGenerator), inputMessageBuffer);
                RegisterInputHandler(_debugMessageHandler        = new DebugMessageHandler(DebugOverlay), inputMessageBuffer);
            }

            _particleSystemManager = AddDisposable(new ParticleSystemManager(game.AssetStore.LoadContext));

            GameContext = new GameContext(
                game.AssetStore.LoadContext,
                game.Audio,
                _particleSystemManager,
                new ObjectCreationListManager(),
                Terrain,
                Navigation);

            GameObjects = AddDisposable(
                new GameObjectCollection(
                    GameContext,
                    game.CivilianPlayer,
                    Navigation));

            GameContext.GameObjects = GameObjects;

            _orderGeneratorSystem = game.OrderGenerator;
        }
Esempio n. 4
0
        internal Scene3D(
            Game game,
            InputMessageBuffer inputMessageBuffer,
            Func <Viewport> getViewport,
            ICameraController cameraController,
            WorldLighting lighting,
            int randomSeed,
            bool isDiagnosticScene = false)
            : this(game, getViewport, inputMessageBuffer, randomSeed, isDiagnosticScene, null, null)
        {
            WaterAreas = AddDisposable(new WaterAreaCollection());
            Lighting   = lighting;

            Roads     = AddDisposable(new RoadCollection());
            Bridges   = Array.Empty <Bridge>();
            Waypoints = new WaypointCollection();
            Cameras   = new CameraCollection();

            CameraController = cameraController;
        }
Esempio n. 5
0
        private Scene3D(Game game, Func <Viewport> getViewport, InputMessageBuffer inputMessageBuffer, int randomSeed, bool isDiagnosticScene, MapFile mapFile, string mapPath)
        {
            Camera = new Camera(getViewport);

            SelectionGui = new SelectionGui();

            DebugOverlay = new DebugOverlay(this, game.ContentManager);

            Random = new Random(randomSeed);

            if (mapFile != null)
            {
                MapFile    = mapFile;
                Terrain    = AddDisposable(new Terrain.Terrain(mapFile, game.AssetStore.LoadContext));
                WaterAreas = AddDisposable(new WaterAreaCollection(mapFile.PolygonTriggers, mapFile.StandingWaterAreas, mapFile.StandingWaveAreas, game.AssetStore.LoadContext));
                Navigation = new Navigation.Navigation(mapFile.BlendTileData, Terrain.HeightMap);
            }

            if (mapPath != null)
            {
                var mapCache = game.AssetStore.MapCaches.GetByName(mapPath.ToLower());
                if (mapCache == null)
                {
                    mapCache = game.AssetStore.MapCaches.GetByName(Path.Combine(game.UserDataFolder, mapPath).ToLower());
                }
                if (mapCache == null)
                {
                    throw new Exception($"Failed to load MapCache \"{mapPath}\"");
                }
                MapCache = mapCache;
            }

            RegisterInputHandler(_cameraInputMessageHandler = new CameraInputMessageHandler(), inputMessageBuffer);

            if (!isDiagnosticScene)
            {
                RegisterInputHandler(new SelectionMessageHandler(game.Selection), inputMessageBuffer);
                RegisterInputHandler(_orderGeneratorInputHandler = new OrderGeneratorInputHandler(game.OrderGenerator), inputMessageBuffer);
                RegisterInputHandler(_debugMessageHandler        = new DebugMessageHandler(DebugOverlay), inputMessageBuffer);
            }

            _particleSystemManager = AddDisposable(new ParticleSystemManager(game.AssetStore.LoadContext));

            Radar = new Radar(this, game.AssetStore, MapCache);

            GameContext = new GameContext(
                game.AssetStore.LoadContext,
                game.Audio,
                _particleSystemManager,
                new ObjectCreationListManager(),
                Terrain,
                Navigation,
                Radar);

            GameObjects = AddDisposable(
                new GameObjectCollection(
                    GameContext,
                    game.CivilianPlayer,
                    Navigation));

            GameContext.GameObjects = GameObjects;

            _orderGeneratorSystem = game.OrderGenerator;
        }