本文整理汇总了Java中ethanjones.cubes.entity.Entity类的典型用法代码示例。如果您正苦于以下问题:Java Entity类的具体用法?Java Entity怎么用?Java Entity使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Entity类属于ethanjones.cubes.entity包,在下文中一共展示了Entity类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: tick
import ethanjones.cubes.entity.Entity; //导入依赖的package包/类
public void tick() {
updateLock.writeLock();
entities.lock.writeLock();
Iterator<Entry<UUID, Entity>> iterator = entities.entrySet().iterator();
while (iterator.hasNext()) {
Entry<UUID, Entity> entry = iterator.next();
if (entry.getValue().update()) {
entry.getValue().dispose();
UUID uuid = entry.getKey();
iterator.remove();
removeEntity(uuid);
}
}
time++;
if (time >= MAX_TIME)
time = 0;
entities.lock.writeUnlock();
updateLock.writeUnlock();
}
示例2: dispose
import ethanjones.cubes.entity.Entity; //导入依赖的package包/类
@Override
public void dispose() {
if (!disposed.compareAndSet(false, true))
return;
WorldTasks.waitSaveFinish();
Lock.lockAll(true, this, map, entities);
if (Side.isServer() || !Area.isShared()) {
for (Area area : map) {
area.unload();
}
}
map.empty();
for (Entity entity : entities.values()) {
entity.dispose();
}
entities.clear();
map.lock.writeUnlock();
entities.lock.writeUnlock();
updateLock.writeUnlock();
}
示例3: tick
import ethanjones.cubes.entity.Entity; //导入依赖的package包/类
public void tick() {
updateLock.writeLock();
entities.lock.writeLock();
Iterator<Entry<UUID, Entity>> iterator = entities.entrySet().iterator();
while (iterator.hasNext()) {
Entry<UUID, Entity> entry = iterator.next();
if (entry.getValue().update()) {
entry.getValue().dispose();
UUID uuid = entry.getKey();
iterator.remove();
removeEntity(uuid);
}
}
time++;
if (time >= MAX_TIME) time = 0;
entities.lock.writeUnlock();
updateLock.writeUnlock();
}
示例4: dispose
import ethanjones.cubes.entity.Entity; //导入依赖的package包/类
@Override
public void dispose() {
if (!disposed.compareAndSet(false, true)) return;
WorldTasks.waitSaveFinish();
Lock.lockAll(true, this, map, entities);
if (Side.isServer()|| !Area.isShared()) {
for (Area area : map) {
area.unload();
}
}
map.empty();
for (Entity entity : entities.values()) {
entity.dispose();
}
entities.clear();
map.lock.writeUnlock();
entities.lock.writeUnlock();
updateLock.writeUnlock();
}
示例5: addEntity
import ethanjones.cubes.entity.Entity; //导入依赖的package包/类
@Override
public void addEntity(Entity entity) {
entities.lock.writeLock();
super.addEntity(entity);
PacketEntityAdd packet = new PacketEntityAdd();
packet.entity = entity;
NetworkingManager.sendPacketToAllClients(packet);
entities.lock.writeUnlock();
}
示例6: getEntitiesForSave
import ethanjones.cubes.entity.Entity; //导入依赖的package包/类
public DataGroup[] getEntitiesForSave(int areaX, int areaZ) {
lock.readLock();
ArrayList<DataGroup> dataGroups = new ArrayList<DataGroup>();
for (Entity entity : values()) {
if (areaX == CoordinateConverter.area(entity.position.x)
&& areaZ == CoordinateConverter.area(entity.position.z) && !(entity instanceof Player)) {
dataGroups.add(entity.write());
}
}
DataGroup[] array = dataGroups.size() == 0 ? new DataGroup[0]
: dataGroups.toArray(new DataGroup[dataGroups.size()]);
lock.readUnlock();
return array;
}
示例7: removeEntity
import ethanjones.cubes.entity.Entity; //导入依赖的package包/类
public void removeEntity(UUID uuid) {
entities.lock.writeLock();
Entity remove = entities.remove(uuid);
if (remove != null)
remove.dispose();
entities.lock.writeUnlock();
}
示例8: updateEntity
import ethanjones.cubes.entity.Entity; //导入依赖的package包/类
public void updateEntity(DataGroup data) {
entities.lock.writeLock();
UUID uuid = (UUID) data.get("uuid");
Entity entity = entities.get(uuid);
if (entity != null) {
entity.read(data);
} else {
Log.warning("No entity with uuid " + uuid.toString());
addEntity(Entity.readType(data));
}
entities.lock.writeUnlock();
}
示例9: addEntityFromSave
import ethanjones.cubes.entity.Entity; //导入依赖的package包/类
public void addEntityFromSave(DataGroup dataGroup) {
entities.lock.writeLock();
Entity entity = Entity.readType(dataGroup);
if (entity != null && !entities.containsKey(entity.uuid)) {
addEntity(entity);
}
entities.lock.writeUnlock();
}
示例10: handlePacket
import ethanjones.cubes.entity.Entity; //导入依赖的package包/类
@Override
public void handlePacket() {
Entity entity = Cubes.getClient().world.getEntity(uuid);
if (entity instanceof Player) {
entity.angle.set(angle);
entity.position.set(position);
} else {
Log.warning("No player with uuid " + uuid.toString());
}
}
示例11: renderFor
import ethanjones.cubes.entity.Entity; //导入依赖的package包/类
private void renderFor(World world, float deltaTime) {
for (Entity entity : world.entities.values()) {
entity.updatePosition(deltaTime);
if (entity instanceof RenderableProvider)
modelBatch.render(((RenderableProvider) entity));
}
}
示例12: initialLoadAreas
import ethanjones.cubes.entity.Entity; //导入依赖的package包/类
private void initialLoadAreas() {
AreaReference check = new AreaReference();
synchronized (this) {
for (int areaX = playerArea.areaX - loadDistance; areaX <= playerArea.areaX + loadDistance; areaX++) {
check.areaX = areaX;
for (int areaZ = playerArea.areaZ - loadDistance; areaZ <= playerArea.areaZ + loadDistance; areaZ++) {
check.areaZ = areaZ;
check.modified();
Area area = server.world.getArea(check, false); // don't
// request
// individually,
// request
// in a
// batch
if (area != null && area.featuresGenerated())
sendArea(area);
}
}
WorldRequestParameter parameter = new WorldRequestParameter(playerArea.copy(), new Runnable() {
@Override
public void run() {
NetworkingManager.sendPacketToClient(new PacketInitialAreasLoaded(), client);
}
});
initialGenerationTask = server.world.requestRegion(new WorldRegion(playerArea, loadDistance), parameter);
PacketEntityAdd packet;
for (Entity entity : Cubes.getServer().world.entities.values()) {
if (positionInLoadRange(entity.position) && !(entity instanceof Player)) {
packet = new PacketEntityAdd();
packet.entity = entity;
NetworkingManager.sendPacketToClient(packet, client);
}
}
}
}
示例13: setPositionFor1
import ethanjones.cubes.entity.Entity; //导入依赖的package包/类
private void setPositionFor1(PacketEntityAdd packet) {
for (Entity entity : Cubes.getServer().world.entities.values()) {
if (!(entity instanceof Player) && newRegion.contains(entity.position)
&& !oldRegion.contains(entity.position)) {
packet = new PacketEntityAdd();
packet.entity = entity;
NetworkingManager.sendPacketToClient(packet, client);
}
}
}
示例14: addEntity
import ethanjones.cubes.entity.Entity; //导入依赖的package包/类
@Override
public void addEntity(Entity entity) {
entities.lock.writeLock();
super.addEntity(entity);
PacketEntityAdd packet = new PacketEntityAdd();
packet.entity = entity;
NetworkingManager.sendPacketToAllClients(packet);
entities.lock.writeUnlock();
}
示例15: syncEntity
import ethanjones.cubes.entity.Entity; //导入依赖的package包/类
@Override
public void syncEntity(UUID uuid) {
Entity entity = getEntity(uuid);
if (entity == null) return;
for (ClientIdentifier clientIdentifier : Cubes.getServer().getAllClients()) {
if (clientIdentifier.getPlayerManager().positionInLoadRange(entity.position)) {
PacketEntityUpdate packet = new PacketEntityUpdate();
packet.data = entity.write();
NetworkingManager.sendPacketToClient(packet, clientIdentifier);
}
}
}