Fix parent names not using no separator

wip/source-generators
copygirl 2 years ago
parent 6e17a525cd
commit dbddd6ee80
  1. 4
      src/gaemstone/ECS/EntityBuilder.cs
  2. 2
      src/gaemstone/ECS/EntityPath.cs
  3. 1
      src/gaemstone/Utility/CStringExtensions.cs

@ -2,7 +2,6 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using gaemstone.Utility; using gaemstone.Utility;
using static flecs_hub.flecs; using static flecs_hub.flecs;
using static flecs_hub.flecs.Runtime;
namespace gaemstone.ECS; namespace gaemstone.ECS;
@ -79,7 +78,6 @@ public class EntityBuilder
public override EntityBuilder Set<T>(T obj) public override EntityBuilder Set<T>(T obj)
{ _toSet.Add(e => e.Set(obj)); return this; } { _toSet.Add(e => e.Set(obj)); return this; }
public static CString ETX { get; } = (CString)"\x3";
public unsafe EntityRef Build() public unsafe EntityRef Build()
{ {
var parent = _parent; var parent = _parent;
@ -98,7 +96,7 @@ public class EntityBuilder
symbol = alloc.AllocateCString(_symbol), symbol = alloc.AllocateCString(_symbol),
add_expr = alloc.AllocateCString(Expression), add_expr = alloc.AllocateCString(Expression),
use_low_id = UseLowID, use_low_id = UseLowID,
sep = ETX, // TODO: Replace with CStringExtensions.Empty once supported. sep = CStringExtensions.ETX,
}; };
var add = desc.add; var index = 0; var add = desc.add; var index = 0;

@ -124,7 +124,7 @@ public class EntityPath
foreach (var part in path) foreach (var part in path)
fixed (byte* ptr = part.AsSpan()) fixed (byte* ptr = part.AsSpan())
if (skipLookup || (parent = new(ecs_lookup_child(universe, parent, ptr))).IsNone) { if (skipLookup || (parent = new(ecs_lookup_child(universe, parent, ptr))).IsNone) {
var desc = new ecs_entity_desc_t { name = ptr }; var desc = new ecs_entity_desc_t { name = ptr, sep = CStringExtensions.ETX };
if (parent.IsSome) desc.add[0] = Identifier.Pair(universe.ChildOf, parent); if (parent.IsSome) desc.add[0] = Identifier.Pair(universe.ChildOf, parent);
parent = new(ecs_entity_init(universe, &desc)); parent = new(ecs_entity_init(universe, &desc));
skipLookup = true; skipLookup = true;

@ -8,6 +8,7 @@ namespace gaemstone.Utility;
public unsafe static class CStringExtensions public unsafe static class CStringExtensions
{ {
public static CString Empty { get; } = (CString)""; public static CString Empty { get; } = (CString)"";
public static CString ETX { get; } = (CString)"\x3"; // TODO: Temporary, until flecs supports Empty.
public static unsafe byte[]? FlecsToBytes(this CString str) public static unsafe byte[]? FlecsToBytes(this CString str)
{ {

Loading…
Cancel
Save