Update to newer gaemstone.ECS and Flecs

wip/source-generators
copygirl 12 months ago
parent c97c4a530f
commit 6a38f97830
  1. 6
      src/Immersion/Program.cs
  2. 39
      src/gaemstone.Client/Systems/InputManager.cs
  3. 2
      src/gaemstone.ECS
  4. 47
      src/gaemstone/Flecs/Core.cs

@ -23,8 +23,8 @@ var universe = new Universe<Program>();
var world = universe.World;
// TODO: Figure out a nice way to get rid of "compile errors" here.
// FIXME: universe.Modules.Register<gaemstone.Flecs.Systems.Monitor>();
universe.Modules.Register<gaemstone.Flecs.Systems.Rest>();
universe.Modules.Register<gaemstone.Flecs.Systems.Monitor>();
var window = Window.Create(WindowOptions.Default with {
Title = "gæmstone",
@ -34,8 +34,8 @@ var window = Window.Create(WindowOptions.Default with {
window.Initialize();
window.Center();
// universe.Modules.Register<ObserverTest>();
// universe.Modules.Register<ManagedComponentTest>();
// universe.Modules.Register<Immersion.ObserverTest>();
// universe.Modules.Register<Immersion.ManagedComponentTest>();
universe.Modules.Register<gaemstone.Client.Systems.Windowing>();
universe.Modules.Register<gaemstone.Components.TransformComponents>();

@ -109,11 +109,18 @@ public partial class InputManager
{
entity.GetMut<RawValue1D>() = current;
if (current >= ActivationThreshold) {
ref var active = ref entity.GetRefOrNull<Active>();
if (Unsafe.IsNullRef(ref active)) {
// TODO: Find out why using GetRefOrNull here crashes.
if (entity.Has<Active>()) {
entity.GetMut<Active>().Duration += delta;
} else {
entity.Set(new Active());
entity.Add<Activated>();
} else active.Duration += delta;
}
// ref var active = ref entity.GetRefOrNull<Active>();
// if (Unsafe.IsNullRef(ref active)) {
// entity.Set(new Active());
// entity.Add<Activated>();
// } else active.Duration += delta;
} else if (current <= DeactivationThreshold)
entity.Remove<Active>();
}
@ -123,11 +130,17 @@ public partial class InputManager
entity.GetMut<RawValue2D>() = current;
var magnitude = current.Length();
if (magnitude >= ActivationThreshold) {
ref var active = ref entity.GetRefOrNull<Active>();
if (Unsafe.IsNullRef(ref active)) {
if (entity.Has<Active>()) {
entity.GetMut<Active>().Duration += delta;
} else {
entity.Set(new Active());
entity.Add<Activated>();
} else active.Duration += delta;
}
// ref var active = ref entity.GetRefOrNull<Active>();
// if (Unsafe.IsNullRef(ref active)) {
// entity.Set(new Active());
// entity.Add<Activated>();
// } else active.Duration += delta;
} else if (magnitude <= DeactivationThreshold)
entity.Remove<Active>();
}
@ -138,12 +151,12 @@ public partial class InputManager
// public static void OnActiveAdded(EntityRef entity, Active _)
// => entity.Add<Activated>();
[Observer<Core.OnRemove>]
public static void OnActiveRemoved<T>(Entity<T> entity, Active _)
=> entity.Add<Deactivated>();
// [Observer<Core.OnRemove>]
// public static void OnActiveRemoved<T>(Entity<T> entity, Active _)
// => entity.Add<Deactivated>();
[System]
[DependsOn<Pipeline.PostFrame>]
public static void ClearDeActivated<T>(Entity<T> entity, Has<Or<Activated, Deactivated>> _)
=> entity.Remove<Activated>().Remove<Deactivated>();
// [System]
// [DependsOn<Pipeline.PostFrame>]
// public static void ClearDeActivated<T>(Entity<T> entity, Has<Or<Activated, Deactivated>> _)
// => entity.Remove<Activated>().Remove<Deactivated>();
}

@ -1 +1 @@
Subproject commit 9eade0adb1200223dffcb2077ecbc992569f4080
Subproject commit eec968d6361930eebad180f6300d126c4bac70f3

@ -7,35 +7,22 @@ public partial class Core
{
// Entity Tags
[Tag] public struct Name { }
[Tag] public struct Symbol { }
[Tag] public struct Alias { }
[Tag] public struct Module { }
[Tag] public struct Private { }
[Tag] public struct Prefab { }
[Tag] public struct SlotOf { }
[Tag] public struct Disabled { }
[Tag] public struct Empty { }
// Entities
[Entity, Path("*")] public struct Wildcard { }
[Entity, Path("_")] public struct Any { }
[Entity] public struct This { }
[Entity, Path("$")] public struct Variable { }
[Entity] public struct Flag { }
// Entity Relationships
[Relation, Tag] public struct IsA { }
[Relation, Tag] public struct ChildOf { }
[Relation, Tag] public struct DependsOn { }
[Tag] public struct SlotOf { }
[Tag] public struct Flag { }
// Component / Relationship Properties
[Entity, Path("*")] public struct Wildcard { }
[Entity, Path("_")] public struct Any { }
[Entity, Path("this")] public struct This { }
[Entity, Path("$")] public struct Variable { }
[Tag] public struct Transitive { }
[Tag] public struct Reflexive { }
[Tag] public struct Symmetric { }
@ -45,16 +32,34 @@ public partial class Core
[Tag] public struct Union { }
[Tag] public struct Exclusive { }
[Tag] public struct Acyclic { }
[Tag] public struct Traversable { }
[Relation, Tag] public struct With { }
[Tag] public struct OneOf { }
// Entity Relationships
[Relation, Tag] public struct ChildOf { }
[Relation, Tag] public struct IsA { }
[Relation, Tag] public struct DependsOn { }
// Identifier Tags
[Tag] public struct Name { }
[Tag] public struct Symbol { }
[Tag] public struct Alias { }
// Observer Events
[Entity] public struct OnAdd { }
[Entity] public struct OnRemove { }
[Entity] public struct OnSet { }
[Entity] public struct UnSet { }
[Entity] public struct OnTableCreate { }
[Entity] public struct OnTableDelete { }
[Entity] public struct OnTableEmpty { }
[Entity] public struct OnTableFilled { }

Loading…
Cancel
Save