GetMembers
GetMembers
Method in Clan Class
Overview
The GetMembers
method in the Clan class retrieves all members of a clan that match a specific role. This method is essential for filtering and accessing clan members based on their roles within the clan's structure.
Method Definition
public IEnumerable<Actor> GetMembers(string roleFilter, bool inclusivePassive = false)
Description
- Parameters:
roleFilter
: A string representing the role to filter the members by (e.g., 'Engineer').inclusivePassive
: A boolean flag. If set totrue
, includes passive (e.g., deceased) members in the results. Defaults tofalse
.
- Returns: An
IEnumerable<Actor>
consisting of members who match the specified role.
Functionality
- The method iterates through the clan's members and selects those whose roles match the specified
roleFilter
. - If
inclusivePassive
istrue
, the method includes members who are not currently active (such as deceased members) in the clan. - This method is useful for managing clan dynamics, executing role-specific actions, or for narrative purposes where certain roles are pivotal.
Usage
This method is commonly used in game mechanics where the role of clan members impacts gameplay decisions, resource allocation, or storyline development. It allows for efficient retrieval of members based on their roles, facilitating targeted actions and interactions.
Example of Usage
public class ClanRoleManager : MonoBehaviour {
private Clan playerClan;
void Start() {
playerClan = IM.Player.Clan;
if (playerClan != null) {
var engineers = playerClan.GetMembers("Engineer");
Debug.Log($"Number of Engineers in the player's clan: {engineers.Count()}");
}
}
}
Description
- This example showcases how to use the
GetMembers
method to retrieve members of the player's clan who are designated as 'Engineers'. - The method call
playerClan.GetMembers("Engineer")
filters and returns an enumerable of actors with the role 'Engineer'. - The count of these members is then logged to the console.
Remarks
- The
GetMembers
method is key for creating dynamic and responsive gameplay experiences, especially in games where clan roles and structures are significant. - It offers developers the flexibility to create nuanced interactions based on the roles of clan members.
- Proper utilization of this method can enhance clan management mechanics and deepen the player's engagement with clan-related activities and narratives.