Esempio n. 1
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. 2
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. 3
0
        public Scene3D(
            Game game,
            InputMessageBuffer inputMessageBuffer,
            Func <Viewport> getViewport,
            ICameraController cameraController,
            MapFile mapFile,
            Terrain.Terrain terrain,
            Terrain.WaterArea[] waterAreas,
            Terrain.Road[] roads,
            Terrain.Bridge[] bridges,
            MapScriptCollection scripts,
            GameObjectCollection gameObjects,
            WaypointCollection waypoints,
            WaypointPathCollection waypointPaths,
            WorldLighting lighting,
            Player[] players,
            Team[] teams,
            bool isDiagnosticScene = false)
        {
            Camera           = new Camera(getViewport);
            CameraController = cameraController;

            MapFile       = mapFile;
            Terrain       = terrain;
            WaterAreas    = waterAreas;
            Roads         = roads;
            Bridges       = bridges;
            Scripts       = scripts;
            GameObjects   = AddDisposable(gameObjects);
            Waypoints     = waypoints;
            WaypointPaths = waypointPaths;
            Lighting      = lighting;

            SelectionGui = new SelectionGui();

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

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

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

            _particleSystemManager = AddDisposable(new ParticleSystemManager(this));

            _players = players.ToList();
            _teams   = teams.ToList();
            // TODO: This is completely wrong.
            LocalPlayer = _players.FirstOrDefault();
        }
Esempio n. 4
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. 5
0
        private Scene3D(Game game, Func <Viewport> getViewport, InputMessageBuffer inputMessageBuffer, bool isDiagnosticScene)
        {
            Camera = new Camera(getViewport);

            SelectionGui = new SelectionGui();

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

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

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

            _particleSystemManager = AddDisposable(new ParticleSystemManager(this));
        }
Esempio n. 6
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. 7
0
 private void RegisterInputHandler(InputMessageHandler handler, InputMessageBuffer inputMessageBuffer)
 {
     inputMessageBuffer.Handlers.Add(handler);
     AddDisposeAction(() => inputMessageBuffer.Handlers.Remove(handler));
 }
Esempio n. 8
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;
        }
Esempio n. 9
0
 public InputSystem(Game game)
     : base(game)
 {
     MessageBuffer = AddDisposable(new InputMessageBuffer());
 }