/// <summary> /// Determines whether the editor settings of the DebugUnitCreator provided allows the candidateOwner to /// become the owner. This is determined by comparing the desiredUserRelationship of the creator to /// the candidateOwner's InitialRelationship with the user. /// </summary> /// <param name="creatorSettings">The creator settings.</param> /// <param name="candidateOwner">The candidate owner.</param> /// <returns> /// <c>true</c> if [is owner of creator] [the specified creator settings]; otherwise, <c>false</c>. /// </returns> private bool IsOwnerOfCreator(AUnitCreatorEditorSettings creatorSettings, Player candidateOwner) { if (creatorSettings.IsOwnerUser != candidateOwner.IsUser) { return false; } if (candidateOwner.IsUser) { return true; } D.Assert(!creatorSettings.IsOwnerUser && !candidateOwner.IsUser); DiplomaticRelationship desiredUserRelationshipOfCreator = creatorSettings.DesiredRelationshipWithUser.Convert(); IList<Player> aiOwnerCandidates; if (_aiPlayerInitialUserRelationsLookup.TryGetValue(desiredUserRelationshipOfCreator, out aiOwnerCandidates)) { return aiOwnerCandidates.Contains(candidateOwner); } return false; }
private void ValidateOwner(Player owner, AUnitCreatorEditorSettings editorSettings) { if (owner.IsUser) { D.Assert(editorSettings.IsOwnerUser); } else { D.AssertEqual(owner.__InitialUserRelationship, editorSettings.DesiredRelationshipWithUser.Convert()); } }