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>()); } }
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); } }