예제 #1
0
        private void SetPropertyData(FieldInfo field, PropertyInfo propSource, object propObject)
        {
            var pType  = propSource.PropertyType;
            var pFlags = BindingFlags.Public | BindingFlags.Instance | BindingFlags.Static;

            //if (pType == typeof(Unit))
            //{
            //    field.SetValue(this, ((Unit)propSource.GetValue(propObject, null)).ToString());
            //    return;
            //}

            if (pType.GetTypeInfo().IsEnum)
            {
                field.SetValue(this, (int)propSource.GetValue(propObject, null));
                return;
            }

            if (pType == typeof(Color))
            {
                var c = (Color)propSource.GetValue(propObject, null);
                field.SetValue(this, RadarUtils.GetHexStringFromColor(c));
                return;
            }

            if (pType == typeof(float))
            {
                field.SetValue(this, Convert.ToInt32(propSource.GetValue(propObject, null)));
                return;
            }


            field.SetValue(this, propSource.GetValue(propObject, null));
        }
        public void DrillAction(PossibleDrillActions Mode)
        {
            DebugLogging.WriteLine("MemberCell.DrillAction({0})", Mode);

            if ((Mode & PossibleDrillActions) != Mode)
            {
                var S = "";
                if (Mode == PossibleDrillActions.esCollapsed)
                {
                    S = RadarUtils.GetResStr("rsDrillAction0");
                }
                if (Mode == PossibleDrillActions.esParentChild)
                {
                    S = RadarUtils.GetResStr("rsDrillAction1");
                }
                if (Mode == PossibleDrillActions.esNextLevel)
                {
                    S = RadarUtils.GetResStr("rsDrillAction2");
                }
                if (Mode == PossibleDrillActions.esNextHierarchy)
                {
                    S = RadarUtils.GetResStr("rsDrillAction3");
                }

                throw new Exception(
                          string.Format(RadarUtils.GetResStr("rsInadmissibleDrillAction"), S, Value));
            }

            CellSet.DrillAction_Inner(Mode, RealMember);
        }
예제 #3
0
        internal static JsonDialog RenderMassage(OlapControl Grid, Exception E)
        {
            var result = new JsonDialog();

            result.title = RadarUtils.GetResStr("rsErrorMessage");

            var buttons = new List <JsonDialogButton>();

            if (!string.IsNullOrEmpty(Grid.SupportEMail))
            {
                buttons.Add(new JsonDialogButton
                {
                    text = "Refresh",             //RadarUtils.GetResStr("rsSendToSupport"),
                    code = "window.location = window.location.pathname; " +
                           "RadarSoft.$(this).dialog('close');"
                });
            }

            buttons.Add(new JsonDialogButton
            {
                text = RadarUtils.GetResStr("rsClose"),
                code = "RadarSoft.$(this).dialog('close')"
            });

            result.data = "<div width='500'>" +
                          "<div style='width:490px;margin:5px;overflow:auto;border:2px inset #C0C0C0;;color:#404040;;height:90px;'>" +
                          E.Message.Replace("\n", "<br />") +
                          "</div>" +
                          "</div>";
            result.buttons = buttons.ToArray();
            return(result);
        }
예제 #4
0
        void ReceiveLaunchWarning(Vector3 source, Vector3 direction)
        {
            if (referenceTransform == null)
            {
                return;
            }
            if (part == null)
            {
                return;
            }
            if (weaponManager == null)
            {
                return;
            }

            float sqrDist = (part.transform.position - source).sqrMagnitude;

            if (sqrDist < Mathf.Pow(BDArmorySettings.MAX_ENGAGEMENT_RANGE, 2) && sqrDist > Mathf.Pow(100, 2) &&
                Vector3.Angle(direction, part.transform.position - source) < 15)
            {
                StartCoroutine(
                    LaunchWarningRoutine(new TargetSignatureData(Vector3.zero,
                                                                 RadarUtils.WorldToRadar(source, referenceTransform, displayRect, rwrDisplayRange), Vector3.zero,
                                                                 true, (float)RWRThreatTypes.MissileLaunch)));
                PlayWarningSound(RWRThreatTypes.MissileLaunch);

                if (weaponManager && weaponManager.guardMode)
                {
                    weaponManager.FireAllCountermeasures(Random.Range(2, 4));
                    weaponManager.incomingThreatPosition = source;
                }
            }
        }
예제 #5
0
        void ReceiveLaunchWarning(Vector3 source, Vector3 direction)
        {
            if (referenceTransform == null)
            {
                return;
            }
            if (part == null || !part.isActiveAndEnabled)
            {
                return;
            }
            if (weaponManager == null)
            {
                return;
            }

            float sqrDist = (part.transform.position - source).sqrMagnitude;

            if (sqrDist < Mathf.Pow(BDArmorySettings.MAX_ENGAGEMENT_RANGE, 2) && sqrDist > Mathf.Pow(100, 2) &&
                Vector3.Angle(direction, part.transform.position - source) < 15)
            {
                StartCoroutine(
                    LaunchWarningRoutine(new TargetSignatureData(Vector3.zero,
                                                                 RadarUtils.WorldToRadar(source, referenceTransform, RwrDisplayRect, rwrDisplayRange), Vector3.zero,
                                                                 true, (float)RWRThreatTypes.MissileLaunch)));
                PlayWarningSound(RWRThreatTypes.MissileLaunch);

                if (weaponManager && weaponManager.guardMode)
                {
                    weaponManager.FireAllCountermeasures(Random.Range(1, 2)); // Was 2-4, but we don't want to take too long doing this initial dump before other routines kick in
                    weaponManager.incomingThreatPosition = source;
                }
            }
        }
예제 #6
0
        internal GenericFilterGrid(OlapControl grid)
        {
            ActionString            = RadarUtils.GetResStr("rsActions");
            ItemString              = RadarUtils.GetResStr("rsItem");
            FilterDescriptionString = RadarUtils.GetResStr("rsFilterDescription");
            EditFilterString        = RadarUtils.GetResStr("rsEditFilter");
            ResetFilterString       = RadarUtils.GetResStr("repResetFilter");

            if (grid.Active)
            {
                foreach (var m in grid.Measures)
                {
                    if (m.Filter != null)
                    {
                        Items.Add(new GenericFilterGridItem(m));
                    }
                }

                foreach (var d in grid.Dimensions)
                {
                    foreach (var h in d.Hierarchies)
                    {
                        var s = h.FilterDescription;
                        if (!string.IsNullOrEmpty(s))
                        {
                            Items.Add(new GenericFilterGridItem(h));
                        }
                    }
                }
            }
        }
예제 #7
0
        internal MetaLine(OlapControl AGrid, IList <int> LevelIndexes)
            : this()
        {
            FGrid   = AGrid;
            fLevels = new List <Level>(LevelIndexes.Count);
            var b = 1;

            fIdxArray  = new List <long>(LevelIndexes.Count);
            fHierArray = new List <int>(LevelIndexes.Count);
            fLines     = new SortedList <string, Line>();
            if (LevelIndexes.Count == 0)
            {
                return;
            }

            for (var i = 0; i < LevelIndexes.Count; i++)
            {
                var L = AGrid.FEngine.FLevelsList[LevelIndexes[i]];
                fLevels.Add(L);
                fIdxArray.Add(FLimit);
                fHierArray.Add(b);
                FLimit *= L.CompleteMembersCount;
                b      *= L.FDepth;
            }
            fID = RadarUtils.Join('.', LevelIndexes);
#if DEBUG
            if (fID == "5")
            {
            }
#endif
        }
예제 #8
0
        internal CubeLevel(CubeHierarchy AHierarchy, CubeHierarchy ASourceHierarchy)
        {
            FCubeHierarchy   = AHierarchy;
            FSourceHierarchy = ASourceHierarchy;

            if (SourceHierarchy != null)
            {
                FDisplayName = SourceHierarchy.DisplayName;
                FUniqueName  = SourceHierarchy.UniqueName;

                if (AHierarchy.Dimension.Cube.GetProductID() == RadarUtils.GetCurrentDesktopProductID())
                {
                    FUniqueName += "1";
                }

                FDescription    = SourceHierarchy.Description;
                FBIMembersType  = SourceHierarchy.BIMembersType;
                FInfoAttributes = SourceHierarchy.InfoAttributes.Clone();
                FFormatString   = SourceHierarchy.FormatString;
            }
            else
            {
                FDisplayName    = AHierarchy.DisplayName;
                FUniqueName     = AHierarchy.UniqueName;
                FDescription    = AHierarchy.Description;
                FBIMembersType  = AHierarchy.BIMembersType;
                FInfoAttributes = AHierarchy.InfoAttributes.Clone();
                FFormatString   = AHierarchy.FormatString;
            }
        }
        void Start()
        {
            Instance = this;
            AddToolbarButton();

            RadarUtils.SetupResources();
            GameEvents.onEditorShipModified.Add(OnEditorShipModifiedEvent);
        }
예제 #10
0
        /// <summary>
        ///     Deletes the specified third-type measure from the list of available Grid
        ///     measures.
        /// </summary>
        public void DeleteCalculatedMeasure(Measure Measure)
        {
            ClearCache();
            if (FLevel == null && Grid.Active)
            {
                throw new InvalidOperationException();
            }
            if (Measure.FFunction != OlapFunction.stCalculated)
            {
                throw new Exception(string.Format(RadarUtils.GetResStr("rsTryToDeleteWrongMeasure"),
                                                  Measure.FDisplayName));
            }
            Measure.Visible = false;
            var Idx = IndexOf(Measure);

            if (FLevel == null) // return;
            {
                // if (Grid.Active) throw exception
                //
                //FGrid.Engine.ClearMeasureData(Measure);
                //Remove(Measure);
                //Grid.EndChange(GridEventType.geChangeCubeStructure, new object[0]);
                //if (Grid.Active) Grid.FCellSet.Rebuild();
                Remove(Measure);
                return;
            }

            FGrid.Engine.ClearMeasureData(Measure);

            var    P = new List <Member>();
            Member M = null;

            for (var i = 0; i < FLevel.Members.Count; i++)
            {
                if (FLevel.Members[i].fVirtualID == Idx)
                {
                    M = FLevel.Members[i];
                }
                if (FLevel.Members[i].fVirtualID > Idx)
                {
                    P.Add(FLevel.Members[i]);
                }
            }
            FLevel.FUniqueNamesArray.Remove(M.UniqueName);
            FLevel.Members.Remove(M);

            foreach (var m in P)
            {
                m.fVirtualID--;
            }
            Remove(Measure);
            Grid.EndChange(GridEventType.geChangeCubeStructure);
            if (Grid.Active && M.Visible)
            {
                Grid.FCellSet.Rebuild();
            }
        }
        /// <exclude />
        public static void CheckTag(BinaryReader reader, Tags tag)
        {
            var t = (Tags)reader.ReadUInt16();

            if (t != tag)
            {
                reader.BaseStream.Seek(-sizeof(ushort), SeekOrigin.Current);
                throw new StreamException(string.Format(RadarUtils.GetResStr("rsInvalidTagError"),
                                                        reader.BaseStream.Position, string.Format("{0}({1:D})", tag, tag)));
            }
        }
예제 #12
0
        private void OnDestroy()
        {
            GameEvents.onEditorShipModified.Remove(OnEditorShipModifiedEvent);
            RadarUtils.CleanupResources();

            if (toolbarButton)
            {
                ApplicationLauncher.Instance.RemoveModApplication(toolbarButton);
                toolbarButton = null;
            }
        }
        /// <summary>
        ///     Restores the standard display modes by deleting all the changes added by a
        ///     programmer.
        /// </summary>
        public void RestoreDefaults()
        {
            Clear();
            if (fMeasure.IsKPI)
            {
                Add(new MeasureShowMode(fMeasure, RadarUtils.GetResStr("rssmKPIValue"),
                                        MeasureShowModeType.smKPIValue, null));

                Add(new MeasureShowMode(fMeasure, RadarUtils.GetResStr("rssmKPIGoal"),
                                        MeasureShowModeType.smKPIGoal, null));

                Add(new MeasureShowMode(fMeasure, RadarUtils.GetResStr("rssmKPIStatus"),
                                        MeasureShowModeType.smKPIStatus, null));

                Add(new MeasureShowMode(fMeasure, RadarUtils.GetResStr("rssmKPITrend"),
                                        MeasureShowModeType.smKPITrend, null));

                Add(new MeasureShowMode(fMeasure, RadarUtils.GetResStr("rssmKPIWeight"),
                                        MeasureShowModeType.smKPIWeight, null));
                for (var i = 0; i < 4; i++)
                {
                    this[i].Visible = true;
                }
            }
            else
            {
                Add(new MeasureShowMode(fMeasure, RadarUtils.GetResStr("rssmNormal"),
                                        MeasureShowModeType.smNormal, null));

                Add(new MeasureShowMode(fMeasure, RadarUtils.GetResStr("rssmPercentRowTotal"),
                                        MeasureShowModeType.smPercentRowTotal, null));

                Add(new MeasureShowMode(fMeasure, RadarUtils.GetResStr("rssmPercentColTotal"),
                                        MeasureShowModeType.smPercentColTotal, null));

                Add(new MeasureShowMode(fMeasure, RadarUtils.GetResStr("rssmPercentParentRowItem"),
                                        MeasureShowModeType.smPercentParentRowItem, null));

                Add(new MeasureShowMode(fMeasure, RadarUtils.GetResStr("rssmPercentParentColItem"),
                                        MeasureShowModeType.smPercentParentColItem, null));

                Add(new MeasureShowMode(fMeasure, RadarUtils.GetResStr("rssmRowRank"),
                                        MeasureShowModeType.smRowRank, null));

                Add(new MeasureShowMode(fMeasure, RadarUtils.GetResStr("rssmColumnRank"),
                                        MeasureShowModeType.smColumnRank, null));

                Add(new MeasureShowMode(fMeasure, RadarUtils.GetResStr("rssmPercentGrandTotal"),
                                        MeasureShowModeType.smPercentGrandTotal, null));
                this[0].Visible = true;
            }
        }
예제 #14
0
 internal void CheckFlat(bool FirstLevel)
 {
     foreach (var m in this)
     {
         if (m.FNextLevelChildren.Count > 0 && m.FChildren.Count > 0)
         {
             throw new Exception(string.Format(RadarUtils.GetResStr("rsHierarchyNotFlat"), m.DisplayName));
         }
         m.Children.CheckFlat(FirstLevel);
         if (!FirstLevel && m.Parent == null)
         {
             throw new Exception(string.Format(RadarUtils.GetResStr("rsNoParentMember"), m.DisplayName));
         }
     }
 }
예제 #15
0
        void UpdateDebugLabels()
        {
            debugString.Length = 0;

            using (var team = TargetDatabase.GetEnumerator())
                while (team.MoveNext())
                {
                    debugString.Append($"Team {team.Current.Key} targets:");
                    debugString.Append(Environment.NewLine);
                    foreach (TargetInfo targetInfo in team.Current.Value)
                    {
                        if (targetInfo)
                        {
                            if (!targetInfo.Vessel)
                            {
                                debugString.Append($"- A target with no vessel reference.");
                                debugString.Append(Environment.NewLine);
                            }
                            else
                            {
                                debugString.Append($"- {targetInfo.Vessel.vesselName} Engaged by {targetInfo.TotalEngaging()}");
                                debugString.Append(Environment.NewLine);
                            }
                        }
                        else
                        {
                            debugString.Append($"- null target info.");
                            debugString.Append(Environment.NewLine);
                        }
                    }
                }

            debugString.Append(Environment.NewLine);
            debugString.Append($"Heat Signature: {GetVesselHeatSignature(FlightGlobals.ActiveVessel):#####}");
            debugString.Append(Environment.NewLine);

            debugString.Append($"Radar Signature: " + RadarUtils.GetVesselRadarSignature(FlightGlobals.ActiveVessel).radarModifiedSignature);
            debugString.Append(Environment.NewLine);

            debugString.Append($"Chaff multiplier: " + RadarUtils.GetVesselChaffFactor(FlightGlobals.ActiveVessel));
            debugString.Append(Environment.NewLine);

            debugString.Append($"ECM Jammer Strength: " + FlightGlobals.ActiveVessel.gameObject.GetComponent <VesselECMJInfo>()?.jammerStrength);
            debugString.Append(Environment.NewLine);

            debugString.Append($"ECM Lockbreak Strength: " + FlightGlobals.ActiveVessel.gameObject.GetComponent <VesselECMJInfo>()?.lockBreakStrength);
            debugString.Append(Environment.NewLine);
        }
예제 #16
0
        void Scan()
        {
            float angleDelta = scanRotationSpeed * Time.fixedDeltaTime;

            RadarUtils.RadarUpdateScanLock(weaponManager, currentAngle, referenceTransform, angleDelta, referenceTransform.position, this, false, ref attemptedLocks);

            if (omnidirectional)
            {
                currentAngle = Mathf.Repeat(currentAngle + angleDelta, 360);
            }
            else
            {
                currentAngle += radialScanDirection * angleDelta;

                if (locked)
                {
                    float targetAngle = VectorUtils.SignedAngle(referenceTransform.forward,
                                                                Vector3.ProjectOnPlane(lockedTarget.position - referenceTransform.position,
                                                                                       referenceTransform.up), referenceTransform.right);
                    leftLimit = Mathf.Clamp(targetAngle - (multiLockFOV / 2), -directionalFieldOfView / 2,
                                            directionalFieldOfView / 2);
                    rightLimit = Mathf.Clamp(targetAngle + (multiLockFOV / 2), -directionalFieldOfView / 2,
                                             directionalFieldOfView / 2);

                    if (radialScanDirection < 0 && currentAngle < leftLimit)
                    {
                        currentAngle        = leftLimit;
                        radialScanDirection = 1;
                    }
                    else if (radialScanDirection > 0 && currentAngle > rightLimit)
                    {
                        currentAngle        = rightLimit;
                        radialScanDirection = -1;
                    }
                }
                else
                {
                    if (Mathf.Abs(currentAngle) > directionalFieldOfView / 2)
                    {
                        currentAngle        = Mathf.Sign(currentAngle) * directionalFieldOfView / 2;
                        radialScanDirection = -radialScanDirection;
                    }
                }
            }
        }
예제 #17
0
        internal List <CubeDataNumeric> RetrieveCubeData(Line l, out List <Level> level_clue)
        {
            level_clue = l.fM.fLevels;
            if (FGrid.DeferLayoutUpdate)
            {
                return(new List <CubeDataNumeric>());
            }

            var data = l.RetrieveCubeData(null);

            ProcessCalculatedMembers(l, data);

            if (FCube.GetProductID() == RadarUtils.GetCurrentDesktopProductID() && l.Measure.Expression.IsFill())
            {
                ProcessCalculatedMeasures(l, data);
            }
            return(data);
        }
        private static Type LookingForType(string name)
        {
            var t = Type.GetType(name);

            if (t != null)
            {
                return(t);
            }
            var asm = RadarUtils.GetReferencingAssemblies();

            foreach (var a in asm)
            {
                t = a.GetType(name);
                if (t != null)
                {
                    return(t);
                }
            }
            return(null);
        }
예제 #19
0
        void BoresightScan()
        {
            if (locked)
            {
                boresightScan = false;
                return;
            }

            currentAngle = Mathf.Lerp(currentAngle, 0, 0.08f);
            RadarUtils.RadarUpdateScanBoresight(new Ray(transform.position, transform.up), boresightFOV, ref attemptedLocks, Time.fixedDeltaTime, this);

            for (int i = 0; i < attemptedLocks.Length; i++)
            {
                if (!attemptedLocks[i].exists || !(attemptedLocks[i].age < 0.1f))
                {
                    continue;
                }
                TryLockTarget(attemptedLocks[i].predictedPosition);
                boresightScan = false;
                return;
            }
        }
예제 #20
0
        void takeRadarSnapshot()
        {
            if (EditorLogic.RootPart == null)
            {
                return;
            }

            // Encapsulate editor ShipConstruct into a vessel:
            Vessel v = new Vessel();

            v.parts = EditorLogic.fetch.ship.Parts;
            RadarUtils.RenderVesselRadarSnapshot(v, EditorLogic.RootPart.transform);       //first rendering for true RCS
            RadarUtils.RenderVesselRadarSnapshot(v, EditorLogic.RootPart.transform, true); //second rendering for nice zoomed-in view
            takeSnapshot = false;

            // get RCS reduction measures (stealth/low observability)
            rcsReductionFactor = 1.0f;
            int rcsCount = 0;

            List <Part> .Enumerator parts = EditorLogic.fetch.ship.Parts.GetEnumerator();
            while (parts.MoveNext())
            {
                ModuleECMJammer rcsJammer = parts.Current.GetComponent <ModuleECMJammer>();
                if (rcsJammer != null)
                {
                    if (rcsJammer.rcsReduction)
                    {
                        rcsReductionFactor *= rcsJammer.rcsReductionFactor;
                        rcsCount++;
                    }
                }
            }
            parts.Dispose();

            if (rcsCount > 0)
            {
                rcsReductionFactor = Mathf.Clamp((rcsReductionFactor * rcsCount), 0.0f, 1);    //same formula as in VesselECMJInfo must be used here!
            }
        }
예제 #21
0
        public SerializedHierarchy(Hierarchy h)
        {
            UnfetchedMembersVisibile = h.UnfetchedMembersVisible;
            UniqueName = h.UniqueName;
            if (h.DisplayName != h.CubeHierarchy.DisplayName)
            {
                DisplayName = h.DisplayName;
            }

            if (h.TotalCaption != RadarUtils.GetResStr("rsTotalCaption"))
            {
                TotalCaption = h.TotalCaption;
            }

            SortType                   = h.SortType;
            FormatString               = h.FormatString;
            TotalAppearance            = h.TotalAppearance;
            AllowResort                = h.AllowResort;
            AllowFilter                = h.AllowFilter;
            AllowPopupOnLevelCaptions  = h.AllowPopupOnLevelCaptions;
            AllowHierarchyEditor       = h.AllowHierarchyEditor;
            AllowPopupOnMembers        = h.AllowPopupOnMembers;
            AllowRegroup               = h.AllowRegroup;
            AllowChangeTotalAppearance = h.AllowChangeTotalAppearance;
            Visible = h.Visible;
            TakeFiltersIntoCalculations = h.TakeFiltersIntoCalculations;
            AllowSwapMembers            = h.AllowSwapMembers;
            AllowMultiselect            = h.AllowMultiselect;
            OverrideSortMethods         = h.OverrideSortMethods;
            ShowEmptyLines = h.FShowEmptyLines;
            if (h.FLevels != null)
            {
                var ll = h.FLevels.Select(L => new SerializedLevel(L)).ToList();
                if (ll.Count > 0)
                {
                    Levels = ll.ToArray();
                }
            }
        }
        internal static Type FindTypeByName(string ATypeName, string ns)
        {
            if (_Types.ContainsKey(ATypeName))
            {
                return(_Types[ATypeName]);
            }
            var assemblies = RadarUtils.GetReferencingAssemblies();

            //Microsoft.Extensions.DependencyModel.DependencyContext.Default.CompileLibraries;
            //System.Runtime.Loader.AssemblyLoadContext.Default.LoadFromAssemblyPath(path)
            foreach (var a in assemblies)
            {
                foreach (var t in a.GetExportedTypes())
                {
                    if (t.Name == ATypeName && t.Namespace == ns)
                    {
                        _Types.Add(ATypeName, t);
                        return(t);
                    }
                }
            }
            return(null);
        }
예제 #23
0
 internal ClientHierarchy(Hierarchy h, OlapControl grid)
 {
     DisplayName = h.DisplayName;
     UniqueName  = h.UniqueName;
     Description = h.Description;
     Group       = h.Origin == HierarchyOrigin.hoNamedSet
         ? RadarUtils.GetResStr("rsNamedSets")
         : (h.CubeHierarchy.DisplayFolder ?? "");
     IsFiltered              = h.Filtered || h.FilteredByLevelFilters;
     Origin                  = h.Origin;
     IsDate                  = h.Dimension.CubeDimension.fDimensionType == DimensionType.dtTime;
     AllowFilter             = h.AllowFilter && h.AllowHierarchyEditor && grid.AllowFiltering;
     UnfetchedMembersVisible = h.UnfetchedMembersVisible;
     if (h.Levels != null && h.Levels.Count > 0)
     {
         var l = new List <ClientLevel>(h.Levels.Count);
         foreach (var ll in h.Levels)
         {
             l.Add(new ClientLevel(ll));
         }
         Levels = l.ToArray();
     }
 }
예제 #24
0
        internal MetaLine GetMetaline(IList <int> LevelIndexes)
        {
            if (cache_indexes != null && cache_indexes.Length == LevelIndexes.Count &&
                cache_ml != null)
            {
                var b = true;
                for (var i = 0; i < LevelIndexes.Count; i++)
                {
                    if (LevelIndexes[i] != cache_indexes[i])
                    {
                        b = false;
                        break;
                    }
                }
                if (b)
                {
                    return(cache_ml);
                }
            }
            cache_indexes = new int[LevelIndexes.Count];
            LevelIndexes.CopyTo(cache_indexes, 0);

            var key = RadarUtils.Join('.', LevelIndexes);

            MetaLine M;

            FMetaLines.TryGetValue(key, out M);
            if (M != null)
            {
                cache_ml = M;
                return(M);
            }
            M = CreateMetaline(FGrid, LevelIndexes);
            FMetaLines.Add(key, M);
            cache_ml = M;
            return(M);
        }
예제 #25
0
        //As the format string can be used template
        //"string1%;string2%; " string3" or "string". Each string can include the following statements,
        //which-naming replaced by real members:
        //%{First} - the First member of the current бакита
        //%{Last} - the Last member of the current бакита
        //%{Previous last} - the Last member of the previous бакита
        //%{Next first} - First слен next бакита
        //%{Min} - Minimum (lowest) member of the current бакита
        //%{Max} - the Maximum (highest) member of the current бакита
        //%{Previous Min} - Minimum (lowest) member of the previous бакита
        //%{Previous Max} - the Maximum (highest) member of the previous бакита
        //%{Next Min} - Minimum (lowest) member of the next бакита
        //%{Next Max} - the Maximum (highest) member of the next бакита
        //%{Index} - the Index of the current бакита

        internal void SetBucketFormat(string BucketNameFormat, string AFormatString)
        {
            fFormatString = AFormatString;

            var S     = BucketNameFormat;
            var bmd   = RadarUtils.GetResStr("rsBucketMemberDelimiter");
            var Index = S.IndexOf(bmd);

            if (Index == -1)
            {
                fString1 = S;
                fString2 = S;
                fString3 = S;
                return;
            }

            fString1 = S.Substring(0, Index);
            S        = S.Substring(Index + bmd.Length, S.Length - 1);

            Index = S.IndexOf(bmd);
            if (Index == -1)
            {
                fString2 = S;
                fString3 = S;
                return;
            }
            fString2 = S.Substring(0, Index - 1);
            S        = S.Substring(Index + bmd.Length, S.Length - (Index + bmd.Length));

            Index = S.IndexOf(bmd);
            if (Index == -1)
            {
                fString3 = S;
                return;
            }
            fString3 = S.Substring(0, Index - 1);
        }
예제 #26
0
        internal static string ExtractOperator(string S, int Index1, int Index2)
        {
            var rsOperatorSign = RadarUtils.GetResStr("rsOperatorSign");
            var StartPos       = S.IndexOf(rsOperatorSign);

            if (StartPos == -1)
            {
                return(null);
            }

            if (S[StartPos + 1] != '{')
            {
                throw new Exception(RadarUtils.GetResStr("rsecWrongBucketOperatorFormat") + S);
            }

            var Index = StartPos + 2;

            while (Index <= S.Length)
            {
                if (S[Index] == '}')
                {
                    break;
                }
                else
                {
                    Index++;
                }
            }
            if (Index > S.Length)
            {
                throw new Exception(RadarUtils.GetResStr("rsecWrongBucketOperatorFormat") + S);
            }

            //var Index1 = StartPos;
            //var Index2 = Index;
            return(S.Substring(StartPos + 2, Index - StartPos - 2));
        }
        internal JsonChartSettings(OlapChart chart)
            : base(chart)
        {
            url_pointsMenu      = chart.ImageUrl("pointsMenu.png");
            url_pointsBtn       = chart.ImageUrl("points.png");
            url_holesBtn        = chart.ImageUrl("holes.png");
            url_linesMenu       = chart.ImageUrl("linesMenu.png");
            url_linesBtn        = chart.ImageUrl("lines.png");
            url_polylinesBtn    = chart.ImageUrl("polylines.png");
            url_stepLinesBtn    = chart.ImageUrl("stepLines.png");
            url_deltaLinesBtn   = chart.ImageUrl("deltaLines.png");
            url_percentLinesBtn = chart.ImageUrl("percentLines.png");
            url_barsMenu        = chart.ImageUrl("barsMenu.png");
            url_barsBtn         = chart.ImageUrl("bars.png");
            url_deltaBarsBtn    = chart.ImageUrl("deltaBars.png");
            url_percentBarsBtn  = chart.ImageUrl("percentBars.png");
            url_areasMenu       = chart.ImageUrl("areasMenu.png");
            url_areasBtn        = chart.ImageUrl("areas.png");
            url_deltaAreasBtn   = chart.ImageUrl("deltaAreas.png");
            url_percentAreasBtn = chart.ImageUrl("percentAreas.png");
            url_piesMenu        = chart.ImageUrl("piesMenu.png");
            url_piesBtn         = chart.ImageUrl("pies.png");
            url_trendsMenu      = chart.ImageUrl("trendsMenu.png");
            url_noTrendsBtn     = chart.ImageUrl("noTrends.png");
            url_linTrendsBtn    = chart.ImageUrl("linTrends.png");
            url_quadTrendsBtn   = chart.ImageUrl("quadTrends.png");
            url_cubicTrendsBtn  = chart.ImageUrl("cubicTrends.png");
            rsClose             = RadarUtils.GetResStr("rsClose");
            rsShowUnderlying    = RadarUtils.GetResStr("mnShowUnderlying");

            //url_nextlevel = chart.ImageUrl("Expand.gif");
            //url_collapsedl = chart.ImageUrl("Collapse.gif");
            //url_nextlevel = chart.ImageUrl("Expand_Level.gif");

            url_nextlevel  = chart.ImageUrl("plus.png");
            url_collapsedl = chart.ImageUrl("minus.png");
        }
        internal Intelligence(Level parent, IntelligenceType type)
        {
            fParent           = parent.Hierarchy;
            fIntelligenceType = type;
            if (type == IntelligenceType.itMemberToDate)
            {
                fDisplayName = string.Format(RadarUtils.GetResStr("rsiMemberToDate"), parent.DisplayName);

                fExpression = "COALESCEEMPTY({2}(PERIODSTODATE(" + parent.UniqueName + ",{0}), {1}), 0)";

                fIntelligenceGroup = string.Format(RadarUtils.GetResStr("rsiTimeIntelligence"), fParent.DisplayName);

                return;
            }
            if (type == IntelligenceType.itMemberGrowth)
            {
                fDisplayName = string.Format(RadarUtils.GetResStr("rsiMemberGrowth"), parent.DisplayName);
                //                fExpression = "COALESCEEMPTY({2}({{0}}, {1}), 0) - COALESCEEMPTY({2}({PARALLELPERIOD(" + parent.UniqueName + ",1,{0})}, {1}), 0)";

                fExpression = "COALESCEEMPTY(({0}, {1}) - (PARALLELPERIOD(" + parent.UniqueName + ",1,{0}), {1}), 0)";

                fIntelligenceGroup = string.Format(RadarUtils.GetResStr("rsiTimeIntelligence"), fParent.DisplayName);
            }
        }
예제 #29
0
        void UpdateLock(int index)
        {
            TargetSignatureData lockedTarget = lockedTargets[index];

            Vector3 targetPlanarDirection =
                Vector3.ProjectOnPlane(lockedTarget.predictedPosition - referenceTransform.position,
                                       referenceTransform.up);
            float lookAngle = Vector3.Angle(targetPlanarDirection, referenceTransform.forward);

            if (referenceTransform.InverseTransformPoint(lockedTarget.predictedPosition).x < 0)
            {
                lookAngle = -lookAngle;
            }

            if (omnidirectional)
            {
                if (lookAngle < 0)
                {
                    lookAngle += 360;
                }
            }

            lockScanAngle = lookAngle + currentAngleLock;
            if (!canTrackWhileScan && index == lockedTargetIndex)
            {
                currentAngle = lockScanAngle;
            }
            float angleDelta          = lockRotationSpeed * Time.fixedDeltaTime;
            float lockedSignalPersist = lockRotationAngle / lockRotationSpeed;
            //RadarUtils.ScanInDirection(lockScanAngle, referenceTransform, angleDelta, referenceTransform.position, minLockedSignalThreshold, ref attemptedLocks, lockedSignalPersist);
            bool radarSnapshot = (snapshotTicker > 30);

            if (radarSnapshot)
            {
                snapshotTicker = 0;
            }
            else
            {
                snapshotTicker++;
            }
            //RadarUtils.ScanInDirection (new Ray (referenceTransform.position, lockedTarget.predictedPosition - referenceTransform.position), lockRotationAngle * 2, minLockedSignalThreshold, ref attemptedLocks, lockedSignalPersist, true, rwrType, radarSnapshot);

            if (
                Vector3.Angle(lockedTarget.position - referenceTransform.position,
                              this.lockedTarget.position - referenceTransform.position) > multiLockFOV / 2)
            {
                UnlockTargetAt(index, true);
                return;
            }

            RadarUtils.RadarUpdateLockTrack(
                new Ray(referenceTransform.position, lockedTarget.predictedPosition - referenceTransform.position),
                lockedTarget.predictedPosition, lockRotationAngle * 2, this, lockedSignalPersist, true, index, lockedTarget.vessel);

            //if still failed or out of FOV, unlock.
            if (!lockedTarget.exists ||
                (!omnidirectional &&
                 Vector3.Angle(lockedTarget.position - referenceTransform.position, transform.up) >
                 directionalFieldOfView / 2))
            {
                //UnlockAllTargets();
                UnlockTargetAt(index, true);
                return;
            }

            //unlock if over-jammed
            // MOVED TO RADARUTILS!

            //cycle scan direction
            if (index == lockedTargetIndex)
            {
                currentAngleLock += lockScanDirection * angleDelta;
                if (Mathf.Abs(currentAngleLock) > lockRotationAngle / 2)
                {
                    currentAngleLock  = Mathf.Sign(currentAngleLock) * lockRotationAngle / 2;
                    lockScanDirection = -lockScanDirection;
                }
            }
        }
예제 #30
0
        public bool TryLockTarget(Vector3 position)
        {
            if (!canLock)
            {
                return(false);
            }

            if (BDArmorySettings.DRAW_DEBUG_LABELS)
            {
                Debug.Log("[BDArmory]: Trying to radar lock target with (" + radarName + ")");
            }

            if (currentLocks == maxLocks)
            {
                if (BDArmorySettings.DRAW_DEBUG_LABELS)
                {
                    Debug.Log("[BDArmory]: - Failed, this radar already has the maximum allowed targets locked.");
                }
                return(false);
            }

            Vector3 targetPlanarDirection = Vector3.ProjectOnPlane(position - referenceTransform.position,
                                                                   referenceTransform.up);
            float angle = Vector3.Angle(targetPlanarDirection, referenceTransform.forward);

            if (referenceTransform.InverseTransformPoint(position).x < 0)
            {
                angle = -angle;
            }
            //TargetSignatureData.ResetTSDArray(ref attemptedLocks);
            RadarUtils.RadarUpdateScanLock(weaponManager, angle, referenceTransform, lockAttemptFOV, referenceTransform.position, this, true, ref attemptedLocks, signalPersistTime);

            for (int i = 0; i < attemptedLocks.Length; i++)
            {
                if (attemptedLocks[i].exists && (attemptedLocks[i].predictedPosition - position).sqrMagnitude < 40 * 40)
                {
                    if (!locked && !omnidirectional)
                    {
                        float targetAngle = VectorUtils.SignedAngle(referenceTransform.forward,
                                                                    Vector3.ProjectOnPlane(attemptedLocks[i].position - referenceTransform.position,
                                                                                           referenceTransform.up), referenceTransform.right);
                        currentAngle = targetAngle;
                    }
                    lockedTargets.Add(attemptedLocks[i]);
                    currLocks = lockedTargets.Count;

                    if (BDArmorySettings.DRAW_DEBUG_LABELS)
                    {
                        Debug.Log("[BDArmory]: - Acquired lock on target (" + attemptedLocks[i].vessel?.name + ")");
                    }

                    vesselRadarData.AddRadarContact(this, lockedTarget, true);
                    vesselRadarData.UpdateLockedTargets();
                    return(true);
                }
            }

            if (BDArmorySettings.DRAW_DEBUG_LABELS)
            {
                Debug.Log("[BDArmory]: - Failed to lock on target.");
            }

            return(false);
        }