public void LeaveGroup() { if (!InGroup()) { return; } if (IsGroupLeader) { if (groupMembers.Count == 0) { return; } IAIGroupable iAIGroupable = groupMembers[0]; if (iAIGroupable == null) { return; } RemoveMember(iAIGroupable); for (int num = groupMembers.Count - 1; num >= 0; num--) { IAIGroupable iAIGroupable2 = groupMembers[num]; if (iAIGroupable2 != null && iAIGroupable2 != iAIGroupable) { RemoveMember(iAIGroupable2); iAIGroupable.AddMember(iAIGroupable2); } } groupMembers.Clear(); } else if (GroupLeader != null) { GroupLeader.RemoveMember(GetComponent <IAIGroupable>()); } }
public bool AddMember(IAIGroupable member) { if (InGroup() && !IsGroupLeader) { return(GroupLeader.AddMember(member)); } if (MaxGroupSize <= 0) { return(false); } if (groupMembers.Contains(member)) { return(true); } if (groupMembers.Count + 1 >= MaxGroupSize) { return(false); } groupMembers.Add(member); IsGrouped = true; IsGroupLeader = true; GroupLeader = this; T entity = GetEntity(); Events.Memory.Entity.Set(entity, 6); member.JoinGroup(this, entity); return(true); }
public void JoinGroup(IAIGroupable leader, BaseEntity leaderEntity) { Events.Memory.Entity.Set(leaderEntity, 6); GroupLeader = leader; IsGroupLeader = false; IsGrouped = true; }
private void UpdateGroup() { if (!AI.groups || MaxGroupSize <= 0 || InGroup() || Senses.Memory.Friendlies.Count <= 0) { return; } IAIGroupable iAIGroupable = null; foreach (BaseEntity friendly in Senses.Memory.Friendlies) { if (friendly == null) { continue; } IAIGroupable component = friendly.GetComponent <IAIGroupable>(); if (component != null) { if (component.InGroup() && component.AddMember(this)) { break; } if (iAIGroupable == null && !component.InGroup()) { iAIGroupable = component; } } } if (!InGroup() && iAIGroupable != null) { AddMember(iAIGroupable); } }
public void RemoveMember(IAIGroupable member) { if (member != null && IsGroupLeader && groupMembers.Contains(member)) { groupMembers.Remove(member); member.SetUngrouped(); if (groupMembers.Count == 0) { SetUngrouped(); } } }