Exemplo n.º 1
0
 public override void OnStart(StartState state)
 {
     base.OnStart(state);
     if (HighLogic.LoadedSceneIsFlight)
     {
         brazo1 = part.FindModelTransform("arm_01 (1)").gameObject;
         brazo2 = part.FindModelTransform("arm_01 (2)").gameObject;
         brazo1.SetActive(true);
         brazo2.SetActive(false);
         foreach (var ciencia in part.FindModulesImplementing <ModuleScienceExperiment>())
         {
             if (ciencia.experimentID == "taladro")
             {
                 tala = ciencia;
             }
             if (ciencia.experimentID == "mobileMaterialsLab")
             {
                 pre = ciencia;
             }
         }
         foreach (var anim in part.FindModulesImplementing <ModuleAnimateGeneric>())
         {
             if (anim.moduleID == "tala")
             {
                 taladro = anim;
             }
             if (anim.moduleID == "pre")
             {
                 presion = anim;
             }
         }
     }
 }
Exemplo n.º 2
0
        private void ArmGrapple(int index, TextMenu.Item ti)
        {
            ModuleGrappleNode thatClaw = null;

            foreach (PartModule thatModule in vessel.GetReferenceTransformPart().Modules)
            {
                thatClaw = thatModule as ModuleGrappleNode;
                if (thatClaw != null)
                {
                    break;
                }
            }

            if (thatClaw != null)
            {
                try
                {
                    ModuleAnimateGeneric clawAnimation = (vessel.GetReferenceTransformPart().Modules[thatClaw.deployAnimationController] as ModuleAnimateGeneric);
                    if (clawAnimation != null)
                    {
                        clawAnimation.Toggle();
                    }
                }
                catch (Exception e)
                {
                    JUtil.LogErrorMessage(this, "Exception trying to arm/disarm Grapple Node: {0}", e.Message);
                }
            }
        }
Exemplo n.º 3
0
    public override void OnStart(StartState state)
    {
        InflateAnim = part.Modules["ModuleAnimateGeneric"] as ModuleAnimateGeneric;
        if (InflateAnim == null)
        {
            Debug.Log("<color=#FF8C00ff>Comfortable Landing:</color>Animation Missing!");
        }

        audioSource = gameObject.AddComponent <AudioSource>();
        audioSource.bypassListenerEffects = true;
        audioSource.minDistance           = .3f;
        audioSource.maxDistance           = 1000;
        audioSource.priority     = 10;
        audioSource.dopplerLevel = 0;
        audioSource.spatialBlend = 1;
        playSound        = GameDatabase.Instance.GetAudioClip(playSoundPath);
        audioSource.clip = playSound;
        audioSource.loop = false;
        audioSource.time = 0;
        if (volume < 0)
        {
            volume = 0.0f;
        }
        else if (volume > 1)
        {
            volume = 1.0f;
        }
        audioSource.volume = volume;
    }
 /// <summary>
 /// Toggles thrust reversers
 /// </summary>
 /// <param name="state"></param>
 public void SetThrustReverser(bool state)
 {
     if (vessel != null)
     {
         RPMVesselComputer comp = RPMVesselComputer.Instance(vessel);
         for (int i = 0; i < comp.availableThrustReverser.Count; ++i)
         {
             ModuleAnimateGeneric thrustReverser = comp.availableThrustReverser[i].thrustReverser;
             if (thrustReverser != null)
             {
                 if (state)
                 {
                     if (thrustReverser.Progress < 0.5f && thrustReverser.CanMove && thrustReverser.aniState != ModuleAnimateGeneric.animationStates.MOVING)
                     {
                         thrustReverser.Toggle();
                     }
                 }
                 else
                 {
                     if (thrustReverser.Progress > 0.5f && thrustReverser.CanMove && thrustReverser.aniState != ModuleAnimateGeneric.animationStates.MOVING)
                     {
                         thrustReverser.Toggle();
                     }
                 }
             }
         }
     }
 }
Exemplo n.º 5
0
        public static bool IsOn(PartModule light)
        {
            switch (light.moduleName)
            {
            case "ModuleColorChanger":
            case "ModuleColorChangerConsumer":
                ModuleColorChanger castMCC = (ModuleColorChanger)light;
                return(castMCC.animState);

            case "ModuleLight":
            case "ModuleStockLightColoredLens":
            case "ModuleMultiPointSurfaceLight":
            case "ModuleColoredLensLight":
                ModuleLight castML = (ModuleLight)light;
                return(castML.isOn);

            case "ModuleAnimateGeneric":
            case "ModuleAnumateGenericConsumer":
                ModuleAnimateGeneric castMAG = (ModuleAnimateGeneric)light;
                return(!castMAG.animSwitch);

            case "WBILight":
                return((bool)light.GetType().InvokeMember("isDeployed", BindingFlags.GetField, null, light, null));

            case "ModuleKELight":
                return((bool)light.GetType().InvokeMember("isOn", BindingFlags.GetField, null, light, null));

            default:
                return(false);
            }
        }
        public void TurnAnimationOn()
        {
            //Turn on the docking lights if we have any
            if (dockingLight != null)
            {
                dockingLight.TurnOnLights();
                return;
            }

            //Legacy method of turning on docking lights.
            ModuleAnimateGeneric glowAnim = null;

            //Get our glow animation (if any)
            glowAnim = this.part.FindModuleImplementing <ModuleAnimateGeneric>();
            if (glowAnim == null)
            {
                return;
            }

            //Ok, now turn on our glow panel if it isn't already.
            if (glowAnim.Events["Toggle"].guiName == glowAnim.startEventGUIName)
            {
                glowAnim.Toggle();
            }
        }
Exemplo n.º 7
0
 public override void OnStart(StartState state)
 {
     Tools.LogFormatted("OnStart");
     foreach (ModuleDockingNode d in part.FindModulesImplementing <ModuleDockingNode>())
     {
         if (d.referenceAttachNode == referenceAttachNode)
         {
             dockingmodule = d;
             break;
         }
     }
     foreach (ModuleAnimateGeneric m in part.FindModulesImplementing <ModuleAnimateGeneric>())
     {
         if (m.animationName == animationName)
         {
             module = m;
             break;
         }
     }
     if (module != null)
     {
         GameEvents.onPartCouple.Add(onPartCouple);
         GameEvents.onPartUndock.Add(onPartUndock);
     }
 }
        public override void OnStart(PartModule.StartState state)
        {
            _antimatterDef = PartResourceLibrary.Instance.GetDefinition(InterstellarResourcesConfiguration.Instance.Antimatter);

            _moduleAnimateGeneric = part.FindModuleImplementing <ModuleAnimateGeneric>();

            powerReqKW = Math.Pow(collectionMultiplier, 0.9);

            if (state == StartState.Editor)
            {
                return;
            }

            _homeworld = FlightGlobals.fetch.bodies.First(m => m.isHomeWorld == true);

            if (last_active_time == 0 || !(vessel.orbit.eccentricity < 1) || !active || !canCollect)
            {
                return;
            }

            var vesselAvgAlt = (vessel.orbit.ApA + vessel.orbit.PeA) / 2;

            flux = collectionMultiplier * 0.5 * (vessel.mainBody.GetBeltAntiparticles(_homeworld, vesselAvgAlt, vessel.orbit.inclination) + vessel.mainBody.GetBeltAntiparticles(_homeworld, vesselAvgAlt, 0.0));
            var timeDiff = Planetarium.GetUniversalTime() - last_active_time;

            _offlineResource = timeDiff * flux;
        }
 public override void OnStart(StartState state)
 {
     deployAnimation = GetDeployAnimation();
     if (deployAnimation == null)
     {
         Log.warn("RetractableLiftingSurface can't find a deploy animation for: {0}", this.part.partInfo.title);
         Destroy(this);
         return;
     }
     controlSurface = GetControlSurface();
     lastAnimtime   = deployAnimation.animTime;
     if (controlSurface)
     {
         ignorePitch         = controlSurface.ignorePitch;
         ignoreRoll          = controlSurface.ignoreRoll;
         ignoreYaw           = controlSurface.ignoreYaw;
         maxCtrlSurfaceRange = controlSurface.ctrlSurfaceRange;
         if (!ignoreRoll)
         {
             ctrlSurfaceRange  = controlSurface.ctrlSurfaceRange;
             ctrlSurfaceActive = true;
         }
         else
         {
             ctrlSurfaceRange  = 0;
             ctrlSurfaceActive = false;
         }
     }
     base.OnStart(state);
 }
Exemplo n.º 10
0
        public override void OnUpdate()
        {
            opFloor = findAcceptableAltitude(vessel.mainBody); // Keep updating tooltip display.
            if (FlightGlobals.getGeeForceAtPosition(vessel.GetWorldPos3D()).magnitude <= gLimit)
            {
                Fields["neededEC"].guiActive = !activated;
            }
            Fields["constantEC"].guiActive = activated;
            ModuleAnimateGeneric MAG = part.FindModuleImplementing <ModuleAnimateGeneric>();

            MAG.Events["Toggle"].guiActive = false;
            if (activated && MAG.Progress == 0 && !MAG.IsMoving())
            {
                MAG.Toggle();
            }
            else if (!activated && MAG.Progress == 1 && !MAG.IsMoving())
            {
                MAG.Toggle();
            }
            double vfuel = 0;

            foreach (Part vpart in vessel.Parts)
            {
                foreach (PartResource vpr in vpart.Resources)
                {
                    if (vpr.resourceName == "Karborundum")
                    {
                        vfuel += vpr.amount;
                    }
                }
            }
            fuelOnBoard = vfuel;
        }
Exemplo n.º 11
0
        public override void OnStart(StartState state)
        {
            base.OnStart(state);
            if (!HighLogic.LoadedSceneIsFlight)
            {
                return;
            }

            //Setup recycle resource
            setupRecycleResource();

            animationModule = this.part.FindModuleImplementing <ModuleAnimateGeneric>();
            if (animationModule != null)
            {
                //Get the toggle event
                toggleEvent = Events["Toggle"];

                //Hide the recycler toggle
                Fields["recyclerToggle"].guiActive       = false;
                Fields["recyclerToggle"].guiActiveEditor = false;
            }
            else
            {
                //Show the recycler toggle
                Fields["recyclerToggle"].guiActive       = true;
                Fields["recyclerToggle"].guiActiveEditor = true;
            }
        }
Exemplo n.º 12
0
        public override void OnStart(PartModule.StartState state)
        {
            base.OnStart(state);
            enabled = false;

            ModuleAnimateGeneric module = part.FindModuleImplementing <ModuleAnimateGeneric>();

            if (module != null)
            {
                soundMoving      = gameObject.AddComponent <AudioSource>();
                soundMoving.clip = GameDatabase.Instance.GetAudioClip(fileMoving);
                soundStop        = gameObject.AddComponent <AudioSource>();
                soundStop.clip   = GameDatabase.Instance.GetAudioClip(fileStop);

                soundMoving.loop         = loopMoving;
                soundMoving.volume       = GameSettings.AMBIENCE_VOLUME;
                soundMoving.dopplerLevel = 0f;
                soundMoving.rolloffMode  = AudioRolloffMode.Logarithmic;
                soundMoving.minDistance  = 0.5f;
                soundMoving.maxDistance  = 1f;

                soundStop.loop         = false;
                soundStop.volume       = GameSettings.AMBIENCE_VOLUME;
                soundStop.dopplerLevel = 0f;
                soundStop.rolloffMode  = AudioRolloffMode.Logarithmic;
                soundStop.minDistance  = 0.5f;
                soundStop.maxDistance  = 1f;

                module.OnMoving.Add(new EventData <float, float> .OnEvent(OnMoving));
                module.OnStop.Add(new EventData <float> .OnEvent(OnStop));

                GameEvents.onGamePause.Add(Pause);
                GameEvents.onGameUnpause.Add(Unpause);
            }
        }
Exemplo n.º 13
0
        public override void OnStart(PartModule.StartState state)
        {
            onMoving = new EventData <float, float>("transmitterMoving");
            onStop   = new EventData <float>("transmitterStop");

            power_capacity = maximumPower * powerMult;

            if (String.IsNullOrEmpty(partId))
            {
                partId = Guid.NewGuid().ToString();
            }

            // store  aperture
            aperture = apertureDiameter;

            ConnectToBeamGenerator();

            if (state == StartState.Editor)
            {
                part.OnEditorAttach += OnEditorAttach;
                return;
            }

            genericAnimation = part.FindModulesImplementing <ModuleAnimateGeneric>().FirstOrDefault(m => m.animationName == animName);

            panels = vessel.FindPartModulesImplementing <ModuleDeployableSolarPanel>();

            vessel_recievers = this.vessel.FindPartModulesImplementing <MicrowavePowerReceiver>().Where(m => m.part != this.part).ToList();
            part_receiver    = part.FindModulesImplementing <MicrowavePowerReceiver>().FirstOrDefault();

            UpdateRelayWavelength();

            //ScreenMessages.PostScreenMessage("Microwave Transmitter Updated Wvelength", 10.0f, ScreenMessageStyle.UPPER_CENTER);

            anim = part.FindModelAnimators(animName).FirstOrDefault();
            if (anim != null && part_receiver == null)
            {
                anim[animName].layer = 1;
                if (IsEnabled)
                {
                    //ScreenMessages.PostScreenMessage("Microwave Transmitter Activates", 10.0f, ScreenMessageStyle.UPPER_CENTER);
                    anim[animName].normalizedTime = 0f;
                    anim[animName].speed          = 1f;
                }
                else
                {
                    //ScreenMessages.PostScreenMessage("Microwave Transmitter Deactivates", 10.0f, ScreenMessageStyle.UPPER_CENTER);
                    anim[animName].normalizedTime = 1f;
                    anim[animName].speed          = -1f;
                }
                //anim.Play();
                anim.Blend(animName, part.mass);
            }

            if (forceActivateAtStartup)
            {
                this.part.force_activate();
            }
            //ScreenMessages.PostScreenMessage("Microwave Transmitter Force Activated", 5.0f, ScreenMessageStyle.UPPER_CENTER);
        }
Exemplo n.º 14
0
        public ModuleAnimateGeneric customAnim;                     // Support to custom animation for ModuleDataTransmitter module

        public override void OnStart(StartState state)
        {
            base.OnStart(state);

            // don't break tutorial scenarios & do something only in Flight scenario
            if (Lib.DisableScenario(this) || !Lib.IsFlight())
            {
                return;
            }

            if (Features.Signal)
            {
                Antenna a = part.FindModuleImplementing <Antenna>();
                if (antennaPower == 0 && a != null)
                {
                    antennaPower = a.dist;
                }
            }
            else
            {
                ModuleDataTransmitter transmitter = part.FindModuleImplementing <ModuleDataTransmitter>();
                if (transmitter != null)
                {
                    antennaPower = new AntennaEC(part.FindModuleImplementing <ModuleDataTransmitter>(), extra_Cost, extra_Deploy, antennaPower).Init(antennaPower);
                }
            }

            // verify if is using custom animation for CommNet
            customAnim = part.FindModuleImplementing <ModuleAnimateGeneric>();
        }
 public void OnDestroy()
 {
     //free referenced modules
     extendAnimation = null;
     dockingNode     = null;
     anim            = null;
 }
Exemplo n.º 16
0
 protected void Start()
 {
     if (HighLogic.LoadedSceneIsFlight)
     {
         animator = (ModuleAnimateGeneric)part.Modules[AnimationModuleIndex];
     }
 }
        public void Update()
        {
            anim = part.FindModelAnimators(this.animationName)[0];
            if (anim[animationName].normalizedTime < 1f)
            {
                part.CrewCapacity = this.crewCapacityRetracted;
            }
            if (this.anim[this.animationName].normalizedTime == 1f)
            {
                base.part.CrewCapacity = this.crewCapacityDeployed;
            }
            ModuleAnimateGeneric moduleAnimateGeneric = (ModuleAnimateGeneric)base.part.GetComponent("ModuleAnimateGeneric");

            if (base.part.protoModuleCrew.Count > 0)
            {
                foreach (BaseEvent current in base.part.GetComponent <ModuleAnimateGeneric>().Events)
                {
                    if (current.guiName == moduleAnimateGeneric.endEventGUIName)
                    {
                        current.guiActive = false;
                    }
                }
            }
            else
            {
                foreach (BaseEvent current in base.part.GetComponent <ModuleAnimateGeneric>().Events)
                {
                    if (current.guiName == moduleAnimateGeneric.endEventGUIName)
                    {
                        current.guiActive = true;
                    }
                }
            }
            base.OnUpdate();
        }
        public override void OnStart(StartState state)
        {
            _liquidHydrogenDefinition   = PartResourceLibrary.Instance.GetDefinition(inputResourceName);
            _metallicHydrogenDefinition = PartResourceLibrary.Instance.GetDefinition(outputResourceName);

            if (state == StartState.Editor)
            {
                return;
            }

            if (!string.IsNullOrEmpty(loopingAnimationName))
            {
                _loopingAnimation = part.FindModulesImplementing <ModuleAnimateGeneric>().SingleOrDefault(m => m.animationName == loopingAnimationName);
            }

            _disabledText = Localizer.Format("#LOC_KSPIE_MetallicHydrogenFactory_disabled");

            Fields[nameof(isActive)].guiName = Localizer.Format(activateTitle);

            if (!isActive)
            {
                return;
            }

            var deltaTime = Planetarium.GetUniversalTime() - lastActiveTime;

            Produce(megajoulesPerSecond, deltaTime);
        }
        public override void OnStart(PartModule.StartState state)
        {
            onMoving = new EventData <float, float>("transmitterMoving");
            onStop   = new EventData <float>("transmitterStop");

            power_capacity = maximumPower * powerMult;

            if (String.IsNullOrEmpty(partId))
            {
                partId = Guid.NewGuid().ToString();
            }

            // store  aperture and diameter
            aperture = apertureDiameter;
            diameter = apertureDiameter;

            ConnectToBeamGenerator();

            if (state == StartState.Editor)
            {
                part.OnEditorAttach += OnEditorAttach;
                return;
            }

            genericAnimation = part.FindModulesImplementing <ModuleAnimateGeneric>().FirstOrDefault(m => m.animationName == animName);

            solarCells = vessel.FindPartModulesImplementing <ISolarPower>();

            vessel_recievers = this.vessel.FindPartModulesImplementing <BeamedPowerReceiver>().Where(m => m.part != this.part).ToList();
            part_receiver    = part.FindModulesImplementing <BeamedPowerReceiver>().FirstOrDefault();

            UpdateRelayWavelength();

            //anim = part.FindModelAnimators(animName).FirstOrDefault();
            //if ( anim != null &&  part_receiver == null)
            //{
            //    anim[animName].layer = 1;
            //    if (IsEnabled)
            //    {
            //        anim[animName].normalizedTime = 0;
            //        anim[animName].speed = 1;
            //    }
            //    else
            //    {
            //        anim[animName].normalizedTime = 1;
            //        anim[animName].speed = -1;
            //    }
            //    //anim.Play();
            //    anim.Blend(animName, part.mass);
            //}

            if (forceActivateAtStartup)
            {
                Debug.Log("[KSPI]: BeamedPowerTransmitter on " + part.name + " was Force Activated");
                this.part.force_activate();
            }
        }
Exemplo n.º 20
0
        public override void OnStart(StartState state)
        {
            Debug.Log(string.Format("{0} ModulePebkacLesPitchControl.OnStart", _myModTag));
            _pitchEngine     = GetPitchEngine();
            _deployAnimation = GetDeployAnimation();
            _liftingSurface  = GetLiftingSurface();

            base.OnStart(state);
        }
Exemplo n.º 21
0
 public override void OnStartFinished(StartState state)
 {
     base.OnStartFinished(state);
     animation = part.Modules.GetScalarModule(animationID) as ModuleAnimateGeneric;
     if (animation != null)
     {
     }
     SSTUMultiDockingPort.updateDockingModuleFieldNames(dock1, portName + "-1");
     SSTUMultiDockingPort.updateDockingModuleFieldNames(dock2, portName + "-2");
 }
Exemplo n.º 22
0
        public void PlayAnimation()
        {
            ModuleAnimateGeneric myAnimation = part.FindModulesImplementing <ModuleAnimateGeneric>().SingleOrDefault();

            if (!myAnimation)
            {
                return;
            }
            myAnimation.Toggle();
        }
Exemplo n.º 23
0
 internal CargoBay(Part part)
 {
     this.part = part;
     bay       = part.InternalPart.Module <ModuleCargoBay> ();
     animation = part.InternalPart.Module <ModuleAnimateGeneric> ();
     if (bay == null || animation == null)
     {
         throw new ArgumentException("Part is not a cargo bay");
     }
 }
Exemplo n.º 24
0
        public override void OnStart(StartState state)
        {
            // hook up to the part attach callback

            /*
             * if (state == StartState.Editor)
             * {
             *  part.OnEditorAttach += OnEditorAttach;
             * }
             */

            List <ModuleEngines> engines = part.FindModulesImplementing <ModuleEngines>();

            foreach (ModuleEngines e in engines)
            {
                if (e.engineID == escapeEngineID)
                {
                    escapeEngine = e;
                }
                else if (e.engineID == pitchEngineID)
                {
                    pitchEngine = e;
                }
                else if (e.engineID == jettisonEngineID)
                {
                    jettisonEngine = e;
                }
                foreach (BaseAction a in e.Actions)
                {
                    a.active = false;
                }
                foreach (BaseField f in e.Fields)
                {
                    f.guiActive       = false;
                    f.guiActiveEditor = false;
                }
                foreach (BaseEvent ev in e.Events)
                {
                    ev.guiActive       = false;
                    ev.guiActiveEditor = false;
                }
            }

            // check for nulls in engines

            // set up the variables used to shift aerodynamics
            _maxFuel       = part.Resources["SolidFuel"].maxAmount;
            _origComOffset = part.CoMOffset;
            _origCopOffset = part.CoPOffset;
            _origColOffset = part.CoLOffset;

            // set up the variables used by code for simming the canards
            _deployAnimation = GetDeployAnimation();
            _liftingSurface  = GetLiftingSurface();
        }
Exemplo n.º 25
0
    public override void OnStart(StartState state)
    {
        InflateAnim = part.Modules["ModuleAnimateGeneric"] as ModuleAnimateGeneric;
        if (InflateAnim == null)
        {
            Debug.Log("<color=#FF8C00ff>Comfortable Landing:</color>Animation Missing!");
        }

        DeflateTransform = base.part.FindModelTransform(DeflateTransformName);
        InflateTransform = base.part.FindModelTransform(InflateTransformName);

        audioSource = gameObject.AddComponent <AudioSource>();
        audioSource.bypassListenerEffects = true;
        audioSource.minDistance           = .3f;
        audioSource.maxDistance           = 1000;
        audioSource.priority     = 10;
        audioSource.dopplerLevel = 0;
        audioSource.spatialBlend = 1;
        inflateSound             = GameDatabase.Instance.GetAudioClip(inflateSoundPath);
        audioSource.clip         = inflateSound;
        audioSource.loop         = false;
        audioSource.time         = 0;
        if (volume < 0)
        {
            volume = 0.0f;
        }
        else if (volume > 1)
        {
            volume = 1.0f;
        }
        audioSource.volume = volume;

        audioSource2 = gameObject.AddComponent <AudioSource>();
        audioSource2.bypassListenerEffects = true;
        audioSource2.minDistance           = .3f;
        audioSource2.maxDistance           = 1000;
        audioSource2.priority     = 10;
        audioSource2.dopplerLevel = 0;
        audioSource2.spatialBlend = 1;
        deflateSound      = GameDatabase.Instance.GetAudioClip(deflateSoundPath);
        audioSource2.clip = deflateSound;
        audioSource2.loop = false;
        audioSource2.time = 0;
        if (volume2 < 0)
        {
            volume2 = 0.0f;
        }
        else if (volume2 > 1)
        {
            volume2 = 1.0f;
        }
        audioSource.volume = volume2;

        originalCrashTolerance = this.part.crashTolerance;
    }
Exemplo n.º 26
0
        public override void OnStart(StartState state)
        {
            List <ModuleEngines> engines = part.FindModulesImplementing <ModuleEngines>();

            foreach (ModuleEngines e in engines)
            {
                if (e.engineID == _escapeEngineID)
                {
                    _escapeEngine = e;
                }
                else if (e.engineID == _pitchEngineID)
                {
                    _pitchEngine = e;
                }
                else if (e.engineID == _jettisonEngineID)
                {
                    _jettisonEngine = e;
                }
                foreach (BaseAction a in e.Actions)
                {
                    a.active = false;
                }
                foreach (BaseField f in e.Fields)
                {
                    f.guiActive       = false;
                    f.guiActiveEditor = false;
                }
                foreach (BaseEvent ev in e.Events)
                {
                    ev.guiActive       = false;
                    ev.guiActiveEditor = false;
                }
            }

            if (hasPitchControl)
            {
                // set up the variables used to shift aerodynamics
                _maxFuel       = part.Resources["SolidFuel"].maxAmount;
                _origComOffset = part.CoMOffset;
                _origColOffset = part.CoLOffset;

                // set up the variables used by code for simming the canards
                _deployAnimation = GetDeployAnimation();
                _liftingSurface  = GetLiftingSurface();
            }

            // get the decoupler
            _lesDecoupler = part.FindModuleImplementing <ModuleDecouple>();

            if (_lesDecoupler == null)
            {
                Debug.LogError(string.Format("{0}: {1}: {2}", _myModTag, part.name, "Did not find a decoupler on the LES!"));
            }
        }
        void retract()
        {
            ModuleAnimateGeneric aModuleAnimateGeneric = new ModuleAnimateGeneric();

            aModuleAnimateGeneric = part.Modules.OfType <ModuleAnimateGeneric>().FirstOrDefault();

            if (aModuleAnimateGeneric.Events["Toggle"].guiName == "Retract" && aModuleAnimateGeneric.Events["Toggle"].guiActive == true)
            {
                aModuleAnimateGeneric.Toggle();
            }
        }
Exemplo n.º 28
0
        public AnimationWrapper(ModuleAnimateGeneric mod, PlayDirection direction) : this(direction)
        {
            Animation[] partAnims = mod.part.FindModelAnimators(mod.animationName);

            if (partAnims.Length > 0)
            {
                this.module         = mod;
                this.animation      = partAnims[0];
                this.animationState = this.animation[mod.animationName];
                this.stateName      = mod.animationName;
            }
        }
Exemplo n.º 29
0
        internal DockingPort(Part part)
        {
            Part = part;
            var internalPart = part.InternalPart;

            port   = internalPart.Module <ModuleDockingNode> ();
            shield = internalPart.Module <ModuleAnimateGeneric> ();
            if (port == null)
            {
                throw new ArgumentException("Part is not a docking port");
            }
        }
Exemplo n.º 30
0
        public override void OnStart(StartState state)
        {
            base.OnStart(state);

            animation = this.part.FindModuleImplementing <ModuleAnimateGeneric>();
            engine    = this.part.FindModuleImplementing <ModuleEngines>();

            if (animation == null || engine == null)
            {
                return;
            }
        }
        public AnimationWrapper(ModuleAnimateGeneric mod, PlayDirection direction)
            : this(direction)
        {
            Animation[] partAnims = mod.part.FindModelAnimators(mod.animationName);

            if (partAnims.Length > 0)
            {
                this.module = mod;
                this.animation = partAnims[0];
                this.animationState = this.animation[mod.animationName];
                this.stateName = mod.animationName;
            }
        }
 /// <summary>
 /// Handle default action groups when we have a part that we want with an animation module that we want.
 /// </summary>
 /// <param name="part">The part whose action groups we need to handle.</param>
 /// <param name="animationModule">The animation whose action we need to add to the appropriate action group.</param>
 /// <param name="defaultActionGroupModule">The ModuleDefaultActionGroup that tells us which action to add to which group.</param>
 private static void handleDefaultGroupsForAnimationModule(
     Part part,
     ModuleAnimateGeneric animationModule,
     ModuleDefaultActionGroup defaultActionGroupModule)
 {
     // ModuleAnimateGeneric needs special handling. If we just ask its actions about their guiName, they'll
     // give a name that's not actually displayed in the editor. So for this case, we ask the module itself
     // for its action GUI name.
     if (animationModule.actionGUIName == defaultActionGroupModule.actionGuiName)
     {
         foreach (BaseAction action in animationModule.Actions)
         {
             Logging.Log("Updating action groups for animation '" + animationModule.actionGUIName + "', "
                 + part.name + "/" + animationModule.moduleName + "/" + action.name + ":" + action.guiName
                 + " to include " + defaultActionGroupModule.defaultActionGroup);
             action.actionGroup |= defaultActionGroupModule.defaultActionGroup;
             action.defaultActionGroup |= defaultActionGroupModule.defaultActionGroup;
         }
     }
 }
        /// <summary>
        /// Startup - look for the first ModuleAnimateGeneric.  Keep a
        /// reference to it.
        /// </summary>
        public void Start()
        {
            if (HighLogic.LoadedSceneIsFlight)
            {
                foreach (var module in part.Modules)
                {
                    if (module is ModuleAnimateGeneric)
                    {
                        thrustReverser = module as ModuleAnimateGeneric;
                        JUtil.LogMessage(this, "Found my thrust reverser");
                        break;
                    }
                }

                if (thrustReverser == null)
                {
                    isEnabled = false;
                }
            }
        }
Exemplo n.º 34
0
        public override void OnStart(StartState state)
        {
            base.OnStart(state);
            if (state == StartState.Editor)
                return;

            opticsAnimate = GetComponent<ModuleAnimateGeneric>();
            if (opticsAnimate == null && !smallApertureOpen)
            {
                isFunctional = false;
                Events["OpenSmallAperture"].active = true;
            }

            if (isDamaged)
            {
                isFunctional = false;
                Events["FixScope"].active = true;
            }

            fullRect = new Rect(0, 0, Screen.width, Screen.height);
            smallRect = new Rect(0, 0, 160, 160 / FlightCamera.fetch.mainCamera.aspect);

            skyboxRenderers = (from Renderer r in (FindObjectsOfType(typeof(Renderer)) as IEnumerable<Renderer>) where (r.name == "XP" || r.name == "XN" || r.name == "YP" || r.name == "YN" || r.name == "ZP" || r.name == "ZN") select r).ToArray<Renderer>();
            scaledSpaceFaders = FindObjectsOfType(typeof(ScaledSpaceFader)) as ScaledSpaceFader[];

            print("CactEye: Creating camera modules...");
            camTrans = part.FindModelTransform(camTransformName);
            CreateCamera("Camera ScaledSpace");
            CreateCamera("Camera VE Underlay");
            CreateCamera("Camera VE Overlay");
            CreateCamera("Camera 01");
            CreateCamera("Camera 00");
            print("CactEye: Finished creating " + cameras.Count + " cameras");

            outputTex = new Texture2D(160, (int)(smallRect.height));
            outputTex.wrapMode = TextureWrapMode.Clamp;
            fullTex = new Texture2D(Screen.width, Screen.height);
            fullTex.wrapMode = TextureWrapMode.Clamp;
            rtLow = new RenderTexture(160, (int)(smallRect.height), 24, RenderTextureFormat.RGB565, RenderTextureReadWrite.sRGB);
            rtLow.Create();
            rtFull = new RenderTexture(Screen.width, Screen.height, 24, RenderTextureFormat.ARGB32, RenderTextureReadWrite.sRGB);
            rtFull.Create();
        }
        public override void OnStart(StartState state)
        {
            // hook up to the part attach callback
            /*
            if (state == StartState.Editor)
            {
                part.OnEditorAttach += OnEditorAttach;
            }
            */

            List<ModuleEngines> engines = part.FindModulesImplementing<ModuleEngines>();
            foreach (ModuleEngines e in engines)
            {
                if (e.engineID == escapeEngineID)
                {
                    escapeEngine = e;
                }
                else if (e.engineID == pitchEngineID)
                {
                    pitchEngine = e;
                }
                else if (e.engineID == jettisonEngineID)
                {
                    jettisonEngine = e;
                }
                foreach (BaseAction a in e.Actions)
                {
                    a.active = false;
                }
                foreach (BaseField f in e.Fields)
                {
                    f.guiActive = false;
                    f.guiActiveEditor = false;
                }
                foreach (BaseEvent ev in e.Events)
                {
                    ev.guiActive = false;
                    ev.guiActiveEditor = false;
                }
            }

            // check for nulls in engines

            // set up the variables used to shift aerodynamics
            _maxFuel = part.Resources["SolidFuel"].maxAmount;
            _origComOffset = part.CoMOffset;
            _origCopOffset = part.CoPOffset;
            _origColOffset = part.CoLOffset;

            // set up the variables used by code for simming the canards
            _deployAnimation = GetDeployAnimation();
            _liftingSurface = GetLiftingSurface();
        }
Exemplo n.º 36
0
 public override void OnStart(StartState st)
 {
     base.OnStart(st);
     anim = this.part.FindModuleImplementing<ModuleAnimateGeneric>();
     GameEvents.onVesselWasModified.Add(OnVesselWasModified);
 }
Exemplo n.º 37
0
        /*
         * Function name: OnStart
         * Purpose: This overrides the OnStart functionality. This function will be called once
         * at the start of the game directly after a scene load. In this case, the function will
         * instatiate the GUI.
         */
        public override void OnStart(StartState state)
        {
            if (!IsSmallOptics)
            {
                //tie-in with Firespitter.
                opticsAnimate = GetComponent<ModuleAnimateGeneric>();
            }
            else if (IsSmallOptics && !SmallApertureOpen)
            {
                Events["OpenSmallAperture"].active = true;
            }

            //Attempt to instantiate the GUI
            Transform temp = part.FindModelTransform(CameraTransformName);
            try
            {
                TelescopeControlMenu = new TelescopeMenu(temp);
            }
            catch (Exception E)
            {
                //Error = true;
                Debug.Log("CactEye 2: Exception 1:  Was not able to create the Telescope Control Menu object. You should try re-installing CactEye2 and ensure that old versions of CactEye are deleted.");
                Debug.Log(E.ToString());
                Debug.Log(temp.ToString());
            }

            if (IsSmallOptics && SmallApertureOpen && !IsDamaged)
            {
                IsFunctional = true;
            }

            if (CactEyeConfig.DebugMode)
            {
                Debug.Log("CactEye 2: Debug: SmallApertureOpen is " + SmallApertureOpen.ToString());
                Debug.Log("CactEye 2: Debug: IsSmallOptics is " + IsSmallOptics.ToString());
                Debug.Log("CactEye 2: Debug: IsFunctional is " + IsFunctional.ToString());
                Debug.Log("CactEye 2: Debug: IsDamaged is " + IsDamaged.ToString());
            }
        }
Exemplo n.º 38
0
 /// <summary>Grabs instance of MAG.</summary>
 /// <remarks>MAG loves being grabbed. You must grab MAG whenever possible.</remarks>
 public void SetupAnimation()
 {
     retractionAnimation = part.FindModulesImplementing<ModuleAnimateGeneric>().SingleOrDefault();
 }
		/*
		 * Methods
		 * */
		// Runs when each new part is started.
		public override void OnStart(StartState st)
		{
			this.dockingNodeModule = (ModuleDockingNode)base.part.Modules["ModuleDockingNode"];

			PartModule needle;

			for (int idx = 0; idx < base.part.Modules.Count; idx++)
			{
				needle = base.part.Modules[idx];

				if (needle is ModuleAnimateGeneric)
				{
					if (((ModuleAnimateGeneric)needle).animationName == this.deployAnimationControllerName)
					{
						this.deployAnimation = (ModuleAnimateGeneric)needle;
						break;
					}
				}
			}

			// If we've loaded a deployAnimationControllerName from the cfg...

			// Start the underlying ModuleDockingNode.
			base.OnStart(st);

			ModuleDockingNode prefabModule = PartLoader.getPartInfoByName(this.part.partInfo.name)
				.partPrefab.getFirstModuleOfType<ModuleDockingNode>();

			TweakableTools.InitializeTweakable<ModuleTweakableDockingNode>(
				this.Fields["acquireRange"].uiControlCurrent(),
				ref this.acquireRange,
				ref this.dockingNodeModule.acquireRange,
				prefabModule.acquireRange
			);

			TweakableTools.InitializeTweakable<ModuleTweakableDockingNode>(
				this.Fields["acquireForce"].uiControlCurrent(),
				ref this.acquireForce,
				ref this.dockingNodeModule.acquireForce,
				prefabModule.acquireForce
			);

			TweakableTools.InitializeTweakable<ModuleTweakableDockingNode>(
				this.Fields["acquireTorque"].uiControlCurrent(),
				ref this.acquireTorque,
				ref this.dockingNodeModule.acquireTorque,
				prefabModule.acquireForce
			);

			TweakableTools.InitializeTweakable<ModuleTweakableDockingNode>(
				this.Fields["undockEjectionForce"].uiControlCurrent(),
				ref this.undockEjectionForce,
				ref this.dockingNodeModule.undockEjectionForce,
				prefabModule.undockEjectionForce
			);

			TweakableTools.InitializeTweakable<ModuleTweakableDockingNode>(
				this.Fields["minDistanceToReEngage"].uiControlCurrent(),
				ref this.minDistanceToReEngage,
				ref this.dockingNodeModule.minDistanceToReEngage,
				prefabModule.minDistanceToReEngage
			);

			this.Fields["maxRollAngle"].uiControlFlight.controlEnabled = false;

			this.maxRollAngle = Mathf.Acos(this.minRollDotProduct) * 180f / Mathf.PI;
			this.dockingNodeModule.acquireMinRollDot = this.minRollDotProduct * this.minRollDotProduct;
			this.dockingNodeModule.captureMinRollDot = this.minRollDotProduct;

			this.lastMaxRollAngle = this.maxRollAngle;

			// If we have a tweakable AttachNode, use it.
			if (this.TDNnodeName != string.Empty)
			{
				this.attachNode = base.part.findAttachNode(this.TDNnodeName);
			}

			base.part.attachRules.allowStack = this.IsOpen | this.AlwaysAllowStack;

			this.dockingNodeModule.Events["EnableXFeed"].guiActive = false;
			this.dockingNodeModule.Events["DisableXFeed"].guiActive = false;

			this.dockingNodeModule.Events["EnableXFeed"].guiActiveEditor = false;
			this.dockingNodeModule.Events["DisableXFeed"].guiActiveEditor = false;

			this.dockingNodeModule.Events["EnableXFeed"].active = false;
			this.dockingNodeModule.Events["DisableXFeed"].active = false;

			/* @subclass
			ModuleStagingToggle stagingToggleModule;

			if (this.part.tryGetFirstModuleOfType<ModuleStagingToggle>(out stagingToggleModule))
			{
				stagingToggleModule.OnToggle += new ModuleStagingToggle.ToggleEventHandler(this.OnStagingToggle);
			}
			*/

			// Yay debugging!
			this.LogDebug(
				"{0}: Started with assembly version {4}." +
				"\n\tdeployAnimationModule={1}, attachNode={2}, TDNnodeName={3}, attachedPart={5}, fuelCrossFeed={6}",
				this.GetType().Name,
				this.deployAnimation,
				this.attachNode,
				this.TDNnodeName,
				this.GetType().Assembly.GetName().Version,
				this.attachedPart
			);
		}
 /// <summary>
 /// Tear down - null our reference to thrustReverser.
 /// </summary>
 public void OnDestroy()
 {
     thrustReverser = null;
 }