Skip to content

Commit

Permalink
Less strict function to Add object to Objects collection
Browse files Browse the repository at this point in the history
  • Loading branch information
lkarlslund committed Oct 30, 2022
1 parent 89a1210 commit 64731ac
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions modules/engine/objects.go
Original file line number Diff line number Diff line change
Expand Up @@ -392,6 +392,19 @@ func (os *Objects) add(o *Object) {
os.typecount[o.Type()]++
}

func (os *Objects) AddRelaxed(o *Object) {
if o.id == 0 {
panic("Objects must have a unique ID")
}

if _, found := os.objects.LoadOrStore(o.ID(), o); !found {
if os.DefaultValues != nil {
o.setFlex(os.DefaultValues...)
}
os.ReindexObject(o, true)
}
}

// First object added is the root object
func (os *Objects) Root() *Object {
return os.root
Expand Down

0 comments on commit 64731ac

Please sign in to comment.