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); } }
public TypeStream(Stream input, Stream output, IFormatter formatter, IIdResolver idResolver) { this.input = input; this.output = output; this.formatter = formatter ?? throw new ArgumentNullException(nameof(formatter)); this.idCache = new IdCache(idResolver ?? throw new ArgumentNullException(nameof(formatter))); }
private static void BuildHardPoints(IIdResolver resolver, Ship ship, IEnumerable<HardPointState> hardPoints) { if ( hardPoints == null ) return; ship._hardPoints.AddRange(hardPoints.Select(h => HardPoint.Builder.Build(resolver, ship, h))); }
private static void ApplyStatDeltas(IIdResolver idResolver, Agent agent) { foreach (var implant in agent.Implants) { agent.Statistics[implant.Stat].Alter(implant); } agent.Statistics.Recalculate(); }
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); }
public void SetIdResolver <TR>() where TR : IIdResolver <T, TId> { var resolverClosedType = typeof(TR); // as long as T matches it's fine. Regardless of it being an open or closed type. Though that does // have impact on the creation as well! if (resolverClosedType.IsConstructedGenericType) { // When we have a resolver for a specific type this does not work such as is the case with countries. var openType = resolverClosedType.GetGenericTypeDefinition(); SetResolver(openType); } else { IdResolver = Activator.CreateInstance <TR>(); } }
private static void SpendByOwner(IIdResolver resolver, Settlement settlement, Dictionary<ObjectReference, long> spendByOwner) { settlement._spendByOwner = spendByOwner.ToDictionary(spend => resolver.Get<Corporation>(spend.Key), spend => spend.Value); }
private static void BuildOrbits(SolarSystemState arg1, IIdResolver arg2) { BuildSatelliteOrbits(arg1, arg2); BuildStructureOrbits(arg1, arg2); }
private static CelestialObject GetParent(IIdResolver resolver, IObject satellite, ObjectReference? orbits) { CelestialObject parent; if (resolver.TryGet(orbits, out parent)) { return parent; } throw new InvalidOperationException(string.Format("{0} is not orbiting anything", satellite.AsObjectReference())); }
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); } }
public TypeConfiguration(IIdResolver <T, TId> resolver, TId defaultExtractorValue) { DefaultExtractorValue = defaultExtractorValue; IdExtractor = resolver.Resolve; }
private static AgentSkillLevel Build(IIdResolver resolver, SkillLevel x) { return new AgentSkillLevel { Skill = resolver.Get<SkillInfo>(x.SkillCode.ToObjectReference()), Level = x.Level }; }
public IdCache(IIdResolver idResolver) { this.cacheByType = new Dictionary <Type, byte[]>(); this.cacheByName = new Dictionary <byte[], Type>(new ByteArrayComparer()); this.idResolver = idResolver; }
private void LoadHangarItems(IIdResolver idresolver, Structure target, IEnumerable<HangarItemState> hangerItems) { if (target.Owner == null) throw new InvalidOperationException("Cannot load hangar items without owner"); foreach (var hangar in hangerItems) { var corporation = idresolver.Get<Corporation>(hangar.Owner); var items = hangar.Items.Select(i => Item.Builder.Build(i, location:target, owner: corporation).Build(idresolver)); var itemCollection = new ItemCollection(corporation.Property, items); target.Hangar.Add(corporation, itemCollection); } }