Ejemplo n.º 1
0
            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);
                }
            }
Ejemplo n.º 2
0
 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)));
 }
Ejemplo n.º 3
0
Archivo: Ship.cs Proyecto: andy-uq/Echo
            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)));
            }
Ejemplo n.º 4
0
            private static void ApplyStatDeltas(IIdResolver idResolver, Agent agent)
            {
                foreach (var implant in agent.Implants)
                {
                    agent.Statistics[implant.Stat].Alter(implant);
                }

                agent.Statistics.Recalculate();
            }
Ejemplo n.º 5
0
            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);
            }
Ejemplo n.º 6
0
        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>();
            }
        }
Ejemplo n.º 7
0
 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);
 }
Ejemplo n.º 8
0
 private static void BuildOrbits(SolarSystemState arg1, IIdResolver arg2)
 {
     BuildSatelliteOrbits(arg1, arg2);
     BuildStructureOrbits(arg1, arg2);
 }
Ejemplo n.º 9
0
            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()));
            }
Ejemplo n.º 10
0
            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);
                }
            }
Ejemplo n.º 11
0
 public TypeConfiguration(IIdResolver <T, TId> resolver, TId defaultExtractorValue)
 {
     DefaultExtractorValue = defaultExtractorValue;
     IdExtractor           = resolver.Resolve;
 }
Ejemplo n.º 12
0
 private static AgentSkillLevel Build(IIdResolver resolver, SkillLevel x)
 {
     return new AgentSkillLevel { Skill = resolver.Get<SkillInfo>(x.SkillCode.ToObjectReference()), Level = x.Level };
 }
Ejemplo n.º 13
0
 public IdCache(IIdResolver idResolver)
 {
     this.cacheByType = new Dictionary <Type, byte[]>();
     this.cacheByName = new Dictionary <byte[], Type>(new ByteArrayComparer());
     this.idResolver  = idResolver;
 }
Ejemplo n.º 14
0
            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);
                }
            }