Example #1
0
        private void FetchDangerRegions(object source = null, ElapsedEventArgs e = null)
        {
            lock (m_FetchDangerRegionsLock)
            {
                if (IsUpdating && DangerRegionsEnabled)
                {
                    try
                    {
                        IEnumerable <ActorCommonData> objects = ActorCommonDataHelper.Enumerate(x => (x.x184_ActorType == ActorType.ServerProp || x.x184_ActorType == ActorType.Monster || x.x184_ActorType == ActorType.Projectile || x.x184_ActorType == ActorType.CustomBrain) && DANGERS.Exists(d => x.x004_Name.Contains(d.name)));

                        HashSet <region_data> dangers = new HashSet <region_data>();

                        foreach (ActorCommonData obj in objects)
                        {
                            danger_data data = DANGERS.Find(d => obj.x004_Name.Contains(d.name));
                            if (data != null)
                            {
                                Vec3 pos  = new Vec3(obj.x0D0_WorldPosX, obj.x0D4_WorldPosY, obj.x0D8_WorldPosZ);
                                AABB area = new AABB(pos - new Vec3(data.range, data.range, pos.Z - 100), pos + new Vec3(data.range, data.range, pos.Z + 100));
                                dangers.Add(new region_data(area, data.move_cost_mult));
                            }
                        }

                        Regions = dangers;
                    }
                    catch (Exception)
                    {
                    }
                }

                m_FetchDangerRegionsTimer.Start();
            }
        }
Example #2
0
        //private static bool IsValidMonster(ActorCommonData acd)
        //{
        //    return acd.x188_Hitpoints > 0.00001 && // seems to be lower limit for what D3 considers dead
        //        (acd.x194_Flags_Is_Trail_Proxy_Etc & 1) == 0 && // this removes most weird actors
        //        acd.x190_TeamId == 10; // = hostile
        //}

        public void GetAllMonsters()
        {
            var engine = Engine.Create();
            var acds   = new ActorCommonData[0];
            var pt     = System.Diagnostics.Stopwatch.StartNew();

            for (int i = 0; i < 1000; i++)
            {
                acds = ActorCommonDataHelper.EnumerateMonsters().ToArray();
            }
            pt.Stop();
            Console.WriteLine("Getting all monster ACDs 1000 times took " + pt.Elapsed.TotalMilliseconds.ToString("0.00") + "ms");
            Console.WriteLine("Max update frequency: " + (1000d / (pt.Elapsed.TotalMilliseconds / 1000)).ToString("0") + "Hz");
            Console.WriteLine("Number of ACDs: " + ActorCommonDataHelper.Enumerate(a => true).Count());
            Console.ReadLine();
        }