Example #1
0
 public void HideAll(BlipType type)
 {
     foreach (var b in Blips.Where(x => x.Type == type))
     {
         b.IsEnabled = false;
     }
 }
Example #2
0
        public void ClearAll()
        {
            lock (HandleMap)
            {
                foreach (var pair in HandleMap)
                {
                    if (Blips.Contains(pair.Value))
                    {
                        new Blip(pair.Value).Remove();
                    }
                    else if (Pickups.Contains(pair.Value))
                    {
                        Function.Call(Hash.REMOVE_PICKUP, pair.Value);
                    }
                    else
                    {
                        new Prop(pair.Value).Delete();
                    }
                }

                HandleMap.Clear();
                Markers.Clear();
                Blips.Clear();
                Pickups.Clear();
                _localMarkers.Clear();
                _markerCount = 0;
            }
        }
Example #3
0
        public Blip CreateBlip(Vector3 pos, int netHandle)
        {
            var blip = World.CreateBlip(pos);

            lock (HandleMap) HandleMap.Add(netHandle, blip.Handle);
            lock (Blips) Blips.Add(blip.Handle);
            return(blip);
        }
Example #4
0
        public PredictionAlgorithm GetBestPredictionAlgorithm(Blips blips, long absoluteTime)
        {
            foreach (var type in _predictions.Keys)
            {
                if (_predictions[type].Any() && blips.Any())
                {
                    double score = _predictions[type].Aggregate(0d, (seed, prediction) =>
                    {
                        Vector actual = blips.Interpolate(prediction.Key);
                        if (actual != null)
                        {
                            const double limit = 160;
                            double dx          = Math.Abs(prediction.Value.X - actual.X);
                            double dy          = Math.Abs(prediction.Value.Y - actual.Y);
                            double h           = Math.Sqrt(dx * dx + dy * dy);
                            return(seed + (h >= limit ? 0d : limit - h));
                        }
                        return(seed);
                    });

                    if (_scores.ContainsKey(type))
                    {
                        _scores[type] += score;
                    }
                    else
                    {
                        _scores.Add(type, score);
                    }
                }
            }

            _scores.OrderByDescending(kvp => kvp.Value).ForEach(kvp => Out.WriteLine("Score: {1} {0}", kvp.Key, kvp.Value));

            double?maxScore            = null;
            PredictionAlgorithm retval = null;

            foreach (var type in _scores.Keys)
            {
                if (!maxScore.HasValue || _scores[type] > maxScore.Value)
                {
                    maxScore = _scores[type];
                    retval   = type;
                }
            }

            //foreach (var type in _scores.Keys)
            //{
            //    //clean up bad predictions
            //    if (_scores[type] <= 0d)
            //    {
            //        _predictions[type].Clear();
            //    }
            //}

            return(retval);
        }
Example #5
0
        public void CreateAndRegisterBlip(BlipType type, int index, Point coords)
        {
            CollectibleBlip blip = new CollectibleBlip()
            {
                Type = type, Index = index, Coords = coords
            };

            blip.PropertyChanged += Blip_PropertyChanged;
            Blips.Add(blip);
        }
Example #6
0
        public Blip CreateBlip(Entity entity, int netHandle)
        {
            if (entity == null)
            {
                return(null);
            }
            var blip = entity.AddBlip();

            lock (HandleMap) HandleMap.Add(netHandle, blip.Handle);
            lock (Blips) Blips.Add(blip.Handle);
            return(blip);
        }
Example #7
0
        public override void Shutdown()
        {
            base.Shutdown();

            foreach (var b in Blips)
            {
                b.PropertyChanged -= Blip_PropertyChanged;
            }
            Blips.Clear();

            TheEditor.FileOpened  -= TheEditor_FileOpened;
            TheEditor.FileClosing -= TheEditor_FileClosing;

            UnregisterChangeHandlers();
        }
Example #8
0
        private void GlobalVariables_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
        {
            if (e.Action != NotifyCollectionChangedAction.Replace)
            {
                return;
            }

            int  packageMin   = TheEditor.GetIndexOfGlobal(GlobalVariable.Package1Collected);
            int  packageMax   = TheEditor.GetIndexOfGlobal(GlobalVariable.Package100Collected);
            int  rampageMin   = TheEditor.GetIndexOfGlobal(GlobalVariable.Rampage1Passed);
            int  rampageMax   = TheEditor.GetIndexOfGlobal(GlobalVariable.Rampage20Passed);
            int  stuntJumpMin = TheEditor.GetIndexOfGlobal(GlobalVariable.StuntJump1Completed);
            int  stuntJumpMax = TheEditor.GetIndexOfGlobal(GlobalVariable.StuntJump26Completed);
            int  index        = e.NewStartingIndex;
            bool isCollected  = ((int)e.NewItems[0]) != 0;

            CollectibleBlip blip = null;

            if (index >= packageMin && index <= packageMax)
            {
                blip = Blips.Where(x => x.Type == BlipType.Package && x.Index == (index - packageMin)).FirstOrDefault();
            }
            if (index >= rampageMin && index <= rampageMax)
            {
                blip = Blips.Where(x => x.Type == BlipType.Rampage && x.Index == (index - rampageMin)).FirstOrDefault();
            }
            if (index >= stuntJumpMin && index <= stuntJumpMax)
            {
                blip = Blips.Where(x => x.Type == BlipType.StuntJump && x.Index == (index - stuntJumpMin)).FirstOrDefault();
            }

            if (blip != null)
            {
                blip.IsCollected = isCollected;
                if (!isCollected || (isCollected && IsShowingCollected))
                {
                    blip.IsEnabled = true;
                }
            }
        }
Example #9
0
        public void PlotAll(BlipType type)
        {
            int stateArrayBase = -1;

            switch (type)
            {
            case BlipType.Package: stateArrayBase = (int)GlobalVariable.Package1Collected; break;

            case BlipType.Rampage: stateArrayBase = (int)GlobalVariable.Rampage1Passed; break;

            case BlipType.StuntJump: stateArrayBase = (int)GlobalVariable.StuntJump1Completed; break;
            }

            var b = Blips.Where(x => x.Type == type).ToArray();

            for (int i = 0; i < b.Length; i++)
            {
                int state = TheEditor.GetGlobal(stateArrayBase + i);
                b[i].IsCollected = (state != 0);
                b[i].IsEnabled   = true;
            }
        }
Example #10
0
 public bool IsBlip(int localHandle)
 {
     return(Blips.Contains(localHandle));
 }