/** Creates a new actor sprite. */ public ActorSprite(TudeyContext ctx, TudeySceneView view, int timestamp, Actor actor) { super(ctx, view); // create the advancer if the actor is client-controlled; otherwise, the history _actor = (Actor) actor.clone(); if ((_advancer = _actor.maybeCreateAdvancer(ctx, view, timestamp)) == null) { _history = new ActorHistory(timestamp, actor, view.getBufferDelay() * 4); } // create the model and the shape _model = new Model(ctx); _model.setUserObject(this); _attachedModels = Maps.newHashMap(); _attachedModels.put(_model, true); _shape = new ShapeElement(_actor.getOriginal().getShape(ctx.getConfigManager())); _shape.setUserObject(this); // register as tick participant _view.addTickParticipant(this); // if the actor is created, add it immediately updateActor(); if (isCreated()) { _view.getScene().add(_model); _view.getActorSpace().add(_shape); _model.tick(0f); update(); if (timestamp == _actor.getCreated()) { _impl.wasCreated(); } } else { _impl = null; // signifies that the actor has not yet been created } }
@Override public GlobalSprite.Implementation getSpriteImplementation( TudeyContext ctx, Scope scope, GlobalSprite.Implementation impl) { SceneGlobalConfig config = ctx.getConfigManager().getConfig(SceneGlobalConfig.class, sceneGlobal); return (config == null) ? null : config.getSpriteImplementation(ctx, scope, impl); }