コード例 #1
0
 public override void OnStart(StartState st)
 {
     base.OnStart(st);
     //initialize Animator
     animator = part.GetAnimator(AnimatorID);
     if(Fixed && animator is HangarAnimator) animator.Open();
     //initialize Fixed state
     StartCoroutine(delayed_disable_decoupling());
 }
コード例 #2
0
        public override void OnStart(StartState state)
        {
            //base OnStart
            base.OnStart(state);
            if (state == StartState.None)
            {
                return;
            }
            //setup hangar name
            if (HangarName == "_none_")
            {
                HangarName = part.partInfo.title;
            }
            //initialize resources
            if (state != StartState.Editor)
            {
                update_resources();
            }
            //initialize Animator
            part.force_activate();
            hangar_gates = part.Modules.OfType <BaseHangarAnimator>().FirstOrDefault(m => m.AnimatorID == AnimatorID);
            if (hangar_gates == null)
            {
                hangar_gates = new BaseHangarAnimator();
                Utils.Log("Using BaseHangarAnimator");
            }
            else
            {
                Events["Open"].guiActiveEditor  = true;
                Events["Close"].guiActiveEditor = true;
            }
            //recalculate volume and mass, start updating labels
            Setup();
            StartCoroutine(UpdateStatus());
            //store packed constructs if any
            if (packed_constructs.Count > 0)
            {
                StartCoroutine(store_constructs());
            }
            //set vessel type
            EditorLogic el = EditorLogic.fetch;

            if (el != null)
            {
                vessel_type = el.editorType == EditorLogic.EditorMode.SPH ? VesselType.SPH : VesselType.VAB;
            }
        }
コード例 #3
0
ファイル: HangarMachinery.cs プロジェクト: pjslauta/hangar
 protected virtual void early_setup(StartState state)
 {
     EditorLogic el = EditorLogic.fetch;
     if(el != null)
     {
         //set vessel type
         facility = el.ship.shipFacility;
         //prevent triggers to catch raycasts
         if(Trigger != string.Empty)
         {
             var triggers = part.FindModelComponents<Collider>(Trigger);
             foreach(var c in triggers) c.gameObject.layer = 21; //Part Triggers
         }
     }
     //setup hangar name
     if(HangarName == "_none_") HangarName = part.Title();
     //initialize resources
     if(state != StartState.Editor) update_resources();
     //initialize Animator
     hangar_gates = part.GetAnimator(AnimatorID);
     if(hangar_gates as HangarAnimator == null)
     {
         Events["Open"].active = false;
         Events["Close"].active = false;
     }
     if(EnergyConsumption > 0)
         socket = part.CreateSocket();
     //get docking ports that are inside hangar sapace
     var docks = part.Modules.OfType<ModuleDockingNode>().ToList();
     foreach(var d in CheckDockingPorts.Split(new []{' '}, StringSplitOptions.RemoveEmptyEntries))
         docks_checklist.AddRange(docks.Where(m => m.referenceAttachNode == d));
     //get all passages in the vessel
     passage_checklist = part.AllModulesOfType<HangarPassage>();
 }
コード例 #4
0
ファイル: Hangar.cs プロジェクト: kevin-ye/hangar
 public override void OnStart(StartState state)
 {
     //base OnStart
     base.OnStart(state);
     if(state == StartState.None) return;
     //setup hangar name
     if(HangarName == "_none_") HangarName = part.partInfo.title;
     //initialize resources
     if(state != StartState.Editor) update_resources();
     //initialize Animator
     part.force_activate();
     hangar_gates = part.Modules.OfType<BaseHangarAnimator>().FirstOrDefault(m => m.AnimatorID == AnimatorID);
     if (hangar_gates == null)
     {
         hangar_gates = new BaseHangarAnimator();
         Utils.Log("Using BaseHangarAnimator");
     }
     else
     {
         Events["Open"].guiActiveEditor = true;
         Events["Close"].guiActiveEditor = true;
     }
     //recalculate volume and mass, start updating labels
     Setup();
     StartCoroutine(UpdateStatus());
     //store packed constructs if any
     if(packed_constructs.Count > 0) StartCoroutine(store_constructs());
     //set vessel type
     EditorLogic el = EditorLogic.fetch;
     if(el != null) vessel_type = el.editorType == EditorLogic.EditorMode.SPH ? VesselType.SPH : VesselType.VAB;
 }
コード例 #5
0
 public override void OnStart(StartState state)
 {
     base.OnStart(state);
     socket = part.CreateSocket();
     //get other converters
     if(AnimatorID != "_none_")
         other_converters.AddRange(from c in part.Modules.OfType<AnimatedConverterBase>()
                                   where c != this && c.AnimatorID == AnimatorID select c);
     //initialize Animator
     emitter = part.FindModelComponents<KSPParticleEmitter>().FirstOrDefault();
     if(emitter != null)
     {
         base_emission[0] = emitter.minEmission;
         base_emission[1] = emitter.maxEmission;
     }
     animator = part.GetAnimator(AnimatorID);
     var an = animator as HangarAnimator;
     if(an != null) base_animation_speed = an.ForwardSpeed;
     //initialize sound
     if(Sound != string.Empty)
     {
         Utils.createFXSound(part, fxSound, Sound, true, MaxDistance);
         fxSound.audio.volume = GameSettings.SHIP_VOLUME * MaxVolume;
     }
     //setup GUI fields
     Fields["Temperature"].guiActive       = HeatProduction > 0;
     Fields["CurrentEnergyDemand"].guiName = Title+" Uses";
     Fields["Rate"].guiName                = Title+" Rate";
     Events["StartConversion"].guiName     = StartEventGUIName+" "+Title;
     Events["StopConversion"].guiName      = StopEventGUIName+" "+Title;
     Actions["ToggleConversion"].guiName   = ActionGUIName+" "+Title;
     //update state
     update_energy_demand();
     update_events();
     StartCoroutine(slow_update());
 }