-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
RFC: Std I/O driven application (aka amethyst_commands
)
#13
Comments
Previous comments #995:
|
Thanks for opening the issue!
Ideally, the editor and the command crate would operate over the same
interface. We should try to get one interface that's useful for the editor,
the command crate, scripting, modding, etc. because otherwise this will get
very chaotic.
|
I was planning on having three frontends (or more) for the command stuff:
|
@Jojolepro "in-game ui"? You mean the one for editing, right? Independent of that, it should be generic enough so crates can register themselves instead of depending on all of them. |
amethyst_ui? :P |
By making a generic framework where anything can register their commands we also upon up for the user to have terminal commands added from the game logic. |
Transferring this to the RFC repo. |
Issue 999, this is gonna be epic!
Summary
Ability to control an Amethyst application using commands issued through stdin, with human-friendly terminal interaction.
Motivation
Inspecting and manipulating the state1 of an application at run time is a crucial part of development, with at least the following use cases:
A command terminal will greatly reduce the effort to carry out the aforementioned tasks.
1 state here means the runtime values, not
amethyst::State
Prior Art
Expand -- copied from #995 (warning: code heavy)
okay, so this post is code heavy, but it's how I've done commands in my game (youtube). It shouldn't force people to use the state machine, since event types are "plug in if you need it".
Crate:
stdio_view
(probably analogous toamethyst_commands
)stdin
strings, usesshell_words
to parse into separate tokens.AppEventVariant
to determine whichAppEvent
the tokens correspond to. On success, it sends a tuple:(AppEventVariant, Vec<String>)
(the tokens) to anEventChannel<(AppEventVariant, Vec<String>)>
.Changes if put into Amethyst:
StdinSystem
would be generic over top level typesE
andEVariant
, which would take inAppEvent
andAppEventVariant
.Crate:
application_event
Contains
AppEvent
andAppEventVariant
.AppEvent
is an enum over all custom event types,AppEventVariant
is derived fromAppEvent
, without the fields.Example:
This would be an application specific crate, so it wouldn't go into Amethyst. If I want to have
State
event control, this will include an additional variantState(StateEvent)
fromuse amethyst_state::StateEvent;
, whereStateEvent
carries the information of what to do (e.g.Pop
orSwitch
).Crate:
stdio_spi
StdinMapper
is a trait with the following associated types:Args
is aT: StructOpt
which we can convert theString
tokens from before we pass it to themap
function.Resource
is there because the constructedAppEvent
can contain fields that are constructed based on an ECS resource.This crate also provides a generic
MapperSystem
that reads fromEventChannel<(AppEventVariant, Vec<String>)>
from thestdio_view
crate. If the variant matches theAppEventVariant
this system is responsible for, it passes all of the tokens to aT: StdinMapper
that understands how to turn them into anAppEvent
, given theResource
.Crate:
character_selection_stdio
(or any other crate that supports stdin -> AppEvent)Implements the
stdio_spi
.The
Args
type:The
StdinMapper
type:The bundle, which adds a
MapperSystem<MapSelectionEventStdinMapper>
:Can use it as inspiration to drive the design, or I'm happy to push my code up for the reusable parts (
stdio_spi
should be usable as is,stdio_view
probably needs a re-write).Detailed Design
TODO: discuss
Alternatives
The
amethyst-editor
will let you do some of the above tasks (inspecting, manipulating entities and components). It doesn't cater for:The text was updated successfully, but these errors were encountered: