Messing with stuff idk if i like
This commit is contained in:
7
Awperative/Kernel/Entities/Entity/Components.cs
Normal file
7
Awperative/Kernel/Entities/Entity/Components.cs
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
namespace Awperative;
|
||||||
|
|
||||||
|
|
||||||
|
internal abstract partial class DockerEntity
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
21
Awperative/Kernel/Entities/Entity/DockerEntity.cs
Normal file
21
Awperative/Kernel/Entities/Entity/DockerEntity.cs
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
|
||||||
|
|
||||||
|
namespace Awperative;
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Base class for all Awperative entities, manages components as a requirement because that is the job of all entities.
|
||||||
|
/// </summary>
|
||||||
|
internal abstract partial class DockerEntity
|
||||||
|
{
|
||||||
|
public Scene scene;
|
||||||
|
|
||||||
|
public List<Component> Components => _components.ToList();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
internal HashSet<Component> _components;
|
||||||
|
}
|
||||||
@@ -5,7 +5,7 @@ using System.Collections.Generic;
|
|||||||
namespace Awperative;
|
namespace Awperative;
|
||||||
|
|
||||||
|
|
||||||
public sealed partial class Scene
|
public sealed partial class Scene : DockerEntity
|
||||||
{
|
{
|
||||||
|
|
||||||
public List<Behavior> behaviors { get; private set; } = [];
|
public List<Behavior> behaviors { get; private set; } = [];
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ using System.Collections.Generic;
|
|||||||
namespace Awperative;
|
namespace Awperative;
|
||||||
|
|
||||||
|
|
||||||
public sealed partial class Scene
|
public sealed partial class Scene : DockerEntity
|
||||||
{
|
{
|
||||||
public List<Body> bodies { get; private set; } = [];
|
public List<Body> bodies { get; private set; } = [];
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
namespace Awperative;
|
namespace Awperative;
|
||||||
|
|
||||||
public sealed partial class Scene
|
public sealed partial class Scene : DockerEntity
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ using System;
|
|||||||
namespace Awperative;
|
namespace Awperative;
|
||||||
|
|
||||||
|
|
||||||
public sealed partial class Scene
|
public sealed partial class Scene : DockerEntity
|
||||||
{
|
{
|
||||||
public event EventHandler<BehaviorCreateEvent> BehaviorCreatedEvent;
|
public event EventHandler<BehaviorCreateEvent> BehaviorCreatedEvent;
|
||||||
public event EventHandler<BehaviorDestroyEvent> BehaviorDestroyedEvent;
|
public event EventHandler<BehaviorDestroyEvent> BehaviorDestroyedEvent;
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ using Microsoft.Xna.Framework;
|
|||||||
|
|
||||||
namespace Awperative;
|
namespace Awperative;
|
||||||
|
|
||||||
public sealed partial class Scene
|
public sealed partial class Scene : DockerEntity
|
||||||
{
|
{
|
||||||
|
|
||||||
public void Unload() {
|
public void Unload() {
|
||||||
|
|||||||
@@ -1,64 +0,0 @@
|
|||||||
|
|
||||||
|
|
||||||
using Microsoft.Xna.Framework;
|
|
||||||
|
|
||||||
|
|
||||||
namespace Awperative;
|
|
||||||
|
|
||||||
public abstract class Behavior
|
|
||||||
{
|
|
||||||
public Scene scene;
|
|
||||||
|
|
||||||
public bool Enabled = false;
|
|
||||||
public bool EnforceSingleton = false;
|
|
||||||
|
|
||||||
public int Priority = 0;
|
|
||||||
|
|
||||||
|
|
||||||
//scene relay
|
|
||||||
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);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
protected Generic AddBehavior<Generic>() where Generic : Behavior => scene.AddBehavior<Generic>();
|
|
||||||
protected Generic AddBehavior<Generic>(object[] __args) where Generic : Behavior => scene.AddBehavior<Generic>(__args);
|
|
||||||
|
|
||||||
protected Generic GetBehavior<Generic>() where Generic : Behavior => scene.GetBehavior<Generic>();
|
|
||||||
protected Generic[] GetBehaviors<Generic>() where Generic : Behavior => scene.GetBehaviors<Generic>();
|
|
||||||
|
|
||||||
protected void RemoveBehavior<Generic>() where Generic : Behavior => scene.RemoveBehavior<Generic>();
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//GAME HAS JUST BEGUN/ended
|
|
||||||
public virtual void Unload() {}
|
|
||||||
|
|
||||||
//WE ARE LOADING STUFF
|
|
||||||
public virtual void Load() {}
|
|
||||||
|
|
||||||
//You know what these do
|
|
||||||
public virtual void Update(GameTime __gameTime) {}
|
|
||||||
public virtual void Draw(GameTime __gameTime) {}
|
|
||||||
|
|
||||||
//component/body/scene is being created or destroyed
|
|
||||||
public virtual void Create() {}
|
|
||||||
public virtual void Destroy() {}
|
|
||||||
|
|
||||||
//New behavior functionality
|
|
||||||
internal void Initiate(Scene __scene) {
|
|
||||||
scene = __scene;
|
|
||||||
Create();
|
|
||||||
}
|
|
||||||
|
|
||||||
//destroy behavior functionality
|
|
||||||
internal void End()
|
|
||||||
{
|
|
||||||
Destroy();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
7
Awperative/Kernel/Scripting/BodyComponent.cs
Normal file
7
Awperative/Kernel/Scripting/BodyComponent.cs
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
namespace Awperative;
|
||||||
|
|
||||||
|
|
||||||
|
public class BodyComponent : Component
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
47
Awperative/Kernel/Scripting/Component/Component.cs
Normal file
47
Awperative/Kernel/Scripting/Component/Component.cs
Normal file
@@ -0,0 +1,47 @@
|
|||||||
|
using Microsoft.Xna.Framework;
|
||||||
|
|
||||||
|
|
||||||
|
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
|
||||||
|
/// </summary>
|
||||||
|
public abstract class Component
|
||||||
|
{
|
||||||
|
internal DockerEntity Parent;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
internal void Initiate(DockerEntity __parent) {
|
||||||
|
Parent = __parent;
|
||||||
|
Create();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
internal void End() {
|
||||||
|
Destroy();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//GAME HAS JUST BEGUN/ended
|
||||||
|
public virtual void Unload() {}
|
||||||
|
|
||||||
|
//WE ARE LOADING STUFF
|
||||||
|
public virtual void Load() {}
|
||||||
|
|
||||||
|
//You know what these do
|
||||||
|
public virtual void Update(GameTime __gameTime) {}
|
||||||
|
public virtual void Draw(GameTime __gameTime) {}
|
||||||
|
|
||||||
|
//component/body/scene is being created or destroyed
|
||||||
|
public virtual void Create() {}
|
||||||
|
public virtual void Destroy() {}
|
||||||
|
}
|
||||||
@@ -5,6 +5,11 @@ namespace Awperative;
|
|||||||
|
|
||||||
public abstract class Component
|
public abstract class Component
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public Scene scene;
|
public Scene scene;
|
||||||
public Body body;
|
public Body body;
|
||||||
|
|
||||||
@@ -51,20 +56,6 @@ public abstract class Component
|
|||||||
public void RemoveComponent<Generic>() where Generic : Component => body.RemoveComponent<Generic>();
|
public void RemoveComponent<Generic>() where Generic : Component => body.RemoveComponent<Generic>();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//GAME HAS JUST BEGUN/ended
|
|
||||||
public virtual void Unload() {}
|
|
||||||
|
|
||||||
//WE ARE LOADING STUFF
|
|
||||||
public virtual void Load() {}
|
|
||||||
|
|
||||||
//You know what these do
|
|
||||||
public virtual void Update(GameTime __gameTime) {}
|
|
||||||
public virtual void Draw(GameTime __gameTime) {}
|
|
||||||
|
|
||||||
//component/body/scene is being created or destroyed
|
|
||||||
public virtual void Create() {}
|
|
||||||
public virtual void Destroy() {}
|
|
||||||
|
|
||||||
//creation logic
|
//creation logic
|
||||||
internal void Initiate(Body __body)
|
internal void Initiate(Body __body)
|
||||||
10
Awperative/Kernel/Scripting/Component/hello.cs
Normal file
10
Awperative/Kernel/Scripting/Component/hello.cs
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
namespace Awperative;
|
||||||
|
|
||||||
|
|
||||||
|
public class hello : BodyComponent
|
||||||
|
{
|
||||||
|
public void Start() {
|
||||||
|
|
||||||
|
this.ExtensionTest();
|
||||||
|
}
|
||||||
|
}
|
||||||
7
Awperative/Kernel/Scripting/SceneComponent.cs
Normal file
7
Awperative/Kernel/Scripting/SceneComponent.cs
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
namespace Awperative;
|
||||||
|
|
||||||
|
|
||||||
|
public class SceneComponent : Component
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user