示例#1
0
        /// <summary>
        /// Sets the DiplomaticRelationship between this player and <c>otherPlayer</c> who have already met.
        /// Then synchronizes <c>otherPlayer</c>'s DiploRelations state with this player, finally raising a
        /// <c>relationsChanged</c> event after both states are synchronized. Internal version intended for Player to Player coordination. 
        /// <remarks>Done this way to allow both player's DiploRelationship state to be
        /// synchronized BEFORE either raises a relationsChanged event.</remarks>
        /// </summary>
        /// <param name="otherPlayer">The otherPlayer.</param>
        /// <param name="newRelationship">The relationship.</param>
        internal virtual void SetRelationsWith_Internal(Player otherPlayer, DiplomaticRelationship newRelationship) {
            D.AssertNotEqual(otherPlayer, TempGameValues.NoPlayer);
            D.AssertNotEqual(otherPlayer, this, "OtherPlayer not allowed to be self.");
            D.AssertNotEqual(newRelationship, DiplomaticRelationship.None);
            D.AssertNotEqual(newRelationship, DiplomaticRelationship.Self);
            if (!IsKnown(otherPlayer)) {
                D.Error("{0}: {1} not yet met.", DebugName, otherPlayer);
            }
            DiplomaticRelationship existingRelationship = _currentRelationship[otherPlayer];
            D.Assert(existingRelationship != DiplomaticRelationship.None && newRelationship != DiplomaticRelationship.Self);
            if (existingRelationship == newRelationship) {
                D.Warn("{0} is attempting to set Relations to {1}, a value it already has.", DebugName, newRelationship.GetValueName());
                return;
            }

            _priorRelationship[otherPlayer] = existingRelationship;
            _currentRelationship[otherPlayer] = newRelationship;
            OnRelationsChanged(otherPlayer);
        }