示例#1
0
 public override void OnStart(StartState startState)
 {
     base.OnStart(startState);
     SpawnManager.Init(part);
     if (!string.IsNullOrEmpty(ConstructionNode))
     {
         construction_node = part.FindAttachNode(ConstructionNode);
         foreach (var port in part.FindModulesImplementing <ModuleDockingNode>())
         {
             if (port.nodeTransformName == ConstructionNode ||
                 port.referenceAttachNode == ConstructionNode)
             {
                 construction_port = port;
                 break;
             }
         }
     }
     if (construction_node == null)
     {
         this.Log("ERROR: unable to find construction AttachNode with id: {}",
                  ConstructionNode);
         this.EnableModule(false);
         return;
     }
     if (kit && ConstructDockingNode >= 0)
     {
         construct_docking_node = kit.DockingNodes[ConstructDockingNode];
     }
     if (vessel != null)
     {
         StartCoroutine(CallbackUtil.DelayedCallback(1, find_connected_workshops));
     }
 }
示例#2
0
        void Update()
        {
            var ship = EditorLogic.fetch != null? EditorLogic.fetch.ship : null;

            if (update)
            {
                highlight_all = all_highlighted;
                disable_highlights();
                if (ship != null)
                {
                    AssembleKit     = new VesselKit(null, ship, false, true);
                    ConstructionKit = new VesselKit(null, ship, true, true);
                }
                update = false;
            }
            if (highlight_node != null)
            {
                Part part;
                if (highlighted_parts.TryGetValue(highlight_node.PartId, out part))
                {
                    part.SetHighlightDefault();
                    highlighted_parts.Remove(highlight_node.PartId);
                }
                else if (ship != null)
                {
                    part = ship.Parts.GetPartByCraftID(highlight_node.PartId);
                    if (part != null)
                    {
                        highlighted_parts.Add(part.craftID, part);
                    }
                }
                highlight_node = null;
            }
            if (highlight_all)
            {
                if (all_highlighted)
                {
                    disable_highlights();
                }
                else if (ship != null)
                {
                    foreach (var n in DockingNodes)
                    {
                        var part = ship.Parts.GetPartByCraftID(n.PartId);
                        if (part != null && !highlighted_parts.ContainsKey(part.craftID))
                        {
                            highlighted_parts.Add(part.craftID, part);
                        }
                    }
                }
                highlight_all = false;
            }
            if (highlighted_parts.Count > 0)
            {
                foreach (var p in highlighted_parts.Values)
                {
                    p.HighlightAlways(Colors.Active.color);
                }
            }
        }
示例#3
0
 protected override void update_part_info()
 {
     base.update_part_info();
     DockableDisplay = kit && kit.DockingPossible;
     if (!DockableDisplay)
     {
         ConstructDockingNode   = -1;
         construct_docking_node = null;
     }
 }
        protected override void update_part_info()
        {
            base.update_part_info();
            DockableDisplay = kit && kit.DockingPossible;
            if (!DockableDisplay)
            {
                ConstructDockingNode   = -1;
                construct_docking_node = null;
                WieldDockingPort       = false;
            }
            var wieldField = Fields[nameof(WieldDockingPort)];

            wieldField.guiActive = wieldField.guiActiveEditor = DockableDisplay;
        }
示例#5
0
 public void ToggleDockedConstruction()
 {
     if (state == DeploymentState.IDLE && kit && kit.DockingPossible)
     {
         ConstructDockingNode += 1;
         if (ConstructDockingNode < kit.DockingNodes.Count)
         {
             construct_docking_node = kit.DockingNodes[ConstructDockingNode];
         }
         else
         {
             ConstructDockingNode   = -1;
             construct_docking_node = null;
         }
         update_part_events();
         create_deploy_hint_mesh();
     }
 }
示例#6
0
 void draw(int windowId)
 {
     GUILayout.BeginVertical(Styles.white);
     if (AssembleKit != null)
     {
         GUILayout.Label("Assembly requirements", Styles.label, GUILayout.ExpandWidth(true));
         AssembleKit.Draw();
     }
     if (ConstructionKit != null)
     {
         GUILayout.Label("Construction requirements", Styles.label, GUILayout.ExpandWidth(true));
         ConstructionKit.Draw();
     }
     if (AssembleKit != null && AssembleKit.DockingPossible)
     {
         GUILayout.Label("Attach nodes for docked construction", Styles.label, GUILayout.ExpandWidth(true));
         if (GUILayout.Button("Highight all nodes",
                              all_highlighted ? Styles.enabled_button : Styles.active_button,
                              GUILayout.ExpandWidth(true)))
         {
             highlight_all = true;
         }
         scroll = GUILayout.BeginScrollView(scroll, GUILayout.Height(100));
         foreach (var n in DockingNodes)
         {
             if (GUILayout.Button(n.ToString(),
                                  highlighted_parts.ContainsKey(n.PartId) ? Styles.active : Styles.white,
                                  GUILayout.ExpandWidth(true)))
             {
                 highlight_node = n;
             }
         }
         GUILayout.EndScrollView();
     }
     GUILayout.EndVertical();
     TooltipsAndDragWindow();
 }
示例#7
0
 public override void DrawOptions()
 {
     GUILayout.BeginVertical();
     base.DrawOptions();
     if (kit.DockingPossible)
     {
         GUILayout.BeginHorizontal(Styles.white);
         GUILayout.Label("After construction:");
         GUILayout.FlexibleSpace();
         if (state == DeploymentState.IDLE)
         {
             var old_value = ConstructDockingNode;
             if (Utils.ButtonSwitch(launch_label,
                                    ConstructDockingNode < 0,
                                    GUILayout.ExpandWidth(false)))
             {
                 ConstructDockingNode   = -1;
                 construct_docking_node = null;
             }
             if (Utils.ButtonSwitch(docked_label,
                                    ConstructDockingNode >= 0,
                                    GUILayout.ExpandWidth(false)))
             {
                 ConstructDockingNode   = 0;
                 construct_docking_node = kit.DockingNodes[0];
             }
             if (ConstructDockingNode != old_value)
             {
                 update_part_events();
                 create_deploy_hint_mesh();
             }
         }
         else if (ConstructDockingNode >= 0)
         {
             GUILayout.Label("Dock " + construct_docking_node,
                             Styles.enabled,
                             GUILayout.ExpandWidth(false));
         }
         else
         {
             GUILayout.Label(launch_label,
                             Styles.enabled,
                             GUILayout.ExpandWidth(false));
         }
         GUILayout.EndHorizontal();
         if (state == DeploymentState.IDLE && ConstructDockingNode >= 0)
         {
             GUILayout.BeginHorizontal(Styles.white);
             GUILayout.Label("Dock via:");
             GUILayout.FlexibleSpace();
             var choice = Utils.LeftRightChooser(construct_docking_node.ToString());
             if (choice != 0)
             {
                 ConstructDockingNode =
                     (ConstructDockingNode + choice) % kit.DockingNodes.Count;
                 if (ConstructDockingNode < 0)
                 {
                     ConstructDockingNode = kit.DockingNodes.Count - 1;
                 }
                 construct_docking_node = kit.DockingNodes[ConstructDockingNode];
                 update_part_events();
                 create_deploy_hint_mesh();
             }
             GUILayout.EndHorizontal();
         }
     }
     GUILayout.EndVertical();
 }