コード例 #1
0
ファイル: GroupMgr.cs プロジェクト: boscorillium/dol
		/// <summary>
		/// Adds a group to the list of groups
		/// </summary>
		/// <param name="key"></param>
		/// <param name="group">The group to add</param>
		/// <returns>True if the function succeeded, otherwise false</returns>
		public static bool AddGroup(object key, Group group)
		{
			lock(m_groups)
			{
				if(!m_groups.Contains(key))
				{
					m_groups.Add(key, group);
					return true;
				}
			}

			return false;
		}
コード例 #2
0
ファイル: WarMapMgr.cs プロジェクト: mynew4/DOLSharp
        public static bool AddGroup(byte zoneid, int x, int y, string name, byte realm)
        {
            if (!ServerProperties.Properties.ENABLE_WARMAPMGR)
                return false;

            lock (m_groups)
            {
                if (m_groups.ContainsKey(name)) return false;
                m_groups.Add(name, new Dictionary<long,Group>());
                Zone zone = WorldMgr.GetZone(zoneid);
                if (zone == null) return false;
                long time = NFTime;
                Group group = new Group();
                group.Zone = zoneid;
                group.X = (byte)((x - zone.XOffset) >> 14);
                group.Y = (byte)((y - zone.YOffset) >> 14);
                group.Realm = realm;
                while (m_groups[name].ContainsKey(time)) time++;
                m_groups[name].Add(time, group);
             }
            return true;
        }
コード例 #3
0
ファイル: GroupMgr.cs プロジェクト: mynew4/DAoC
		/// <summary>
		/// Removes a group from the manager
		/// </summary>
		/// <param name="group"></param>
		/// <returns></returns>
		public static bool RemoveGroup(Group group)
		{
			bool dummy;
			return m_groups.TryRemove(group, out dummy);
		}
コード例 #4
0
ファイル: GroupMgr.cs プロジェクト: mynew4/DAoC
		/// <summary>
		/// Adds a group to the list of groups
		/// </summary>
		/// <param name="group">The group to add</param>
		/// <returns>True if the function succeeded, otherwise false</returns>
		public static bool AddGroup(Group group)
		{
			return m_groups.AddIfNotExists(group, true);
		}
コード例 #5
0
        /// <summary>
        /// Update Instance Owner based on population still inside.
        /// </summary>
        public void UpdateInstanceOwner()
        {
            if(this.NumPlayers < 1)
            {
                return;
            }

            //there is still player inside search for owner or any change.

            //search vars
            GamePlayer arbitraryplayer = null;
            Group arbitrarygroup = null;
            bool stillOwner = false;

            // group instance
            if(m_group != null)
            {
                // check if group still inside
                foreach(GamePlayer ininstance in this.PlayersInside)
                {
                    if(ininstance.Group != null && m_group == ininstance.Group)
                    {
                        m_player = ininstance.Group.Leader;
                        stillOwner = true;
                        break;
                    }
                    else if(ininstance.Group != null)
                    {
                        arbitrarygroup = ininstance.Group;
                        arbitraryplayer = ininstance.Group.Leader;
                    }
                }
            }

            // check if player owner is still inside
            if(!stillOwner && m_player != null)
            {
                foreach(GamePlayer ininstance in this.PlayersInside)
                {
                    if(ininstance == m_player)
                    {
                        if(m_player.Group != null)
                        {
                            m_group = m_player.Group;
                            m_player = m_player.Group.Leader;
                        }
                        stillOwner = true;
                        break;
                    }
                    else
                    {
                        arbitraryplayer = ininstance;
                    }
                }
            }

            // if no owner found
            if(!stillOwner)
            {
                //give ownership arbitrarly
                if(arbitrarygroup != null)
                {
                    m_group = arbitrarygroup;
                    m_player = arbitrarygroup.Leader;
                }
                else if(arbitraryplayer != null)
                {
                    m_group = null;
                    m_player = arbitraryplayer;
                }

            }
        }
コード例 #6
0
        /// <summary>
        /// Player Leaving instance, start destroy timer if needed
        /// </summary>
        /// <param name="player">The Player exiting</param>
        public override void OnPlayerLeaveInstance(GamePlayer player)
        {
            // last player going out
            if(this.NumPlayers == 1)
            {
                if(player.Group != null)
                {
                    this.m_group = player.Group;
                    this.m_player = player.Group.Leader;
                }
                else {
                    this.m_group = null;
                    this.m_player = player;
                }
            }

            //Decrease the amount of players
            base.OnPlayerLeaveInstance(player);

            if(this.NumPlayers > 0)
            {
                UpdateInstanceOwner();
            }
            else
            {
                // check if there is still alive mobs
                foreach (GameNPC mob in GetMobsInsideInstance(true))
                {
                    // there is still something => standard autoclosure + break;
                    log.Warn("Instance now empty, will destroy instance " + Description + ", ID: " + ID + ", type=" + GetType().ToString() + ". In " + ServerProperties.Properties.ADVENTUREWING_TIME_TO_DESTROY + " min.");
                    this.BeginAutoClosureCountdown(ServerProperties.Properties.ADVENTUREWING_TIME_TO_DESTROY);

                    return;
                }

                //destroy
                log.Warn("Instance now empty, will destroy instance " + Description + ", ID: " + ID + ", type=" + GetType().ToString() + ". Now !");
                WorldMgr.RemoveInstance(this);
            }
        }