Finished docking

This commit is contained in:
2026-02-08 20:58:08 -05:00
parent 67fca0c271
commit a6555e3a48
41 changed files with 194 additions and 407 deletions

View File

@@ -7,23 +7,27 @@ namespace Awperative;
/// <summary>
/// The lowest level scripting class in Awperative. Components are scene level and provide access to all scene level methods, can be applied to any docker and inherited
/// Sadly component does not have excessive access to specific types.
/// Anything that inherits Component is built to work in any DockerEntity, which leads to generic
/// Assumptions. If you want to make a body specific or scene specific component both classes are available.
/// </summary>
public abstract class Component
public abstract partial class Component
{
internal DockerEntity Parent;
public Scene Scene { get; set; }
internal DockerEntity Docker;
internal void Initiate(DockerEntity __parent) {
Parent = __parent;
internal virtual void Initiate(DockerEntity __docker) {
Docker = __docker;
Create();
}
internal void End() {
internal virtual void End() {
Destroy();
}

View File

@@ -0,0 +1,26 @@
namespace Awperative;
public abstract partial class Component
{
protected Body AddBody() => Scene.AddBody();
protected Body AddBody(Transform __transform) => Scene.AddBody(__transform);
protected Body GetBody(string __tag) => Scene.GetBody(__tag);
protected Body[] GetBodies(string __tag) => Scene.GetBodies(__tag);
protected void DestroyBody(Body __body) => Scene.DestroyBody(__body);
public Component AddComponent<Generic>() where Generic : Component => Docker.AddComponent<Generic>();
public Component AddComponent<Generic>(object[] __args) where Generic : Component => Docker.AddComponent<Generic>(__args);
public Component GetComponent<Generic>() where Generic : Component => Docker.GetComponent<Generic>();
public Component[] GetComponents<Generic>() where Generic : Component => Docker.GetComponents<Generic>();
public void RemoveComponent<Generic>() where Generic : Component => Docker.RemoveComponent<Generic>();
}

View File

@@ -1,72 +0,0 @@
using Microsoft.Xna.Framework;
namespace Awperative;
public abstract class Component
{
public Scene scene;
public Body body;
public bool Enabled = false;
public bool EnforceSingleton = false;
//0 = default highest priority called first, lowest priority called last
//todo: add optional parameter for priority at creation
public int Priority {
get => _priority;
set { _priority = value; }
} private int _priority = 0;
protected Transform transform => body.transform;
protected Body AddBody() => scene.AddBody();
protected Body AddBody(Transform __transform) => scene.AddBody(__transform);
protected Body GetBody(string __tag) => scene.GetBody(__tag);
protected Body[] GetBodies(string __tag) => scene.GetBodies(__tag);
protected void DestroyBody(Body __body) => scene.DestroyBody(__body);
public Generic AddBehavior<Generic>() where Generic : Behavior => scene.AddBehavior<Generic>();
public Generic AddBehavior<Generic>(object[] __args) where Generic : Behavior => scene.AddBehavior<Generic>(__args);
public Generic GetBehavior<Generic>() where Generic : Behavior => scene.GetBehavior<Generic>();
public Generic[] GetBehaviors<Generic>() where Generic : Behavior => scene.GetBehaviors<Generic>();
public void RemoveBehavior<Generic>() where Generic : Behavior => scene.RemoveBehavior<Generic>();
public Component AddComponent<Generic>() where Generic : Component => body.AddComponent<Generic>();
public Component AddComponent<Generic>(object[] __args) where Generic : Component => body.AddComponent<Generic>(__args);
public Component GetComponent<Generic>() where Generic : Component => body.GetComponent<Generic>();
public Component[] GetComponents<Generic>() where Generic : Component => body.GetComponents<Generic>();
public void RemoveComponent<Generic>() where Generic : Component => body.RemoveComponent<Generic>();
//creation logic
internal void Initiate(Body __body)
{
body = __body;
scene = __body.Scene;
Create();
}
internal void End()
{
Destroy();
}
}

View File

@@ -1,10 +0,0 @@
namespace Awperative;
public class hello : BodyComponent
{
public void Start() {
this.ExtensionTest();
}
}