public static Weapon Build(IIdResolver resolver, WeaponState state) { if ( state == null ) { return null; } var weaponInfo = resolver.GetById<WeaponInfo>(ItemType.ShipWeapons.ToId(state.Code)); return Build(state.ObjectId, weaponInfo); }
private static void BuildSatelliteOrbits(SolarSystemState state, IIdResolver resolver) { Ensure.That(resolver).IsNotNull(); var query = ( from s in state.Satellites let satellite = resolver.GetById<CelestialObject>(s.ObjectId) where s.Orbits.HasValue select new { s.ObjectId, s.Orbits, s.LocalCoordinates, Instance = satellite, } ); foreach (var satellite in query) { var parent = GetParent(resolver, satellite.Instance, satellite.Orbits); parent.Satellites.Add(satellite.Instance); satellite.Instance.Position = new Position(parent, satellite.LocalCoordinates); var orbitDistance = satellite.LocalCoordinates.Magnitude - satellite.Instance.Size; CheckOrbitDistance(satellite.Instance, parent, orbitDistance); } }
private static void BuildStructureOrbits(SolarSystemState state, IIdResolver resolver) { Ensure.That(resolver).IsNotNull(); var query = ( from s in state.Structures let structure = resolver.GetById<Structure>(s.ObjectId) select new { s.ObjectId, s.Orbits, s.LocalCoordinates, Instance = structure, } ); foreach ( var structure in query ) { var parent = GetParent(resolver, structure.Instance, structure.Orbits); parent.Structures.Add(structure.Instance); structure.Instance.Position = new Position(parent, structure.LocalCoordinates); var orbitDistance = structure.LocalCoordinates.Magnitude; CheckOrbitDistance(structure.Instance, parent, orbitDistance); } }