Beispiel #1
0
 public override void OnStart(StartState state)
 {
     base.OnStart(state);
     //get grapple transforms
     foreach (var grapple in Utils.ParseLine(GrappleTransforms, Utils.Whitespace))
     {
         grapple_transforms.AddRange(part.FindModelTransforms(grapple));
     }
     //initialize animators
     armAnimator = part.GetAnimator <MultiAnimator>(ArmAnimatorID);
     fixAnimator = part.GetAnimator <MultiAnimator>(FixAnimatorID);
     if (IsDocked)
     {
         var dockedPart = vessel[dockedPartUId];
         if (dockedPart == part.parent)
         {
             setup_grapple_node(dockedPart, part);
         }
         else
         {
             setup_grapple_node(dockedPart, dockedPart);
         }
     }
     else if (this.state > State.Armed)
     {
         this.state = State.Armed;
     }
     if (this.state != State.Idle)
     {
         if (armAnimator != null)
         {
             armAnimator.Open();
         }
     }
     if (this.state == State.Fixed)
     {
         if (fixAnimator != null)
         {
             fixAnimator.Open();
         }
     }
     update_part_menu();
     //initialize socket
     if (GrappleEnergyConsumption > 0)
     {
         socket = part.CreateSocket();
     }
 }
 protected override void early_setup(StartState state)
 {
     SpawnSpaceSensor = false;
     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 == null)
         {
             this.Log("ModuleSave is null. THIS SHOULD NEVER HAPPEN!"); return;
         }
         var node = ModuleSave.GetNode(SwitchableTankManager.NODE_NAME) ??
                    new ConfigNode(SwitchableTankManager.NODE_NAME);
         tank_manager.Load(node);
         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.Tanks
                             .Aggregate(0f, (m, t) =>
                                        m + (metal_for_hull(t.Volume) + metal_for_tank(t.TankType, t.Volume)) *
                                        metal_pump.Resource.density);
             }
         }
     }
 }
 public void Init(Part p)
 {
     part = p; socket = p.CreateSocket();
 }