Table of Contents

Class NPCGroup

Namespace
FishMMO.Shared
Assembly
FishMMO.Shared.dll

Coordinates a pack of NPCs that fight together. Provides shared state so individual NPC brains can make group-aware decisions via the behavior tree or state machine.

Shared state includes:

  • Group target — the enemy the group is focusing.
  • Lowest-health member — so healers know who needs help.
  • Alive member count — for pack-wipe / rally logic.
  • Combat flag — whether any member is in combat.

Place this component on an empty GameObject near the pack spawn point. Assign members in the inspector or call AddMember(AIController, NPCGroupRole) at runtime. Each member's Group is set automatically.

public class NPCGroup : MonoBehaviour
Inheritance
Object
Component
Behaviour
MonoBehaviour
NPCGroup
Inherited Members
MonoBehaviour.IsInvoking()
MonoBehaviour.CancelInvoke()
MonoBehaviour.StopCoroutine(Coroutine)
MonoBehaviour.StopAllCoroutines()
MonoBehaviour.destroyCancellationToken
MonoBehaviour.useGUILayout
MonoBehaviour.didStart
MonoBehaviour.didAwake
MonoBehaviour.runInEditMode
Behaviour.enabled
Behaviour.isActiveAndEnabled
Component.GetComponent<T>()
Component.TryGetComponent<T>(out T)
Component.GetComponentInChildren<T>()
Component.GetComponentsInChildren<T>()
Component.GetComponentInParent<T>()
Component.GetComponentsInParent<T>()
Component.GetComponents<T>()
Component.GetComponentIndex()
Component.CompareTag(TagHandle)
Component.transform
Component.transformHandle
Component.gameObject
Component.tag
Object.GetEntityId()
Object.GetInstanceID()
Object.GetHashCode()
Object.InstantiateAsync<T>(T)
Object.InstantiateAsync<T>(T, Transform)
Object.InstantiateAsync<T>(T, Vector3, Quaternion)
Object.InstantiateAsync<T>(T, Transform, Vector3, Quaternion)
Object.Instantiate(Object, Vector3, Quaternion)
Object.Instantiate(Object, Vector3, Quaternion, Transform)
Object.Instantiate(Object)
Object.Instantiate(Object, Scene)
Object.Instantiate<T>(T, InstantiateParameters)
Object.Instantiate<T>(T, Vector3, Quaternion, InstantiateParameters)
Object.Instantiate(Object, Transform)
Object.Instantiate<T>(T)
Object.Instantiate<T>(T, Vector3, Quaternion)
Object.Instantiate<T>(T, Vector3, Quaternion, Transform)
Object.Instantiate<T>(T, Transform)
Object.Destroy(Object)
Object.DestroyImmediate(Object)
Object.DontDestroyOnLoad(Object)
Object.DestroyObject(Object)
Object.FindObjectsOfType<T>()
Object.FindObjectsByType<T>(FindObjectsSortMode)
Object.FindObjectsByType<T>(FindObjectsInactive, FindObjectsSortMode)
Object.FindObjectOfType<T>()
Object.FindFirstObjectByType<T>()
Object.FindAnyObjectByType<T>()
Object.FindFirstObjectByType<T>(FindObjectsInactive)
Object.FindAnyObjectByType<T>(FindObjectsInactive)
Object.FindObjectsByType<T>()
Object.FindObjectsByType<T>(FindObjectsInactive)
Object.ToString()
Object.name
Object.hideFlags

Fields

FocusTargeting

[Header("Targeting")]
[Tooltip("When true, all DPS members share the tank's target.")]
public bool FocusTargeting

Field Value

bool

KiteRotationSpeed

[Tooltip("Degrees per second the Kite tactic rotates the group ring.")]
public float KiteRotationSpeed

Field Value

float

Tactic

[Header("Pack Tactics")]
[Tooltip("How the group coordinates spatial positioning around the target during combat.")]
public PackTactic Tactic

Field Value

PackTactic

TacticOrbitRadius

[Tooltip("Base orbit radius for pack tactic positioning (meters from target).")]
public float TacticOrbitRadius

Field Value

float

Properties

AliveMemberCount

Number of members currently alive.

public int AliveMemberCount { get; }

Property Value

int

GroupTarget

The group's shared combat target. Typically set by the tank or by whichever member first enters combat.

public Transform GroupTarget { get; set; }

Property Value

Transform

IsInCombat

True if any member is in an attacking state.

public bool IsInCombat { get; }

Property Value

bool

LowestHealthMember

The member with the lowest health percentage. Updated every evaluation. Healers can read this to decide who to heal.

public AIController LowestHealthMember { get; }

Property Value

AIController

LowestHealthPercent

Percentage (0-1) of the lowest-health member's HP.

public float LowestHealthPercent { get; }

Property Value

float

MemberCount

Total number of members (alive or dead).

public int MemberCount { get; }

Property Value

int

Members

Read-only access to the member list.

public IReadOnlyList<NPCGroupMember> Members { get; }

Property Value

IReadOnlyList<NPCGroupMember>

Methods

AddMember(AIController, NPCGroupRole)

Adds a member at runtime and links the group reference.

public void AddMember(AIController controller, NPCGroupRole role = NPCGroupRole.DPS)

Parameters

controller AIController
role NPCGroupRole

AlertGroup(Transform)

Signals the entire group that combat has started with the given target. Each member that isn't already fighting will transition to its attacking state.

public void AlertGroup(Transform enemy)

Parameters

enemy Transform

GetMemberByRole(NPCGroupRole)

Returns the first member with the given role, or null.

public AIController GetMemberByRole(NPCGroupRole role)

Parameters

role NPCGroupRole

Returns

AIController

RemoveMember(AIController)

Removes a member from the group.

public void RemoveMember(AIController controller)

Parameters

controller AIController