Awperative V1.1
This commit is contained in:
@@ -26,6 +26,13 @@ public abstract partial class Component : ComponentDocker
|
||||
public bool Enabled = true;
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Component name
|
||||
/// </summary>
|
||||
public string Name;
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 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.
|
||||
/// </summary>
|
||||
/// <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;
|
||||
Name = __name;
|
||||
_tags = [..__tags];
|
||||
Create();
|
||||
}
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Immutable;
|
||||
using System.Linq;
|
||||
|
||||
using System.Reflection;
|
||||
|
||||
|
||||
namespace AwperativeKernel;
|
||||
@@ -130,7 +130,11 @@ public abstract class ComponentDocker
|
||||
/// <param name="__args"> Arguments to construct the Component with</param>
|
||||
/// <typeparam name="__Type"> Type of Component to instantiate</typeparam>
|
||||
/// <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
|
||||
_Components.Add(newComponent);
|
||||
newComponent.Initiate(this);
|
||||
newComponent.Initiate(this, name, tags);
|
||||
|
||||
|
||||
return (__Type) newComponent;
|
||||
@@ -175,7 +179,7 @@ public abstract class ComponentDocker
|
||||
/// </summary>
|
||||
/// <typeparam name="__Type"></typeparam>
|
||||
/// <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>
|
||||
/// Finds the first instance of a component with a given tag
|
||||
/// </summary>
|
||||
/// <param name="__tag"></param>
|
||||
/// <param name="__tag"> Tag to search for</param>
|
||||
/// <returns></returns>
|
||||
internal Component Get(string __tag) {
|
||||
if (_taggedComponents.TryGetValue(__tag, out SortedSet<Component> components))
|
||||
@@ -325,7 +329,17 @@ public abstract class ComponentDocker
|
||||
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>
|
||||
/// 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>
|
||||
/// 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>
|
||||
/// Finds all Components that have all the given tags
|
||||
/// </summary>
|
||||
@@ -370,6 +403,16 @@ public abstract class ComponentDocker
|
||||
|
||||
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"],
|
||||
[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];
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <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; }
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
11
AwperativeKernel/Kernel/Inspector/Show.cs
Normal file
11
AwperativeKernel/Kernel/Inspector/Show.cs
Normal file
@@ -0,0 +1,11 @@
|
||||
using System;
|
||||
|
||||
|
||||
namespace AwperativeKernel;
|
||||
|
||||
|
||||
[AttributeUsage(AttributeTargets.Field | AttributeTargets.Property)]
|
||||
public class Show : Attribute
|
||||
{
|
||||
public bool UseInspectorDefaults = true;
|
||||
}
|
||||
@@ -13,7 +13,7 @@ using System.Reflection;
|
||||
[assembly: System.Reflection.AssemblyCompanyAttribute("AwperativeKernel")]
|
||||
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
|
||||
[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.AssemblyTitleAttribute("AwperativeKernel")]
|
||||
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
|
||||
|
||||
@@ -1 +1 @@
|
||||
58a3ed0a72d5710615a3b290d863e83a9ed7dd9e66d3e9ec7d3e4367fd65f804
|
||||
35c328d3af30548ed777d71d5913f389ba8fda839eeb8f7de7916868a456c94c
|
||||
|
||||
@@ -1 +1 @@
|
||||
e9ac80148ad36c975d2dc92051a6a9a191bea17d88f00cb4594c69ebd55d71a4
|
||||
1492481e4eae3b80db2d149ab088600d21214f29161b6bc87c6dbab466600b9b
|
||||
|
||||
@@ -25,3 +25,4 @@
|
||||
/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.pdb
|
||||
/home/avery/Projects/Awperative/AwperativeKernel/AwperativeKernel/obj/Debug/net8.0/AwperativeKernel.sourcelink.json
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user