private void GetCurrentBullets(string bulletName, int hits)
 {
     if (hits == -1)
     {
         Hits = 0;
         while (true)
         {
             var hit = PartGameObject.GetChild($"{bulletName}{Hits + 1:000}");
             if (hit == null)
             {
                 break;
             }
             Hits++;
         }
     }
     else
     {
         Hits = hits;
         var i = Hits + 1;
         while (true)
         {
             var hit = PartGameObject.GetChild($"{bulletName}{i:000}");
             if (hit == null)
             {
                 break;
             }
             Object.Destroy(hit);
             i++;
         }
     }
 }
Exemple #2
0
        public DockingCamera(Part thisPart, bool noise, bool crossDPAI, bool crossOLDD, int windowSize, string windowLabel = "DockCam")
            : base(thisPart, windowSize, windowLabel)
        {
            GameEvents.onGameSceneLoadRequested.Add(LevelWasLoaded);
            Noise           = noise;
            TargetCrossDPAI = crossDPAI;
            TargetCrossOLDD = crossOLDD;
            _target         = new TargetHelper(thisPart);
            _moduleDockingNodeGameObject = PartGameObject.GetChild("dockingNode") ?? PartGameObject;  //GET orientation from dockingnode

            if (_textureWhiteNoise != null || !Noise)
            {
                return;
            }

            _textureWhiteNoise = new List <Texture2D> [3];
            for (int j = 0; j < 3; j++)
            {
                _textureWhiteNoise[j] = new List <Texture2D>();
                for (int i = 0; i < 4; i++)
                {
                    _textureWhiteNoise[j].Add(Util.WhiteNoiseTexture((int)TexturePosition.width, (int)TexturePosition.height));
                }
            }
        }
Exemple #3
0
        public DockingCamera(Part thisPart, bool noise, bool crossStock, bool crossDPAI, bool crossOLDD, int windowSize,
                             string windowLabel = "DockCam", string cameraName = "dockingNode", bool slidingOptionWindow = false, bool allowZoom = false)
            : base(thisPart, windowSize, windowLabel)
        {
            GameEvents.onGameSceneLoadRequested.Add(LevelWasLoaded);
            Noise            = noise;
            TargetCrossDPAI  = crossDPAI;
            TargetCrossOLDD  = crossOLDD;
            TargetCrossStock = crossStock;
            AuxWindowAllowed = slidingOptionWindow;
            IsZoomAllowed    = allowZoom;

            _target = new TargetHelper(thisPart);
            _moduleDockingNodeGameObject = PartGameObject.GetChild(cameraName) ?? PartGameObject;  //GET orientation from dockingnode

            if (_textureWhiteNoise != null)
            {
                return;
            }

            _textureWhiteNoise = new List <Texture2D> [4];
            for (int j = 0; j < 3; j++)
            {
                _textureWhiteNoise[j] = new List <Texture2D>();
                for (int i = 0; i < 4; i++)
                {
                    _textureWhiteNoise[j].Add(Util.WhiteNoiseTexture((int)TexturePosition.width, (int)TexturePosition.height));
                }
            }
        }
        public DockingCamera(OLDD_camera.Modules.DockingCameraModule dcm, Part thisPart,
                             bool noise, double electricchargeCost, bool crossStock, bool crossDPAI, bool crossOLDD, bool transformModification,
                             int windowSize, string restrictShaderTo,
                             string windowLabel       = "DockCam", string cameraName = "dockingNode",
                             bool slidingOptionWindow = false, bool allowZoom        = false, bool noTransformMod = false)
            : base(thisPart, windowSize, windowLabel)
        {
            GameEvents.onGameSceneLoadRequested.Add(LevelWasLoaded);
            Noise            = noise;
            TargetCrossDPAI  = crossDPAI;
            TargetCrossOLDD  = crossOLDD;
            TargetCrossStock = crossStock;
            AuxWindowAllowed = slidingOptionWindow;
            IsZoomAllowed    = allowZoom;

            availableShaders             = new ShaderInfo(restrictShaderTo);
            _target                      = new TargetHelper(thisPart);
            _moduleDockingNodeGameObject = PartGameObject.GetChild(cameraName) ?? PartGameObject;  //GET orientation from dockingnode

            if (cameraName != "dockingNode" && transformModification)
            {
                Vector3 v3 = dcm.cameraPosition;

                _moduleDockingNodeGameObject.transform.position += _moduleDockingNodeGameObject.transform.rotation * v3;
                _moduleDockingNodeGameObject.transform.rotation  = dcm.part.transform.rotation;
                _moduleDockingNodeGameObject.transform.rotation *= Quaternion.LookRotation(dcm.cameraForward, dcm.cameraUp);
            }

            if (_textureWhiteNoise == null)
            {
                _textureWhiteNoise = new List <Texture2D> [4];
                for (int j = 0; j < 3; j++)
                {
                    _textureWhiteNoise[j] = new List <Texture2D>();
                    for (int i = 0; i < 4; i++)
                    {
                        _textureWhiteNoise[j].Add(Util.WhiteNoiseTexture((int)TexturePosition.width, (int)TexturePosition.height));
                    }
                }
            }
        }
 private void DrawButtonsBlock(float widthOffset)
 {
     if (GUI.Button(new Rect(widthOffset, 36, ButtonSize, ButtonSize), "↻"))
     {
         _camObject.transform.Rotate(new Vector3(0, 0, 180f));
         _isUpsideDown = !_isUpsideDown;
     }
     if (GUI.RepeatButton(new Rect(widthOffset + ButtonSize, 36, ButtonSize, ButtonSize), "↑"))
     {
         if (_rotateYbuffer < 180)
         {
             if (!_isUpsideDown)
             {
                 RotateY += _rotateStep;
             }
             else
             {
                 RotateY -= _rotateStep;
             }
         }
     }
     if (GUI.Button(new Rect(widthOffset + ButtonSize * 2, 36, ButtonSize, ButtonSize), "⦿"))
     {
         if (ThisPart.vessel.Equals(FlightGlobals.ActiveVessel))
         {
             if (!TargetHelper.IsTargetSelect)
             {
                 ScreenMessages.PostScreenMessage("NO TARGET FOR SCANNING", 3f, ScreenMessageStyle.UPPER_CENTER);
             }
             else
             {
                 if (Hits <= 0)
                 {
                     ScreenMessages.PostScreenMessage("BULLETS DEPLETED", 3f, ScreenMessageStyle.UPPER_CENTER);
                 }
                 else
                 {
                     var    id = PartResourceLibrary.Instance.GetDefinition(_resourceName).id;
                     double amount;
                     double maxAmount;
                     ThisPart.GetConnectedResourceTotals(id, out amount, out maxAmount);
                     if (amount > _resourceUsage)
                     {
                         ThisPart.RequestResource(id, _resourceUsage);
                         var hit = PartGameObject.GetChild($"{_bulletName}{Hits:000}");
                         Object.Destroy(hit);
                         Hits--;
                         _isRayEnabled      = true;
                         IsWaitForRay       = true;
                         _isScienceActivate = false;
                     }
                     else
                     {
                         ScreenMessages.PostScreenMessage("NOT ENOUGH ELECTRICITY FOR SCAN", 3f, ScreenMessageStyle.UPPER_CENTER);
                     }
                 }
                 //if (HitCounter() && UseResourceForScanning())
                 //{
                 //    _isRayEnabled = true;
                 //    IsWaitForRay = true;
                 //    _isScienceActivate = false;
                 //}
             }
         }
         else
         {
             ScreenMessages.PostScreenMessage("Camera not on active vessel", 3f, ScreenMessageStyle.UPPER_CENTER);
         }
     }
     if (GUI.RepeatButton(new Rect(widthOffset, 36 + ButtonSize, ButtonSize, ButtonSize), "←"))
     {
         if (!_isUpsideDown)
         {
             RotateZ -= _rotateStep;
         }
         else
         {
             RotateZ += _rotateStep;
         }
     }
     if (GUI.Button(new Rect(widthOffset + ButtonSize, 36 + ButtonSize, ButtonSize, ButtonSize), "o"))
     {
         IsToZero = true;
     }
     if (GUI.RepeatButton(new Rect(widthOffset + ButtonSize * 2, 36 + ButtonSize, ButtonSize, ButtonSize), "→"))
     {
         if (!_isUpsideDown)
         {
             RotateZ += _rotateStep;
         }
         else
         {
             RotateZ -= _rotateStep;
         }
     }
     if (GUI.Button(new Rect(widthOffset, 36 + ButtonSize * 2, ButtonSize, ButtonSize), "-"))
     {
         CurrentZoom += 0.5f;
         if (CurrentZoom > MaxZoom)
         {
             CurrentZoom = MaxZoom;
         }
     }
     if (GUI.RepeatButton(new Rect(widthOffset + ButtonSize, 36 + ButtonSize * 2, ButtonSize, ButtonSize), "↓"))
     {
         if (_rotateYbuffer > 0)
         {
             if (!_isUpsideDown)
             {
                 RotateY -= _rotateStep;
             }
             else
             {
                 RotateY += _rotateStep;
             }
         }
     }
     if (GUI.Button(new Rect(widthOffset + ButtonSize * 2, 36 + ButtonSize * 2, ButtonSize, ButtonSize), "+"))
     {
         CurrentZoom -= 0.5f;
         if (CurrentZoom < MinZoom)
         {
             CurrentZoom = MinZoom;
         }
     }
 }