/* * SPDX-License-Identifier: AGPL-3.0-or-later * Copyright (C) 2025 Sergej Görzen * This file is part of OmiLAXR. */ using System.Linq; using UnityEngine; namespace OmiLAXR { /// /// Represents a collection of actors that can be treated as a single entity. /// Allows multiple actors to be grouped together and managed collectively. /// [AddComponentMenu("OmiLAXR / Actors / Actor Group")] [RequireComponent(typeof(Actor))] public class ActorGroup : Actor { /// /// Internal storage for the group members. /// private Actor[] _members; /// /// Returns the current array of actors that belong to this group. /// /// An array of Actor components that are members of this group. public Actor[] GetMembers() => _members; /// /// Initializes the group by collecting all member actors. /// private void Start() { UpdateMemberList(); } /// /// Refreshes the internal list of group members by finding all Actor components /// attached to this GameObject, excluding the ActorGroup component itself. /// public void UpdateMemberList() { _members = GetComponents() .Where(a => a.GetType() != typeof(ActorGroup)).ToArray(); } /// /// Indicates that this actor represents a group rather than an individual. /// public override bool IsGroupActor => true; /// /// Sets default values for the group when the component is first added /// or reset in the Unity Inspector. /// private void Reset() { actorName = "Group"; actorEmail = "group@omilaxr.dev"; } } }