Пример #1
0
        /// <summary>
        /// Adds an object to the list of visible objects
        /// only maintained for players
        /// </summary>
        /// <returns>TRUE if object was previously not visible, and added to the visible list</returns>
        public bool AddVisibleObject(PhysicsObj obj)
        {
            rwLock.EnterWriteLock();
            try
            {
                if (VisibleObjects.ContainsKey(obj.ID))
                {
                    return(false);
                }

                if (InitialClamp && !KnownObjects.ContainsKey(obj.ID))
                {
                    var distSq = PhysicsObj.Position.Distance2DSquared(obj.Position);

                    if (distSq > InitialClamp_DistSq)
                    {
                        return(false);
                    }
                }

                //Console.WriteLine($"{PhysicsObj.Name}.AddVisibleObject({obj.Name})");
                VisibleObjects.TryAdd(obj.ID, obj);

                if (obj.WeenieObj.IsMonster)
                {
                    obj.ObjMaint.AddVisibleTarget(PhysicsObj, false);
                }

                return(true);
            }
            finally
            {
                rwLock.ExitWriteLock();
            }
        }
Пример #2
0
 public bool VisibleObjectsContainsKey(uint key)
 {
     rwLock.EnterReadLock();
     try
     {
         return(VisibleObjects.ContainsKey(key));
     }
     finally
     {
         rwLock.ExitReadLock();
     }
 }
Пример #3
0
        public void Faded()
        {
            Monster m;

            Owner.DeadMembers.Enqueue(this);
            Owner.DyingMembers.TryRemove(UID, out m);
            Common.MapService.RemoveFlag(MapID, X, Y, TinyMap.TileFlag.Monster);
            var packet = GeneralActionPacket.Create(UID, DataAction.RemoveEntity, 0, 0);

            foreach (var p in Map.QueryPlayers(this))
            {
                if (p.VisibleObjects.ContainsKey(UID))
                {
                    uint x; p.Send(packet); p.VisibleObjects.TryRemove(UID, out x);
                }
                if (VisibleObjects.ContainsKey(p.UID))
                {
                    uint x; VisibleObjects.TryRemove(p.UID, out x);
                }
            }
        }