// Puts the passed entity in an empty position as close to pos as possible. // TODO: Current implementation doesn't try very hard at closeness ;) func (w *World) putInEmptyPos(ent *EntityDesc, pos *s3dm.V3) { old_pos := pos.Copy() for { if _, ok := w.ents[hashV3(pos)]; !ok { break // Empty, proceed } inc := &s3dm.V3{1, 1, 0} pos = pos.Add(inc) } w.setPos(ent, pos, nil) if !pos.Equals(old_pos) { // Update with new pos Send(w, ent.Chan, MsgSetState{Position{pos}}) } }