only register if not in lower dm
This commit is contained in:
parent
6301c01026
commit
d37a26eb70
2 changed files with 12 additions and 3 deletions
|
@ -139,6 +139,18 @@ func (d *DrawDAG) Update() error {
|
||||||
// DrawBoxers into internal data structures (the DAG, etc) unless they are
|
// DrawBoxers into internal data structures (the DAG, etc) unless they are
|
||||||
// descendants of a different DrawManager.
|
// descendants of a different DrawManager.
|
||||||
func (d *DrawDAG) Register(component, _ interface{}) error {
|
func (d *DrawDAG) Register(component, _ interface{}) error {
|
||||||
|
// *Don't* register the component if it is inside a descendant DrawManager.
|
||||||
|
// These queries work because component should be registered in game before
|
||||||
|
// this call.
|
||||||
|
for dm := range d.game.Query(d, DrawManagerType) {
|
||||||
|
if dm == d {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
dbs := d.game.Query(dm, DrawBoxerType)
|
||||||
|
if _, found := dbs[component]; found {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
}
|
||||||
if db, ok := component.(DrawBoxer); ok {
|
if db, ok := component.(DrawBoxer); ok {
|
||||||
d.registerOne(db)
|
d.registerOne(db)
|
||||||
}
|
}
|
||||||
|
|
|
@ -114,9 +114,6 @@ func (g *Game) Parent(c interface{}) interface{} {
|
||||||
// PathRegister calls Register on every Registrar in the path between g and
|
// PathRegister calls Register on every Registrar in the path between g and
|
||||||
// parent (top-to-bottom, i.e. g first)
|
// parent (top-to-bottom, i.e. g first)
|
||||||
func (g *Game) PathRegister(component, parent interface{}) error {
|
func (g *Game) PathRegister(component, parent interface{}) error {
|
||||||
// The only issue with this approach is... component gets registered in
|
|
||||||
// *every* drawmanager...
|
|
||||||
// TODO: Way of registering/unregistering from lowest DM only?
|
|
||||||
rp := g.ReversePath(parent)
|
rp := g.ReversePath(parent)
|
||||||
for i := len(rp) - 1; i >= 0; i-- {
|
for i := len(rp) - 1; i >= 0; i-- {
|
||||||
if r, ok := rp[i].(Registrar); ok {
|
if r, ok := rp[i].(Registrar); ok {
|
||||||
|
|
Loading…
Reference in a new issue