Example #1
0
 /// <summary>
 /// Adds the given SwitchableTank to the list of all tanks
 /// whose CurrentResource is checked upon resource switching.
 /// </summary>
 public void RegisterOtherTank(ModuleSwitchableTank tank)
 {
     if (!other_tanks.Contains(tank))
     {
         other_tanks.Add(tank);
     }
 }
        /// <summary>
        /// Removes the tank from the part, if possible. Removed tank is destroyed immidiately,
        /// so the provided reference becomes invalid.
        /// </summary>
        /// <returns><c>true</c>, if tank was removed, <c>false</c> otherwise.</returns>
        /// <param name="tank">Tank to be removed.</param>
        /// <param name="update_counterparts">If counterparts are to be updated.</param>
        public bool RemoveTank(ModuleSwitchableTank tank, bool update_counterparts = true)
        {
            if (!AddRemoveEnabled)
            {
                return(false);
            }
            var wrapper = tanks.Find(t => t.Tank == tank);

            if (wrapper == null)
            {
                return(false);
            }
            if (!tank.TryRemoveResource())
            {
                return(false);
            }
            tanks.Remove(wrapper);
            tanks.ForEach(t => t.Tank.UnregisterOtherTank(tank));
            part.RemoveModule(tank);
            total_volume = -1;
            if (update_counterparts)
            {
                update_symmetry_managers(m => m.RemoveTank(m.GetTank(tank.id), false));
            }
            return(true);
        }
 void update_symmetry_tanks(ModuleSwitchableTank tank, Action <ModuleSwitchableTank> action)
 {
     update_symmetry_managers
         (m =>
     {
         var tank1 = m.GetTank(tank.id);
         if (tank1 == null)
         {
             Utils.Log("SwitchableTankManager: WARNING, no tank with {} id", tank.id);
         }
         else
         {
             action(tank1);
         }
     });
 }
 void remove_tank(ModuleSwitchableTank tank)
 {
     tank_manager.RemoveTank(tank);
 }
Example #5
0
 public ResourceBoiloff(ModuleSwitchableTank tank)
 {
     this.tank = tank;
     part      = tank.part;
 }
Example #6
0
 /// <summary>
 /// Remoes the given SwitchableTank from the list of all tanks
 /// whose CurrentResource is checked upon resource switching.
 /// </summary>
 public bool UnregisterOtherTank(ModuleSwitchableTank tank)
 {
     return(other_tanks.Remove(tank));
 }
 public ActiveCooling(ModuleSwitchableTank tank) : base(tank)
 {
 }
Example #8
0
 public TankWrapper(ModuleSwitchableTank tank, SwitchableTankManager manager)
 {
     this.tank         = tank;
     this.manager      = manager;
     VolumeField.Value = tank.Volume;
 }