Esempio n. 1
0
func (self *Region) GetEvent(evt_type events.EventType, body string, origin entities.Entity) *events.Event {
	str_origin := ""
	if origin != nil {
		str_origin = origin.ID()
	}

	return &events.Event{self.ID(), evt_type, str_origin, body}
}
Esempio n. 2
0
func (self *Region) RemoveEntity(entity entities.Entity) {
	// Tell everyone else that the entity is leaving.
	self.Broadcast(self.GetEvent(events.REGION_EXIT, entity.ID(), entity))

	// Find the entity
	location := -1
	for i, e := range self.entities {
		if *e == entity {
			location = i
			break
		}
	}

	if location == -1 {
		log.Println("Could not find entity to remove!")
		return
	}

	// ...and remove it
	self.entities = append(self.entities[:location], self.entities[location+1:]...)

}