private static Structure <Guid> CompileType(IUniverse universe, Class <Guid, Guid, Func <Term <Guid>, Term <Guid> > > @class) { switch (@class.Tag) { case Class <Guid, Guid, Func <Term <Guid>, Term <Guid> > > .Tags.Quantifier: { var quantifier = (Class <Guid, Guid, Func <Term <Guid>, Term <Guid> > > .Quantifier)@class; Term <Guid> dependency = Compile(quantifier.Dependency.TypeOf()); var depUniverse = new Term <Guid> .Universe(quantifier.Dependency.Universe.Rank); var qualifiedDependency = new Qualified <Guid, Guid>(depUniverse, dependency, quantifier.Dependency.Term); return(new Structure <Guid> .Pair(qualifiedDependency, quantifier.Dependent(null))); } case Class <Guid, Guid, Func <Term <Guid>, Term <Guid> > > .Tags.Shift: { var shift = (Class <Guid, Guid, Func <Term <Guid>, Term <Guid> > > .Shift)@class; return(new Structure <Guid> .Continuation(shift.Content(null))); } default: throw new InvalidProgramException("Should never happen."); } }
public void ResetCamera(IUniverse universe) { if (universe == null) return; var volumeCopy = universe.Volume.Clone(); ActiveCamera = new Camera(volumeCopy); }
public IUniverse GetUniverse(int id) { if (universeCache == null) universeCache = mapGenerator.GenerateUniverse(id); return universeCache; }
public Body NextBody(IUniverse universe) { const float centralBodyMass = 1e16f; if (didGenerateCentralBody == false) { didGenerateCentralBody = true; return(new Body( mass: centralBodyMass, position: Vector2.Zero, velocity: Vector2.Zero, acceleration: Vector2.Zero )); } const uint dMin = 300; const uint dMax = 500; const float mMin = centralBodyMass / 1e6f; const float mMax = centralBodyMass / 1e5f; double tetha = random.NextDouble() * 2 * Math.PI; double distance = random.NextDouble() * (dMax - dMin) + dMin; double velocity = Math.Sqrt((universe.GravitationalConstant * centralBodyMass) / distance); float bodyMass = (float)random.NextDouble() * (mMax - mMin) + mMin; return(new Body( mass: bodyMass, position: new Vector2((float)(Math.Cos(tetha) * distance), (float)(Math.Sin(tetha) * distance)), velocity: new Vector2((float)(Math.Cos(tetha - 0.5 * Math.PI) * velocity), (float)(Math.Sin(tetha - 0.5 * Math.PI) * velocity)), acceleration: Vector2.Zero )); }
/// <summary> /// The initiate event logger. /// </summary> /// <param name="universe"> /// The universe. /// </param> public void InitiateEventLogger(IUniverse universe) { if (universe == null) { return; } var events = (decimal)universe.UniverseEvents.Count(); if (events < 10m) { this.logger.LogInformation("Less than 10 events in the universe. Not logging (%) completion."); return; } for (decimal i = 1; i <= 10m; i++) { var fraction = 0.1m * i; var percentageEventIndex = (int)Math.Floor(events * fraction); var universeEvent = universe.UniverseEvents.ElementAt(percentageEventIndex - 1); var landMark = new PercentageLandMark( universeEvent, $"Universe event processing {fraction * 100}% towards completion. {universeEvent.EventTime}"); this.list.Add(landMark); } }
/// <summary> /// Initializes a new instance of the <see cref="LiveSubscription"/> class /// </summary> /// <param name="universe">The universe of the subscription</param> /// <param name="security">The security this subscription is for</param> /// <param name="enumerator">The subscription's data source</param> /// <param name="utcStartTime">The start time of the subscription</param> /// <param name="utcEndTime">The end time of the subscription</param> public LiveSubscription(IUniverse universe, Security security, IEnumerator<BaseData> enumerator, DateTime utcStartTime, DateTime utcEndTime) : base(universe, security, enumerator, utcStartTime, utcEndTime) { NeedsMoveNext = true; IsCustomData = security.SubscriptionDataConfig.IsCustomData; StreamStore = new StreamStore(Configuration, security); }
public SimulationRecorder(IUniverse universe, float duration, float framesPerSecond) { Universe = universe; Duration = duration; FramesPerSecond = framesPerSecond; snapshots = new SerializedUniverse(universe.BodyCount, duration, framesPerSecond); }
public GameState() { // By default create a standard player and add to the list of players ActivePlayer = new Player(); Players.Add(ActivePlayer); Universe = new Universe(); }
public TestDataUniverse(IUniverse universe) { _universe = universe; var planets = _universe.Planets(); var mercury = planets.Create("Mercury"); var venus = planets.Create("Venus"); var earth = planets.Create("Earth"); planets.Create("Mars"); planets.Create("Jupiter"); planets.Create("Saturn"); planets.Create("Uranus"); var properties = _universe.Properties(); var atmosphere = properties.Create("Atmosphere"); var water = properties.Create("Water"); var solid = properties.Create("Solid"); var radiation = properties.Create("Radiation"); var hot = properties.Create("Hot"); var cold = properties.Create("Cold"); var ice = properties.Create("Ice"); earth.Properties().Add(atmosphere); earth.Properties().Add(water); venus.Properties().Add(hot); venus.Properties().Add(radiation); mercury.Properties().Add(solid); mercury.Properties().Add(ice); mercury.Properties().Add(cold); }
private static SimResults RunSim(long numSteps) { double halfYear = 3.1558149 * Math.Pow(10, 7) / 2.0; // seconds; double timeStep = halfYear / numSteps; IUniverse sunEarthUni = SunEarthUniverse(); var earth = sunEarthUni.Bodies.First(); Vector3 earthStartPos = earth.Dynamics.Kinematics.Transform.Pos; Vector3 expectedHalfway = new Vector3(-earthStartPos.X, earthStartPos.Y, earthStartPos.Z); Stopwatch stopwatch = Stopwatch.StartNew(); for (int i = 0; i < numSteps; i++) { sunEarthUni.Update(timeStep); } stopwatch.Stop(); double halfwayTime = stopwatch.Elapsed.TotalSeconds; double halfwayDiff = (expectedHalfway - earth.Dynamics.Kinematics.Transform.Pos).Magnitude; stopwatch.Start(); for (int i = 0; i < numSteps; i++) { sunEarthUni.Update(timeStep); } stopwatch.Stop(); double endTime = stopwatch.Elapsed.TotalSeconds; double endDiff = (earthStartPos - earth.Dynamics.Kinematics.Transform.Pos).Magnitude; return(new SimResults(numSteps, halfwayTime, halfwayDiff, endTime, endDiff)); }
public static IEnumerable <Bits> EncodeUniverse(IUniverse universe) { var rank = Encoding.EncodeNumber(universe.Rank); var polarity = Encoding.EncodeNullable(Encoding.EncodePolarity, universe.Polarity); return(Encoding.Concatenate(rank, polarity)); }
/// <summary> /// Initializes a new instance of the <see cref="UniverseSelectionEventArgs"/> class /// </summary> /// <param name="universe">The universe that raised this event</param> /// <param name="configuration">Theconfiguration for the data</param> /// <param name="dateTimeUtc">The date time this event was fired in UTC</param> /// <param name="data">The data contained within this event</param> public UniverseSelectionEventArgs(IUniverse universe, SubscriptionDataConfig configuration, DateTime dateTimeUtc, IReadOnlyList<BaseData> data) { Universe = universe; Configuration = configuration; DateTimeUtc = dateTimeUtc; Data = data; }
float AnalizeDescriptor(IUniverse universe, int x, int y) { int desc = universe.GetObjectDescriptor(x, y); if (desc == 0)//empty { return(0); } else if (desc == descriptor)//friend { return(genome.GetFriendly()); } else if (desc < 0)//food { return(genome.GetHunger()); } else//enemy { if (GetAge() >= ConstsUniverse.CellAge_AdultCell) { return(genome.GetAggression()); } else { return(ConstsUniverse.CellGenome_Child_Aggression); } } }
public byte[] GetData(IScene scene, IUniverse universe) { var data = new byte[512]; foreach (var state in scene.DeviceStates) { var device = state.Device; var deviceType = state.GetDeviceType(); var currentState = state; foreach (var filter in DeviceFilters) { var filterType = filter.GetDeviceType(); if (filterType.IsAssignableFrom(deviceType)) { currentState = filter.Filter(currentState); } } if (currentState.Data.Length != device.ChannelsCount) { throw new InvalidOperationException($"device {device.Identifier} should have {device.ChannelsCount} channels but it's state's payload is {currentState.Data.Length}."); } currentState.Data.CopyTo(data, universe.Devices[device] - 1); } return(data); }
public FixedTimePhysicsRunner(IUniverse uni, double timeStep = 0) { Universe = uni; if (timeStep != 0) { FrameLength = timeStep; } }
/// <summary> /// Erzuegt ein neues Universum. /// </summary> /// <param name="name">Name des neuen Universums.</param> /// <param name="seed">Weltgenerator-Seed für das neue Universum.</param> /// <returns>Die Guid des neuen Universums.</returns> public Guid NewUniverse(string name, int seed) { Guid guid = Guid.NewGuid(); universe = new Universe(guid, name, seed); persistenceManager.SaveUniverse(universe); return(guid); }
public MainViewModel(IUniverse universe) { ListPlanetsViewModel = new ListPlanetsViewModel(universe); ListPropertiesViewModel = new ListPropertiesViewModel(universe); PlanetDescriptionViewModel = new PlanetDescriptionViewModel(universe); ListPlanetsViewModel.PlanetSelected += PlanetDescriptionViewModel.ShowPlanetDescription; }
private static ITerm <Id, Id> ForallType <Id>(IUniverse universe, Id identifier, Func <ITerm <Id, Id>, ITerm <Id, Id> > dependent) { var dependency = universe.Qualify <Id, Id, Id>(term: identifier); var variable = new Term <Id, Id>(new TermF <Id, Id, ITerm <Id, Id> > .Variable(dependency.Term)); return(new Term <Id, Id>(new TermF <Id, Id, ITerm <Id, Id> > .Type(new Class <Id, Id, ITerm <Id, Id> > .Quantifier(dependency, dependent(variable))))); }
// use the scene generator factory, because a specific SceneGenerator might be shared if given as argument public ControllerBase(IUniverse universe, ISceneTranslator sceneTranslator, ISceneGeneratorFactory sceneGeneratorFactory, ISink channelSink) { _channelSink = channelSink; Universe = universe; SceneTranslator = sceneTranslator; SceneGenerator = sceneGeneratorFactory.CreateGenerator(Universe); SceneGenerator.SceneChanged += SceneChanged; SceneGenerator.Signal(StartupSignal.Value); }
public void TestMethod2() { Factory factory = new Factory(); IUniverse rebelde = factory.getUniverse("Rebelde"); rebelde.SetName("Erick"); Assert.AreEqual("Erick", rebelde.GetName()); }
public void TestMethod3() { Factory factory = new Factory(); IUniverse planeta = factory.getUniverse("Planeta"); planeta.SetName("Mercurio"); Assert.AreEqual("Mercurio", planeta.GetName()); }
public ListPropertiesViewModel(IUniverse universe) { _properties = new AsyncProperties(universe.Properties()); _properties.NewPropertyEvent += (sender, args) => _addProperty(args.Property); CreateProperty = new CreateProperty(_properties); _loadProperties(); }
public IUniverse GetUniverse(int id) { if (universeCache == null) { universeCache = mapGenerator.GenerateUniverse(id); } return(universeCache); }
public void TestMethod4() { Factory factory = new Factory(); IUniverse soldado = factory.getUniverse("Soldado"); soldado.SetName("Capitán"); Assert.AreEqual("Capitán", soldado.GetName()); }
public static IExpression <Bind, Id, T> Qualify <Bind, Id, T>(this IUniverse universe, T term) { var type = new Term <Bind, Id>(new TermF <Bind, Id, ITerm <Bind, Id> > .Universe(universe)); return(new Expression <Bind, Id, T>( universe: universe.TypeOf(), type: type, term: term)); }
private static IEnumerable <Bits> EncodeTerm(IUniverse universe, Productions production) { if (universe.Rank == 0) { return(EncodeTerm(production)); } return(EncodeType(production)); }
public void Listen(IUniverse uni) { ProcessBeforeFrame(uni); uni.FrameFinished += (sender, e) => { T res = ProcessAfterFrame(uni); ReadingComplete?.Invoke(this, new FrameReading <T>(res, e.FrameLength)); }; }
public ListPlanetsViewModel(IUniverse universe) { _planets = new AsyncPlanets(universe.Planets()); _planets.NewPlanetEvent += (sender, args) => { _addPlanet(args.Planet); }; CreatePlanet = new CreatePlanet(_planets); ReloadPlanets = new RelayCommand(_loadPlanets); _loadPlanets(); }
/// <summary> /// The play. /// </summary> /// <param name="universe"> /// The universe. /// </param> public void Play(IUniverse universe) { if (universe == null) { this.logger.LogError("added to play null universe. Returning."); return; } this.PlayUniverse(universe); }
private void saveChunk(int planetId, IChunk value) { IUniverse universe = GetUniverse(0); if (!disablePersistence && value.ChangeCounter > 0) { chunkPersistence.Save(universe.Id, planetId, value); value.ChangeCounter = 0; } }
private IPlanet loadPlanet(int index) { IUniverse universe = GetUniverse(0); var cache = new ChunkCache(idx => loadChunk(index, idx), (_, chunk) => saveChunk(index, chunk)); _managers[index] = new PlanetResourceManager(cache); return(mapGenerator.GeneratePlanet(universe.Id, 4567)); }
public static IUniverse Dual(this IUniverse universe) { if (universe.Polarity == null) { throw new ArgumentException("Universe must describe a polarized type."); } var polarity = Dual(universe.Polarity.Value); return(new Universe(universe.Rank, polarity)); }
public void SetUp() { _universe = Substitute.For<IUniverse>(); _gravitySimulator = Substitute.For<IGravitySimulator>(); _gameObjectFactory = Substitute.For<IGameObjectFactory>(); _keyboardHandler = Substitute.For<IKeyboardHandler>(); _actionHandler = Substitute.For<IActionHandler>(); _drawingManager = Substitute.For<IDrawingManager>(); _gameEngine = new GameEngine(_universe, _gravitySimulator, _gameObjectFactory, _keyboardHandler, _actionHandler, _drawingManager); }
internal GameObjectFactory(IContentManager contentManager, IGraphicsFactory graphicsFactory, IGravitySimulator gravitySimulator, IDrawingManager drawingManager, IUniverse universe, IShipComponentFactory shipComponentFactory) { _contentManager = contentManager; _graphicsFactory = graphicsFactory; _gravitySimulator = gravitySimulator; _drawingManager = drawingManager; _universe = universe; _shipComponentFactory = shipComponentFactory; _gameObjects = new List<IGameObject>(); }
internal void SnapshotUniverse(IUniverse universe) { List <float[]> bodies = new List <float[]>(); foreach (Body body in universe.Bodies) { bodies.Add(new float[] { body.Radius, body.Position.X, body.Position.Y }); } framesBodiesCoordinates.Add(bodies); }
public ConsoleOutputManager(IUniverse universe) { this.universe = universe; width = universe.GetWidth(); height = universe.GetHeight(); borderStr += '+'; for (int i = 0; i < width; i++) { borderStr += '-'; } borderStr += '+'; disposed = false; }
internal GameEngine(IUniverse universe, IGravitySimulator gravitySimulator, IGameObjectFactory gameObjectFactory, IKeyboardHandler keyboardHandler, IActionHandler actionHandler, IDrawingManager drawingManager) { _universe = universe; _drawingManager = drawingManager; _gravitySimulator = gravitySimulator; _gameObjectFactory = gameObjectFactory; _keyboardHandler = keyboardHandler; _actionHandler = actionHandler; _controllerFactory = new ControllerFactory(_keyboardHandler); actionHandler.RegisterTriggerAction(Keys.Space, () => _paused = !_paused); }
internal SpaceWar2Game() { _contentManager = new ContentManagerWrapper(Content.ServiceProvider, "Content"); var graphicsDeviceManager = new GraphicsDeviceManager(this); _graphicsDevice = new GraphicsDeviceWrapper(graphicsDeviceManager); _universe = Universe.CreateDefault(); _drawingManager = new DrawingManager(_universe); _gravitySimulator = new GravitySimulator(); _shipComponentFactory = new ShipComponentFactory(); _graphicsFactory = new GraphicsFactory(); _gameObjectFactory = new GameObjectFactory(_contentManager, _graphicsFactory, _gravitySimulator, _drawingManager, _universe, _shipComponentFactory); _keyboardHandler = new KeyboardHandler(new KeyboardWrapper()); var actionHandler = new ActionHandler(_keyboardHandler); _gameEngine = new GameEngine(_universe, _gravitySimulator, _gameObjectFactory, _keyboardHandler, actionHandler, _drawingManager); SetUpActions(actionHandler); }
/// <summary> /// Erzuegt ein neues Universum. /// </summary> /// <param name="name">Name des neuen Universums.</param> /// <param name="seed">Weltgenerator-Seed für das neue Universum.</param> /// <returns>Die Guid des neuen Universums.</returns> public Guid NewUniverse(string name, int seed) { Guid guid = Guid.NewGuid(); universe = new Universe(guid, name, seed); persistenceManager.SaveUniverse(universe); return guid; }
public FixedTimePhysicsRunner(IUniverse uni, double timeStep = 0) { Universe = uni; if (timeStep != 0) FrameLength = timeStep; }
private static IUniverse EvolveUniverse(IUniverse initialUniverse) { var game = new Game(); return game.Tick(initialUniverse); }
public IEnumerable<ICellLocation> Filter(IUniverse universe) { return new CellsWithLiveNeighbourCountFilter(universe.LiveCellLocations, 2, 3) .Filter(universe.LiveCellLocations); }
public RealTimePhysicsRunner(IUniverse uni) { Universe = uni; }
public static ItemSelector<IBody> BodySelector(IInputObservable input, IUniverse uni, Func<Vector3> rayOrigin, Func<Vector3> rayDir) { return new ItemSelector<IBody>(input, () => uni.RaySelect(rayOrigin(), rayDir())); }
private void WhenGettingAUniverse() { result = GetModel().GetByName(UniverseName); }
private void LoadGenerator(IMapGenerator generator) { Generator = generator; generatorName = generator.GetType().Name; Universe = generator.GenerateUniverse(0); Planet = generator.GeneratePlanet(0, seed); }
/// <summary> /// Event invocator for the <see cref="UniverseSelection"/> event /// </summary> /// <param name="universe">The universe to perform selection on the data</param> /// <param name="config">The configuration of the universe</param> /// <param name="dateTimeUtc">The current date time in UTC</param> /// <param name="data">The universe selection data to be operated on</param> protected virtual void OnUniverseSelection(IUniverse universe, SubscriptionDataConfig config, DateTime dateTimeUtc, IReadOnlyList<BaseData> data) { var handler = UniverseSelection; if (handler != null) handler(this, new UniverseSelectionEventArgs(universe, config, dateTimeUtc, data)); }
public void SetUp() { _universe = Substitute.For<IUniverse>(); _universe.Volume.Returns(_volume); _drawingManager = new DrawingManager(_universe); }
public static ItemSelector<IBody> BodySelector(IInputObservable input, IUniverse uni, ICamera cam) { return BodySelector(input, uni, () => cam.Pos, () => (cam.LookAtPos - cam.Pos).UnitDirection); }
public IUniverse Tick(IUniverse universe) { return new Universe(FilterNextGenerationLiveCells(universe)); }
public IEnumerable<ICellLocation> FilterNextGenerationLiveCells(IUniverse universe) { return _cellLocationFilters.SelectMany(f => f.Filter(universe)); }
private static void RenderUniverse(IUniverse universe) { Console.Clear(); foreach (var cell in universe.LiveCellLocations.Cast<XYCellLocation>()) { Console.SetCursorPosition(cell.X, cell.Y); Console.Write("O"); } }
/// <summary> /// Erzuegt ein neues Universum. /// </summary> /// <param name="name">Name des neuen Universums.</param> /// <param name="seed">Weltgenerator-Seed für das neue Universum.</param> public void NewUniverse(string name, int seed) { universe = new Universe(Guid.NewGuid(), name, seed); persistenceManager.SaveUniverse(universe); }
/// <summary> /// Lädt das Universum mit der angegebenen Guid. /// </summary> /// <param name="universeId">Die Guid des Universums.</param> /// <returns>Das geladene Universum.</returns> public void LoadUniverse(Guid universeId) { // Alte Daten entfernen if (universe != null) UnloadUniverse(); // Neuen Daten loaden/generieren universe = persistenceManager.LoadUniverse(universeId); if (universe == null) throw new Exception(); }
internal DrawingManager(IUniverse universe) { ResetCamera(universe); _drawableObjects = new List<IGameObject>(); }
public static ItemSelector<IBody> BodySelector(IInputObservable input, IUniverse uni, Vector3 rayOrigin, Vector3 rayDir) { return BodySelector(input, uni, () => rayOrigin, () => rayDir); }
/// <summary> /// Creates a new subscription for universe selection /// </summary> /// <param name="universe">The universe to add a subscription for</param> /// <param name="startTimeUtc">The start time of the subscription in utc</param> /// <param name="endTimeUtc">The end time of the subscription in utc</param> protected virtual Subscription CreateUniverseSubscription( IUniverse universe, DateTime startTimeUtc, DateTime endTimeUtc ) { // grab the relevant exchange hours var config = universe.Configuration; var exchangeHours = SecurityExchangeHoursProvider.FromDataFolder() .GetExchangeHours(config.Market, null, config.SecurityType); // create a canonical security object var security = new Security(exchangeHours, config, universe.SubscriptionSettings.Leverage); IEnumerator<BaseData> enumerator; if (config.Type == typeof (CoarseFundamental)) { // since we're binding to the data queue exchange we'll need to let him // know that we expect this data _dataQueueHandler.Subscribe(_job, new Dictionary<SecurityType, List<string>> { {config.SecurityType, new List<string>{config.Symbol}} }); var enqueable = new EnqueableEnumerator<BaseData>(); _exchange.SetHandler(config.Symbol, data => { var universeData = data as BaseDataCollection; if (universeData != null) { enqueable.EnqueueRange(universeData.Data); } }); enumerator = enqueable; } else { var localStartTime = startTimeUtc.ConvertFromUtc(config.TimeZone); var localEndTime = endTimeUtc.ConvertFromUtc(config.TimeZone); // define our data enumerator var tradeableDates = Time.EachTradeableDay(security, localStartTime, localEndTime); var reader = new SubscriptionDataReader(config, localStartTime, localEndTime, _resultHandler, tradeableDates, true); _customExchange.AddEnumerator(reader); var enqueable = new EnqueableEnumerator<BaseData>(); _customExchange.SetHandler(config.Symbol, data => { var universeData = data as BaseDataCollection; if (universeData != null) { enqueable.EnqueueRange(universeData.Data); } else { enqueable.Enqueue(data); } }); enumerator = enqueable; } // create the subscription var subscription = new Subscription(universe, security, enumerator, new TimeZoneOffsetProvider(security.SubscriptionDataConfig.TimeZone, startTimeUtc, endTimeUtc), startTimeUtc, endTimeUtc); return subscription; }
/// <summary> /// Adds a new subscription for universe selection /// </summary> /// <param name="universe">The universe to add a subscription for</param> /// <param name="startTimeUtc">The start time of the subscription in utc</param> /// <param name="endTimeUtc">The end time of the subscription in utc</param> public void AddUniverseSubscription( IUniverse universe, DateTime startTimeUtc, DateTime endTimeUtc ) { // grab the relevant exchange hours SubscriptionDataConfig config = universe.Configuration; var exchangeHours = SecurityExchangeHoursProvider.FromDataFolder() .GetExchangeHours(config.Market, null, config.SecurityType); // create a canonical security object var security = new Security(exchangeHours, config, universe.SubscriptionSettings.Leverage); var localStartTime = startTimeUtc.ConvertFromUtc(config.TimeZone); var localEndTime = endTimeUtc.ConvertFromUtc(config.TimeZone); // define our data enumerator var tradeableDates = Time.EachTradeableDay(security, localStartTime, localEndTime); var enumerator = new SubscriptionDataReader(config, localStartTime, localEndTime, _resultHandler, tradeableDates, false); // create the subscription var subscription = new LiveSubscription(universe, security, enumerator, startTimeUtc, endTimeUtc); // only message the user if it's one of their universe types _subscriptions.AddOrUpdate(new SymbolSecurityType(subscription), subscription); }
public void SetUp() { _contentManager = Substitute.For<IContentManager>(); _graphicsFactory = Substitute.For<IGraphicsFactory>(); _gravitySimulator = Substitute.For<IGravitySimulator>(); _drawingManager = Substitute.For<IDrawingManager>(); _universe = Substitute.For<IUniverse>(); _shipComponentFactory = Substitute.For<IShipComponentFactory>(); _gameObjectFactory = new GameObjectFactory(_contentManager, _graphicsFactory, _gravitySimulator, _drawingManager, _universe, _shipComponentFactory); }
/// <summary> /// Speichert das Universum. /// </summary> /// <param name="universe">Das zu speichernde Universum</param> public void SaveUniverse(IUniverse universe) { string path = Path.Combine(GetRoot(), universe.Id.ToString()); Directory.CreateDirectory(path); string file = Path.Combine(path, UniverseFilename); using (Stream stream = File.Open(file, FileMode.Create, FileAccess.Write)) { using (GZipStream zip = new GZipStream(stream, CompressionMode.Compress)) { universe.Serialize(zip); } } }