using System; using System.Collections.Generic; namespace Awperative; public abstract partial class Docker { internal HashSet _behaviors = []; public Behavior Add() where Generic : Behavior => Add([]); public Behavior Add(object[] __args) where Generic : Behavior { if(typeof(Generic).GetConstructor((Type[]) __args) == null) { Debug.LogError("Component does not contain a valid constructor"); return null; }; try { Behavior behavior = (Generic)Activator.CreateInstance(typeof(Generic), __args); if(behavior == null) { Debug.LogError("Failed to create component"); return null; } _behaviors.Add(behavior); behavior.Initiate(DockerScene, this); return behavior; }catch { Debug.LogError("Failed to create component"); return null; } } public Behavior Get() where Generic : Behavior => GetAll()[0]; public Behavior[] GetAll() where Generic : Behavior { List returnValue = []; foreach (Behavior component in _behaviors) if (component is Generic) returnValue.Add(component); if(returnValue.Count == 0) { Debug.LogWarning("Scene has no components of this type"); return null; } return returnValue.ToArray(); } public void Destroy(Behavior behavior) { if(!_behaviors.Contains(behavior)) { Debug.LogError("Body does not have a component of this type"); return; } behavior.End(); _behaviors.Remove(behavior); } public void Destroy() where Generic : Behavior { try { Behavior foundBehavior = Get(); foundBehavior.End(); _behaviors.Remove(foundBehavior); }catch { Debug.LogError("Removal failed"); } } public void DestroyAll() where Generic : Behavior { try { foreach (Behavior component in GetAll()) { component.End(); _behaviors.Remove(component); } }catch { Debug.LogError("Removal failed"); } } public void Remove(Behavior behavior) { if(!_behaviors.Contains(behavior)) { Debug.LogError("Body does not have a component of this type"); return; } _behaviors.Remove(behavior); } public void Remove< }