Beispiel #1
0
 public void SetTubeRenderer(bool activated)
 {
     if (activated)
     {
         // loading strut renderer
         tubeRenderer = this.part.gameObject.AddComponent<KAS_Tube>();
         tubeRenderer.tubeTexTilingOffset = 4;
         tubeRenderer.tubeScale = cableWidth;
         tubeRenderer.sphereScale = cableWidth;
         tubeRenderer.tubeTexture = texCable;
         tubeRenderer.sphereTexture = texCable;
         tubeRenderer.tubeJoinedTexture = texCable;
         tubeRenderer.srcJointType = KAS_Tube.tubeJointType.Joined;
         tubeRenderer.tgtJointType = KAS_Tube.tubeJointType.Joined;
         // Set source and target 
         tubeRenderer.srcNode = headAnchorNode;
         tubeRenderer.tgtNode = winchAnchorNode;
         // Load the tube
         tubeRenderer.Load();
     }
     else
     {
         tubeRenderer.UnLoad();
     }
 }
Beispiel #2
0
        public override void OnStart(StartState state)
        {
            base.OnStart(state);
            if (state == StartState.Editor || state == StartState.None)
            {
                return;
            }
            //Loading texture
            texStrut = GameDatabase.Instance.GetTexture(tubeTexPath, false);
            if (!texStrut)
            {
                KAS_Shared.DebugError("tube texture loading error !");
                ScreenMessages.PostScreenMessage(
                    "Texture file : " + tubeTexPath
                    + " as not been found, please check your KAS installation !",
                    10, ScreenMessageStyle.UPPER_CENTER);
            }
            // loading sounds
            KAS_Shared.createFXSound(this.part, fxSndLink, sndLinkPath, false);
            KAS_Shared.createFXSound(this.part, fxSndUnlink, sndUnlinkPath, false);
            KAS_Shared.createFXSound(this.part, fxSndBroke, sndBrokePath, false);

            // loading strut renderer
            strutRenderer = this.part.gameObject.AddComponent <KAS_Tube>();
            strutRenderer.tubeTexTilingOffset = textureTiling;
            strutRenderer.tubeScale           = tubeScale;
            strutRenderer.sphereScale         = jointScale;
            strutRenderer.tubeTexture         = texStrut;
            strutRenderer.sphereTexture       = texStrut;
            strutRenderer.tubeJoinedTexture   = texStrut;
            strutRenderer.srcNode             = strutTransform;

            // loading tube type
            switch (tubeSrcType)
            {
            case "None":
                strutRenderer.srcJointType = KAS_Tube.tubeJointType.None;
                break;

            case "Rounded":
                strutRenderer.srcJointType = KAS_Tube.tubeJointType.Rounded;
                break;

            case "ShiftedAndRounded":
                strutRenderer.srcJointType = KAS_Tube.tubeJointType.ShiftedAndRounded;
                break;

            case "Joined":
                strutRenderer.srcJointType = KAS_Tube.tubeJointType.Joined;
                break;

            default:
                strutRenderer.srcJointType = KAS_Tube.tubeJointType.Joined;
                break;
            }
            switch (tubeTgtType)
            {
            case "None":
                strutRenderer.tgtJointType = KAS_Tube.tubeJointType.None;
                break;

            case "Rounded":
                strutRenderer.tgtJointType = KAS_Tube.tubeJointType.Rounded;
                break;

            case "ShiftedAndRounded":
                strutRenderer.tgtJointType = KAS_Tube.tubeJointType.ShiftedAndRounded;
                break;

            case "Joined":
                strutRenderer.tgtJointType = KAS_Tube.tubeJointType.Joined;
                break;

            default:
                strutRenderer.tgtJointType = KAS_Tube.tubeJointType.Joined;
                break;
            }

            // Reset link if docked
            if (attachMode.Docked && !linked)
            {
                KAS_Shared.DebugLog("OnStart(strut) Docked strut detected from save, relinking...");
                KASModuleStrut linkedStrutModuleSavedD = dockedAttachModule.GetComponent <KASModuleStrut>();
                LinkTo(linkedStrutModuleSavedD, false, true);
            }

            // Loading onVesselWasModified KSP event
            GameEvents.onVesselWasModified.Add(new EventData <Vessel> .OnEvent(this.OnVesselWasModified));
        }
Beispiel #3
0
        public override void OnStart(StartState state)
        {
            base.OnStart(state);
            if (state == StartState.Editor || state == StartState.None) return;
            //Loading texture
            texStrut = GameDatabase.Instance.GetTexture(tubeTexPath, false);
            if (!texStrut)
            {
                KAS_Shared.DebugError("tube texture loading error !");
                ScreenMessages.PostScreenMessage("Texture file : " + tubeTexPath + " as not been found, please check your KAS installation !", 10, ScreenMessageStyle.UPPER_CENTER);
            }
            // loading sounds
            KAS_Shared.createFXSound(this.part, fxSndLink, sndLinkPath, false);
            KAS_Shared.createFXSound(this.part, fxSndUnlink, sndUnlinkPath, false);
            KAS_Shared.createFXSound(this.part, fxSndBroke, sndBrokePath, false);

            // loading strut renderer
            strutRenderer = this.part.gameObject.AddComponent<KAS_Tube>();
            strutRenderer.tubeTexTilingOffset = textureTiling;
            strutRenderer.tubeScale = tubeScale;
            strutRenderer.sphereScale = jointScale;
            strutRenderer.tubeTexture = texStrut;
            strutRenderer.sphereTexture = texStrut;
            strutRenderer.tubeJoinedTexture = texStrut;
            strutRenderer.srcNode = strutTransform;

            // loading tube type
            switch (tubeSrcType)
            {
                case "None":
                    strutRenderer.srcJointType = KAS_Tube.tubeJointType.None;
                    break;
                case "Rounded":
                    strutRenderer.srcJointType = KAS_Tube.tubeJointType.Rounded;
                    break;
                case "ShiftedAndRounded":
                    strutRenderer.srcJointType = KAS_Tube.tubeJointType.ShiftedAndRounded;
                    break;
                case "Joined":
                    strutRenderer.srcJointType = KAS_Tube.tubeJointType.Joined;
                    break;
                default:
                    strutRenderer.srcJointType = KAS_Tube.tubeJointType.Joined;
                    break;
            }
            switch (tubeTgtType)
            {
                case "None":
                    strutRenderer.tgtJointType = KAS_Tube.tubeJointType.None;
                    break;
                case "Rounded":
                    strutRenderer.tgtJointType = KAS_Tube.tubeJointType.Rounded;
                    break;
                case "ShiftedAndRounded":
                    strutRenderer.tgtJointType = KAS_Tube.tubeJointType.ShiftedAndRounded;
                    break;
                case "Joined":
                    strutRenderer.tgtJointType = KAS_Tube.tubeJointType.Joined;
                    break;
                default:
                    strutRenderer.tgtJointType = KAS_Tube.tubeJointType.Joined;
                    break;
            }

            // Reset link if a fixed joint exist
            if (attachMode.FixedJoint)
            {
                KAS_Shared.DebugLog("OnStart(strut) Docked / fixed joint detected from save, relinking...");
                KASModuleStrut linkedStrutModuleSavedF = FixedAttach.connectedPart.GetComponent<KASModuleStrut>();
                LinkTo(linkedStrutModuleSavedF, false, true);
            }

            // Reset link if docked
            if (attachMode.Docked && !linked)
            {
                KAS_Shared.DebugLog("OnStart(strut) Docked strut detected from save, relinking...");
                KASModuleStrut linkedStrutModuleSavedD = dockedAttachModule.GetComponent<KASModuleStrut>();
                LinkTo(linkedStrutModuleSavedD, false, true);
            }

            // Loading onVesselWasModified KSP event
            GameEvents.onVesselWasModified.Add(new EventData<Vessel>.OnEvent(this.OnVesselWasModified));
        }