diff --git a/sjplayer/src/sjplayer/Context.d b/sjplayer/src/sjplayer/Context.d new file mode 100644 index 0000000..7e4620f --- /dev/null +++ b/sjplayer/src/sjplayer/Context.d @@ -0,0 +1,42 @@ +/// License: MIT +module sjplayer.Context; + +import std.algorithm; + +import sjplayer.ElementInterface, + sjplayer.ScheduledControllerInterface; + +/// +struct Context { + public: + @disable this(); + @disable this(this); + + /// + ~this() { + controllers_.each!destroy; + drawers_.each!destroy; + elements_.each!destroy; + } + + /// + ElementInterface.DamageCalculationResult CalculateDamage() const { + assert(false); // TODO: + } + + /// + void DrawElements() { + drawers_.each!(x => x.Draw()); + } + /// + void OperateScheduledControllers(float time) { + controllers_.each!(x => x.Operate(time)); + } + + private: + ElementInterface[] elements_; + + ElementDrawerInterface[] drawers_; + + ScheduledControllerInterface[] controllers_; +} diff --git a/sjplayer/src/sjplayer/package.d b/sjplayer/src/sjplayer/package.d index 3264cb2..5a2cbf1 100644 --- a/sjplayer/src/sjplayer/package.d +++ b/sjplayer/src/sjplayer/package.d @@ -4,15 +4,16 @@ module sjplayer; import sjscript; public { - import sjplayer.ElementProgramSet; + import sjplayer.Context, + sjplayer.ElementProgramSet; } /// -auto CreateContextFromText(string src, ElementProgramSet programs) { +Context CreateContextFromText(string src, ElementProgramSet programs) { return src.CreateScriptAst().CreateContextFromScriptAst(programs); } /// -auto CreateContextFromScriptAst( +Context CreateContextFromScriptAst( ParametersBlock[] params, ElementProgramSet programs) { // TODO: assert(false);