public bool TryEnterShip(DSWaitingParty party) { Dictionary <long, DSPlayer> members = party.Members; if (this.DSWaitingQueue.ShipSize < this.Players.Count + members.Count) { return(false); } if (this.IsEnterable(this, members) && !this.IsTimePassed) { this.QuestID = party.QuestID; if (!this.DSWaitingQueue.IsGiantRaid) { this.MicroPlayID = party.MicroPlayID; this.PartyID = party.PartyID; this.IsAdultMode = party.IsAdultMode; } foreach (DSPlayer dsplayer in members.Values) { this.Players[dsplayer.CID] = dsplayer; dsplayer.RegisterShip(this); } if (this.ShipState == DSShipState.Launched) { this.SyncAllDSMemberStatus(); } return(true); } return(false); }
public void UnregisterPlayer(DSPlayer player) { if (player.WaitingParty != null) { DSWaitingParty waitingParty = player.WaitingParty; waitingParty.RemovePlayer(player); if (waitingParty.Members.Count == 0) { this.WaitingParties.Remove(waitingParty.Node); if (FeatureMatrix.IsEnable("DSDynamicLoad") && this.WaitingParties.Count == 0) { DSService.Instance.DSEntityMakerSystem.Dequeue(this.ID, this.DSType); } } this.Process(this.WaitingParties.First); return; } if (player.Ship != null) { DSShip ship = player.Ship; ship.RemovePlayer(player); if (ship.HasEmptySlot) { this.Process(this.WaitingParties.First); } } }
public RegisterDSPartyResult Register(string quest, List <DSPlayerInfo> partyInfo, long microPlayID, long partyID, bool isGiantRaid, bool isAdultMode) { DSLog.AddLog(-1, quest, -1L, -1, "Register", partyInfo.Count.ToString()); string key = isGiantRaid ? quest : (this.DSStorage.CheckIsolateNormalQuest(quest) ? "isolate" : "normal"); DSWaitingQueue dswaitingQueue = this.QueueDict.TryGetValue(key); if (dswaitingQueue == null) { Log <DSWaitingSystem> .Logger.InfoFormat("[RegisterFail NoSuchQuest] quest:{0} microPlayID:{1} partyID:{2} partyCount:{3}", new object[] { quest, microPlayID, partyID, partyInfo.Count }); return(RegisterDSPartyResult.NoSuchQuest); } foreach (DSPlayerInfo dsplayerInfo in partyInfo) { if (this.DSPlayerDict.ContainsKey(dsplayerInfo.CID)) { Log <DSWaitingSystem> .Logger.InfoFormat("[RegisterFail AlreadyInQueue] quest:{0} microPlayID:{1} partyID:{2} partyCount:{3} cid:{4}", new object[] { quest, microPlayID, partyID, partyInfo.Count, dsplayerInfo.CID }); return(RegisterDSPartyResult.AlreadyInQueue); } } DSWaitingParty dswaitingParty = new DSWaitingParty(dswaitingQueue, partyInfo, quest, microPlayID, partyID, isGiantRaid, isAdultMode); foreach (DSPlayer dsplayer in dswaitingParty.Members.Values) { this.DSPlayerDict.Add(dsplayer.CID, dsplayer); } if (!dswaitingQueue.RegisterParty(dswaitingParty)) { foreach (DSPlayer dsplayer2 in dswaitingParty.Members.Values) { this.DSPlayerDict.Remove(dsplayer2.CID); Log <DSWaitingSystem> .Logger.InfoFormat("[RegisterFail CannotJoinQuest] quest:{0} microPlayID:{1} partyID:{2} partyCount:{3} cid:{4}", new object[] { quest, microPlayID, partyID, partyInfo.Count, dsplayer2.CID }); } dswaitingParty.Clear(); return(RegisterDSPartyResult.CannotJoinQuest); } return(RegisterDSPartyResult.Success); }
public bool Step(ref LinkedListNode <DSWaitingParty> from) { if (this.WaitingParties.Count == 0 || from == null) { return(false); } bool flag = true; foreach (DSShip dsship in this.Ships) { if (dsship.HasEmptySlot) { flag = false; break; } } if (flag) { DSInfo waitingDS = this.Parent.DSStorage.GetWaitingDS(this.DSType); if (waitingDS == null) { if (FeatureMatrix.IsEnable("DSDynamicLoad")) { DSService.Instance.DSEntityMakerSystem.Enqueue(this.ID, this.DSType); } return(false); } DSShip dsship2 = new DSShip(this, waitingDS); dsship2.Node = this.Ships.AddLast(dsship2); } do { DSWaitingParty value = from.Value; from = from.Next; foreach (DSShip dsship3 in this.Ships) { if (dsship3.HasEmptySlot && dsship3.TryEnterShip(value)) { value.Clear(); this.WaitingParties.Remove(value); return(true); } } }while (from != null); DSInfo waitingDS2 = this.Parent.DSStorage.GetWaitingDS(this.DSType); if (waitingDS2 == null) { return(false); } DSShip dsship4 = new DSShip(this, waitingDS2); dsship4.Node = this.Ships.AddLast(dsship4); from = this.WaitingParties.First; return(true); }
public DSPlayer(DSWaitingParty parent, long cid, long fid, int level, bool isGiantRaid) { this.DSWaitingQueue = parent.DSWaitingQueue; this.WaitingParty = parent; this.Status = DSPlayerStatus.Waiting; this.CID = cid; this.FID = fid; this.Level = level; this.IsGiantRaid = isGiantRaid; if (this.FID > 0L) { this.FrontendConn = DSService.Instance.Connect(DSService.Instance.DSServiceEntity, new Location(this.FID, "FrontendServiceCore.FrontendService")); this.FrontendConn.Closed += delegate(object _, EventArgs <IEntityProxy> __) { this.DSWaitingQueue.Parent.Unregister(this.CID, false); }; return; } this.FrontendConn = null; }
public bool RegisterParty(DSWaitingParty party) { if (this.IsGiantRaid) { if (party.Members.Count > this.ShipSize) { return(false); } foreach (KeyValuePair <long, DSPlayer> keyValuePair in party.Members) { if (keyValuePair.Value.Level < this.LevelConstraint) { return(false); } } } LinkedListNode <DSWaitingParty> linkedListNode = this.WaitingParties.AddLast(party); this.Process(linkedListNode); party.Node = linkedListNode; return(true); }