public PartCamera(Part thisPart, string resourceScanning, string bName, int hits, string rotZ, string rotY, string _zoommer, float _stepper, string cameraName, int _allowedScanDistance, int windowSize, bool isOnboard, bool isLookAtMe, bool isLookAtMeAutoZoom, bool isFollowMe, bool isTargetCam, float isFollowMeOffsetX, float isFollowMeOffsetY, float isFollowMeOffsetZ, float targetOffset, string windowLabel = "Camera") : base(thisPart, (float)windowSize, windowLabel)
        {
            List <string> list = resourceScanning.Split(new char[]
            {
                '.'
            }).ToList <string>();

            resourceName        = list[0];
            resourceUsage       = int.Parse(list[1]);
            bulletName          = bName;
            rotatorZ            = GameObjectExtension.GetChild(partGameObject.gameObject, rotZ);
            rotatorY            = GameObjectExtension.GetChild(partGameObject.gameObject, rotY);
            zoommer             = GameObjectExtension.GetChild(partGameObject.gameObject, _zoommer);
            camObject           = GameObjectExtension.GetChild(partGameObject.gameObject, cameraName);
            stepper             = _stepper;
            allowedScanDistance = _allowedScanDistance;
            lastZoom            = CurrentZoom;
            IsOnboard           = isOnboard;
            IsLookAtMe          = isLookAtMe;
            IsFollowMe          = isFollowMe;
            IsLookAtMeAutoZoom  = isLookAtMeAutoZoom;
            IsTargetCam         = isTargetCam;
            IsFollowMeOffsetX   = isFollowMeOffsetX;
            IsFollowMeOffsetY   = isFollowMeOffsetY;
            IsFollowMeOffsetZ   = isFollowMeOffsetZ;
            TargetOffset        = targetOffset;
            GameEvents.onGameSceneLoadRequested.Add(new EventData <GameScenes> .OnEvent(LevelWasLoaded));
            GetCurrentBullets(bName, hits);
        }
 private void GetCurrentBullets(string bulletName, int hits)
 {
     if (hits == -1)
     {
         Hits = 0;
         while (true)
         {
             GameObject child = GameObjectExtension.GetChild(partGameObject, string.Format("{0}{1:000}", bulletName, Hits + 1));
             if (child == null)
             {
                 break;
             }
             Hits++;
         }
     }
     else
     {
         Hits = hits;
         int num = Hits + 1;
         while (true)
         {
             GameObject child2 = GameObjectExtension.GetChild(partGameObject, string.Format("{0}{1:000}", bulletName, num));
             if (child2 == null)
             {
                 break;
             }
             GameObject.Destroy(child2);
             num++;
         }
     }
 }
Пример #3
0
 public override void OnStart(PartModule.StartState state)
 {
     if (camera != null)
     {
         return;
     }
     camera                         = new PartCamera(base.part, resourceScanning, bulletName, _currentHits, rotatorZ, rotatorY, zoommer, stepper, cameraName, allowedScanDistance, windowSize, isOnboard, isLookAtMe, isLookAtMeAutoZoom, isFollowMe, isTargetCam, _isFollowMeOffsetX, _isFollowMeOffsetY, _isFollowMeOffsetZ, _targetOffset, "Camera");
     capObject                      = GameObjectExtension.GetChild(base.part.gameObject, cap);
     camObject                      = GameObjectExtension.GetChild(base.part.gameObject, cameraName);
     initialUpVector                = camObject.transform.up;
     camera.InitialCamRotation      = (camera.CurrentCamRotation = camObject.transform.rotation);
     camera.InitialCamPosition      = (camera.CurrentCamPosition = camObject.transform.position);
     camera.InitialCamLocalRotation = (camera.CurrentCamLocalRotation = camObject.transform.localRotation);
     camera.InitialCamLocalPosition = (camera.CurrentCamLocalPosition = camObject.transform.localPosition);
 }
 public DockingCamera(Part thisPart, bool noise, bool crossDPAI, bool crossOLDD, int windowSize, string windowLabel = "DockCam") : base(thisPart, (float)windowSize, windowLabel)
 {
     GameEvents.onGameSceneLoadRequested.Add(new EventData <GameScenes> .OnEvent(LevelWasLoaded));
     Noise                       = noise;
     TargetCrossDPAI             = crossDPAI;
     TargetCrossOLDD             = crossOLDD;
     target                      = new TargetHelper(thisPart);
     moduleDockingNodeGameObject = (GameObjectExtension.GetChild(partGameObject, "dockingNode") ?? partGameObject);
     if (DockingCamera.textureWhiteNoise != null || !Noise)
     {
         return;
     }
     DockingCamera.textureWhiteNoise = new List <Texture2D> [3];
     for (int i = 0; i < 3; i++)
     {
         DockingCamera.textureWhiteNoise[i] = new List <Texture2D>();
         for (int j = 0; j < 4; j++)
         {
             DockingCamera.textureWhiteNoise[i].Add(Util.WhiteNoiseTexture((int)texturePosition.width, (int)texturePosition.height, 0.16f));
         }
     }
 }
 private void DrawButtonsBlock(float widthOffset)
 {
     if (GUI.Button(new Rect(widthOffset, 36f, 25f, 25f), "↻"))
     {
         camObject.transform.Rotate(new Vector3(0f, 0f, 180f));
         isUpsideDown = !isUpsideDown;
     }
     if (GUI.RepeatButton(new Rect(widthOffset + 25f, 36f, 25f, 25f), "↑"))
     {
         if (!isUpsideDown)
         {
             if (rotateYbuffer < 180f)
             {
                 RotateY += rotateStep;
             }
         }
         else
         {
             if (rotateYbuffer > 0)
             {
                 RotateY -= rotateStep;
             }
         }
     }
     if (GUI.Button(new Rect(widthOffset + 50f, 36f, 25f, 25f), "⦿"))
     {
         if (part.vessel.Equals(FlightGlobals.ActiveVessel))
         {
             if (!TargetHelper.IsTargetSelect)
             {
                 ScreenMessages.PostScreenMessage("No target for scanning", 3f, 0);
             }
             else
             {
                 if (Hits <= 0)
                 {
                     ScreenMessages.PostScreenMessage("Bullets depleted", 3f, 0);
                 }
                 else
                 {
                     int    id = PartResourceLibrary.Instance.GetDefinition(resourceName).id;
                     double num;
                     double num2;
                     part.GetConnectedResourceTotals(id, out num, out num2, true);
                     if (num > (double)resourceUsage)
                     {
                         part.RequestResource(id, (float)resourceUsage);
                         GameObject child = GameObjectExtension.GetChild(partGameObject, string.Format("{0}{1:000}", bulletName, Hits));
                         GameObject.Destroy(child);
                         Hits--;
                         isRayEnabled      = true;
                         IsWaitForRay      = true;
                         isScienceActivate = false;
                     }
                     else
                     {
                         ScreenMessages.PostScreenMessage("Not enough electricity for scan", 3f, 0);
                     }
                 }
             }
         }
         else
         {
             ScreenMessages.PostScreenMessage("Camera not on active vessel", 3f, 0);
         }
     }
     if (GUI.RepeatButton(new Rect(widthOffset, 61f, 25f, 25f), "←"))
     {
         if (!isUpsideDown)
         {
             RotateZ -= rotateStep;
         }
         else
         {
             RotateZ += rotateStep;
         }
     }
     if (GUI.Button(new Rect(widthOffset + 25f, 61f, 25f, 25f), "o"))
     {
         IsToZero = true;
     }
     if (GUI.RepeatButton(new Rect(widthOffset + 50f, 61f, 25f, 25f), "→"))
     {
         if (!isUpsideDown)
         {
             RotateZ += rotateStep;
         }
         else
         {
             RotateZ -= rotateStep;
         }
     }
     if (GUI.RepeatButton(new Rect(widthOffset, 86f, 25f, 25f), "-"))
     {
         CurrentZoom += 0.5f;
         if (CurrentZoom > MaxZoom)
         {
             CurrentZoom = MaxZoom;
         }
     }
     if (GUI.RepeatButton(new Rect(widthOffset + 25f, 86f, 25f, 25f), "↓"))
     {
         if (!isUpsideDown)
         {
             if (rotateYbuffer > 0f)
             {
                 RotateY -= rotateStep;
             }
         }
         else
         {
             if (rotateYbuffer < 180f)
             {
                 RotateY += rotateStep;
             }
         }
     }
     if (GUI.RepeatButton(new Rect(widthOffset + 50f, 86f, 25f, 25f), "+"))
     {
         CurrentZoom -= 0.5f;
         if (CurrentZoom < MinZoom)
         {
             CurrentZoom = MinZoom;
         }
     }
 }