Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
public abstract class SystemsRxApplication
{
public ISystemExecutor SystemExecutor { get; }
public IEventSystem EventSystem { get; }
public IUpdateScheduler UpdateScheduler { get; }
protected EcsRxApplication()
{
// For sending events around
EventSystem = new EventSystem(new MessageBroker());
// Update scheduler for deciding when an *update* should happen
UpdateScheduler = new DefaultUpdateScheduler(); // 60 fps default
// All system handlers for the system types you want to support
var manualSystemHandler = new ManualSystemHandler(UpdateScheduler);
var basicSystemHandler = new BasicSystemHandler();
var reactToEventSystemHandler = new ReactToEventSystemHandler(EventSystem);
var conventionalSystems = new List<IConventionalSystemHandler>
{
manualSystemHandler,
basicSystemHandler,
reactToEventSystemHandler
};
// The main executor which manages how systems are given information
SystemExecutor = new SystemExecutor(conventionalSystems);
}
public abstract void StartApplication();
}public class HelloWorldExampleApplication : EcsRxApplication
{
public override void StartApplication()
{
SystemExecutor.AddSystem(new SomeSystemHere());
}
}IDependencyRegistry and IDependencyResolverIDependencyRegistry FeaturesBind<From, To>, Bind<T>, Unbind<T>LoadModule<T>, LoadModule(IDependencyModule)boolstringobjectFunc<IDependencyContainer, object>IDependencyResolver FeaturesResolve<T>, ResolveAll<T>dependencyRegistry.Bind<IEventSystem, EventSystem>(new BindingConfiguration{AsSingleton = true});var someInstance = new Something(foo, bar);
dependencyRegistry.Bind<ISomething>(new BindingConfiguration{ToInstance = someInstance});var bindingConfiguration = new BindingConfiguration({
ToMethod: container =>
{
var foo = container.Resolve<Foo>();
return new Something(foo, "woop woop");
});
});
dependencyRegistry.Bind<ISomething>(bindingConfiguration);dependencyRegistry.Bind<ISomething>(config => config
.AsSingleton()
.WithName("something-1")
});// With instance
dependencyRegistry.Bind<ISomething>(config => config
.ToInstance(new InstanceOfISomething())
});
// Wouldnt work, incorrect type
dependencyRegistry.Bind<ISomething>(config => config
.ToInstance(new InstanceOfISomethingElse()) // error, not ISomething
});
// With method
dependencyRegistry.Bind<ISomething>(config => config
.ToMethod(dependencyResolver =>
{
var foo = dependencyResolver.Resolve<Foo>();
return new Something(foo, "woop woop");
})
});public abstract class SystemsRxConsoleApplication : SystemsRxApplication
{
public override IDependencyContainer Container { get; } = new NinjectDependencyContainer();
protected override void LoadPlugins()
{
// Register the plugins we want to use
RegisterPlugin(new ComputedsPlugin());
}
protected override void StartSystems()
{
this.StartAllBoundSystems();
}
}public class ReactiveSystemsPlugin : ISystemsRxPlugin
{
public string Name => "Reactive Systems";
public Version Version { get; } = new Version("1.0.0");
public void SetupDependencies(IDependencyContainer container)
{
container.Bind<IConventionalSystemHandler, ReactToEntitySystemHandler>();
container.Bind<IConventionalSystemHandler, ReactToGroupSystemHandler>();
container.Bind<IConventionalSystemHandler, ReactToDataSystemHandler>();
container.Bind<IConventionalSystemHandler, SetupSystemHandler>();
container.Bind<IConventionalSystemHandler, TeardownSystemHandler>();
}
public IEnumerable<ISystem> GetSystemsForRegistration(IDependencyContainer container) => Array.Empty<ISystem>();
}IComputed<T> (For computed single values)IComputedCollection<T> (For computed collections of data)ComputedFromDataIComputedCollection scenario)IComputed scenario)var firstPlaceRacer = new ComputedFirstPlace(collectionOfRacers); // inherits from ComputedFromData<Racer, IEnumerable<Racer>>
RacerHud.CurrentWinner.Text = firstPlaceRacer.Value.Name;