Exemplo n.º 1
0
        public void Chart(int maxDistanceFromNode)
        {
            _maxDistanceFromNode = maxDistanceFromNode;

            foreach (DictionaryEntry entry in MappedPoints)
            {
                (entry.Value as PlottedMapPoint).NonPlayerEntities.Clear();
            }

            //locate all npcs
            foreach (var npc in _npcs)
            {
                NonPlayerEntity entity = npc;
                _npcLocations.Remove(entity);

                Vector3         coords = new Vector3(entity.X, entity.Y, entity.Z);
                PlottedMapPoint pt     = FindNearest(coords, entity.ZoneId);
                if ((pt != null) && (pt.Location.Distance(coords) < maxDistanceFromNode))
                {
                    pt.AddNPC(entity);
                    _npcLocations.Add(entity, pt);
                }
            }

            //find shortest routes for each type (caching here so faster when playing game).
        }
Exemplo n.º 2
0
        public void AddNPE(NonPlayerEntity entity)
        {
            string key = entity.RomId.ToString() + "." + entity.UniqueId.ToString();

            if (_npcLookup.ContainsKey(key))
            {
                throw new ArgumentException("Entity Id already exists in the map", "entity");
            }

            _npcLookup.Add(key, entity);
            if (_npcByRomId.ContainsKey(entity.RomId))
            {
                throw new ArgumentException("Entity RomId already exists in the map", "entity");
            }
            ;
            _npcByRomId.Add(entity.RomId, entity);

            Vector3         coords = new Vector3(entity.X, entity.Y, entity.Z);
            PlottedMapPoint pt     = FindNearest(coords, entity.ZoneId);

            if ((pt != null) && (pt.Location.Distance(coords) < _maxDistanceFromNode))
            {
                pt.AddNPC(entity);
                _npcLocations.Add(entity, pt);
            }
        }