Esempio n. 1
0
        private void CheckCustomInfo()
        {
            if (TermBlock == null)
            {
                return;
            }

            bool needToRefresh = false;

            if (IsJammer)
            {
                if (PowerLevel_Current != previous_PowerLevel_Current)
                {
                    needToRefresh = true;
                    previous_PowerLevel_Current = PowerLevel_Current;
                }
            }

            if (deliberateJamming != previous_deliberateJamming)
            {
                needToRefresh = true;
                previous_deliberateJamming = deliberateJamming;
            }

            if (IsRadar)
            {
                if (PowerLevel_Radar != previous_PowerLevel_Radar)
                {
                    needToRefresh             = true;
                    previous_PowerLevel_Radar = PowerLevel_Radar;
                }
                if (PowerLevel_RadarEffective != previous_PowerLevel_RadarEffective)
                {
                    needToRefresh = true;
                    previous_PowerLevel_RadarEffective = PowerLevel_RadarEffective;
                }
            }

            if (beingJammedBy.Count != previous_beingJammedBy_Count)
            {
                needToRefresh = true;
                previous_beingJammedBy_Count = beingJammedBy.Count;
            }

            if (myLastSeen.Count != previous_detectedObjects_Count)
            {
                needToRefresh = true;
                previous_detectedObjects_Count = myLastSeen.Count;
            }

            if (needToRefresh)
            {
                TermBlock.UpdateCustomInfo();
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Create a RadarEquipment for a block, getting the definition from the block.
        /// </summary>
        public RadarEquipment(IMyCubeBlock block)
        {
            this.Log = new Logger(block);

            this.Entity         = block;
            this.RelationsBlock = block;
            this.myDefinition   = GetDefinition(block);

            Registrar.Add(block, this);

            TermBlock.OnClose += CustomInfoBlock_OnClose;

            TermBlock.AppendingCustomInfo += AppendingCustomInfo;

            UpdateTargetPowerLevel();
            PowerLevel_Current = Math.Min(PowerLevel_Target, myDefinition.MaxPowerLevel);
            MyAPIGateway.Utilities.InvokeOnGameThread(UpdatePowerConsumption);

            // maybe this is a bug fix?
            MyFunctionalBlock func = (MyFunctionalBlock)block;

            func.Enabled = false;
            func.Enabled = true;

            TermBlock.UpdateCustomInfo();

            byte detectionTypes = 0;

            if (myDefinition.Radar)
            {
                detectionTypes++;
            }
            if (myDefinition.PassiveDetect_Jamming > 0)
            {
                detectionTypes++;
            }
            if (myDefinition.PassiveDetect_Radar > 0)
            {
                detectionTypes++;
            }
            if (detectionTypes > 1)
            {
                detectedObjects_hash = new Dictionary <IMyEntity, DetectedInfo>();
            }

            m_beaconLight = GetLight();

            Log.DebugLog("Radar equipment initialized, power level: " + PowerLevel_Current, Logger.severity.INFO);
        }