Пример #1
0
 /// <summary>
 ///    Returns all equipment of specified type in this spacecraft.
 /// </summary>
 public List <TEquipmentType> GetAllEquipment <TEquipmentType>() where TEquipmentType : Equipment
 {
     return(Hardpoints
            .Select(hardpoint => hardpoint.InstalledEquipment as TEquipmentType)
            .Where(equipment => equipment != null)
            .ToList());
 }
Пример #2
0
        private void RecalculateMass()
        {
            Single result = 0;

            Hardpoints.ForEach(hp => result += hp.Mass);

            Mass = result;
        }
Пример #3
0
        protected Spacecraft(WorldContext worldContext, SpacecraftData data) : base(worldContext, data)
        {
            Hardpoints = new Hardpoints(this);
            Hardpoints.HardpointMounted   += OnHardpointMounted;
            Hardpoints.HardpointUnmounted += OnHardpointUnmounted;

            EquipmentTrackingSubsystem = new EquipmentTrackingSubsystem(this);
            ElectricitySubsystem       = new ElectricitySubsystem(this);

            foreach (var hardpointData in data.HardpointsData)
            {
                Hardpoints.Mount(hardpointData.GetInstanceFromData());
            }
        }
Пример #4
0
 private void OnHardpointUnmounted(Hardpoints sender, Hardpoint hardpoint)
 {
     hardpoint.MassChanged -= OnHardpointMassChanged;
     RecalculateMass();
 }