// TODO: There are some other parts where this can be probably used. // Refactor the parts there #pragma warning disable 618 private void SetRelationship(NetworkInstanceId partnerId, RelationshipState newState) #pragma warning restore 618 { int index = PlayerRelationships.Find(partnerId); var relationship = PlayerRelationships[index]; relationship.State = newState; PlayerRelationships[index] = relationship; }
#pragma warning restore 618 /// <summary> /// Request to make peace with another player /// </summary> /// <param name="playerId">player who requests to make peace</param> #pragma warning disable 618 public void RequestPeace(NetworkInstanceId playerId) #pragma warning restore 618 { Assert.IsTrue(isServer, "Only call RequestPeace on the Server"); UpdateGUIForRequest = true; ReceivedRequest = true; PlayerOfRequest = playerId; RequestType = RelationshipState.Peace; Player.LocalPlayer.ProcessGUINextFrame(); }
#pragma warning disable 618 private void RequestTradingAgreement(NetworkInstanceId partnerId) #pragma warning restore 618 { Assert.IsTrue(isServer, "Only call RequestTradingAgreement on the Server"); UpdateGUIForRequest = true; ReceivedRequest = true; Player.LocalPlayer.ProcessGUINextFrame(); PlayerOfRequest = partnerId; RequestType = RelationshipState.TradingAgreement; }
/// <summary> /// /// </summary> /// <param name="partnerId"></param> #pragma warning disable 618 public void RequestAlliance(NetworkInstanceId partnerId) #pragma warning disable 618 { UpdateGUIForRequest = true; Assert.IsTrue(isServer, "Only call RequestTradingAgreement on the Server"); ReceivedRequest = true; Player.LocalPlayer.ProcessGUINextFrame(); PlayerOfRequest = partnerId; RequestType = RelationshipState.Alliance; }
public List <Relationship> FindAll(RelationshipState relationship) { var list = new List <Relationship>(); foreach (var element in this) { if (element.State == relationship) { list.Add(element); } } return(list); }
private Value CommittedValue(RelationshipState relState, int property, StorageRelationshipScanCursor relationship, StoragePropertyCursor properties) { if (_state.relationshipIsAddedInThisTx(relState.Id)) { return(Values.NO_VALUE); } relationship.Single(relState.Id); if (!relationship.Next()) { return(Values.NO_VALUE); } return(CommittedValue(properties, relationship.PropertiesReference(), property)); }
#pragma warning disable 618 public void DisplayRelationShipView(SyncListInt oldStates, RelationshipState newState) #pragma warning restore 618 { Show(); DisableAllViews(); ChangeRelationShipView.SetActive(true); foreach (Transform child in RelationShipListRoot) { Destroy(child.gameObject); } #pragma warning disable 618 var alreadySeenRelationships = new HashSet <(NetworkInstanceId, NetworkInstanceId)>(); #pragma warning restore 618 foreach (var player in GameManager.Instance.Players) { for (int i = 0; i < player.Diplomacy.PlayerRelationships.Count; i++) { var relationship = player.Diplomacy.PlayerRelationships[i]; if (oldStates.Contains((int)relationship.State) && !alreadySeenRelationships.Contains((relationship.PartnerId, player.netId))) { var partner = GameManager.Instance.GetPlayerOfId(relationship.PartnerId); alreadySeenRelationships.Add((player.netId, relationship.PartnerId)); string label = $"{relationship}: {player.ToString()} <-> {partner.ToString()}"; AddRelationShipRepresantation(label, () => { player.Diplomacy.CmdSetRelation(relationship.PartnerId, newState); #pragma warning disable 618 ClientScene.FindLocalObject(relationship.PartnerId).GetComponent <Diplomacy>().CmdSetRelation(player.netId, newState); #pragma warning restore 618 }); Player.LocalPlayer.MoveEventCardOnGraveyard(); } } } Player.LocalPlayer.PopulateRelationshipView = false; OnDone = OnClickDoneRelationships; }
private void CmdAcceptRequest(RelationshipState type) #pragma warning restore 618 { Assert.IsTrue(isServer, "Only run CmdAcceptRequest on the server"); #pragma warning disable 618 var requester = NetworkServer.FindLocalObject(PlayerOfRequest).GetComponent <Diplomacy>(); #pragma warning restore 618 int index = requester.PlayerRelationships.Find(netId); if (index != -1) { var relationship = requester.PlayerRelationships[index]; relationship.State = type; requester.PlayerRelationships[index] = relationship; index = PlayerRelationships.Find(PlayerOfRequest); relationship = PlayerRelationships[index]; relationship.State = type; PlayerRelationships[index] = relationship; } else { requester.PlayerRelationships.Add(new Relationship { PartnerId = netId, State = type }); PlayerRelationships.Add(new Relationship { PartnerId = PlayerOfRequest, State = type }); } ReceivedRequest = false; #pragma warning disable 618 PlayerOfRequest = NetworkInstanceId.Invalid; #pragma warning restore 618 }
private bool RestoreCircles(string[] abIds, RelationshipState state) { if (abIds == null) return false; foreach (string abId in abIds) { RestoreCircleFromAddressBook(abId, state); } return true; }
public EllieNightTwoFailure(RelationshipState relationship) { this.relationship = relationship; }
private void Create(PropertyMetadata property, object item) { var state = new RelationshipState(item); _relationshipState.Add(property.Relationship, state); }
public void CmdSetRelation(NetworkInstanceId partnerId, RelationshipState newState) #pragma warning restore 618 { SetRelationship(partnerId, newState); }
private string[] FilterWLConnections(List<string> abIds, RelationshipState state) { List<string> returnValues = new List<string>(0); foreach (string abId in abIds) { string lowerId = abId.ToLowerInvariant(); if (CircleResults.ContainsKey(lowerId)) { CircleInverseInfoType inverseInfo = CircleResults[lowerId]; if (inverseInfo.PersonalInfo.MembershipInfo.CirclePersonalMembership.State == state.ToString()) returnValues.Add(abId); } } return returnValues.ToArray(); }
/// <summary> /// Get a circle addressbook by addressbook identifier. /// </summary> /// <param name="abId"></param> /// <param name="state"></param> /// <param name="scene"></param> /// <returns></returns> private bool RequestAddressBookByABId(string abId, RelationshipState state, Scenario scene) { Trace.WriteLineIf(Settings.TraceSwitch.TraceVerbose, "Requesting AddressBook by ABId: " + abId + ", Scenario: " + scene.ToString()); abId = abId.ToLowerInvariant(); abHandleType individualAB = new abHandleType(); individualAB.ABId = abId; individualAB.Cid = 0; individualAB.Puid = 0; switch (state) { case RelationshipState.Accepted: requestCircleCount++; try { NSMessageHandler.ContactService.abRequest(PartnerScenario.Initial, individualAB, null); } catch (Exception ex1) { requestCircleCount--; Trace.WriteLineIf(Settings.TraceSwitch.TraceError, "[RequestAddressBookByABId] Error: " + ex1.Message); } break; case RelationshipState.WaitingResponse: try { NSMessageHandler.ContactService.abRequest(PartnerScenario.Initial, individualAB, null); } catch (Exception ex2) { Trace.WriteLineIf(Settings.TraceSwitch.TraceError, "[RequestAddressBookByABId] Error: " + ex2.Message); } break; } return true; }
private string[] SelectWLConnection(List<string> abIds, RelationshipState state) { List<string> results = new List<string>(0); lock (CircleResults) { foreach (string abId in abIds) { if (HasWLConnection(abId)) { if (state == RelationshipState.None) { results.Add(abId); } else { if (CircleResults[abId.ToLowerInvariant()].PersonalInfo.MembershipInfo.CirclePersonalMembership.State == state.ToString()) results.Add(abId); } } } } return results.ToArray(); }
private bool RestoreCircleFromAddressBook(string abId, RelationshipState state) { string lowerId = abId.ToLowerInvariant(); if (lowerId == WebServiceConstants.MessengerIndividualAddressBookId) return true; if (!HasAddressBook(lowerId)) { Trace.WriteLineIf(Settings.TraceSwitch.TraceVerbose, "[RestoreCircleFromAddressBook] failed, cannot find specific addressbook :" + lowerId); return false; } if (!AddressbookContacts.ContainsKey(lowerId)) { Trace.WriteLineIf(Settings.TraceSwitch.TraceVerbose, "[RestoreCircleFromAddressBook] failed, cannot find specific addressbook contact group:" + lowerId); return false; } //We use addressbook list to boot the restore procedure. ContactType me = SelectMeContactFromContactList(new List<ContactType>(AddressbookContacts[lowerId].Values).ToArray()); CircleInverseInfoType inverseInfo = SelectCircleInverseInfo(lowerId); if (me == null) { Trace.WriteLineIf(Settings.TraceSwitch.TraceVerbose, "[RestoreCircleFromAddressBook] Me Contact not found, restore circle failed:" + lowerId); return false; } if (inverseInfo == null) { Trace.WriteLineIf(Settings.TraceSwitch.TraceVerbose, "[RestoreCircleFromAddressBook] Circle inverse info not found, restore circle failed:" + lowerId); return false; } string circleMail = lowerId + "@" + Contact.DefaultHostDomain; Contact circle = NSMessageHandler.ContactList.GetCircle(circleMail); if (circle != null && circle.circleInfo != null) { Trace.WriteLineIf(Settings.TraceSwitch.TraceVerbose, "[RestoreCircleFromAddressBook] circle inverse info already exists, restore skipped:" + lowerId); return false; } circle = CreateCircle(me, inverseInfo); if (circle != null) { UpdateCircleMembersFromAddressBookContactPage(circle, Scenario.Restore); switch (circle.CircleRole) { case RoleId.Admin: case RoleId.AssistantAdmin: case RoleId.Member: AddCircleToCircleList(circle); break; case RoleId.StatePendingOutbound: FireJoinCircleInvitationReceivedEvents(circle); break; } return true; } return false; }
/// <summary> /// Use msn webservices to get addressbooks. /// </summary> /// <param name="abIds"></param> /// <param name="state"></param> /// <param name="scene"></param> private void RequestCircles(string[] abIds, RelationshipState state, Scenario scene) { if (abIds == null) return; foreach (string abId in abIds) { RequestAddressBookByABId(abId, state, scene); } }