コード例 #1
0
 public override void OnStart(StartState state)
 {
     base.OnStart(state);
     entrance = part.GetPassage();
     if(entrance == null) return;
     passage_checklist = part.AllModulesOfType<HangarPassage>();
     resource = this.GetResourceDef(OutputResource);
     if(resource == null) return;
     pump = new ResourcePump(part, resource.id);
     StartCoroutine(delayed_update_state());
 }
コード例 #2
0
 public GasCompressor(Part p)
 {
     part = p; socket = p.CreateSocket();
 }
コード例 #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
 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());
 }
コード例 #5
0
ファイル: HangarAnimator.cs プロジェクト: pjslauta/hangar
 public override void OnStart(StartState state)
 {
     base.OnStart(state);
     if(State == AnimatorState.Opened) progress = 1f;
     setup_animation();
     seek(progress);
     if(EnergyConsumption > 0)
         socket = part.CreateSocket();
     //GUI
     Events["OpenEvent"].guiName     = OpenEventGUIName;
     Events["CloseEvent"].guiName    = CloseEventGUIName;
     Actions["ToggleAction"].guiName = ActionGUIName;
     Fields["StopTime"].guiName      = StopTimeGUIName;
     update_events();
 }
コード例 #6
0
 protected override void early_setup(StartState state)
 {
     base.early_setup(state);
     Fields["hangar_v"].guiActive = true;
     Fields["hangar_d"].guiActive = true;
     max_side = Mathf.Pow(TotalVolume, 1f/3);
     //init tank manager
     if(HasTankManager)
     {
         tank_manager = new SwitchableTankManager(this);
         if(ModuleSave.HasNode(SwitchableTankManager.NODE_NAME))
             tank_manager.Load(ModuleSave.GetNode(SwitchableTankManager.NODE_NAME));
         Events["EditTanks"].active = true;
         if(BuildTanksFrom != string.Empty)
         {
             metal_pump = new ResourcePump(part, BuildTanksFrom);
             if(!metal_pump.Valid) metal_pump = null;
             else if(TanksMass <= 0)
                 TanksMass = tank_manager.TanksVolumes
                     .Aggregate(0f, (m, v) => m+metal_for_tank(v)*metal_pump.Resource.density);
         }
     }
 }