Awperative V1.1

This commit is contained in:
2026-02-22 21:49:18 -05:00
parent 31304e9361
commit c40a76cc10
11 changed files with 96 additions and 9 deletions

View File

@@ -26,6 +26,13 @@ public abstract partial class Component : ComponentDocker
public bool Enabled = true; public bool Enabled = true;
/// <summary>
/// Component name
/// </summary>
public string Name;
/// <summary> /// <summary>
/// Order for when Components are called on. Only applies between Components on the same Docker. /// Order for when Components are called on. Only applies between Components on the same Docker.
@@ -42,8 +49,11 @@ public abstract partial class Component : ComponentDocker
/// To be called when the Component is created. /// To be called when the Component is created.
/// </summary> /// </summary>
/// <param name="__parent"> Docker that this spawned in this Component</param> /// <param name="__parent"> Docker that this spawned in this Component</param>
internal void Initiate(ComponentDocker __parent) { /// <param name="__name"> Name of the component</param>
internal void Initiate(ComponentDocker __parent, string __name, string[] __tags) {
ComponentDocker = __parent; ComponentDocker = __parent;
Name = __name;
_tags = [..__tags];
Create(); Create();
} }

View File

@@ -2,7 +2,7 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Collections.Immutable; using System.Collections.Immutable;
using System.Linq; using System.Linq;
using System.Reflection;
namespace AwperativeKernel; namespace AwperativeKernel;
@@ -130,7 +130,11 @@ public abstract class ComponentDocker
/// <param name="__args"> Arguments to construct the Component with</param> /// <param name="__args"> Arguments to construct the Component with</param>
/// <typeparam name="__Type"> Type of Component to instantiate</typeparam> /// <typeparam name="__Type"> Type of Component to instantiate</typeparam>
/// <returns></returns> /// <returns></returns>
public __Type Add<__Type>(object[] __args) where __Type : Component { public __Type Add<__Type>(object[] __args, string name = "", string[] tags = null) where __Type : Component {
if(name == "") { name = typeof(__Type).Name; }
if (tags == null) tags = [];
@@ -162,7 +166,7 @@ public abstract class ComponentDocker
//Add to docker and initialize the new Component //Add to docker and initialize the new Component
_Components.Add(newComponent); _Components.Add(newComponent);
newComponent.Initiate(this); newComponent.Initiate(this, name, tags);
return (__Type) newComponent; return (__Type) newComponent;
@@ -175,7 +179,7 @@ public abstract class ComponentDocker
/// </summary> /// </summary>
/// <typeparam name="__Type"></typeparam> /// <typeparam name="__Type"></typeparam>
/// <returns></returns> /// <returns></returns>
public __Type Add<__Type>() where __Type : Component => Add<__Type>([]); public __Type Add<__Type>(string name = "", string[] tags = null) where __Type : Component => Add<__Type>([], name: name, tags: tags);
@@ -316,7 +320,7 @@ public abstract class ComponentDocker
/// <summary> /// <summary>
/// Finds the first instance of a component with a given tag /// Finds the first instance of a component with a given tag
/// </summary> /// </summary>
/// <param name="__tag"></param> /// <param name="__tag"> Tag to search for</param>
/// <returns></returns> /// <returns></returns>
internal Component Get(string __tag) { internal Component Get(string __tag) {
if (_taggedComponents.TryGetValue(__tag, out SortedSet<Component> components)) if (_taggedComponents.TryGetValue(__tag, out SortedSet<Component> components))
@@ -325,7 +329,17 @@ public abstract class ComponentDocker
return null; return null;
} }
/// <summary>
/// Finds the first instance of a component with a given tag
/// </summary>
/// <param name="__tag"> Tag to search for</param>
/// <param name="__component">Component that has been found</param>
/// <returns></returns>
internal bool TryGet(string __tag, out Component __component) { __component = Get(__tag); return __component != null; }
/// <summary> /// <summary>
/// Finds all Components with a given tag /// Finds all Components with a given tag
@@ -340,6 +354,16 @@ public abstract class ComponentDocker
} }
/// <summary>
/// Searches for all Components with a given tag
/// </summary>
/// <param name="__tag"></param>
/// <param name="__components"></param>
/// <returns></returns>
internal bool TryGetAll(string __tag, out ImmutableArray<Component> __components) { __components = GetAll(__tag); return __components.Length > 0; }
/// <summary> /// <summary>
/// Finds the first Component that has all the given tags /// Finds the first Component that has all the given tags
@@ -350,6 +374,15 @@ public abstract class ComponentDocker
/// <summary>
/// Finds the first Component that has all the given tags
/// </summary>
/// <param name="__tags"></param>
/// <returns></returns>
internal bool TryGet(List<string> __tags, out Component __component) { __component = Get(__tags); return __component != null; }
/// <summary> /// <summary>
/// Finds all Components that have all the given tags /// Finds all Components that have all the given tags
/// </summary> /// </summary>
@@ -370,6 +403,16 @@ public abstract class ComponentDocker
return [..foundComponents]; return [..foundComponents];
} }
/// <summary>
/// Tries to get all components with the given tags
/// </summary>
/// <param name="__tags"></param>
/// <param name="__components"></param>
/// <returns></returns>
internal bool TryGetAll(List<string> __tags, out ImmutableArray<Component> __components) { __components = GetAll(__tags); return __components.Length > 0; }
@@ -394,6 +437,16 @@ public abstract class ComponentDocker
Debug.LogError("Docker does not have target Component", ["Type", "Docker"], Debug.LogError("Docker does not have target Component", ["Type", "Docker"],
[typeof(__Type).ToString(), GetHashCode().ToString()]); return null; [typeof(__Type).ToString(), GetHashCode().ToString()]); return null;
} }
/// <summary>
///
/// </summary>
/// <param name="__component"></param>
/// <typeparam name="__Type"></typeparam>
/// <returns></returns>
public bool TryGet<__Type>(out __Type __component) where __Type : Component { __component = Get<__Type>(); return __component != null; }
@@ -430,6 +483,18 @@ public abstract class ComponentDocker
return [..foundComponents]; return [..foundComponents];
} }
/// <summary>
///
/// </summary>
/// <param name="__components"></param>
/// <typeparam name="__Type"></typeparam>
/// <returns></returns>
public bool TryGetAll<__Type>(out ImmutableArray<__Type> __components) where __Type : Component { __components = GetAll<__Type>(); return __components.Length > 0; }

View File

@@ -0,0 +1,11 @@
using System;
namespace AwperativeKernel;
[AttributeUsage(AttributeTargets.Field | AttributeTargets.Property)]
public class Show : Attribute
{
public bool UseInspectorDefaults = true;
}

View File

@@ -13,7 +13,7 @@ using System.Reflection;
[assembly: System.Reflection.AssemblyCompanyAttribute("AwperativeKernel")] [assembly: System.Reflection.AssemblyCompanyAttribute("AwperativeKernel")]
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")] [assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")] [assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+b0f5efc0d7c0e8575f8d65258fc04f5f6c0198ff")] [assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+31304e9361e9cb2c8a96c5b71df5898a3a6da2a5")]
[assembly: System.Reflection.AssemblyProductAttribute("AwperativeKernel")] [assembly: System.Reflection.AssemblyProductAttribute("AwperativeKernel")]
[assembly: System.Reflection.AssemblyTitleAttribute("AwperativeKernel")] [assembly: System.Reflection.AssemblyTitleAttribute("AwperativeKernel")]
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")] [assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]

View File

@@ -1 +1 @@
58a3ed0a72d5710615a3b290d863e83a9ed7dd9e66d3e9ec7d3e4367fd65f804 35c328d3af30548ed777d71d5913f389ba8fda839eeb8f7de7916868a456c94c

View File

@@ -1 +1 @@
e9ac80148ad36c975d2dc92051a6a9a191bea17d88f00cb4594c69ebd55d71a4 1492481e4eae3b80db2d149ab088600d21214f29161b6bc87c6dbab466600b9b

View File

@@ -25,3 +25,4 @@
/home/avery/Projects/Awperative/Build/Kernel/net8.0/AwperativeKernel.deps.json /home/avery/Projects/Awperative/Build/Kernel/net8.0/AwperativeKernel.deps.json
/home/avery/Projects/Awperative/Build/Kernel/net8.0/AwperativeKernel.dll /home/avery/Projects/Awperative/Build/Kernel/net8.0/AwperativeKernel.dll
/home/avery/Projects/Awperative/Build/Kernel/net8.0/AwperativeKernel.pdb /home/avery/Projects/Awperative/Build/Kernel/net8.0/AwperativeKernel.pdb
/home/avery/Projects/Awperative/AwperativeKernel/AwperativeKernel/obj/Debug/net8.0/AwperativeKernel.sourcelink.json