Ejemplo n.º 1
0
        public bool IsPlayerNearby(TriggerProfile control, bool playerOutsideDistance = false)
        {
            IMyPlayer player = null;

            var remotePosition = Vector3D.Transform(control.PlayerNearPositionOffset, RemoteControl.WorldMatrix);

            if (control.MinPlayerReputation != -1501 || control.MaxPlayerReputation != 1501)
            {
                player = TargetHelper.GetClosestPlayerWithReputation(remotePosition, _owner.FactionId, control);
            }
            else
            {
                player = TargetHelper.GetClosestPlayer(remotePosition);
            }

            if (player == null)
            {
                //Logger.MsgDebug(control.ProfileSubtypeId + ": No Eligible Player for PlayerNear Check", DebugTypeEnum.Trigger);
                return(false);
            }

            var playerDist = Vector3D.Distance(player.GetPosition(), remotePosition);

            if (playerOutsideDistance)
            {
                if (playerDist < control.TargetDistance)
                {
                    return(false);
                }
            }
            else
            {
                if (playerDist > control.TargetDistance)
                {
                    return(false);
                }
            }



            if (control.InsideAntenna == true)
            {
                var antenna = _behavior.Grid.GetAntennaWithHighestRange(control.InsideAntennaName);

                if (antenna != null)
                {
                    playerDist = Vector3D.Distance(player.GetPosition(), antenna.GetPosition());
                    if (playerDist > antenna.Radius)
                    {
                        return(false);
                    }
                }
                else
                {
                    return(false);
                }
            }

            return(true);
        }
Ejemplo n.º 2
0
        public IEnumerator WaitForRay()
        {
            yield return(new WaitForSeconds(1f));

            isRayEnabled = false;
            TargetHelper targetHelper = new TargetHelper(part);

            targetHelper.Update();
            Vector3 vector;

            if (targetHelper.Destination <= (float)allowedScanDistance && IsInsight(out vector) && IsTargetVisiable())
            {
                ScreenMessages.PostScreenMessage(FlightGlobals.activeTarget.vessel.vesselName + " HAS BEEN SCANNED", 3f, 0);
                if (!isScienceActivate)
                {
                    ModuleSpyExperiment moduleSpyExperiment = part.GetComponent <ModuleSpyExperiment>();
                    if (moduleSpyExperiment != null)
                    {
                        moduleSpyExperiment.DeployExperiment();
                    }
                    isScienceActivate   = true;
                    moduleSpyExperiment = null;
                }
            }
            else
            {
                ScreenMessages.PostScreenMessage("NO DATA, TARGET " + FlightGlobals.activeTarget.vessel.vesselName + " IS OUT OF RANGE  OR VISIBILITY", 3f, 0);
            }
            yield break;
        }
Ejemplo n.º 3
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));
                }
            }
        }
Ejemplo n.º 4
0
    protected void OnTriggerEnter(Collider other)
    {
        if (_damageDone)
        {
            return;
        }

        if (other.gameObject.CompareTag("Enemy"))
        {
            DetachEffects();
            Destroy(gameObject);

            if (Explosion != null)
            {
                Instantiate(Explosion, transform.position, transform.rotation);
            }

            if (Aoe < 0.001)
            {
                other.gameObject.GetComponent <EnemyController>().TakeDamage(Damage);
            }
            else
            {
                foreach (var enemy in TargetHelper.GetTargets(gameObject, Aoe))
                {
                    enemy.gameObject.GetComponent <EnemyController>().TakeDamage(Damage);
                }
            }

            _damageDone = true;
        }
    }
Ejemplo n.º 5
0
        public IEnumerator WaitForRay()
        {
            yield return(new WaitForSeconds(1));

            _isRayEnabled = false;
            var target = new TargetHelper(ThisPart);

            target.Update();
            Vector3 endPoint;

            if (target.Destination <= _allowedScanDistance && IsInsight(out endPoint) && IsTargetVisiable())
            {
                ScreenMessages.PostScreenMessage(FlightGlobals.activeTarget.vessel.vesselName + " HAS BEEN SCANNED", 3f, ScreenMessageStyle.UPPER_CENTER);
                if (!_isScienceActivate)
                {
                    var spyScience = ThisPart.GetComponent <ModuleSpyExperiment>();
                    if (spyScience != null)
                    {
                        spyScience.DeployExperiment();
                    }
                    _isScienceActivate = true;
                }
            }
            else
            {
                ScreenMessages.PostScreenMessage("NO DATA, TARGET " + FlightGlobals.activeTarget.vessel.vesselName + " IS OUT OF RANGE  OR VISIBILITY", 3f, ScreenMessageStyle.UPPER_CENTER);
            }
        }
Ejemplo n.º 6
0
        public ITypedTargetExpression <TMessage, TCommand, TTarget> ForType <TTarget>()
        {
            var helper = new TargetHelper <TTarget>(this);

            helper.TargetsMessage();
            return(helper);
        }
Ejemplo n.º 7
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));
                }
            }
        }
Ejemplo n.º 8
0
    private void Update()
    {
        _attackCooldown -= Time.deltaTime;

        ManageDelayedAttacks();

        if (AttackIsReady())
        {
            if (Target != null)
            {
                if (!TargetHelper.TargetIsInRange(gameObject, Target, AttackRange))
                {
                    Target = null;
                }
            }

            if (Target == null)
            {
                Target = TargetHelper.GetNearestTargetInRange(gameObject, AttackRange);
            }

            if (Target != null)
            {
                Attack();
            }
        }
    }
Ejemplo n.º 9
0
        public DockingCamera(Part part, bool noiseActive, int windowSize, string windowLabel = "DockCam")
            : base(part, windowSize, windowLabel)
        {
            this.noiseActive   = noiseActive;
            target             = new TargetHelper(part);
            guiStyleRedLabel   = new GUIStyle(HighLogic.Skin.label);
            guiStyleGreenLabel = new GUIStyle(HighLogic.Skin.label);
            guiStyleRedLabel.normal.textColor   = Color.red;
            guiStyleGreenLabel.normal.textColor = Color.green;

            //GameEvents.onVesselChange.Add(vesselChange);

            moduleDockingNodeGameObject = partGameObject.GetChild("dockingNode") ?? partGameObject;  //GET orientation from dockingnode

            if (textureWhiteNoise != null || !noiseActive)
            {
                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));
                }
            }
        }
Ejemplo n.º 10
0
        public void BuildLists()
        {
            if (ListsBuilt)
            {
                return;
            }

            ListsBuilt = true;

            if (this.RemoteControl?.SlimBlock?.CubeGrid == null)
            {
                return;
            }

            this.RemoteControl.SlimBlock.CubeGrid.OnGridSplit += GridSplit;

            OverrideConnectedGridCheck = true;
            CheckConnectedGrids();

            var tempAllBlocks = TargetHelper.GetAllBlocks(this.RemoteControl.SlimBlock.CubeGrid);

            foreach (var block in tempAllBlocks)
            {
                AddBlock(block, true);
            }

            this.RemoteControl.SlimBlock.CubeGrid.OnBlockAdded += AddBlock;
        }
Ejemplo n.º 11
0
 /// <summary>
 ///Overrides base.OnTarget and handles entity targets.
 ///      Allowed parameters are :
 ///       * Object inherited from UOEntity
 ///       * Object inherited from Serial
 ///       * ID of datatype "uint"
 /// </summary>
 protected override bool OnTarget(params object[] args)
 {
     if (base.OnTarget(args))
     {
         if (args != null)
         {
             if (args.Length.Equals(1))
             {
                 if (args[0] is UOEntity)
                 {
                     return(TargetHelper.GetTarget().TargetTo(((UOEntity)args[0]).Serial));
                 }
                 if (args[0] is Serial)
                 {
                     return(TargetHelper.GetTarget().TargetTo((Serial)args[0]));
                 }
                 if (args[0] is uint)
                 {
                     return(TargetHelper.GetTarget().TargetTo(new Serial((uint)args[0])));
                 }
             }
         }
     }
     return(false);
 }
Ejemplo n.º 12
0
 public iOS()
 {
     TargetHelper.Target("Default", FSharpFunc.FromAction(() =>
     {
         Console.WriteLine("iOS");
     }));
 }
Ejemplo n.º 13
0
 public UWP()
 {
     TargetHelper.Target("Default", FSharpFunc.FromAction(() =>
     {
         Console.WriteLine("Android");
     }));
 }
 public void WhenGetTarget()
 {
     uint   nbits  = 0x1d00ffff; // 4 bits
     var    result = TargetHelper.GetTarget(nbits);
     var    hex    = result.ToHexString();
     string s      = "";
 }
Ejemplo n.º 15
0
 /// <summary>
 ///Function wich controls the targeting workflow.
 /// </summary>
 public virtual bool Action(params object[] args)
 {
     if (TargetHelper.GetTarget().WaitForTarget(Delay))
     {
         return(OnTarget(args) ? OnFinish(args) : OnCancel(args));
     }
     return(OnTimeout(args));
 }
        private TargetValueEnum GetTargetValue()
        {
            var activeWalls = _wallFilter
                              .ToEntitiesList()
                              .Count();

            return(TargetHelper.GetTargetValue(activeWalls / 2));
        }
        private void CreateTarget(Target element)
        {
            var target = element.GetTargetElement();

            target.gameObject.SetActive(true);
            element.Transform = target.transform;

            target.transform.position = TargetHelper.GetPositionVector(element.Row, element.Column);
        }
Ejemplo n.º 18
0
        private void SetupWatchedBlocks()
        {
            Logger.MsgDebug("Setting Up Required Block Watcher", DebugTypeEnum.Condition);
            _gotWatchedBlocks = true;
            _watchedAnyBlocks.Clear();
            _watchedAllBlocks.Clear();
            _watchedNoneBlocks.Clear();

            if (!UseRequiredFunctionalBlocks)
            {
                return;
            }

            _remoteControl.SlimBlock.CubeGrid.OnGridSplit += GridSplitHandler;
            var allBlocks = TargetHelper.GetAllBlocks(_remoteControl?.SlimBlock?.CubeGrid).Where(x => x.FatBlock != null);

            foreach (var block in allBlocks)
            {
                var terminalBlock = block.FatBlock as IMyTerminalBlock;

                if (terminalBlock == null)
                {
                    continue;
                }

                Logger.MsgDebug(" - " + terminalBlock.CustomName.Trim(), DebugTypeEnum.Condition);

                if (RequiredAllFunctionalBlockNames.Contains(terminalBlock.CustomName.Trim()))
                {
                    Logger.MsgDebug("Monitoring Required-All Block: " + terminalBlock.CustomName, DebugTypeEnum.Condition);
                    _watchedAllBlocks.Add(block.FatBlock);
                    block.FatBlock.IsWorkingChanged += CheckAllBlocks;
                    _watchingAllBlocks = true;
                }

                if (RequiredAnyFunctionalBlockNames.Contains(terminalBlock.CustomName.Trim()))
                {
                    Logger.MsgDebug("Monitoring Required-Any Block: " + terminalBlock.CustomName, DebugTypeEnum.Condition);
                    _watchedAnyBlocks.Add(block.FatBlock);
                    block.FatBlock.IsWorkingChanged += CheckAnyBlocks;
                    _watchingAnyBlocks = true;
                }

                if (RequiredNoneFunctionalBlockNames.Contains(terminalBlock.CustomName.Trim()))
                {
                    Logger.MsgDebug("Monitoring Required-None Block: " + terminalBlock.CustomName, DebugTypeEnum.Condition);
                    _watchedNoneBlocks.Add(block.FatBlock);
                    block.FatBlock.IsWorkingChanged += CheckNoneBlocks;
                    _watchingNoneBlocks              = true;
                }
            }

            CheckAllBlocks();
            CheckAnyBlocks();
            CheckNoneBlocks();
        }
Ejemplo n.º 19
0
        public bool TestCharacterTriggerEffect(CharacterTriggerRelicEffectParams relicEffectParams)
        {
            CharacterState characterState = relicEffectParams.characterState;

            if (characterState.IsDestroyed)
            {
                return(false);
            }
            if (relicEffectParams.trigger != CharacterTriggerData.Trigger.OnAttacking)
            {
                return(false);
            }
            if (relicEffectParams.combatManager.GetCombatPhase() == CombatManager.Phase.HeroTurn || relicEffectParams.combatManager.GetCombatPhase() == CombatManager.Phase.PreCombat || relicEffectParams.combatManager.GetCombatPhase() == CombatManager.Phase.BossActionPreCombat)
            {
                return(false);
            }
            if (characterState.GetStatusEffectStacks("ambush") <= 0)
            {
                return(false);
            }

            TargetMode targetMode = TargetMode.LastAttackedCharacter;

            if (characterState.GetStatusEffectStacks("sweep") > 0)
            {
                targetMode = TargetMode.Room;
            }

            try
            {
                TargetHelper.CollectTargetsData collectTargetsData = default(TargetHelper.CollectTargetsData);
                collectTargetsData.targetMode = targetMode;
                collectTargetsData.targetModeStatusEffectsFilter = new List <string>();
                collectTargetsData.targetModeHealthFilter        = CardEffectData.HealthFilter.Both;
                collectTargetsData.targetTeamType = Team.Type.Heroes;
                collectTargetsData.roomIndex      = characterState.GetSpawnPoint().GetRoomOwner().GetRoomIndex();
                collectTargetsData.heroManager    = relicEffectParams.heroManager;
                collectTargetsData.monsterManager = relicEffectParams.monsterManager;
                collectTargetsData.roomManager    = relicEffectParams.roomManager;
                collectTargetsData.inCombat       = false;
                collectTargetsData.isTesting      = true;
                collectTargetsData.selfTarget     = characterState;

                _targets.Clear();
                TargetHelper.CollectTargets(collectTargetsData, ref _targets);

                return(_targets.Count > 0);
            }
            catch (System.Exception)
            {
                return(false);
            }
        }
Ejemplo n.º 20
0
    // Update is called once per frame
    void Update()
    {
        Rigidbody rb = GetComponent <Rigidbody> ();
        //find target (closest to position that will be held in X time
        GameObject target = TargetHelper.findClosestPlayer(rb, rb.velocity.magnitude * predictionDetection);
        //get direction to target
        Vector3 dirToTar = rb.transform.position - target.transform.position;

        /*	//display marker
         *      Destroy(refr);
         *      refr = Instantiate(prefab, -(rb.position+dirToTar.normalized), Quaternion.identity);
         */
        //set course and compensate for current velocity (adjust/tweek for focusing on target or balancing out momentum)
        rb.AddForce((-(dirToTar * maneuverability + rb.velocity).normalized) * acceleration);
    }
        private void UpdateTarget(Target element)
        {
            element.Transform.gameObject.SetActive(false);

            element.Value = GetTargetValue();

            var target = element.GetTargetElement();

            target.gameObject.SetActive(true);
            element.Transform = target.transform;

            target.transform.position = TargetHelper.GetPositionVector(element.Row, element.Column);

            _stateManager.RemoveTarget(OldTarget.Row, OldTarget.Column, OldTarget.Value, OldTarget.Round);
            _stateManager.AddTarget(element.Row, element.Column, element.Value, element.Round);
        }
Ejemplo n.º 22
0
        private JObject GetBlockTemplate(JObject response)
        {
            var transactions = MemoryPool.Instance().GetTransactions();
            var blockChain   = _blockChainStore.GetBlockChain();

            if (transactions == null || !transactions.Any())
            {
                response["result"] = null;
                return(response);
            }

            var currentBlock       = blockChain.GetCurrentBlock();
            var height             = blockChain.GetCurrentBlockHeight();
            var previousBlockHash  = currentBlock.GetHashHeader().ToHexString();
            var transactionBuilder = new TransactionBuilder();
            var nonce = BitConverter.GetBytes(NonceHelper.GetNonceUInt64());
            var value = transactions.Sum(t => _transactionHelper.GetFee(t.Transaction, _network));
            var coinBaseTransaction = transactionBuilder.NewCoinbaseTransaction()
                                      .SetInput((uint)height + 1, nonce)
                                      .AddOutput(value, Script.CreateCorrectScript())
                                      .Build();
            var result        = new JObject();
            var jTransactions = new JArray();

            foreach (var transaction in transactions)
            {
                jTransactions.Add(transaction.Transaction.Serialize().ToHexString());
            }


            var currentTime    = DateTime.UtcNow.ToUnixTimeUInt32();
            var coinBaseTxnObj = new JObject();

            coinBaseTxnObj.Add("data", coinBaseTransaction.Serialize().ToHexString());
            result.Add("coinbasetxn", coinBaseTxnObj);
            result.Add("expires", "120");
            result.Add("longpollid", "");
            result.Add("height", blockChain.GetCurrentBlockHeight() + 1);
            result.Add("curtime", currentTime);
            result.Add("previousblockhash", previousBlockHash);
            result.Add("transactions", jTransactions);
            result.Add("version", BlockHeader.CURRENT_VERSION);
            result.Add("target", TargetHelper.GetTarget(Constants.DEFAULT_NBITS).ToHexString());
            result.Add("bits", Constants.DEFAULT_NBITS);
            response["result"] = result;
            return(response);
        }
Ejemplo n.º 23
0
    private bool IsElementAvailable(int column, int row, int round, int number, DirectionEnum direction)
    {
        var position = PositionHelper.GetNextPosition(column, row, direction);
        var element  = GetBoardElement(position);
        var wall     = GetWall(position, DirectionHelper.GetReverseDirection(direction));

        if (
            wall != null ||
            (element.ContainsSnakeStep && element.Round == round) ||
            (element.ContainsTarget && element.Round == round && !TargetHelper.CanGetTargetElement(number))
            )
        {
            return(false);
        }

        return(true);
    }
Ejemplo n.º 24
0
        private void SetupWatchedBlocks()
        {
            _gotWatchedBlocks = true;
            _watchedAnyBlocks.Clear();
            _watchedAllBlocks.Clear();

            if (!UseRequiredFunctionalBlocks)
            {
                return;
            }

            _remoteControl.SlimBlock.CubeGrid.OnGridSplit += GridSplitHandler;
            var allBlocks = TargetHelper.GetAllBlocks(_remoteControl?.SlimBlock?.CubeGrid).Where(x => x.FatBlock != null);

            foreach (var block in allBlocks)
            {
                var terminalBlock = block.FatBlock as IMyTerminalBlock;

                if (terminalBlock == null)
                {
                    continue;
                }

                if (this.RequiredAllFunctionalBlockNames.Contains(terminalBlock.CustomName))
                {
                    _watchedAllBlocks.Add(block.FatBlock);
                    block.FatBlock.IsWorkingChanged += CheckAllBlocks;
                }

                if (this.RequiredAnyFunctionalBlockNames.Contains(terminalBlock.CustomName))
                {
                    _watchedAnyBlocks.Add(block.FatBlock);
                    block.FatBlock.IsWorkingChanged += CheckAnyBlocks;
                }

                if (this.RequiredNoneFunctionalBlockNames.Contains(terminalBlock.CustomName))
                {
                    _watchedNoneBlocks.Add(block.FatBlock);
                    block.FatBlock.IsWorkingChanged += CheckNoneBlocks;
                }
            }

            CheckAllBlocks();
            CheckAnyBlocks();
            CheckNoneBlocks();
        }
Ejemplo n.º 25
0
        public static void InsureItem(Loot _loot)
        {
            Stealth.Client.RequestContextMenu(Self.Serial.Value);
            Stealth.Client.SetContextMenuHook(Self.Serial.Value, 9);

            Thread.Sleep(1500);

            var _helper = TargetHelper.GetTarget();

            _helper.AutoTargetTo(_loot.Serial);

            Thread.Sleep(500);

            Stealth.Client.CancelMenu();
            Stealth.Client.CancelTarget();

            ConsoleMessage("Insured Item: {0}", _loot.Serial.Value);
        }
Ejemplo n.º 26
0
        public static void SendParticleEffectRequest(string id, MatrixD remoteMatrix, Vector3D offset, float scale, float maxTime, Vector3D color)
        {
            var effect = new Effects();

            effect.Mode               = EffectSyncMode.Particle;
            effect.Coords             = Vector3D.Transform(offset, remoteMatrix);
            effect.ParticleId         = id;
            effect.ParticleScale      = scale;
            effect.ParticleColor      = color;
            effect.ParticleMaxTime    = maxTime;
            effect.ParticleForwardDir = remoteMatrix.Forward;
            effect.ParticleUpDir      = remoteMatrix.Up;
            var syncData = new SyncContainer(effect);

            foreach (var player in TargetHelper.GetPlayersWithinDistance(effect.Coords, 15000))
            {
                SyncManager.SendSyncMesage(syncData, player.SteamUserId);
            }
        }
Ejemplo n.º 27
0
        /*
         * private void GetRandomChatAndSoundFromLists(List<string> messages, List<string> sounds, List<BroadcastType> broadcastTypes, List<string> avatars, ref string message, ref string sound, ref BroadcastType broadcastType, ref string avatar){
         *
         *      if(messages.Count == 0) {
         *
         *              return;
         *
         *      }
         *
         *      var index = Rnd.Next(0, messages.Count);
         *      message = messages[index];
         *
         *      if(sounds.Count >= messages.Count) {
         *
         *              sound = sounds[index];
         *
         *      }
         *
         *      if(broadcastTypes.Count >= messages.Count) {
         *
         *              broadcastType = broadcastTypes[index];
         *
         *      }
         *
         *      if(avatars.Count >= messages.Count) {
         *
         *              avatar = avatars[index];
         *
         *      }
         *
         * }
         */
        public void RefreshAntennaList()
        {
            if (this.RemoteControl == null || MyAPIGateway.Entities.Exist(this.RemoteControl?.SlimBlock?.CubeGrid) == false)
            {
                return;
            }

            this.AntennaList.Clear();
            var blockList = TargetHelper.GetAllBlocks(this.RemoteControl.SlimBlock.CubeGrid);

            foreach (var block in blockList.Where(x => x.FatBlock != null))
            {
                var antenna = block.FatBlock as IMyRadioAntenna;

                if (antenna != null)
                {
                    this.AntennaList.Add(antenna);
                }
            }
        }
Ejemplo n.º 28
0
        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));
                    }
                }
            }
        }
Ejemplo n.º 29
0
        private static Block CalculateHeader(BlockTemplate blockTemplate, uint nonce, uint extraNonce, Networks network)
        {
            var transactions    = new List <BaseTransaction>();
            var coinBaseInTrans = blockTemplate.CoinBaseTx.TransactionIn[0] as TransactionInCoinbase;

            coinBaseInTrans.CoinBaseScript = BitConverter.GetBytes(extraNonce);
            transactions.Add(blockTemplate.CoinBaseTx);
            transactions.AddRange(blockTemplate.Transactions);
            var block = new Block(blockTemplate.PreviousBlockHash, blockTemplate.Bits, nonce, blockTemplate.Version);

            block.Transactions = transactions;
            var serialized = block.GetHashHeader();

            if (TargetHelper.IsValid(serialized, blockTemplate.Target))
            {
                var txOut       = blockTemplate.CoinBaseTx.TransactionOut;
                var firstTxOut  = txOut.First();
                var adr         = GenerateAdr(network);
                var minerScript = Script.CreateP2PKHScript(adr.PublicKeyHash);
                firstTxOut.Script = minerScript;
                return(block);
            }

            var difference = DateTime.UtcNow.ToUnixTimeUInt32() - blockTemplate.CurrentTime;

            if (difference >= blockTemplate.Expires) // EXPIRATION.
            {
                return(null);
            }

            if (nonce == uint.MaxValue)
            {
                nonce = 0;
                extraNonce++;
            }

            Thread.Sleep(100);
            nonce++;
            return(CalculateHeader(blockTemplate, nonce, extraNonce, network));
        }
 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));
         }
     }
 }
Ejemplo n.º 31
0
        public DockingCamera(Part part, bool noiseActive, int windowSize, string windowLabel = "DockCam")
            : base(part, windowSize, windowLabel)
        {
            this.noiseActive = noiseActive;
            target = new TargetHelper(part);
            guiStyleRedLabel = new GUIStyle(HighLogic.Skin.label);
            guiStyleGreenLabel = new GUIStyle(HighLogic.Skin.label);
            guiStyleRedLabel.normal.textColor = Color.red;
            guiStyleGreenLabel.normal.textColor = Color.green;

            //GameEvents.onVesselChange.Add(vesselChange);

            moduleDockingNodeGameObject = partGameObject.GetChild("dockingNode") ?? partGameObject;  //GET orientation from dockingnode

            if (textureWhiteNoise != null || !noiseActive) 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));
            }
        }
Ejemplo n.º 32
0
 public IEnumerator WaitForRay()
 {
     yield return new WaitForSeconds(1);
     IsRayEnabled = false;
     var target = new TargetHelper(part);
     target.Update();
     Vector3 endPoint;
     if (target.Destination <= AllowedDistance && isInsight(out endPoint) && isTargetVisiable())
     {
         ScreenMessages.PostScreenMessage(FlightGlobals.activeTarget.vessel.vesselName + " HAS BEEN SCANNED", 3f, ScreenMessageStyle.UPPER_CENTER);
         if (!IsScienceActivate)
         {
             var spyScience = part.GetComponent<ModuleSpyExperiment>();
             if (spyScience != null)
                 spyScience.DeployExperiment();
             IsScienceActivate = true;
         }
     }
     else
     {
         ScreenMessages.PostScreenMessage("NO DATA, TARGET " + FlightGlobals.activeTarget.vessel.vesselName + " IS OUT OF RANGE  OR VISIBILITY", 3f, ScreenMessageStyle.UPPER_CENTER);
     }
 }