/// <summary> /// Adds a UnitRoster to the UnitBook and their relation to the playerTeam /// </summary> /// <param name="roster"></param> /// <param name="relation"></param> /// <returns>True - the roster was added. False - the roster was not added</returns> public bool AddRoster(UnitRoster roster, TeamRelation relation) { if (unitLists.ContainsKey(roster.TeamID)) { return(false); //already exists, can't add } switch (relation) { case TeamRelation.enemy: enemyTeams.Add(roster.TeamID); break; case TeamRelation.ally: otherTeams.Add(roster.TeamID); break; } unitLists.Add(roster.TeamID, roster); return(true); }
public bool IsAllowed(TeamRelation relation) { var flag = relation.ToFlag(); return(IsAllowed(flag)); }
/// <summary> /// Check if the provided relation is the relation from other to teamable. /// </summary> /// <param name="teamable">This teamable.</param> /// <param name="other">The other teamable.</param> /// <param name="relation">The relation to check.</param> /// <returns>True if the relation between the two is the same as the one provided.</returns> public static bool IsRelation(this ITeamable teamable, ITeamable other, TeamRelation relation) => teamable.GetRelation(other) == relation;
public static bool HasValue(this TeamRelationFlag flags, TeamRelation value) { var valueAsFlag = value.ToFlag(); return(flags.HasFlag(valueAsFlag)); }
public static TeamRelationFlag ToFlag(this TeamRelation relation) => (TeamRelationFlag)(1 << (int)relation);