Spite up project, added BeltData, some asoited compoents, remvoed unused usings, and removed uneeded comment code.

This commit is contained in:
2026-05-10 12:33:20 -04:00
parent d620189e4e
commit 4db51be374
53 changed files with 1892 additions and 608 deletions

61
src/VoxelGrid/Balancer.cs Normal file
View File

@@ -0,0 +1,61 @@
namespace ChickenGameTest;
using Godot;
using System.Collections.Generic;
using System.Linq;
using Chickensoft.AutoInject;
using Chickensoft.Introspection;
[Meta(typeof(IAutoNode))]
public partial class Balancer : Node3D, IProvide<IBeltPortHost>, IProvide<IVoxelGridRegistry>
{
public override void _Notification(int what) => this.Notify(what);
private BeltPortHost _insertLogic = default!;
public IBeltPortHost Value() => _insertLogic;
IVoxelGridRegistry IProvide<IVoxelGridRegistry>.Value() => GridRegistry;
[Dependency] public IVoxelGridRegistry GridRegistry => this.DependOn<IVoxelGridRegistry>();
private List<BeltPort> _outPuts = new();
public GridTransform3D VoxelTransform
{
get => GridTransform3D.FromGodot(GlobalTransform);
set => GlobalTransform = value.ToGodot();
}
public void OnResolved()
{
_insertLogic = new BeltPortHost();
_insertLogic.Bind(port => port is BeltPort beltPort && beltPort.Access.HasFlag(PortAccess.In), () => new DelegateInsertBeltItemLogic(CanAccept, CanInsert));
_insertLogic.Bind(port => port is BeltPort beltPort && beltPort.Access.HasFlag(PortAccess.Out), () => new DelegateInsertBeltItemLogic((_, _) => true, (_, _) => true));
this.Provide();
_outPuts = [.. OutputPorts];
}
private bool CanAccept(IBeltPort port, IBeltItem item)
{
foreach (var portOther in OutputPorts)
{
if (portOther.GetPortFacing(GridRegistry).Map(f => f.CanAccept(item, LaneSpan.One, 0)).Or(false))
{
return true;
}
}
return false;
}
private IEnumerable<BeltPort> OutputPorts => _insertLogic.GetPorts().OfType<BeltPort>().Where(i => i.Access.HasFlag(PortAccess.Out));
private bool CanInsert(IBeltPort port, IBeltItem item)
{
for (var i = 0; i < _outPuts.Count; i++)
{
var facing = _outPuts[i].GetPortFacing(GridRegistry);
if (facing.HasValue(out var face) && face.CanAccept(item, LaneSpan.One, 0) && face.TryInsert(item, LaneSpan.One, 0))
{
var c = _outPuts[i];
_outPuts.RemoveAt(i);
_outPuts.Add(c);
return true;
}
}
return false;
}
}

View File

@@ -0,0 +1 @@
uid://opbkqoaa7x2n

View File

@@ -1,14 +1,9 @@
namespace ChickenGameTest;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using Chickensoft.AutoInject;
using Chickensoft.Introspection;
using Godot;
using SJK.Functional;
[Tool]
[Meta(typeof(IAutoNode))]
@@ -21,11 +16,9 @@ public partial class BeltPort : Node3D, IBeltPort
[Export] public Direction Face { get; set; } = default!;
[Export] public int Width { get; set; } = default!;
[Export] public PortAccess Access { get; set; } = default!;
[Export] public Path3D Path { get; set; } = default!;
[Export] public string PortName { get; set; } = "";
[Dependency] public IItemRenderer ItemRenderer => this.DependOn<IItemRenderer>();
public BeltPortProfile Profile => new(GridTransform3D.FromGodot(GlobalTransform), Width, Access);
[Dependency] public IItemTransferAnimator ItemTransferAnimator => this.DependOn<IItemTransferAnimator>(() => new CurveItemTransfer() { Curve3D = Path.Curve, Tree = GetTree(), ItemRenderer = ItemRenderer, Transform3D = GlobalTransform });
private VoxelGuid _guid = new(Guid.Empty);
public void OnResolved()
{
@@ -37,26 +30,7 @@ public partial class BeltPort : Node3D, IBeltPort
_guid = Grid.Register<IBeltPort>(this, [.. (this as IBeltPort).Points()]);
GD.Print(_guid);
}
public override void _Process(double delta)
{
DebugDraw3D.DrawLine(GlobalPosition, GlobalTransform * Face.ToVector(), Colors.Red);
if (Engine.IsEditorHint())
{
return;
}
for (int i = 0; i < _itemsDummys.Count; i++)
{
_itemsDummys[i] = (_itemsDummys[i].i + (float)delta, _itemsDummys[i].beltItem);
// GD.Print(_itemsDummys[i].i);
ItemRenderer.UpdateTransform(_itemsDummys[i].beltItem, GlobalTransform * Path.Curve.SampleBakedWithRotation(_itemsDummys[i].i));
if (_itemsDummys[i].i > Path.Curve.GetBakedLength())
{
_itemsDummys[i].beltItem.Dispose();
_itemsDummys.RemoveAt(i);
i--;
}
}
}
public override void _Process(double delta) => DebugDraw3D.DrawLine(GlobalPosition, GlobalTransform * Face.ToVector(), Colors.Red);
public override void _ExitTree()
{
@@ -69,20 +43,7 @@ public partial class BeltPort : Node3D, IBeltPort
}
public bool CanAccept(IBeltItem item, LaneSpan laneSpan, float beltT) => Access.HasFlag(PortAccess.In) && InsertLogic.CanAccept(this, item);
List<(float i, IBeltItem beltItem)> _itemsDummys = [];
public bool TryInsert(IBeltItem item, LaneSpan laneSpan, float beltT) => CanAccept(item, laneSpan, beltT) && InsertLogic.CanInsert(this, item);
// {
// var tween = ItemTransferAnimator.StartTransfer(new(item, beltT) { LaneSpan = laneSpan }, () => GD.Print("Done"));
// // GD.Print("gg "+laneSpan);
// tween.TweenCallback(Callable.From(item.Dispose));
// // GD.Print(laneSpan);
// // GD.Print(item.ToString());
// // _itemsDummys.Add((0,item));
// // item.Dispose();
// return true;
// throw new System.NotImplementedException();
// }
}
public interface IBeltItemInsertLogic
@@ -90,106 +51,3 @@ public interface IBeltItemInsertLogic
bool CanInsert(IBeltPort beltPort, IBeltItem item);
bool CanAccept(IBeltPort beltPort, IBeltItem item);
}
public interface IBeltPortHost
{
IBeltItemInsertLogic ResolveInsertLogic(IBeltPort port);
}
public class BeltPortHost : IBeltPortHost
{
private readonly List<(Func<IBeltPort, bool> match, Func<IBeltItemInsertLogic> factory)> _bindings
= new();
public BeltPortHost Bind(
Func<IBeltPort, bool> match,
Func<IBeltItemInsertLogic> factory)
{
_bindings.Add((match, factory));
return this;
}
private HashSet<IBeltPort> _ports = [];
public IBeltItemInsertLogic? Default;
/// <summary>
/// Resolve the insert logic for a port. If no matching bind exists then the default is returned if supplied. Other wise throws an Exception.
/// </summary>
/// <param name="port"></param>
/// <returns></returns>
/// <exception cref="Exception"></exception>
public IBeltItemInsertLogic ResolveInsertLogic(IBeltPort port)
{
_ports.Add(port);
foreach (var (match, factory) in _bindings)
{
if (match(port))
{
return factory();
}
}
if (Default is null)
{
throw new Exception($"{nameof(port)} does not have any binding attached that accepts it.");
}
return Default;
}
public IEnumerable<IBeltPort> GetPorts() => _ports;
}
public interface IItemTransferAnimator
{
Tween StartTransfer(
ConveyorSlice item,
Action onFinished = null);
}
public class InstanceItemTransfer : IItemTransferAnimator
{
public SceneTree Tree = default!;
public Func<ConveyorSlice, bool> AcceptFunc = default!;
public Tween StartTransfer(ConveyorSlice item, Action onFinished = null)
{
AcceptFunc(item);
onFinished?.Invoke();
return Tree.CreateTween();
throw new NotImplementedException();
}
}
public class CurveItemTransfer : IItemTransferAnimator
{
public Curve3D Curve3D = default!;
public IItemRenderer ItemRenderer = default!;
public Func<ConveyorSlice, bool> AcceptFunc = default!;
public SceneTree Tree = default!;
public Transform3D Transform3D;
public Tween AnimateAlongCurve(
ConveyorSlice item,
Curve3D curve,
float duration,
IItemRenderer renderer)
{
float length = curve.GetBakedLength();
var tween = Tree.CreateTween();
tween.TweenMethod(
Callable.From<float>(t =>
{
//Transform is not being set when using update transform in a tween, but can set position
// renderer.UpdateTransform(item, Transform3D * curve.SampleBakedWithRotation(t),1/duration);
(renderer as TestItemRendered)._items[item.Item].Transform = Transform3D * Curve3D.SampleBakedWithRotation(t).Translated(-Curve3D.SampleBakedWithRotation(t).Basis.X * item.LaneSpan.Start);
// GD.PrintS(Transform3D * curve.SampleBakedWithRotation(t).Origin,1/duration,(renderer as TestItemRendered)._items[item].GlobalPosition);
}),
0f,
length,
duration
);
return tween;
}
public Tween StartTransfer(ConveyorSlice item, Action onFinished = null)
{
var tween = AnimateAlongCurve(item, Curve3D, 1, ItemRenderer);
if (onFinished is not null)
{
tween.TweenCallback(Callable.From(onFinished));
}
return tween;
}
}

View File

@@ -0,0 +1,48 @@
namespace ChickenGameTest;
using System;
using System.Collections.Generic;
public interface IBeltPortHost
{
IBeltItemInsertLogic ResolveInsertLogic(IBeltPort port);
}
public class BeltPortHost : IBeltPortHost
{
private readonly List<(Func<IBeltPort, bool> match, Func<IBeltItemInsertLogic> factory)> _bindings
= new();
public BeltPortHost Bind(
Func<IBeltPort, bool> match,
Func<IBeltItemInsertLogic> factory)
{
_bindings.Add((match, factory));
return this;
}
private HashSet<IBeltPort> _ports = [];
public IBeltItemInsertLogic? Default;
/// <summary>
/// Resolve the insert logic for a port. If no matching bind exists then the default is returned if supplied. Other wise throws an Exception.
/// </summary>
/// <param name="port"></param>
/// <returns></returns>
/// <exception cref="Exception"></exception>
public IBeltItemInsertLogic ResolveInsertLogic(IBeltPort port)
{
_ports.Add(port);
foreach (var (match, factory) in _bindings)
{
if (match(port))
{
return factory();
}
}
if (Default is null)
{
throw new Exception($"{nameof(port)} does not have any binding attached that accepts it.");
}
return Default;
}
public IEnumerable<IBeltPort> GetPorts() => _ports;
}

View File

@@ -0,0 +1 @@
uid://mimkyombngwg

View File

@@ -1,10 +1,7 @@
namespace ChickenGameTest;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Threading.Tasks;
using Chickensoft.AutoInject;
using Chickensoft.Introspection;
using Godot;
@@ -55,6 +52,32 @@ public interface IItemRenderer
void UpdateTransform(IBeltItem beltItem, Transform3D newTransform, float time);
void Remove(IBeltItem beltItem);
}
public partial class ItemRenderSimple : Node3D, IItemRenderer
{
public Dictionary<IBeltItem, Node3D> _items = [];
public void Remove(IBeltItem beltItem)
{
if (_items.TryGetValue(beltItem, out var node))
{
node.QueueFree();
}
_items.Remove(beltItem);
}
public void UpdateTransform(IBeltItem beltItem, Transform3D newTransform, float time)
{
if (!_items.TryGetValue(beltItem, out var node))
{
_items.Add(beltItem, node = beltItem.CreateItemVisual());
AddChild(node);
beltItem.Disposed += _ => { node.QueueFree(); _items.Remove(beltItem); };
node.Transform = newTransform;
return;
}
node.Transform = newTransform;
}
public void UpdateTransform(IBeltItem beltItem, Transform3D newTransform) => UpdateTransform(beltItem, newTransform, .25f);
}
public partial class TestItemRendered : Node3D, IItemRenderer
{
public Dictionary<IBeltItem, Node3D> _items = [];

View File

@@ -1,14 +1,11 @@
namespace ChickenGameTest;
using Chickensoft.Introspection;
using Chickensoft.AutoInject;
using Godot;
using System;
using System.Collections.Generic;
using System.Linq;
using Chickensoft.Sync.Primitives;
using SJK.Functional;
using System.Diagnostics.CodeAnalysis;
public interface IMovementConveyor
{

View File

@@ -0,0 +1,70 @@
using Godot;
using System;
namespace FoodFactory;
using Arch.Core;
using ChickenGameTest;
using Chickensoft.AutoInject;
using Chickensoft.Introspection;
using FoodFactory.Recipes;
using Godot;
[Meta(typeof(IAutoNode))]
public partial class ItemSpawner : Node3D, IProvide<IBeltPortHost>
{
public override void _Notification(int what) => this.Notify(what);
[Dependency] public IVoxelGridRegistry GridRegistry => this.DependOn<IVoxelGridRegistry>();
[Dependency] public IBlueprintManger ItemFactory => this.DependOn<IBlueprintManger>();
[Dependency] public World World => this.DependOn<World>();
[Dependency] public IRecipes Recipes => this.DependOn<IRecipes>();
private BeltPortHost _insertLogic = default!;
public IBeltPortHost Value() => _insertLogic;
private VoxelGuid _guid;
public GridTransform3D VoxelTransform
{
get => GridTransform3D.FromGodot(GlobalTransform);
set => GlobalTransform = value.ToGodot();
}
[Export] public string ItemName { get; set; } = default!;
public override void _Ready()
{
_insertLogic = new BeltPortHost
{
Default = new DelegateInsertBeltItemLogic((_, _) => false, (_, _) => false)
};
var timer = new Timer() { Autostart = true, WaitTime = 1f };
AddChild(timer);
timer.Timeout += Tick;
this.Provide();
}
public void OnResolved() => _guid = GridRegistry.Register(this, VoxelTransform.Origin);
public override void _ExitTree() => GridRegistry.UnRegister(_guid);
public void Tick()
{
var ports = _insertLogic.GetPorts();
foreach (var item in ports)
{
var port = item.GetPortFacing(GridRegistry);
if (!port.HasValue(out var beltPort))
{
continue;
}
var itemBlueprint = ItemFactory.GetBlueprint(ItemName);
var dummyItem = new TestItem();
if (beltPort.CanAccept(dummyItem, LaneSpan.One, 0))
{
var ctx = new BlueprintContext() { BluePrintId = new BlueprintId(itemBlueprint), World = World };
dummyItem.Item = itemBlueprint.Factory(ctx);
if (!beltPort.TryInsert(dummyItem, LaneSpan.One, 0))
{
World.Destroy(dummyItem.Item);//TODO this should not call, but not sure
GD.PushWarning("Item failed to insert into port and removed item, item was destroyed but make sure item to prevent overhead.");
}
}
}
}
}

View File

@@ -0,0 +1 @@
uid://btmbv7oaeps4p

View File

@@ -0,0 +1,17 @@
[gd_scene format=3 uid="uid://bktqs1lw6go4"]
[ext_resource type="Script" uid="uid://btmbv7oaeps4p" path="res://src/VoxelGrid/ItemSpawner.cs" id="1_3dxrm"]
[ext_resource type="PackedScene" uid="uid://bfwvlnurlcbwk" path="res://assets/kenney_conveyor-kit/Models/GLB format/cover-hopper.glb" id="2_552yl"]
[ext_resource type="Script" uid="uid://ee5aoxi8mjnw" path="res://src/VoxelGrid/BeltPort.cs" id="3_0b0h5"]
[node name="ItemSpawner" type="Node3D" unique_id=966349707]
script = ExtResource("1_3dxrm")
[node name="cover-hopper2" parent="." unique_id=2099493372 instance=ExtResource("2_552yl")]
transform = Transform3D(-4.371139e-08, 0, -1, 0, 1, 0, 1, 0, -4.371139e-08, 0, 0, 0)
[node name="Node3D" type="Node3D" parent="." unique_id=430904887]
script = ExtResource("3_0b0h5")
Face = 4
Width = 1
Access = 2

View File

@@ -2,38 +2,50 @@ namespace ChickenGameTest;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using Arch.Core;
using Arch.Core.Extensions;
using Chickensoft.AutoInject;
using Chickensoft.Introspection;
using FoodFactory;
using FoodFactory.Items;
using FoodFactory.Recipes;
using Godot;
using SJK.Functional;
[Meta(typeof(IAutoNode))]
public partial class OvenTest : Node3D, IProvide<IBeltPortHost>, IProvide<IVoxelGridRegistry>
{
private BeltPortHost _insertLogic;
public IBeltPortHost Value() => _insertLogic;
public override void _Notification(int what) => this.Notify(what);
private BeltPortHost _insertLogic = default!;
public IBeltPortHost Value() => _insertLogic;
[Dependency] public IVoxelGridRegistry GridRegistry => this.DependOn<IVoxelGridRegistry>();
[Dependency] public IRecipes Recipes => this.DependOn<IRecipes>();
IVoxelGridRegistry IProvide<IVoxelGridRegistry>.Value() => GridRegistry;
public GridTransform3D VoxelTransform
{
get => GridTransform3D.FromGodot(GlobalTransform);
set => GlobalTransform = value.ToGodot();
}
private Dictionary<string, object>? _placeholderItem = null;
private VoxelGuid _guid = default;
private Entity _itemBeingHeld = Entity.Null;
private VoxelGuid _guid;
public void OnResolved()
{
_insertLogic = new BeltPortHost();
_insertLogic.Bind(port => port is BeltPort beltPort && beltPort.PortName == "Input", () => new DelegateInsertBeltItemLogic(canAccept, canInsert));
_insertLogic.Bind(port => port is BeltPort beltPort && beltPort.PortName == "OutPut", () => new DelegateInsertBeltItemLogic((_, _) => false, (_, _) => false));
bool canAccept(IBeltPort port, IBeltItem item) => _placeholderItem is null;
bool canAccept(IBeltPort port, IBeltItem item) => _itemBeingHeld.Id == -1 && !_itemBeingHeld.IsAlive();
bool canInsert(IBeltPort beltPort, IBeltItem item)
{
_placeholderItem = (item as TestItem).PlaceHolderData;
item.Dispose();
GD.Print("Added Item");
return true;
if (item is IBeltItemData<Entity> itemData)
{
_itemBeingHeld = itemData.GetItem();
item.Dispose();
GD.Print("Added Item");
return true;
}
throw new NotImplementedException();
}
_guid = GridRegistry.Register(this, VoxelTransform.Origin);
this.Provide();
@@ -43,22 +55,54 @@ public partial class OvenTest : Node3D, IProvide<IBeltPortHost>, IProvide<IVoxel
time.Timeout += () =>
{
if (_placeholderItem is null)
if (_itemBeingHeld.Id == -1 && !_itemBeingHeld.IsAlive())//TODO have a better way of dertming if item is valid, possibly nullable
{
return;
}
_placeholderItem.GetValue("temp").IfSome(some => _placeholderItem["temp"] = (float)some + 1);
if (_placeholderItem.GetValue("temp").Map(f => ((float)f) < 5).Or(true))
if (!_itemBeingHeld.TryGet<Temperature>(out var temp))
{
return;
}
var port = _insertLogic.GetPorts().FirstOrNone(port => port is BeltPort beltPort && beltPort.PortName == "OutPut").Bind(f => f.GetPortFacing(GridRegistry));
if (port.HasValue(out var v) && _placeholderItem is not null && v.TryInsert(new TestItem() { PlaceHolderData = _placeholderItem }, LaneSpan.One, 0))
temp.Kelvin += new TemperatureDelta(5f, TemperatureUnit.Fahrenheit).KelvinDelta;
_itemBeingHeld.Set(temp);
Span<Entity> items = [_itemBeingHeld];
var context = new RecipeContext(World.Worlds[0], items);
var builder = new RecipeResultBuilder(stackalloc bool[10], new ItemBuilder[10]);
Span<int> mapping = stackalloc int[1];
var recipes = Recipes.GetRecipes(new RecipeAction("cook"), 1, [_itemBeingHeld.Get<Tags>()], [], RecipeOutput.Any, mapping);
// Span<Entity> created = stackalloc Entity[10];
unsafe
{
_placeholderItem = null;
while (RecipeProcessor.TryProcess(
ref recipes,
ref context,
ref builder,
&DestroyEntity,
out var created
))
{
Debug.Assert(created.Length <= 1);
_itemBeingHeld = created[0];
break;
}
}
if (_itemBeingHeld.TryGet<Tags>(out var tags) && tags.Contains(TagRegistry.GetTag("cooked")))
{
var port = _insertLogic.GetPorts().FirstOrNone(port => port is BeltPort beltPort && beltPort.PortName == "OutPut").Bind(f => f.GetPortFacing(GridRegistry));
if (port.HasValue(out var v) && _itemBeingHeld.Id != -1 && _itemBeingHeld.IsAlive() && v.TryInsert(new TestItem() { Item = _itemBeingHeld }, LaneSpan.One, 0))
{
_itemBeingHeld = Entity.Null;
}
}
};
}
private static void DestroyEntity(Entity entity) => World.Worlds[entity.WorldId].Destroy(entity);
public override void _ExitTree()
{
GridRegistry.UnRegister(_guid);
@@ -79,3 +123,123 @@ public class DelegateInsertBeltItemLogic : IBeltItemInsertLogic
public bool CanAccept(IBeltPort beltPort, IBeltItem item) => _canAccept(beltPort, item);
public bool CanInsert(IBeltPort beltPort, IBeltItem item) => _canInsert(beltPort, item);
}
public readonly ref struct RecipeMatch
{
public readonly Recipe Recipe;
public readonly ReadOnlySpan<int> Mapping;
public RecipeMatch(
Recipe recipe,
ReadOnlySpan<int> mapping)
{
Recipe = recipe;
Mapping = mapping;
}
}
public interface IRecipeEnumerator
{
RecipeMatch Current { get; }
bool MoveNext();
}
public unsafe ref struct RecipeEnumerator : IRecipeEnumerator
{
public readonly RecipeMatch Current => _match;
private RecipeMatch _match;
private int _index;
private readonly ReadOnlySpan<CompiledRecipe> _recipes;
private readonly RecipeInput _input;
private readonly Span<int> _mapping;
private readonly delegate*<RecipeInput, CompiledRecipe, Span<int>, out RecipeMatch, bool> _filter;
public RecipeEnumerator(ReadOnlySpan<CompiledRecipe> compiledRecipes, RecipeInput input, delegate*<RecipeInput, CompiledRecipe, Span<int>, out RecipeMatch, bool> filter, Span<int> mapping)
{
_recipes = compiledRecipes;
_input = input;
_index = -1;
_filter = filter;
_mapping = mapping;
}
public bool MoveNext()
{
_index++;
while (_index < _recipes.Length)
{
if (_filter(_input, _recipes[_index], _mapping, out _match))
{
break;
}
_index++;
}
return _index < _recipes.Length;
}
}
public static class RecipeProcessor
{
public static unsafe bool TryProcess<TRecipeEnumerator>(
ref TRecipeEnumerator recipes,
scoped ref RecipeContext context,
scoped ref RecipeResultBuilder builder,
delegate*<Entity, void> destroyEntity,
out Span<Entity> resultEntity)
where TRecipeEnumerator : IRecipeEnumerator, allows ref struct
{
resultEntity = default;
while (recipes.MoveNext())
{
var entry = recipes.Current;
var recipe = entry.Recipe;
if (!recipe.CanProcess(context))
{
continue;
}
var result = recipe.Process(context, ref builder);
ApplyResult(
in context,
result,
destroyEntity,
out resultEntity);
builder.Clear();
return true;
}
return false;
}
private static unsafe void ApplyResult(
scoped in RecipeContext context,
scoped RecipeResult result,
delegate*<Entity, void> destroyEntity,
out Span<Entity> created)
{
created = default;
result.Mutate?.Invoke(context);
created = new Entity[result.CreateLength];
for (int i = 0; i < result.CreateLength; i++)
{
created[i] = result.Create[i](in context);
}
if (result.RemoveLength > 0)
{
for (var i = 0; i < result.RemoveLength; i++)
{
if (result.Remove[i])
{
destroyEntity(context.Items[i]);
}
}
}
}
}

106
src/VoxelGrid/SlicerTest.cs Normal file
View File

@@ -0,0 +1,106 @@
namespace ChickenGameTest;
using System;
using System.Collections.Generic;
using System.Linq;
using Arch.Core;
using Arch.Core.Extensions;
using Chickensoft.AutoInject;
using Chickensoft.Introspection;
using FoodFactory;
using FoodFactory.Items;
using FoodFactory.Recipes;
using Godot;
using SJK.Functional;
[Meta(typeof(IAutoNode))]
public partial class SlicerTest : Node3D, IProvide<IBeltPortHost>, IProvide<IVoxelGridRegistry>
{
public override void _Notification(int what) => this.Notify(what);
private BeltPortHost _insertLogic = default!;
public IBeltPortHost Value() => _insertLogic;
[Dependency] public IVoxelGridRegistry GridRegistry => this.DependOn<IVoxelGridRegistry>();
[Dependency] public IRecipes Recipes => this.DependOn<IRecipes>();
IVoxelGridRegistry IProvide<IVoxelGridRegistry>.Value() => GridRegistry;
public GridTransform3D VoxelTransform
{
get => GridTransform3D.FromGodot(GlobalTransform);
set => GlobalTransform = value.ToGodot();
}
private Entity _itemBeingHeld = Entity.Null;
private List<Entity> sliced = [];
private VoxelGuid _guid;
public void OnResolved()
{
_insertLogic = new BeltPortHost();
_insertLogic.Bind(port => port is BeltPort beltPort && beltPort.PortName == "Input", () => new DelegateInsertBeltItemLogic(canAccept, canInsert));
_insertLogic.Bind(port => port is BeltPort beltPort && beltPort.PortName == "OutPut", () => new DelegateInsertBeltItemLogic((_, _) => false, (_, _) => false));
bool canAccept(IBeltPort port, IBeltItem item) => _itemBeingHeld.Id == -1 && !_itemBeingHeld.IsAlive() && item is IBeltItemData<Entity> beltItemData && beltItemData.GetItem().TryGet<Tags>(out var tags) && tags.Contains(TagRegistry.GetTag("sliceable"));
bool canInsert(IBeltPort beltPort, IBeltItem item)
{
if (item is IBeltItemData<Entity> itemData)
{
_itemBeingHeld = itemData.GetItem();
item.Dispose();
GD.Print("Added Item to slicer");
return true;
}
throw new NotImplementedException();
}
_guid = GridRegistry.Register(this, VoxelTransform.Origin);
this.Provide();
var time = new Timer() { Autostart = true, OneShot = false, WaitTime = .1 };
AddChild(time);
time.Timeout += () =>
{
if (sliced.Any())
{
var port = _insertLogic.GetPorts().FirstOrNone(port => port is BeltPort beltPort && beltPort.PortName == "OutPut").Bind(f => f.GetPortFacing(GridRegistry));
if (port.HasValue(out var v) && v.TryInsert(new TestItem() { Item = sliced[0] }, LaneSpan.One, 0))
{
GD.Print(sliced[0].Get<Carbohydrates>());
sliced.RemoveAt(0);
}
}
if (_itemBeingHeld.Id == -1)//TODO have a better way of dertming if item is valid, possibly nullable
{
return;
}
Span<Entity> items = [_itemBeingHeld];
var context = new RecipeContext(World.Worlds[0], items);
var builder = new RecipeResultBuilder(stackalloc bool[10], new ItemBuilder[10]);
Span<int> mapping = stackalloc int[1];
// var recipe = new PotatoCookRecipe();
var recipes = Recipes.GetRecipes("slice", 1, [_itemBeingHeld.Get<Tags>()], [], new RecipeOutput(2), mapping);
unsafe
{
while (RecipeProcessor.TryProcess(
ref recipes,
ref context,
ref builder,
&DestroyEntity,
out var created
))
{
_itemBeingHeld = Entity.Null;
sliced.AddRange(created);
break;
}
}
};
}
private static void DestroyEntity(Entity entity) => World.Worlds[entity.WorldId].Destroy(entity);
public override void _ExitTree()
{
GridRegistry.UnRegister(_guid);
base._ExitTree();
}
}

View File

@@ -0,0 +1 @@
uid://yec84plemjv1

View File

@@ -8,6 +8,8 @@ using System.Collections.Generic;
using System.Linq;
using Chickensoft.Sync.Primitives;
using SJK.Functional;
using FoodFactory.Recipes;
using Arch.Core;
public class Sorted1DList<T>
{
@@ -258,7 +260,6 @@ public partial class TestItemConveyor : Node, IMovementConveyor
var guid = GridRegistry.Register(item, [.. points]);
TreeExiting += () => GridRegistry.UnRegister(guid);
}
StartPort.TryInsert(new TestItem() { PlaceHolderData = new() { ["temp"] = 0f } }, LaneSpan.Shifted(LaneSpan.One, 0), 0);
}
//ChatGPT Assisted
public BeltObstacle GetDistanceToNextItem(
@@ -458,22 +459,22 @@ public partial class TestItemConveyor : Node, IMovementConveyor
public const float ITEMSIZE = .2f;
private const float ITEMHALFSIZE = ITEMSIZE / 2f;
public override void _Process(double delta)
{
if (StartPort is null || EndPort is null)
{
return;
}
foreach (var item in GetPorts())
{
for (int ii = 0; ii < item.Profile.Width; ii++)
{
DebugDraw3D.DrawLinePath(_square.Select(i => item.Profile.LocalOffset.ToGodot().TranslatedLocal(i).TranslatedLocal(new Vector3(ii, 0, 0)).Origin).ToArray(), (!Engine.IsEditorHint()) && GetPortFacing(item).HasValue() ? Colors.Green : Colors.Red);
// public override void _Process(double delta)
// {
// if (StartPort is null || EndPort is null)
// {
// return;
// }
// foreach (var item in GetPorts())
// {
// for (int ii = 0; ii < item.Profile.Width; ii++)
// {
// DebugDraw3D.DrawLinePath(_square.Select(i => item.Profile.LocalOffset.ToGodot().TranslatedLocal(i).TranslatedLocal(new Vector3(ii, 0, 0)).Origin).ToArray(), (!Engine.IsEditorHint()) && GetPortFacing(item).HasValue() ? Colors.Green : Colors.Red);
}
// DebugDraw3D.DrawArrow(item.Profile.LocalOffset.Origin, item.Profile.LocalOffset.LocalToWorld(item.Profile.Face.ToVector()),(!Engine.IsEditorHint())&&GetPortFacing(item).HasValue()?Colors.Green:Colors.Red);
}
}
// }
// // DebugDraw3D.DrawArrow(item.Profile.LocalOffset.Origin, item.Profile.LocalOffset.LocalToWorld(item.Profile.Face.ToVector()),(!Engine.IsEditorHint())&&GetPortFacing(item).HasValue()?Colors.Green:Colors.Red);
// }
// }
public ConveyorPort CreatePort(BeltPortProfile profile, BeltT beltT, LaneSpan laneSpan)
{

View File

@@ -2,36 +2,90 @@ namespace ChickenGameTest;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using Arch.Core;
using Arch.Core.Extensions;
using Arch.LowLevel;
using Arch.System;
using Chickensoft.AutoInject;
using Chickensoft.Introspection;
using FoodFactory;
using FoodFactory.Recipes;
using Godot;
using Godot.Collections;
using SJK.Functional;
public class BacterialSystem : BaseSystem<World, float>
{
private QueryDescription _desc = new QueryDescription().WithAll<Bacteria, Temperature>();
public static Resources<List<BacteriaData>> Resources = new();
public BacterialSystem(World world) : base(world)
{
}
public override void Update(in float t)
{
var delta = t;
World.ParallelQuery(in _desc, (Entity entity, ref Bacteria bacteria, ref Temperature temperature) =>
{
var handle = bacteria.Data;
var data = Resources.Get(in handle);
for (int i = 0; i < data.Count; i++)
{
data[i] = data[i] with { Count = BacteriaModel.UpdatePopulation(data[i].Count, temperature.Celsius, delta) };
// GD.Print(data[i].Count);
if (data[i].Count <= 0.5)
{
data.RemoveAt(i);
i--;
}
}
});
}
}
//Will Liklely be the game instead of a node like this
[Meta(typeof(IAutoNode))]// [Tool]
public partial class VoxelGridNode : Node3D, IProvide<IVoxelGridRegistry>, IProvide<IItemRenderer>
public partial class VoxelGridNode : Node3D, IProvide<IVoxelGridRegistry>, IProvide<IItemRenderer>, IProvide<IRecipes>, IProvide<IBlueprintManger>, IProvide<World>
{
public override void _Notification(int what) => this.Notify(what);
private World _world = default!;
World IProvide<World>.Value() => _world;
private IVoxelGridRegistry _voxelGridRegistry = default!;
IVoxelGridRegistry IProvide<IVoxelGridRegistry>.Value() => _voxelGridRegistry;
private IBlueprintManger _blueprintManger = default!;
IBlueprintManger IProvide<IBlueprintManger>.Value() => _blueprintManger;
private Recipes _recipes = default!;
IRecipes IProvide<IRecipes>.Value() => _recipes;
private IItemRenderer _itemRenderer = default!;
IItemRenderer IProvide<IItemRenderer>.Value() => _itemRenderer;
Group<float> _systems;
public override void _Ready()
{
// GD.Print();
base._Ready();
_voxelGridRegistry = new VoxelRegistry();
_itemRenderer = new TestItemRendered();
_itemRenderer = new ItemRenderSimple();
_blueprintManger = new BlueprintManger();
_recipes = new Recipes();
_world = World.Create();
_systems = new Group<float>("Items", new BacterialSystem(_world));
AddChild(_itemRenderer as Node);
Timer timer = new Timer() { WaitTime = .25f, Autostart = true };//TEST
AddChild(timer);//TEST
// timer.Timeout += _itemRenderer.Tick;//TEST
timer.Timeout += () =>
{
_systems.BeforeUpdate(.25f);
_systems.Update(.25f);
_systems.AfterUpdate(.25f);
};
_systems.Initialize();
this.Provide();
}
public override void _Input(InputEvent @event)
{
if (@event.IsActionPressed("ui_up"))
@@ -46,4 +100,51 @@ public partial class VoxelGridNode : Node3D, IProvide<IVoxelGridRegistry>, IProv
}
}
}
public override void _ExitTree()
{
base._ExitTree();
_systems.Dispose();
_world.Dispose();
}
}
public static class BacteriaModel
{
// population = current bacteria count
// temperature = degrees Celsius
// deltaTime = elapsed time (hours)
public static double UpdatePopulation(
double population,
double temperature,
double deltaTime)
{
double rate;
// Very cold -> slight die-off
if (temperature <= 5)
{
rate = -0.1;
}
// Growth zone
else if (temperature < 35)
{
rate = 0.06 * (temperature - 5);
}
// Hot but still survivable
else if (temperature < 60)
{
rate = 1.8 - 0.08 * (temperature - 35);
}
// Dangerous heat -> bacteria die
else
{
rate = -0.8;
}
// Population update
double newPopulation =
population + (deltaTime * population * rate);
// Prevent negative bacteria counts
return Math.Max(0, newPopulation);
}
}

View File

@@ -2,9 +2,12 @@
[ext_resource type="Script" uid="uid://dcrb286hmpli" path="res://src/VoxelGrid/VoxelGridNode.cs" id="1_tsdpe"]
[ext_resource type="Script" uid="uid://cnkblltup5guy" path="res://src/VoxelGrid/OvenTest.cs" id="3_r7dgx"]
[ext_resource type="PackedScene" uid="uid://bktqs1lw6go4" path="res://src/VoxelGrid/ItemSpawner.tscn" id="5_mxaon"]
[ext_resource type="PackedScene" uid="uid://h00mq2srsbfa" path="res://assets/kenney_conveyor-kit/Models/GLB format/door.glb" id="5_wk2t5"]
[ext_resource type="Script" uid="uid://ee5aoxi8mjnw" path="res://src/VoxelGrid/BeltPort.cs" id="6_2wkfx"]
[ext_resource type="PackedScene" uid="uid://c4h7mwnfrdesg" path="res://src/Conveyors/ConveyorBeltStraight/ConveyorBeltStraight.tscn" id="6_mxaon"]
[ext_resource type="Script" uid="uid://opbkqoaa7x2n" path="res://src/VoxelGrid/Balancer.cs" id="7_2wkfx"]
[ext_resource type="Script" uid="uid://yec84plemjv1" path="res://src/VoxelGrid/SlicerTest.cs" id="8_2lg7i"]
[sub_resource type="Curve3D" id="Curve3D_mxaon"]
_data = {
@@ -13,6 +16,9 @@ _data = {
}
point_count = 2
[sub_resource type="BoxMesh" id="BoxMesh_2wkfx"]
size = Vector3(1, 1, 2)
[node name="VoxelGridNode" type="Node3D" unique_id=825696340]
script = ExtResource("1_tsdpe")
@@ -20,108 +26,123 @@ script = ExtResource("1_tsdpe")
transform = Transform3D(0.6279494, -0.32487354, 0.70720345, -8.896721e-09, 0.908705, 0.4174389, -0.77825415, -0.26213053, 0.5706208, 4.635174, 2.6038146, 2.739409)
[node name="ConveyorBeltStraight5" parent="." unique_id=975225936 instance=ExtResource("6_mxaon")]
transform = Transform3D(1.3113416e-07, 0, -1, 0, 1, 0, 1, 0, 1.3113416e-07, 3, 0, 0)
Width = 1
[node name="ConveyorBeltStraight22" parent="." unique_id=81137442 instance=ExtResource("6_mxaon")]
transform = Transform3D(1.3113416e-07, 0, -1, 0, 1, 0, 1, 0, 1.3113416e-07, 2, 0, 0)
Width = 1
[node name="ConveyorBeltStraight13" parent="." unique_id=607296315 instance=ExtResource("6_mxaon")]
transform = Transform3D(1.3113416e-07, 0, -1, 0, 1, 0, 1, 0, 1.3113416e-07, 0, 0, 0)
Width = 1
[node name="ConveyorBeltStraight26" parent="." unique_id=626657643 instance=ExtResource("6_mxaon")]
transform = Transform3D(1.3113416e-07, 0, -1, 0, 1, 0, 1, 0, 1.3113416e-07, 1, 0, 0)
Width = 1
[node name="ConveyorBeltStraight6" parent="." unique_id=264656404 instance=ExtResource("6_mxaon")]
transform = Transform3D(1.3113416e-07, 0, -1, 0, 1, 0, 1, 0, 1.3113416e-07, -1, 0, 0)
Width = 1
[node name="ConveyorBeltStraight23" parent="." unique_id=1438072389 instance=ExtResource("6_mxaon")]
transform = Transform3D(1.3113416e-07, 0, -1, 0, 1, 0, 1, 0, 1.3113416e-07, -2, 0, 0)
Width = 1
[node name="ConveyorBeltStraight14" parent="." unique_id=1045608025 instance=ExtResource("6_mxaon")]
transform = Transform3D(1.3113416e-07, 0, -1, 0, 1, 0, 1, 0, 1.3113416e-07, -4, 0, 0)
Width = 1
[node name="ConveyorBeltStraight27" parent="." unique_id=899289297 instance=ExtResource("6_mxaon")]
transform = Transform3D(1.3113416e-07, 0, -1, 0, 1, 0, 1, 0, 1.3113416e-07, -3, 0, 0)
Width = 1
transform = Transform3D(1.3113416e-07, 0, -1, 0, 1, 0, 1, 0, 1.3113416e-07, 0, 0, 0)
[node name="ConveyorBeltStraight7" parent="." unique_id=1602707514 instance=ExtResource("6_mxaon")]
transform = Transform3D(1.3113416e-07, 0, -1, 0, 1, 0, 1, 0, 1.3113416e-07, 3, 0, 1)
Width = 1
transform = Transform3D(-1, 0, -8.742277e-08, 0, 1, 0, 8.742277e-08, 0, -1, 1, 0, 1)
[node name="ConveyorBeltStraight8" parent="." unique_id=1032197109 instance=ExtResource("6_mxaon")]
transform = Transform3D(1.3113416e-07, 0, -1, 0, 1, 0, 1, 0, 1.3113416e-07, 1, 0, 2)
[node name="ConveyorBeltStraight24" parent="." unique_id=574723066 instance=ExtResource("6_mxaon")]
transform = Transform3D(1.3113416e-07, 0, -1, 0, 1, 0, 1, 0, 1.3113416e-07, 1, 0, 6)
[node name="ConveyorBeltStraight25" parent="." unique_id=1584944068 instance=ExtResource("6_mxaon")]
transform = Transform3D(1.3113416e-07, 0, -1, 0, 1, 0, 1, 0, 1.3113416e-07, 0, 0, 6)
[node name="ConveyorBeltStraight13" parent="." unique_id=490179430 instance=ExtResource("6_mxaon")]
transform = Transform3D(1.3113416e-07, 0, -1, 0, 1, 0, 1, 0, 1.3113416e-07, 3, 0, 2)
[node name="ConveyorBeltStraight20" parent="." unique_id=1684880263 instance=ExtResource("6_mxaon")]
transform = Transform3D(1, 0, 1.7484555e-07, 0, 1, 0, -1.7484555e-07, 0, 1, 4, 0, 2)
[node name="ConveyorBeltStraight15" parent="." unique_id=1971663524 instance=ExtResource("6_mxaon")]
transform = Transform3D(1.3113416e-07, 0, -1, 0, 1, 0, 1, 0, 1.3113416e-07, 3, 0, 3)
[node name="ConveyorBeltStraight23" parent="." unique_id=830278017 instance=ExtResource("6_mxaon")]
transform = Transform3D(1, 0, 1.7484555e-07, 0, 1, 0, -1.7484555e-07, 0, 1, 4, 0, 3)
[node name="ConveyorBeltStraight9" parent="." unique_id=1449572266 instance=ExtResource("6_mxaon")]
transform = Transform3D(1.3113416e-07, 0, -1, 0, 1, 0, 1, 0, 1.3113416e-07, 5, 0, 1)
Width = 1
transform = Transform3D(1.3113416e-07, 0, -1, 0, 1, 0, 1, 0, 1.3113416e-07, 3, 0, 1)
[node name="ConveyorBeltStraight26" parent="." unique_id=181268712 instance=ExtResource("6_mxaon")]
transform = Transform3D(1.3113416e-07, 0, -1, 0, 1, 0, 1, 0, 1.3113416e-07, 5, 0, 5)
[node name="ConveyorBeltStraight27" parent="." unique_id=1546024538 instance=ExtResource("6_mxaon")]
transform = Transform3D(1.3113416e-07, 0, -1, 0, 1, 0, 1, 0, 1.3113416e-07, 5, 0, 6)
[node name="ConveyorBeltStraight28" parent="." unique_id=1945842047 instance=ExtResource("6_mxaon")]
transform = Transform3D(1.3113416e-07, 0, -1, 0, 1, 0, 1, 0, 1.3113416e-07, 5, 0, 4)
[node name="ConveyorBeltStraight29" parent="." unique_id=116753972 instance=ExtResource("6_mxaon")]
transform = Transform3D(1.3113416e-07, 0, -1, 0, 1, 0, 1, 0, 1.3113416e-07, 5, 0, 8)
[node name="ConveyorBeltStraight30" parent="." unique_id=903050872 instance=ExtResource("6_mxaon")]
transform = Transform3D(1.3113416e-07, 0, -1, 0, 1, 0, 1, 0, 1.3113416e-07, 5, 0, 9)
[node name="ConveyorBeltStraight31" parent="." unique_id=848458617 instance=ExtResource("6_mxaon")]
transform = Transform3D(1.3113416e-07, 0, -1, 0, 1, 0, 1, 0, 1.3113416e-07, 5, 0, 7)
[node name="ConveyorBeltStraight32" parent="." unique_id=889036013 instance=ExtResource("6_mxaon")]
transform = Transform3D(1.3113416e-07, 0, -1, 0, 1, 0, 1, 0, 1.3113416e-07, 6, 0, 8)
[node name="ConveyorBeltStraight33" parent="." unique_id=992629708 instance=ExtResource("6_mxaon")]
transform = Transform3D(1.3113416e-07, 0, -1, 0, 1, 0, 1, 0, 1.3113416e-07, 6, 0, 9)
[node name="ConveyorBeltStraight34" parent="." unique_id=795974742 instance=ExtResource("6_mxaon")]
transform = Transform3D(1.3113416e-07, 0, -1, 0, 1, 0, 1, 0, 1.3113416e-07, 7, 0, 9)
[node name="ConveyorBeltStraight35" parent="." unique_id=601890089 instance=ExtResource("6_mxaon")]
transform = Transform3D(1.3113416e-07, 0, -1, 0, 1, 0, 1, 0, 1.3113416e-07, 6, 0, 5)
[node name="ConveyorBeltStraight36" parent="." unique_id=2134741630 instance=ExtResource("6_mxaon")]
transform = Transform3D(1.3113416e-07, 0, -1, 0, 1, 0, 1, 0, 1.3113416e-07, 7, 0, 4)
[node name="ConveyorBeltStraight37" parent="." unique_id=196786809 instance=ExtResource("6_mxaon")]
transform = Transform3D(1.3113416e-07, 0, -1, 0, 1, 0, 1, 0, 1.3113416e-07, 6, 0, 4)
[node name="ConveyorBeltStraight10" parent="." unique_id=68139731 instance=ExtResource("6_mxaon")]
transform = Transform3D(1.3113416e-07, 0, -1, 0, 1, 0, 1, 0, 1.3113416e-07, 6, 0, 1)
Width = 1
transform = Transform3D(1.3113416e-07, 0, -1, 0, 1, 0, 1, 0, 1.3113416e-07, 4, 0, 1)
[node name="ConveyorBeltStraight11" parent="." unique_id=358641682 instance=ExtResource("6_mxaon")]
transform = Transform3D(1.3113416e-07, 0, -1, 0, 1, 0, 1, 0, 1.3113416e-07, 7, 0, 1)
Width = 1
transform = Transform3D(1.3113416e-07, 0, -1, 0, 1, 0, 1, 0, 1.3113416e-07, 5, 0, 1)
[node name="ConveyorBeltStraight12" parent="." unique_id=310565328 instance=ExtResource("6_mxaon")]
transform = Transform3D(1.3113416e-07, 0, -1, 0, 1, 0, 1, 0, 1.3113416e-07, 8, 0, 1)
Width = 1
transform = Transform3D(1.3113416e-07, 0, -1, 0, 1, 0, 1, 0, 1.3113416e-07, 6, 0, 1)
[node name="ConveyorBeltStraight17" parent="." unique_id=111805683 instance=ExtResource("6_mxaon")]
transform = Transform3D(1, 0, 1.7484555e-07, 0, 1, 0, -1.7484555e-07, 0, 1, 9, 0, 1)
Width = 1
transform = Transform3D(1, 0, 1.7484555e-07, 0, 1, 0, -1.7484555e-07, 0, 1, 7, 0, 1)
[node name="ConveyorBeltStraight21" parent="." unique_id=764425478 instance=ExtResource("6_mxaon")]
transform = Transform3D(1, 0, 1.7484555e-07, 0, 1, 0, -1.7484555e-07, 0, 1, 7, 0, 2)
[node name="ConveyorBeltStraight22" parent="." unique_id=1089887693 instance=ExtResource("6_mxaon")]
transform = Transform3D(1, 0, 1.7484555e-07, 0, 1, 0, -1.7484555e-07, 0, 1, 7, 0, 3)
[node name="ConveyorBeltStraight18" parent="." unique_id=971476244 instance=ExtResource("6_mxaon")]
transform = Transform3D(1, 0, 1.7484555e-07, 0, 1, 0, -1.7484555e-07, 0, 1, 9, 0, 0)
Width = 1
transform = Transform3D(1, 0, 1.7484555e-07, 0, 1, 0, -1.7484555e-07, 0, 1, 7, 0, 0)
[node name="ConveyorBeltStraight19" parent="." unique_id=87035771 instance=ExtResource("6_mxaon")]
transform = Transform3D(1, 0, 1.7484555e-07, 0, 1, 0, -1.7484555e-07, 0, 1, 9, 0, -1)
Width = 1
[node name="ConveyorBeltStraight19" parent="." unique_id=1940918727 instance=ExtResource("6_mxaon")]
transform = Transform3D(1, 0, 1.7484555e-07, 0, 1, 0, -1.7484555e-07, 0, 1, 8, 0, -3)
[node name="ConveyorBeltStraight24" parent="." unique_id=904248251 instance=ExtResource("6_mxaon")]
transform = Transform3D(1.3113416e-07, 0, -1, 0, 1, 0, 1, 0, 1.3113416e-07, 2, 0, 1)
Width = 1
[node name="ConveyorBeltStraight40" parent="." unique_id=1578916497 instance=ExtResource("6_mxaon")]
transform = Transform3D(1, 0, 1.7484555e-07, 0, 1, 0, -1.7484555e-07, 0, 1, 8, 0, -2)
[node name="ConveyorBeltStraight15" parent="." unique_id=533235542 instance=ExtResource("6_mxaon")]
transform = Transform3D(1.3113416e-07, 0, -1, 0, 1, 0, 1, 0, 1.3113416e-07, 0, 0, 1)
Width = 1
[node name="ConveyorBeltStraight41" parent="." unique_id=1562444632 instance=ExtResource("6_mxaon")]
transform = Transform3D(1, 0, 1.7484555e-07, 0, 1, 0, -1.7484555e-07, 0, 1, 8, 0, -4)
[node name="ConveyorBeltStraight28" parent="." unique_id=2116943332 instance=ExtResource("6_mxaon")]
transform = Transform3D(1.3113416e-07, 0, -1, 0, 1, 0, 1, 0, 1.3113416e-07, 1, 0, 1)
Width = 1
[node name="ConveyorBeltStraight38" parent="." unique_id=1520289120 instance=ExtResource("6_mxaon")]
transform = Transform3D(1, 0, 1.7484555e-07, 0, 1, 0, -1.7484555e-07, 0, 1, 7, 0, -3)
[node name="ConveyorBeltStraight8" parent="." unique_id=1109978762 instance=ExtResource("6_mxaon")]
transform = Transform3D(1.3113416e-07, 0, -1, 0, 1, 0, 1, 0, 1.3113416e-07, -1, 0, 1)
Width = 1
[node name="ConveyorBeltStraight25" parent="." unique_id=1110001269 instance=ExtResource("6_mxaon")]
transform = Transform3D(1.3113416e-07, 0, -1, 0, 1, 0, 1, 0, 1.3113416e-07, -2, 0, 1)
Width = 1
[node name="ConveyorBeltStraight39" parent="." unique_id=44974977 instance=ExtResource("6_mxaon")]
transform = Transform3D(1, 0, 1.7484555e-07, 0, 1, 0, -1.7484555e-07, 0, 1, 7, 0, -4)
[node name="ConveyorBeltStraight16" parent="." unique_id=1178816500 instance=ExtResource("6_mxaon")]
transform = Transform3D(1.3113416e-07, 0, -1, 0, 1, 0, 1, 0, 1.3113416e-07, -4, 0, 1)
Width = 1
[node name="ConveyorBeltStraight29" parent="." unique_id=1537356869 instance=ExtResource("6_mxaon")]
transform = Transform3D(1.3113416e-07, 0, -1, 0, 1, 0, 1, 0, 1.3113416e-07, -3, 0, 1)
Width = 1
transform = Transform3D(1.3113416e-07, 0, -1, 0, 1, 0, 1, 0, 1.3113416e-07, 0, 0, 1)
[node name="OvenTest" type="Node3D" parent="." unique_id=824176002]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 4, 0, 0)
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 2, 0, 0)
script = ExtResource("3_r7dgx")
[node name="Node3D2" type="Node3D" parent="OvenTest" unique_id=1815100025 node_paths=PackedStringArray("Path")]
[node name="Node3D2" type="Node3D" parent="OvenTest" unique_id=1815100025]
transform = Transform3D(1.3113416e-07, 0, 1, 0, 1, 0, -1, 0, 1.3113416e-07, 0, 0, 0)
script = ExtResource("6_2wkfx")
Face = 4
Width = 1
Access = 3
Path = NodePath("Path3D")
Access = 1
PortName = "Input"
[node name="Path3D" type="Path3D" parent="OvenTest/Node3D2" unique_id=1525648764]
@@ -130,13 +151,12 @@ curve = SubResource("Curve3D_mxaon")
[node name="door3" parent="OvenTest/Node3D2" unique_id=351624885 instance=ExtResource("5_wk2t5")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -7.870017e-08, 0, -0.6001501)
[node name="Node3D3" type="Node3D" parent="OvenTest" unique_id=1033202746 node_paths=PackedStringArray("Path")]
[node name="Node3D3" type="Node3D" parent="OvenTest" unique_id=1033202746]
transform = Transform3D(-2.1855693e-07, 0, -1, 0, 1, 0, 1, 0, -2.1855693e-07, 0, 0, 1)
script = ExtResource("6_2wkfx")
Face = 4
Width = 1
Access = 3
Path = NodePath("Path3D2")
Access = 2
PortName = "OutPut"
[node name="Path3D2" type="Path3D" parent="OvenTest/Node3D3" unique_id=739562310]
@@ -144,3 +164,115 @@ curve = SubResource("Curve3D_mxaon")
[node name="door4" parent="OvenTest/Node3D3" unique_id=1602265662 instance=ExtResource("5_wk2t5")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -5.9604645e-08, 0, -0.3998499)
[node name="door5" parent="OvenTest/Node3D3" unique_id=102838222 instance=ExtResource("5_wk2t5")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -5.9604645e-08, 0, -0.3998499)
[node name="ItemSpawner" parent="." unique_id=966349707 instance=ExtResource("5_mxaon")]
transform = Transform3D(-4.371139e-08, 0, -1, 0, 1, 0, 1, 0, -4.371139e-08, -1.0023941, 0, 0.0019463301)
ItemName = "Potato"
[node name="ItemSpawner2" parent="." unique_id=405829395 instance=ExtResource("5_mxaon")]
transform = Transform3D(3.059797e-07, 0, -1, 0, 1, 0, 1, 0, 3.059797e-07, -1, 0, 1)
ItemName = "Onion"
[node name="ItemSpawner3" parent="." unique_id=422927887 instance=ExtResource("5_mxaon")]
transform = Transform3D(3.059797e-07, 0, -1, 0, 1, 0, 1, 0, 3.059797e-07, -1, 0, 6)
ItemName = "Potato"
[node name="Balancer" type="Node3D" parent="." unique_id=619243985]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 2, 0, 2)
script = ExtResource("7_2wkfx")
[node name="Node3D" type="Node3D" parent="Balancer" unique_id=793236513]
transform = Transform3D(-4.371139e-08, 0, -1, 0, 1, 0, 1, 0, -4.371139e-08, 0, 0, 0)
script = ExtResource("6_2wkfx")
Face = 4
Width = 1
Access = 1
[node name="Node3D3" type="Node3D" parent="Balancer" unique_id=1846433120]
transform = Transform3D(-4.371139e-08, 0, 1, 0, 1, 0, -1, 0, -4.371139e-08, 0, 0, 0)
script = ExtResource("6_2wkfx")
Face = 4
Width = 1
Access = 2
[node name="Node3D4" type="Node3D" parent="Balancer" unique_id=1579207766]
transform = Transform3D(-4.371139e-08, 0, 1, 0, 1, 0, -1, 0, -4.371139e-08, 0, 0, 1)
script = ExtResource("6_2wkfx")
Face = 4
Width = 1
Access = 1
[node name="Node3D2" type="Node3D" parent="Balancer" unique_id=717100096]
transform = Transform3D(-4.371139e-08, 0, -1, 0, 1, 0, 1, 0, -4.371139e-08, 0, 0, 1)
script = ExtResource("6_2wkfx")
Face = 4
Width = 1
Access = 2
[node name="MeshInstance3D" type="MeshInstance3D" parent="Balancer" unique_id=383290173]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.5, 0.5)
mesh = SubResource("BoxMesh_2wkfx")
[node name="Balancer8" type="Node3D" parent="." unique_id=1783081047]
transform = Transform3D(-4.371139e-08, 0, 1, 0, 1, 0, -1, 0, -4.371139e-08, 7, 0, -1)
script = ExtResource("7_2wkfx")
[node name="Node3D" type="Node3D" parent="Balancer8" unique_id=1818940385]
transform = Transform3D(-4.371139e-08, 0, -1, 0, 1, 0, 1, 0, -4.371139e-08, 0, 0, 0)
script = ExtResource("6_2wkfx")
Face = 4
Width = 1
Access = 1
[node name="Node3D3" type="Node3D" parent="Balancer8" unique_id=51764402]
transform = Transform3D(-4.371139e-08, 0, 1, 0, 1, 0, -1, 0, -4.371139e-08, 0, 0, 0)
script = ExtResource("6_2wkfx")
Face = 4
Width = 1
Access = 2
[node name="Node3D4" type="Node3D" parent="Balancer8" unique_id=233486636]
transform = Transform3D(-4.371139e-08, 0, 1, 0, 1, 0, -1, 0, -4.371139e-08, 0, 0, 1)
script = ExtResource("6_2wkfx")
Face = 4
Width = 1
Access = 1
[node name="Node3D2" type="Node3D" parent="Balancer8" unique_id=1446214840]
transform = Transform3D(-4.371139e-08, 0, -1, 0, 1, 0, 1, 0, -4.371139e-08, 0, 0, 1)
script = ExtResource("6_2wkfx")
Face = 4
Width = 1
Access = 2
[node name="MeshInstance3D" type="MeshInstance3D" parent="Balancer8" unique_id=556689065]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.5, 0.5)
mesh = SubResource("BoxMesh_2wkfx")
[node name="Slicer" type="Node3D" parent="." unique_id=566544377]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 7, 0, -2)
script = ExtResource("8_2lg7i")
[node name="Node3D4" type="Node3D" parent="Slicer" unique_id=1206144064]
transform = Transform3D(-1, 0, 8.742277e-08, 0, 1, 0, -8.742277e-08, 0, -1, 0, 0, 0)
[node name="Path3D" type="Path3D" parent="Slicer/Node3D4" unique_id=894348025]
curve = SubResource("Curve3D_mxaon")
[node name="door3" parent="Slicer/Node3D4" unique_id=1024066398 instance=ExtResource("5_wk2t5")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -7.870017e-08, 0, -0.6001501)
[node name="Node3D5" type="Node3D" parent="Slicer" unique_id=1113082191]
transform = Transform3D(1, 0, -1.7484555e-07, 0, 1, 0, 1.7484555e-07, 0, 1, 0, 0, 0)
[node name="Path3D2" type="Path3D" parent="Slicer/Node3D5" unique_id=1352328131]
curve = SubResource("Curve3D_mxaon")
[node name="door4" parent="Slicer/Node3D5" unique_id=1411233670 instance=ExtResource("5_wk2t5")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -5.9604645e-08, 0, -0.3998499)
[node name="door5" parent="Slicer/Node3D5" unique_id=770270315 instance=ExtResource("5_wk2t5")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -5.9604645e-08, 0, -0.3998499)

View File

@@ -1,13 +1,9 @@
namespace ChickenGameTest;
using Chickensoft.GodotNodeInterfaces;
using Chickensoft.Introspection;
using Chickensoft.AutoInject;
using Godot;
using System;
using System.Collections.Generic;
using System.Linq;
using ChickenGameTest;
using SJK.Functional;
public interface IVoxelGridRegistry