Esempio n. 1
0
        private void SetNewSubtype(int newIndex, bool force)
        {
            // For symmetry
            subtypeIndexControl = newIndex;

            if (newIndex == currentSubtypeIndex && !force)
            {
                return;
            }

            if (newIndex < 0 || newIndex >= subtypes.Count)
            {
                throw new ArgumentException("Subtype index must be between 0 and " + subtypes.Count.ToString());
            }

            if (newIndex != currentSubtypeIndex)
            {
                CurrentSubtype.DeactivateObjects();
                if (HighLogic.LoadedSceneIsEditor)
                {
                    CurrentSubtype.DeactivateNodes();
                }
            }

            currentSubtypeIndex = newIndex;

            UpdateSubtype(true);

            foreach (var counterpart in this.FindSymmetryCounterparts <ModuleB9PartSwitch>())
            {
                counterpart.SetNewSubtype(newIndex, force);
            }
        }
        private void UpdateOnStart()
        {
            subtypes.ForEach(subtype => subtype.DeactivateOnStart());
            RemoveUnusedResources();
            CurrentSubtype.ActivateOnStart();
            UpdateGeometry();

            LogInfo($"Switched subtype to {CurrentSubtype.Name}");
        }
 private void SetupForIcon()
 {
     // This will deactivate objects on non-active subtypes before the part icon is created, avoiding a visual mess
     foreach (var subtype in subtypes)
     {
         subtype.Setup(this);
         subtype.DeactivateObjects();
     }
     CurrentSubtype.ActivateObjects();
 }
        private void UpdateFromSymmetry(int newIndex)
        {
            CurrentSubtype.DeactivateOnSwitch();

            currentSubtypeIndex = newIndex;
            currentSubtypeName  = CurrentSubtype.Name;

            CurrentSubtype.ActivateOnSwitch();
            UpdateGeometry();
            LogInfo($"Switched subtype to {CurrentSubtype.Name}");
        }
Esempio n. 5
0
        public override void OnLoad(ConfigNode node)
        {
            base.OnLoad(node);

            // This will deactivate objects before the part icon is created, avoiding a visual mess
            for (int i = 0; i < subtypes.Count; i++)
            {
                PartSubtype subtype = subtypes[i];
                subtype.SetParent(this);
                subtype.FindObjects();

                subtype.DeactivateObjects();
            }

            CurrentSubtype.ActivateObjects();
        }
        private void UpdateFromGUI(BaseField field, object oldFieldValueObj)
        {
            int oldIndex = (int)oldFieldValueObj;

            subtypes[oldIndex].DeactivateOnSwitch();

            currentSubtypeName = CurrentSubtype.Name;

            CurrentSubtype.ActivateOnSwitch();
            UpdateGeometry();
            LogInfo($"Switched subtype to {CurrentSubtype.Name}");

            foreach (var counterpart in this.FindSymmetryCounterparts())
            {
                counterpart.UpdateFromSymmetry(currentSubtypeIndex);
            }

            UpdatePartActionWindow();
            FireEvents();
        }
Esempio n. 7
0
        private void UpdateSubtype(bool fillTanks)
        {
            CurrentSubtype.ActivateObjects();
            if (HighLogic.LoadedSceneIsEditor)
            {
                CurrentSubtype.ActivateNodes();
            }

            UpdateTankSetup(fillTanks);

            if (CurrentSubtype.maxTemp > 0)
            {
                part.maxTemp = CurrentSubtype.maxTemp;
            }
            else
            {
                part.maxTemp = part.GetPrefab().maxTemp;
            }

            if (CurrentSubtype.skinMaxTemp > 0)
            {
                part.skinMaxTemp = CurrentSubtype.skinMaxTemp;
            }
            else
            {
                part.skinMaxTemp = part.GetPrefab().skinMaxTemp;
            }

            if (AttachNodeManaged && part.attachRules.allowSrfAttach && part.srfAttachNode != null)
            {
                var referenceNode = CurrentSubtype.attachNode ?? part.GetPrefab().srfAttachNode;
                part.srfAttachNode.position    = referenceNode.position;
                part.srfAttachNode.orientation = referenceNode.orientation;
                part.srfAttachNode.size        = referenceNode.size;
            }

            if (FARWrapper.FARLoaded && affectFARVoxels && managedTransformNames.Count > 0)
            {
                part.SendMessage("GeometryPartModuleRebuildMeshData");
            }

            if (affectDragCubes && managedTransformNames.Count > 0)
            {
                DragCube newCube = DragCubeSystem.Instance.RenderProceduralDragCube(part);
                part.DragCubes.ClearCubes();
                part.DragCubes.Cubes.Add(newCube);
                part.DragCubes.ResetCubeWeights();
            }

            var window = FindObjectsOfType <UIPartActionWindow>().FirstOrDefault(w => w.part == part);

            if (window.IsNotNull())
            {
                window.displayDirty = true;
            }

            if (HighLogic.LoadedSceneIsEditor)
            {
                GameEvents.onEditorPartEvent.Fire(ConstructionEventType.PartTweaked, part);
                GameEvents.onEditorShipModified.Fire(EditorLogic.fetch.ship);
            }
            else if (HighLogic.LoadedSceneIsFlight)
            {
                GameEvents.onVesselWasModified.Fire(this.vessel);
            }

            LogInfo("Switched subtype to " + CurrentSubtype.Name);
        }