oakmound / oak

A pure Go game engine
Apache License 2.0
1.52k stars 84 forks source link

scene: Embed Eventhandler to allow for some embedded calls #197

Closed Implausiblyfun closed 2 years ago

Implausiblyfun commented 2 years ago

Not sold on this but its the only shortening of methods that seems even slightly reasonable. Unfortunately creating helper functions around the context with it still working on the generic functions doesnt work and the embedded interface doesnt allow for this to be passwed as an eventhandler to binds. So definitely not ideal and we refer to it as ctx.Handler rather than ctx.EventHandler which while shorter seems less descriptive.

The bonus of course is signature for callermap interactions so one can call things like ctx.Register(entity)

Thoughts?

200sc commented 2 years ago

If we rename CallerMap.Reset to Clear, then a Context satisfies the property of having no ambiguous method names in its embedded types, so you can then do event.Bind(ctx, ...

Implausiblyfun commented 2 years ago

Ah nice I guess I didnt dig deep enough on it. This now definitely feels worth it. Shall we merge this into the events branch?