本文整理汇总了Java中com.badlogic.gdx.utils.ObjectSet类的典型用法代码示例。如果您正苦于以下问题:Java ObjectSet类的具体用法?Java ObjectSet怎么用?Java ObjectSet使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ObjectSet类属于com.badlogic.gdx.utils包,在下文中一共展示了ObjectSet类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: discover
import com.badlogic.gdx.utils.ObjectSet; //导入依赖的package包/类
@Override
public Array<Host> discover(){
addresses.clear();
List<InetAddress> list = client.discoverHosts(Vars.port, 3000);
ObjectSet<String> hostnames = new ObjectSet<>();
Array<Host> result = new Array<>();
for(InetAddress a : list){
if(!hostnames.contains(a.getHostName())) {
Host address = addresses.get(a);
if(address != null) result.add(address);
}
hostnames.add(a.getHostName());
}
return result;
}
示例2: add
import com.badlogic.gdx.utils.ObjectSet; //导入依赖的package包/类
/** Add a Batchable to the queue. */
public void add (T batchable) {
if (batchable.isOpaque()) {
for (ObjectMap.Entry<T, ObjectSet<T>> entry : opaqueBatchables) {
if (batchable.hasEquivalentTextures(entry.key)) {
entry.value.add((T)batchable);
return;
}
}
ObjectSet<T> set = objectSetPool.obtain();
set.add(batchable);
opaqueBatchables.put(batchable, set);
} else {
blendedBatchables.add(batchable);
}
needSort = true;
}
示例3: WorldObject
import com.badlogic.gdx.utils.ObjectSet; //导入依赖的package包/类
public WorldObject() {
this.id = nextId++;
this.destroyed = false;
this.boundingQueue = new ObjectSet<>();
this.def = new BodyDef();
this.persistent = false;
this.visible = true;
this.layer = 0;
this.def.active = true;
this.def.awake = true;
this.def.fixedRotation = true;
this.def.type = BodyType.DynamicBody;
this.groupId = -1;
this.canCollide = true;
this.events = new EventHelper(this);
}
示例4: WorldRoom
import com.badlogic.gdx.utils.ObjectSet; //导入依赖的package包/类
public WorldRoom(Tilemap map) {
this.destroyed = false;
this.prepared = false;
this.events = new EventHelper(this);
this.bodyQueue = new ObjectSet<>();
this.entrypointQueue = new ObjectSet<>();
this.tilemap = map;
this.controller = null;
this.obj = new ObjectSet<>();
this.entrypoints = new ObjectMap<>();
this.opacityMapping = new IntFloatMap();
this.collisionLayers = new ObjectMap<>();
this.renderOrder = new Array<>(true, 16);
this.disabledCollision = new ObjectSet<>();
}
示例5: setCollisionLayerState
import com.badlogic.gdx.utils.ObjectSet; //导入依赖的package包/类
/**
* Sets the state of a collision layer.
*
* @param layerName the name of the layer
* @param flag whether or not the layer is active
*/
public void setCollisionLayerState(String layerName, boolean flag) {
if (flag != this.getCollisionLayerState(layerName)) {
if (flag) {
this.disabledCollision.remove(layerName);
} else {
this.disabledCollision.add(layerName);
}
ObjectSet<Body> bodies = this.collisionLayers.get(layerName);
if (bodies != null) {
bodies.forEach(body -> {
body.setActive(flag);
});
}
}
}
示例6: showTileBackgrounds
import com.badlogic.gdx.utils.ObjectSet; //导入依赖的package包/类
private void showTileBackgrounds() {
ObjectSet<Grid2D.Coordinate> processed = new ObjectSet<Grid2D.Coordinate>();
final ArrayList<Grid2D.Coordinate> list = new ArrayList<Grid2D.Coordinate>(world.level.getCoordinates(tile));
Collections.sort(list, new Comparator<Grid2D.Coordinate>() {
@Override public int compare(Grid2D.Coordinate o1, Grid2D.Coordinate o2) {
return o2.y() - o1.y();
}
});
for (Grid2D.Coordinate coordinate : list) {
showTileBackground(processed, coordinate.x() - 1, coordinate.y());
showTileBackground(processed, coordinate.x() + 1, coordinate.y());
showTileBackground(processed, coordinate.x(), coordinate.y() - 1);
showTileBackground(processed, coordinate.x(), coordinate.y() + 1);
showTileBackground(processed, coordinate.x() + 1, coordinate.y() + 1);
showTileBackground(processed, coordinate.x() - 1, coordinate.y() + 1);
showTileBackground(processed, coordinate.x() + 1, coordinate.y() - 1);
showTileBackground(processed, coordinate.x() - 1, coordinate.y() - 1);
showTransitions(coordinate.x(), coordinate.y());
}
}
示例7: loadInvitations
import com.badlogic.gdx.utils.ObjectSet; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public void loadInvitations(InvitationBuffer invitations) {
ObjectSet<String> tmp = Pools.obtain(ObjectSet.class);
tmp.addAll(invites);
invites.clear();
for (Invitation invitation : invitations) {
invites.add(invitation.getInvitationId());
if (!tmp.contains(invitation.getInvitationId())) {
showInvitation(invitation);
}
}
tmp.clear();
Pools.free(tmp);
Gdx.app.postRunnable(new Runnable() {
@Override public void run() {
invitesDispatcher.setState(invites.size);
}
});
}
示例8: LocalSession
import com.badlogic.gdx.utils.ObjectSet; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public LocalSession(final LocalMultiplayer multiplayer, final String otherPlayerId) {
this.multiplayer = multiplayer;
this.otherPlayerId = otherPlayerId;
setVariant(Config.pvpModes.get("global-2").variant);
me = new IParticipant() {
@Override public String getDisplayedName() { return multiplayer.participantId; }
@Override public String getImageUrl() { return "https://pp.vk.me/c307401/v307401067/e8db/rg1r1GJ-dME.jpg"; }
@Override public String getId() { return multiplayer.participantId; }
@Override public String toString() { return getId(); }
};
other = new IParticipant() {
@Override public String getDisplayedName() { return otherPlayerId; }
@Override public String getImageUrl() { return "https://pp.vk.me/c620127/v620127169/11996/5TkNN6HNbPE.jpg"; }
@Override public String getId() { return otherPlayerId; }
@Override public String toString() { return getId(); }
};
others = ObjectSet.with(other);
all.put(me.getId(), me);
all.put(other.getId(), other);
disconnectFuture().addListener(new IFutureListener() {
@Override public void onHappened(Object o) {
multiplayer.sendToServer(ClientServerMessage.Type.endSession);
}
});
}
示例9: determineTextToDisplay
import com.badlogic.gdx.utils.ObjectSet; //导入依赖的package包/类
private void determineTextToDisplay(float delta, ObjectSet<GameLocation> locations) {
Array<String> texts = chatter != null ? chatter.getTexts(ChatterType.GENERAL, locations) : null;
if (texts == null || texts.size < 1) {
currentText = null;
return;
}
stateTime += delta;
if (stateTime < chatter.getCheckFrequency(ChatterType.GENERAL, locations)) {
return;
}
stateTime = 0;
if (MathUtils.random(100) > chatter.getChanceToSay(ChatterType.GENERAL, locations)) {
return;
}
setDrawnText(texts.random());
}
示例10: removeGameObject
import com.badlogic.gdx.utils.ObjectSet; //导入依赖的package包/类
/**
* Removes the supplied GameObject from this map.
*
* The GO will no longer be rendered.
*
* @param go
*/
public void removeGameObject(GameObject go) {
gameObjects.removeValue(go, false);
if (go instanceof Drawable) {
removeDrawable((Drawable)go);
}
if (go instanceof TextDrawer) {
textDrawers.removeValue((TextDrawer)go, false);
}
if (go instanceof TileBlocker) {
blockers.removeValue((TileBlocker)go, false);
}
if (gameObjectsByType.containsKey(go.getType())) {
gameObjectsByType.get(go.getType()).removeValue(go, false);
}
if (gameObjectsByClass.containsKey(go.getClass())) {
gameObjectsByClass.get(go.getClass()).removeValue(go, false);
}
if (gameObjectTileMap != null) {
for (ObjectSet<GameObject> objects : gameObjectTileMap) {
objects.remove(go);
}
}
}
示例11: TiledMapObject
import com.badlogic.gdx.utils.ObjectSet; //导入依赖的package包/类
public TiledMapObject(MapTileObjectGround ground, int[] objectTiles, GameMap map, Array<TiledMapTileLayer> layers,
boolean shouldDrawAsAWhole) {
this.ground = ground;
alreadySeenTiles = new ObjectSet<Tile>();
objectTilesVectors = new Array<Tile>();
for (int i = 0; i < objectTiles.length; i += 2) {
objectTilesVectors.add(new Tile(objectTiles[i],objectTiles[i+1]));
}
this.shouldDrawAsAWhole = shouldDrawAsAWhole;
this.map = map;
this.layers = new Array<TiledMapTileLayer>(layers);
this.position = new Position();
wasDiscovered = false;
isVisibleByPC = false;
fogColor = Color.toFloatBits(Configuration.getFogColor().r,
Configuration.getFogColor().g, Configuration.getFogColor().b,
1f);
visibleColor = Color.toFloatBits(1, 1, 1, 1f);
notVisibleColor = Color.toFloatBits(0f,0f,0f,1f);
calculateDimensions();
removeEmptyLayers();
}
示例12: init
import com.badlogic.gdx.utils.ObjectSet; //导入依赖的package包/类
private void init() {
// width and height of characters is always one, since they occupy only one tile
setWidth(1);
setHeight(1);
temporaryHostility = new ObjectMap<Faction, Pair<GameCalendarDate, Integer>>();
s_stateChangeDelay = -1;
s_newState = null;
s_noCircle = false;
s_sightDisabled = false;
visibleTilesLookupCounter = 1;
lights = new ObjectMap<LightDescriptor, Light>();
lightDescriptors = new Array<LightDescriptor>();
characterCircle = new CharacterCircle(this);
destinationIndicator = new CharacterCircle(this);
destinationIndicator.addAction(FadeAction.class, 0.5f, true, 0f, 0.5f);
visibleArea = new PositionArray();
viewConeArea = new PositionArray();
setPlayingAnimation(true);
tempSet = new ObjectSet<AbstractGameCharacter>();
tempPosition = new Position();
brain = createBrain();
}
示例13: LineOfSight
import com.badlogic.gdx.utils.ObjectSet; //导入依赖的package包/类
LineOfSight(RayHandler rayHandler, int rays,
int distance, float x, float y, GameMap map) {
start.x = x;
start.y = y;
sin = new float[rays];
cos = new float[rays];
endX = new float[rays];
endY = new float[rays];
visibleShapePolygons = new ObjectSet<Polygon>();
this.rayHandler = rayHandler;
setRayNum(rays);
this.distance = distance < 1 ? 1 : distance;
tileVertices = new TileSet((distance+1)*2);
this.map = map;
}
示例14: determineWitnesses
import com.badlogic.gdx.utils.ObjectSet; //导入依赖的package包/类
private void determineWitnesses() {
this.witnesses = new Array<GameCharacter>();
GameMap map = perpetrator.getMap();
if (map == null) {
return;
}
int radius = map.isWorldMap() ? Configuration.getSightRadiusWorld() : Configuration.getSightRadiusLocal();
// make the radius two tiles bigger to account for any rounding errors
radius += 2;
PositionArray circle = MathUtil.getCircle(perpetrator.position().tile().getX(), perpetrator.position().tile().getY(), radius, true);
ObjectSet<GameCharacter> potentialWitnesses = new ObjectSet<GameCharacter>();
map.getAllObjectsInArea(potentialWitnesses, circle, GameCharacter.class);
Faction victimFaction = getVictimFaction();
Faction perpFaction = perpetrator.getFaction();
for (GameObject go : potentialWitnesses) {
GameCharacter potentialWitness = (GameCharacter) go;
Faction witnessFaction = potentialWitness.getFaction();
if (!perpFaction.equals(witnessFaction) && !Faction.areHostile(witnessFaction, victimFaction) && potentialWitness.canSee(perpetrator)) {
witnesses.add(potentialWitness);
}
}
}
示例15: setBlockingPath
import com.badlogic.gdx.utils.ObjectSet; //导入依赖的package包/类
public void setBlockingPath(boolean blockingPath) {
s_blockingPath = blockingPath;
if (blockingPath) {
// any characters will be pushed back when a usable becomes impassable
ObjectSet<GameObject> chars = getMap().getAllGameObjectsAt(
0.5f + (int) position.getX(), 0.5f + (int) position.getY(), GameCharacter.class);
if (chars.size > 0) {
Vector2 offset = MathUtil.getVector2();
findFreeTile(s_orientation, offset);
for (GameObject character : chars) {
character.addAction(TweenToAction.class, offset.x, offset.y, 10f);
}
MathUtil.freeVector2(offset);
}
}
}