[update] Added Context struct for sjplayer.

This commit is contained in:
falsycat 2019-10-06 00:00:00 +00:00
parent 5722f65892
commit ecbed62b80
2 changed files with 46 additions and 3 deletions

View File

@ -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_;
}

View File

@ -4,15 +4,16 @@ module sjplayer;
import sjscript; import sjscript;
public { 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); return src.CreateScriptAst().CreateContextFromScriptAst(programs);
} }
/// ///
auto CreateContextFromScriptAst( Context CreateContextFromScriptAst(
ParametersBlock[] params, ElementProgramSet programs) { ParametersBlock[] params, ElementProgramSet programs) {
// TODO: // TODO:
assert(false); assert(false);