AddEntity() публичный Метод

Add an entity to this zone
public AddEntity ( ServerEntity entity ) : void
entity ServerEntity
Результат void
Пример #1
0
        /// <summary>
        /// Tries to move a user in to a new zone.
        /// </summary>
        public bool RequestZoneTransfer(ServerEntity entity, int newZoneID)
        {
            //Check the zone exists
            if (m_zones.ContainsKey(newZoneID))
            {
                Zone newZone = m_zones[newZoneID];

                //See if the user is already in a zone
                if (m_userZones.ContainsKey(entity))
                {
                    //Remove them from their current zone
                    Zone currentZone = m_userZones[entity];
                    currentZone.RemoveEntity(entity);
                }
                else
                {
                    //Add them to the zone index
                    m_userZones.Add(entity, newZone);
                }

                //Move them in to their new zone
                m_userZones[entity] = newZone;
                newZone.AddEntity(entity);

                return(true);
            }

            return(false);
        }