Exemplo n.º 1
0
func (chunk *Chunk) removeEntity(s gamerules.INonPlayerEntity) {
	e := s.GetEntityId()
	chunk.shard.entityMgr.RemoveEntityById(e)
	delete(chunk.entities, e)
	// Tell all subscribers that the spawn's entity is destroyed.
	buf := new(bytes.Buffer)
	proto.WriteEntityDestroy(buf, e)
	chunk.reqMulticastPlayers(-1, buf.Bytes())

	chunk.storeDirty = true
}
Exemplo n.º 2
0
// AddEntity creates a mob or item in this chunk and notifies all chunk
// subscribers of the new entity
func (chunk *Chunk) AddEntity(s gamerules.INonPlayerEntity) {
	newEntityId := chunk.shard.entityMgr.NewEntity()
	s.SetEntityId(newEntityId)
	chunk.entities[newEntityId] = s

	// Spawn new item/mob for players.
	buf := &bytes.Buffer{}
	s.SendSpawn(buf)
	chunk.reqMulticastPlayers(-1, buf.Bytes())

	chunk.storeDirty = true
}
Exemplo n.º 3
0
// Tells the chunk to take posession of the item/mob from another chunk.
func (chunk *Chunk) transferEntity(s gamerules.INonPlayerEntity) {
	chunk.entities[s.GetEntityId()] = s
	chunk.storeDirty = true
}