Exemplo n.º 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();
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Adds an object to the list of known objects
        /// only maintained for players
        /// </summary>
        /// <returns>true if previously an unknown object</returns>
        public bool AddKnownObject(PhysicsObj obj)
        {
            rwLock.EnterWriteLock();
            try
            {
                if (KnownObjects.ContainsKey(obj.ID))
                {
                    return(false);
                }

                KnownObjects.TryAdd(obj.ID, obj);

                // maintain KnownPlayers for both parties
                if (obj.IsPlayer)
                {
                    AddKnownPlayer(obj);
                }

                obj.ObjMaint.AddKnownPlayer(PhysicsObj);

                return(true);
            }
            finally
            {
                rwLock.ExitWriteLock();
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Adds an object.
        /// </summary>
        /// <param name="o"></param>
        /// <returns>The object's ID. IDs are unique within any any given object type but not across types.</returns>
        public int Add(object o)
        {
            if (o == null)
            {
                return(-1);
            }
            var type = o.GetType();

            if (!KnownTypes.ContainsKey(type.AssemblyQualifiedName))
            {
                KnownTypes.Add(type.AssemblyQualifiedName, type);
            }
            if (!KnownObjects.ContainsKey(type))
            {
                KnownObjects.Add(type, new List <object>());
            }
//			if (!KnownObjects[type].Contains(o))
            KnownObjects[type].Add(o);
            if (!KnownIDs.ContainsKey(type))
            {
                KnownIDs.Add(type, new SafeDictionary <object, int>());
            }
            var id = KnownObjects[type].Count - 1;

            KnownIDs[type].Add(o, id);
            AddProperties(type);
            return(id);
        }
Exemplo n.º 4
0
 public bool KnownObjectsContainsKey(uint guid)
 {
     rwLock.EnterReadLock();
     try
     {
         return(KnownObjects.ContainsKey(guid));
     }
     finally
     {
         rwLock.ExitReadLock();
     }
 }
Exemplo n.º 5
0
        /// <summary>
        /// Adds an object to the list of known objects
        /// only maintained for players
        /// </summary>
        /// <returns>true if previously an unknown object</returns>
        public bool AddKnownObject(PhysicsObj obj)
        {
            if (KnownObjects.ContainsKey(obj.ID))
            {
                return(false);
            }

            KnownObjects.Add(obj.ID, obj);

            // maintain KnownPlayers for both parties
            if (obj.IsPlayer)
            {
                AddKnownPlayer(obj);
            }

            obj.ObjMaint.AddKnownPlayer(PhysicsObj);

            return(true);
        }