本文整理汇总了Java中com.badlogic.ashley.core.Family类的典型用法代码示例。如果您正苦于以下问题:Java Family类的具体用法?Java Family怎么用?Java Family使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Family类属于com.badlogic.ashley.core包,在下文中一共展示了Family类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: applyEffect
import com.badlogic.ashley.core.Family; //导入依赖的package包/类
@Override
protected void
applyEffect(PooledEngine engine, Entity entity, EffectComponent effectComponent) {
damageComponent = damageMapper.get(entity);
if (damageComponent != null) {
damageComponent.ignoredEntities = null;
} else {
damageComponent = engine.createComponent(DamageComponent.class);
entity.add(damageComponent);
}
healthComponent = healthMapper.get(entity);
if (healthComponent == null) {
healthComponent = engine.createComponent(HealthComponent.class);
entity.add(healthComponent);
}
oldHealthIgnore = healthComponent.ignoredEntities;
healthComponent.ignoredEntities = Family.one(ObstacleClass.class, BulletClass.class).get();
}
示例2: PathFindingSystem
import com.badlogic.ashley.core.Family; //导入依赖的package包/类
public PathFindingSystem(int mapHeight, int mapWidth, TiledMap tiledMap) {
super(Family.all(PathComponent.class, TransformComponent.class).get());
this.mapHeight = mapHeight;
this.mapWidth = mapWidth;
map = new TileType[mapWidth][mapHeight];
TiledMapTileLayer path = (TiledMapTileLayer) tiledMap.getLayers().get("Path");
TiledMapTileLayer rocks = (TiledMapTileLayer) tiledMap.getLayers().get("Rocks");
TiledMapTileLayer bushes = (TiledMapTileLayer) tiledMap.getLayers().get("Bushes");
for (int x = 0; x < map.length; x++) {
for (int y = 0; y < map[x].length; y++) {
if (path.getCell(x, y) != null) {
map[x][y] = TileType.FLOOR;
} else if (rocks.getCell(x, y) != null || bushes.getCell(x, y) != null) {
map[x][y] = TileType.WALL;
} else {
map[x][y] = TileType.EMPTY;
}
}
}
}
示例3: intervalSystem
import com.badlogic.ashley.core.Family; //导入依赖的package包/类
@Test
public void intervalSystem () {
Engine engine = new Engine();
IntervalIteratingSystemSpy intervalSystemSpy = new IntervalIteratingSystemSpy();
ImmutableArray<Entity> entities = engine.getEntitiesFor(Family.all(IntervalComponentSpy.class).get());
ComponentMapper<IntervalComponentSpy> im = ComponentMapper.getFor(IntervalComponentSpy.class);
engine.addSystem(intervalSystemSpy);
for (int i = 0; i < 10; ++i) {
Entity entity = new Entity();
entity.add(new IntervalComponentSpy());
engine.addEntity(entity);
}
for (int i = 1; i <= 10; ++i) {
engine.update(deltaTime);
for (int j = 0; j < entities.size(); ++j) {
assertEquals(i / 2, im.get(entities.get(j)).numUpdates);
}
}
}
示例4: RenderingSystem
import com.badlogic.ashley.core.Family; //导入依赖的package包/类
public RenderingSystem(SpriteBatch batch) {
super(Family.all(TransformComponent.class, TextureComponent.class).get());
textureM = ComponentMapper.getFor(TextureComponent.class);
transformM = ComponentMapper.getFor(TransformComponent.class);
renderQueue = new Array<Entity>();
comparator = new Comparator<Entity>() {
@Override
public int compare(Entity entityA, Entity entityB) {
return (int) Math.signum(transformM.get(entityB).pos.z -
transformM.get(entityA).pos.z);
}
};
this.batch = batch;
cam = new OrthographicCamera(FRUSTUM_WIDTH, FRUSTUM_HEIGHT);
cam.position.set(FRUSTUM_WIDTH / 2, FRUSTUM_HEIGHT / 2, 0);
}
示例5: AttackSystem
import com.badlogic.ashley.core.Family; //导入依赖的package包/类
public AttackSystem(World world,
Categories categories,
CollisionHandler handler) {
super(Family.all(
AttackComponent.class,
SpineComponent.class
).get());
logger.info("initialize");
this.world = world;
this.categories = categories;
this.handler = handler;
AssetManager manager = Env.getGame().getAssetManager();
laserSfx = manager.get(Env.SFX_FOLDER + "/laser.ogg", Sound.class);
}
示例6: SensorSystem
import com.badlogic.ashley.core.Family; //导入依赖的package包/类
public SensorSystem(PhysicsSystem physicsSystem)
{
super(Family.all(PhysicsComponent.class, SensorComponent.class).get());
this.physicsSystem = physicsSystem;
Categories categories = physicsSystem.getCategories();
physicsSystem.getHandler().add(
categories.getBits("sensor"),
categories.getBits("player"),
new SensorPlayerContactListener()
);
physicsSystem.getHandler().add(
categories.getBits("sensor"),
categories.getBits("box"),
new SensorBoxContactListener()
);
}
示例7: CCTvSystem
import com.badlogic.ashley.core.Family; //导入依赖的package包/类
public CCTvSystem(VisionSystem visionSystem, Tags tags) {
super(Family.all(
CCTvComponent.class,
TransformComponent.class,
AnimationControlComponent.class
).get());
logger.info("initialize");
this.visionSystem = visionSystem;
this.tags = tags;
this.cctvTags = new CCTVTags();
AssetManager manager = Env.getGame().getAssetManager();
foundSfx = manager.get(Env.SFX_FOLDER + "/found.ogg");
alarmSfx = manager.get(Env.SFX_FOLDER + "/alarm.ogg");
}
示例8: clearTarget
import com.badlogic.ashley.core.Family; //导入依赖的package包/类
public static void clearTarget (Entity target) {
ImmutableArray<Entity> entities = engine.getEntitiesFor(Family.all(TargetComponent.class).get());
for (Entity entity : entities) {
TargetComponent targetComp = Components.TARGET.get(entity);
if (targetComp.getTarget() == target) {
targetComp.setTarget(null);
//Dispatch a message to the entites FSM that there target was removed from the engine
if (Components.FSM.has(entity)) {
FSMComponent fsm = Components.FSM.get(entity);
MessageManager.getInstance().dispatchMessage(null, fsm, TelegramMessage.TARGET_REMOVED.ordinal(), target);
}
}
}
}
示例9: EntityRenderSystem
import com.badlogic.ashley.core.Family; //导入依赖的package包/类
public EntityRenderSystem () {
super(Family.one(SpriteComponent.class, SquadComponent.class).get(), new Comparator<Entity>() {
@Override
public int compare (Entity e1, Entity e2) {
if (Components.PARALAX.has(e1) && Components.PARALAX.has(e2)) {
ParalaxComponent p1 = Components.PARALAX.get(e1);
ParalaxComponent p2 = Components.PARALAX.get(e2);
return p1.layer < p2.layer ? 1 : 0;
} else if (Components.PARALAX.has(e1) || Components.PARALAX.has(e2)) {
return Components.PARALAX.has(e1) ? -1 : 1;
} else {
return 0;
}
}
});
batch = new SpriteBatch();
shapeRenderer = new ShapeRenderer();
}
示例10: clearTarget
import com.badlogic.ashley.core.Family; //导入依赖的package包/类
public void clearTarget (Entity target) {
ImmutableArray<Entity> entities = engine.getEntitiesFor(Family.all(TargetComponent.class, SquadComponent.class).get());
for (Entity squad : entities) {
SquadComponent squadComp = Components.SQUAD.get(squad);
squadComp.untrack(squad, target); //The squad no longer will track the target
TargetComponent targetComp = Components.TARGET.get(squad);
//If we were targeting that squad we remove it from our target
if (targetComp.getTarget() == target) {
targetComp.setTarget(null);
//Dispatch a message to the entites FSM that there target was removed from the engine
if (Components.FSM.has(squad)) {
FSMComponent fsm = Components.FSM.get(squad);
MessageManager.getInstance().dispatchMessage(null, fsm, TelegramMessage.TARGET_REMOVED.ordinal(), target);
}
}
}
}
示例11: printUserData
import com.badlogic.ashley.core.Family; //导入依赖的package包/类
public void printUserData() {
Family market = Family.all(MarketItemComponent.class, PriceComponent.class, NameComponent.class, PriceHistoryComponent.class).get();
ImmutableArray<Entity> marketItemEntities = entityEngine.getEntitiesFor(market);
Family players = Family.all(WalletComponent.class, NameComponent.class, InventoryComponent.class).get();
for (Entity player : entityEngine.getEntitiesFor(players)) {
NameComponent nc = player.getComponent(NameComponent.class);
WalletComponent wc = player.getComponent(WalletComponent.class);
InventoryComponent ic = player.getComponent(InventoryComponent.class);
System.out.println("Name: " + nc.name);
ic.printInventory(marketItemEntities);
long value = ic.getInventoryValue(marketItemEntities);
System.out.println("Inventory Value: $" + value);
System.out.println(" Wallet Balance: $" + wc.balance);
System.out.println(" Total Value: $" + (value + wc.balance));
}
}
示例12: printMarketHistory
import com.badlogic.ashley.core.Family; //导入依赖的package包/类
public void printMarketHistory() {
Family market = Family.all(MarketItemComponent.class, PriceComponent.class, NameComponent.class, PriceHistoryComponent.class).get();
ImmutableArray<Entity> entities = entityEngine.getEntitiesFor(market);
System.out.println("Current Prices: ");
for (Entity e : entities) {
PriceComponent p = e.getComponent(PriceComponent.class);
NameComponent n = e.getComponent(NameComponent.class);
PriceHistoryComponent history = e.getComponent(PriceHistoryComponent.class);
Iterator itr;
System.out.print(n.name + " Resolution 1 \n");
itr = history.getPriceHistory().iterator();
while (itr.hasNext()) System.out.print((Integer) itr.next() + "\n");
System.out.print(n.name + " Resolution 5\n");
itr = history.getPriceHistorySkipFive().iterator();
while (itr.hasNext()) System.out.print((Integer) itr.next() + "\n");
System.out.print(n.name + " Resolution 15\n");
itr = history.getPriceHistorySkipFifteen().iterator();
while (itr.hasNext()) System.out.print((Integer) itr.next() + "\n");
}
}
示例13: DebugUISystem
import com.badlogic.ashley.core.Family; //导入依赖的package包/类
public DebugUISystem(OrthographicCamera camera, SpriteBatch spriteBatch, ShapeRenderer shapeRenderer) {
super(Family.all(TransformComponent.class).get());
cam = camera;
batch = spriteBatch;
shape = shapeRenderer;
fontSmall = FontFactory.createFont(FontFactory.fontBitstreamVM, 10);
fontLarge = FontFactory.createFont(FontFactory.fontBitstreamVMBold, 20);
objects = new Array<Entity>();
boolean showInfo = false;
if (showInfo) {
System.out.println("\n------- sys info -------");
System.getProperties().list(System.out);
System.out.println("-------------------------\n");
/*
System.out.println(String.format("%s %s", Gdx.graphics.getPpiX(), Gdx.graphics.getPpiY()));
for (DisplayMode mode : Gdx.graphics.getDisplayModes()) {
System.out.println(String.format("%s %s %s %s", mode.width, mode.height, mode.bitsPerPixel, mode.refreshRate));
}
System.out.println("-------------------------\n");
*/
}
}
示例14: update
import com.badlogic.ashley.core.Family; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Override
public void update(float deltaTime) {
GameEngine engine = App.engine;
ComponentMappers maps = engine.mappers;
for (DropOffPoint point : points){
for (Entity e : engine.getEntitiesFor(Family.all(Collector.class).get())){
Collector c = maps.collector.get(e);
PhysicsComponent phys = maps.physics.get(e);
if (phys.getPosition().dst(point.position) < point.range){
totalCivsReturned += c.civilians;
c.civilians = 0;
}
}
}
}
示例15: processEntity
import com.badlogic.ashley.core.Family; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Override
protected void processEntity(Entity entity, float deltaTime) {
ComponentMappers maps =App.engine.mappers;
PhysicsComponent physics = maps.physics.get(entity);
Collector collector = maps.collector.get(entity);
for (Entity e : App.engine.getEntitiesFor(Family.all(Collectable.class).get())){
Collectable c = maps.collectable.get(e);
PhysicsComponent p = maps.physics.get(e);
if (c!= null && p != null){
if (p.getPosition().sub(physics.getPosition()).len() < c.pickupRange){
if (c.type == Collectable.ItemType.Civilian && collector.civilians < collector.maxCivilians) {
collector.civilians += 1;
App.engine.removeEntity(p.ownerEntity);
}
}
}
}
}