public static ObjectBuilder<SolarSystem> Build(StarCluster starCluster, SolarSystemState state) { var solarSystem = new SolarSystem { Id = state.ObjectId, Name = state.Name, Position = new Position(starCluster, state.LocalCoordinates), }; var builder = new ObjectBuilder<SolarSystem>(solarSystem) .Resolve((target, resolver) => BuildOrbits(state, target)); builder .Dependents(state.Ships) .Build(Echo.Ships.Ship.Builder.Build) .Resolve((resolver, target, dependent) => target.Ships.Add(dependent)); builder .Dependents(state.JumpGates) .Build(Echo.JumpGates.JumpGate.Builder.Build) .Resolve((resolver, target, dependent) => target.JumpGates.Add(dependent)); builder .Dependents(state.Satellites) .Build((target, dependent) => CelestialObject.Builder.For(dependent).Build(solarSystem)) .Resolve((resolver, target, dependent) => target.Satellites.Add(dependent)); builder .Dependents(state.Structures) .Build((target, dependent) => Structure.Builder.For(dependent).Build(solarSystem)) .Resolve((resolver, target, dependent) => target.Structures.Add(dependent)); return builder; }
public static StarClusterState Save(StarCluster starCluster) { return new StarClusterState { ObjectId = starCluster.Id, Name = starCluster.Name, LocalCoordinates = starCluster.Position.LocalCoordinates, SolarSystems = starCluster.SolarSystems.Save(), MarketPlace = starCluster.MarketPlace.Save(), }; }
public static ObjectBuilder<StarCluster> Build(Universe universe, StarClusterState state) { var starCluster = new StarCluster { Id = state.ObjectId, Name = state.Name, Position = new Position(universe, state.LocalCoordinates), }; var builder = new ObjectBuilder<StarCluster>(starCluster); builder.Resolve((resolver, target) => target.MarketPlace = Market.MarketPlace.Builder.Build(state.MarketPlace, starCluster).Build(resolver)); builder .Dependents(state.SolarSystems) .Build(SolarSystem.Builder.Build) .Resolve((resolver, target, dependent) => target.SolarSystems.Add(dependent)); return builder; }
public static ObjectBuilder<MarketPlace> Build(MarketPlaceState state, StarCluster starCluster) { var marketPlace = new MarketPlace { AuctionLength = state.AuctionLength, SettlementDelay = state.SettlementDelay, StarCluster = starCluster, }; var builder = new ObjectBuilder<MarketPlace>(marketPlace); builder .Dependents(state.Settlements) .Build(Settlement.Builder.Build) .Resolve((resolver, target, settlement) => target._settlements.Add(settlement)); builder .Resolve((resolver, target) => target._auctions.AddRange(state.Auctions.Select(resolver.Get<Auction>))); return builder; }
public void SetUp() { _marketPlace = new MarketPlace(); _sc = new StarCluster { MarketPlace = _marketPlace }; _sol = new SolarSystem { Position = new Position(_sc, Vector.Zero) }; _tradingStation = new TradingStation { Position = new Position(_sol, Vector.Zero) }; _marketPlace.StarCluster = _sc; _marketPlace.ObjectType.ShouldBe(ObjectType.MarketPlace); }