/// <summary> /// Remoes the given SwitchableTank from the list of all tanks /// whose CurrentResource is checked upon resource switching. /// </summary> public bool UnregisterOtherTank(HangarSwitchableTank tank) { return other_tanks.Remove(tank); }
void remove_tank(HangarSwitchableTank tank) { tank_manager.RemoveTank(tank); }
void update_symmetry_tanks(HangarSwitchableTank tank, Action<HangarSwitchableTank> action) { update_symmetry_managers (m => { var tank1 = m.GetTank(tank.id); if(tank1 == null) Utils.Log("SwitchableTankManager: WARNING, no tank with {0} id", tank.id); else action(tank1); }); }
/// <summary> /// Adds the given SwitchableTank to the list of all tanks /// whose CurrentResource is checked upon resource switching. /// </summary> public void RegisterOtherTank(HangarSwitchableTank tank) { if(!other_tanks.Contains(tank)) other_tanks.Add(tank); }
void tank_type_gui(HangarSwitchableTank tank) { var choice = HangarGUI.LeftRightChooser(tank.TankType, 120); SwitchableTankType new_type = null; if(choice < 0) new_type = SwitchableTankType.TankTypes.Prev(tank.TankType); else if(choice > 0) new_type = SwitchableTankType.TankTypes.Next(tank.TankType); if(new_type != null) { tank.TankType = new_type.name; update_symmetry_tanks(tank, t => t.TankType = tank.TankType); } }
void tank_resource_gui(HangarSwitchableTank tank) { var choice = HangarGUI.LeftRightChooser(tank.CurrentResource, 120); TankResource new_res = null; if(choice < 0) new_res = tank.Type.Resources.Prev(tank.CurrentResource); else if(choice > 0) new_res = tank.Type.Resources.Next(tank.CurrentResource); if(new_res != null) { tank.CurrentResource = new_res.Name; update_symmetry_tanks(tank, t => t.CurrentResource = tank.CurrentResource); } }
void tank_gui(HangarSwitchableTank tank) { GUILayout.BeginHorizontal(); if(TypeChangeEnabled) tank_type_gui(tank); tank_resource_gui(tank); GUILayout.FlexibleSpace(); GUILayout.Label(Utils.formatVolume(tank.Volume), GUILayout.ExpandWidth(true)); var usage = tank.Usage; GUILayout.Label("Filled: "+usage.ToString("P1"), Styles.fracStyle(usage), GUILayout.Width(95)); if(AddRemoveEnabled) { if(tank.Usage > 0) GUILayout.Label("X", Styles.grey, GUILayout.Width(20)); else if(GUILayout.Button("X", Styles.red_button, GUILayout.Width(20))) remove_tank_delegate(tank); } GUILayout.EndHorizontal(); }
/// <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(HangarSwitchableTank tank, bool update_counterparts = true) { if(!AddRemoveEnabled) return false; if(!tanks.Contains(tank)) return false; if(!tank.TryRemoveResource()) return false; tanks.Remove(tank); tanks.ForEach(t => t.UnregisterOtherTank(tank)); part.RemoveModule(tank); if(update_counterparts) update_symmetry_managers(m => m.RemoveTank(m.GetTank(tank.id), false)); return true; }
void remove_tank(HangarSwitchableTank tank) { var volume = tank.Volume; if(!tank_manager.RemoveTank(tank)) return; if(metal_pump != null && !convert_metal(-volume)) return; change_size(volume); }