Added Arch Persitance and Relationships, styackable items, hot fixed Tags.containsAll. AutoList in Ordered!DList
This commit is contained in:
50
src/Api/IFoodFactoryApi.cs
Normal file
50
src/Api/IFoodFactoryApi.cs
Normal file
@@ -0,0 +1,50 @@
|
||||
namespace FoodFactory;
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using FoodFactory.Conveyors;
|
||||
using FoodFactory.Recipes;
|
||||
using FoodFactory.Voxel;
|
||||
|
||||
public interface IFoodFactoryApi
|
||||
{
|
||||
T? GetApi<T>() where T : class;
|
||||
IRecipes Recipes { get; }
|
||||
IBlueprintManger BlueprintManger { get; }
|
||||
ITickManger TickManger { get; }
|
||||
IItemRenderer ItemRenderer { get; }
|
||||
IVoxelGridRegistry GridRegistry { get; }
|
||||
}
|
||||
public interface ITickManger
|
||||
{
|
||||
delegate void Tick(TickArgs args);
|
||||
event Tick GameTick;
|
||||
}
|
||||
public record struct TickArgs(int Tick, double Delta);
|
||||
public class TickManger : ITickManger
|
||||
{
|
||||
public event ITickManger.Tick? GameTick;
|
||||
public void BroadCast(TickArgs args) => GameTick?.Invoke(args);
|
||||
}
|
||||
public class FoodFactoryApi : IFoodFactoryApi
|
||||
{
|
||||
public required IRecipes Recipes { get; set; }
|
||||
|
||||
public required IBlueprintManger BlueprintManger { get; set; }
|
||||
|
||||
public required ITickManger TickManger { get; set; }
|
||||
|
||||
public required IItemRenderer ItemRenderer { get; set; }
|
||||
|
||||
public required IVoxelGridRegistry GridRegistry { get; set; }
|
||||
|
||||
private readonly Dictionary<Type, object> _otherApi = [];
|
||||
public T? GetApi<T>() where T : class
|
||||
{
|
||||
if (_otherApi.TryGetValue(typeof(T), out var api))
|
||||
{
|
||||
return api as T;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user