From a78b5aef96c286d7f54b11963ffa6c3090398b85 Mon Sep 17 00:00:00 2001 From: Avery Norris Date: Sun, 8 Feb 2026 15:31:07 -0500 Subject: [PATCH] aa --- .../Kernel/Entities/Bodies/Components/Addition.cs | 7 ++----- .../Kernel/Entities/Bodies/Components/Location.cs | 15 ++++++++------- .../Kernel/Entities/Bodies/Components/Removal.cs | 2 -- Awperative/Kernel/Entities/Bodies/Events.cs | 10 ---------- 4 files changed, 10 insertions(+), 24 deletions(-) delete mode 100644 Awperative/Kernel/Entities/Bodies/Events.cs diff --git a/Awperative/Kernel/Entities/Bodies/Components/Addition.cs b/Awperative/Kernel/Entities/Bodies/Components/Addition.cs index 78bc540..424a869 100644 --- a/Awperative/Kernel/Entities/Bodies/Components/Addition.cs +++ b/Awperative/Kernel/Entities/Bodies/Components/Addition.cs @@ -12,15 +12,12 @@ public sealed partial class Body if(typeof(Generic).GetConstructor((Type[]) __args) == null) { Debug.LogError("Component does not contain a valid constructor"); return null; }; try { - Component component = (Generic)Activator.CreateInstance(typeof(Generic), __args); - if(component == null) { Debug.LogError("Failed to create component"); return null; }; - + if(component == null) { Debug.LogError("Failed to create component"); return null; } + _components.Add(component); component.Initiate(this); - ComponentCreatedEvent?.Invoke(this, new ComponentCreateEvent(component, this, Scene)); - return component; }catch { Debug.LogError("Failed to create component"); return null; } diff --git a/Awperative/Kernel/Entities/Bodies/Components/Location.cs b/Awperative/Kernel/Entities/Bodies/Components/Location.cs index f02e3c4..d9b19f2 100644 --- a/Awperative/Kernel/Entities/Bodies/Components/Location.cs +++ b/Awperative/Kernel/Entities/Bodies/Components/Location.cs @@ -17,16 +17,17 @@ public sealed partial class Body return returnValue.ToArray(); } - public Generic FindSingleton() where Generic : Component - { + public Component FindSingleton() where Generic : Component { foreach (Component component in _components) if (component.GetType() == typeof(Generic)) if(component.EnforceSingleton) - return (Generic) component; - else - throw new Exception("Component is not a singleton"); - - throw new Exception("Component not found"); + return component; + else { + Debug.LogError("Component is not a singleton"); + return null; + } + + Debug.LogError("Scene does not contain a component of this type"); return null; } diff --git a/Awperative/Kernel/Entities/Bodies/Components/Removal.cs b/Awperative/Kernel/Entities/Bodies/Components/Removal.cs index e3a1d65..12aa5d2 100644 --- a/Awperative/Kernel/Entities/Bodies/Components/Removal.cs +++ b/Awperative/Kernel/Entities/Bodies/Components/Removal.cs @@ -17,7 +17,6 @@ public sealed partial class Body foundComponent.End(); _components.Remove(foundComponent); - ComponentDestroyedEvent?.Invoke(this, new ComponentDestroyEvent(foundComponent, this, Scene)); }catch { Debug.LogError("Removal failed"); } } @@ -26,7 +25,6 @@ public sealed partial class Body foreach (Component component in GetComponents()) { component.End(); _components.Remove(component); - ComponentDestroyedEvent?.Invoke(this, new ComponentDestroyEvent(component, this, Scene)); } }catch { Debug.LogError("Removal failed"); } } diff --git a/Awperative/Kernel/Entities/Bodies/Events.cs b/Awperative/Kernel/Entities/Bodies/Events.cs deleted file mode 100644 index 6cb59b5..0000000 --- a/Awperative/Kernel/Entities/Bodies/Events.cs +++ /dev/null @@ -1,10 +0,0 @@ -using System; - - -namespace Awperative; - -public sealed partial class Body -{ - public event EventHandler ComponentCreatedEvent; - public event EventHandler ComponentDestroyedEvent; -} \ No newline at end of file