当前位置: 首页>>代码示例>>Java>>正文


Java Component类代码示例

本文整理汇总了Java中com.artemis.Component的典型用法代码示例。如果您正苦于以下问题:Java Component类的具体用法?Java Component怎么用?Java Component使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Component类属于com.artemis包,在下文中一共展示了Component类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: openPackage

import com.artemis.Component; //导入依赖的package包/类
public Entity openPackage() {
	Entity e = EntityManager.createEntity();
	for (Component c : components) {
		if (c instanceof CSpriteName && !AppUtil.isServer) {
			String name = ((CSpriteName) c).name;
			if (SpriteLoader.isAnimated(name)) {
				e.addComponent(new CAnimatedRenderable(name));
			} else {
				e.addComponent(new CRenderable(name));
			}
		}
		e.addComponent(c);
	}
	for (int i = 0; i < tags.size(); i++) {
		EntityManager.tagEntity(e, tags.get(i));
	}
	return e;
}
 
开发者ID:Teascade,项目名称:Shadow-of-Goritur,代码行数:19,代码来源:EntityPackage.java

示例2: setup

import com.artemis.Component; //导入依赖的package包/类
/**
 * Setup tween between two component states.
 * <p/>
 * From/to states are not pool managed, and will be garbage collected.
 *
 * @param a             component a starting state.
 * @param b             component b starting state.
 * @param duration      duration of tween, in seconds.
 * @param interpolation method of interpolation.
 */
public <T extends Component & Tweenable<T>> void setup(T a, T b, Interpolation interpolation, float duration) {

	final Class<?> typeA = a.getClass();
	final Class<?> typeB = b.getClass();

	if (typeA != typeB) {
		throw new IllegalArgumentException("Can't tween between different types " + typeA + " and " + typeB + ".");
	}

	Preconditions.checkArgument(duration != 0, "Duration cannot be zero.");

	this.a = Preconditions.checkNotNull(a);
	this.b = Preconditions.checkNotNull(b);

	this.interpolation = Preconditions.checkNotNull(interpolation);
	this.duration = duration;
}
 
开发者ID:DaanVanYperen,项目名称:artemis-odb-contrib,代码行数:28,代码来源:UnpooledTweenOperation.java

示例3: EntityScheme

import com.artemis.Component; //导入依赖的package包/类
private EntityScheme (Entity entity, Cloner cloner, CloningPolicy cloningPolicy) {
	fillBag.clear();
	entity.getComponents(fillBag);
	components = new Array<>(fillBag.size());

	for (Component component : fillBag) {
		if (component == null) continue;
		if (component.getClass().isAnnotationPresent(Transient.class)) continue;
		if (cloningPolicy == CloningPolicy.SKIP_INVISIBLE && component instanceof Invisible) continue;

		if (component instanceof VisUUID) schemeUUID = ((VisUUID) component).getUUID();

		if (component instanceof UsesProtoComponent) {
			components.add(((UsesProtoComponent) component).toProtoComponent());
		} else {
			components.add(component);
		}
	}

	if (schemeUUID == null) throw new IllegalStateException("Missing VisUUID component in Entity");

	if (cloner != null) {
		components = cloner.deepClone(components);
	}
}
 
开发者ID:kotcrab,项目名称:vis-editor,代码行数:26,代码来源:EntityScheme.java

示例4: getSchemeUUID

import com.artemis.Component; //导入依赖的package包/类
/**
 * Returns this scheme UUID. Note that if scheme was deserlzied a UUID lookup on component will be performed first, if
 * there is no {@link VisUUID} component an exception will be thrown.
 * @throws IllegalStateException when VisUUID component is missing on deserialized instance
 */
public UUID getSchemeUUID () {
	if (schemeUUID == null) {
		for (Component component : components) {
			if (component instanceof VisUUID) {
				schemeUUID = ((VisUUID) component).getUUID();
				break;
			}
		}

		//uuid was not found
		if (schemeUUID == null) {
			throw new IllegalStateException("Missing VisUUID component in EntityScheme");
		}
	}

	return schemeUUID;
}
 
开发者ID:kotcrab,项目名称:vis-editor,代码行数:23,代码来源:EntityScheme.java

示例5: process

import com.artemis.Component; //导入依赖的package包/类
@Override
protected void process (Entity e) {
	fillBag.clear();
	e.getComponents(fillBag);

	for (Component component : fillBag) {
		if (component instanceof StoresAssetDescriptor) {
			StoresAssetDescriptor storage = (StoresAssetDescriptor) component;
			VisAssetDescriptor asset = storage.getAsset();

			if (asset != null && asset.compare(searchFor)) {
				ids.add(e.getId());
				return;
			}
		}
	}
}
 
开发者ID:kotcrab,项目名称:vis-editor,代码行数:18,代码来源:AssetsUsageAnalyzer.java

示例6: swapAssets

import com.artemis.Component; //导入依赖的package包/类
private void swapAssets (VisAssetDescriptor asset1, VisAssetDescriptor asset2) {
	for (FileHandle sceneFile : fileAccess.getSceneFiles()) {
		EditorScene scene = sceneCache.get(sceneFile);

		for (EntityScheme scheme : scene.getSchemes()) {
			for (Component component : scheme.getComponents()) {
				if (component instanceof AssetReference) {
					AssetReference assetRef = (AssetReference) component;
					if (assetRef.asset.compare(asset1)) {
						assetRef.asset = assetProvider.parametrize(asset2, assetRef.asset);
					}
				}
			}
		}
	}
}
 
开发者ID:kotcrab,项目名称:vis-editor,代码行数:17,代码来源:UpdateReferencesAction.java

示例7: addNativeComponent

import com.artemis.Component; //导入依赖的package包/类
public void addNativeComponent(Component component) {
	if(component == null){
		Gdx.app.error(getClass().getSimpleName(), "Try add null component for rapid");
		return;
	}
	nativeComponents.add(component);
}
 
开发者ID:Radomiej,项目名称:JavityEngine,代码行数:8,代码来源:NativeComponent.java

示例8: copyEntityFromOldWorld

import com.artemis.Component; //导入依赖的package包/类
/**
 * Copy entity from old world into the new one.
 *
 * This assumes the old world is no longer in use, and is potentially unsafe if it isn't. (The components are not cloned, just reused!)
 */
public static Entity copyEntityFromOldWorld( Entity old )
{
    Entity entity = Tox.world.createEntity();

    Bag<Component> fillBag = new Bag<Component>();

    old.getComponents(fillBag);
    for ( Component comp : fillBag )
    {
        entity.addComponent(comp);
    }

    return entity;
}
 
开发者ID:DaanVanYperen,项目名称:tox,代码行数:20,代码来源:EntityUtils.java

示例9: tickAction

import com.artemis.Component; //导入依赖的package包/类
@Override
public void tickAction(List<Component> listComponents) {
	super.tickAction(listComponents);
	
	Velocity vel = (Velocity) listComponents.get(0);
	
	vel.x = motion.x;
	vel.y = motion.y;
}
 
开发者ID:Corosauce,项目名称:AI_TestBed_v3,代码行数:10,代码来源:ActionRoutineDodge.java

示例10: tick

import com.artemis.Component; //导入依赖的package包/类
public void tick(List<Component> listComponents) {
	
	if (isActive()) {
		ticksCur--;
		tickAction(listComponents);
		
		if (!isActive()) {
			endRoutine();
		}
	} else {
		if (ticksCooldownCur > 0) {
			ticksCooldownCur--;
		}
	}
}
 
开发者ID:Corosauce,项目名称:AI_TestBed_v3,代码行数:16,代码来源:ActionRoutine.java

示例11: EntityDeleterSystem

import com.artemis.Component; //导入依赖的package包/类
public EntityDeleterSystem(long seed, int entityCount, Class<? extends Component> c1, Class<? extends Component> c2) {
	this.c1 = c1;
	this.c2 = c2;
	Random rng = new Random(seed);
	ENTITY_COUNT = entityCount;
	ids = new int[ENTITY_COUNT];
	for (int i = 0; ids.length > i; i++)
		ids[i] = (int)(rng.nextFloat() * ENTITY_COUNT);
}
 
开发者ID:junkdog,项目名称:entity-system-benchmarks,代码行数:10,代码来源:EntityDeleterSystem.java

示例12: initialize

import com.artemis.Component; //导入依赖的package包/类
@Override
public void initialize() {
	for (int i = 0; permutations.length > i; i++) {
		Array<Class<? extends Component>> components = new Array<Class<? extends Component>>();
		for (int classIndex = 0, s = (int)(rng.nextFloat() * 7) + 3; s > classIndex; classIndex++) {
			components.add(types.get((int)(rng.nextFloat() * types.size)));
		}
		permutations[i] = components;
	}
	
	for (int i = 0; ENTITY_COUNT > i; i++)
		createEntity();
}
 
开发者ID:junkdog,项目名称:entity-system-benchmarks,代码行数:14,代码来源:EntityManglerSystem.java

示例13: EntityManglerSystem

import com.artemis.Component; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public EntityManglerSystem(long seed, int entityCount) {
	// 4096 entities = 256 compositions, 262144 = 2048
	entityPermutations = (int)Math.sqrt(entityCount * 16);
	rng = new Random(seed);
	ENTITY_COUNT = entityCount;
	RENEW = ENTITY_COUNT / 4;

	ArrayList<Integer> idsList = new ArrayList<Integer>();
	for (int i = 0; ENTITY_COUNT > i; i++)
		idsList.add(i);
	Collections.shuffle(idsList);
	
	ids = new int[ENTITY_COUNT];
	for (int i = 0; ids.length > i; i++)
		ids[i] = idsList.get(i);

	types = new Bag<Class<? extends Component>>();
	types.add(Comp1.class);
	types.add(Comp2.class);
	types.add(Comp3.class);
	types.add(Comp4.class);
	types.add(Comp5.class);
	types.add(Comp6.class);
	types.add(Comp7.class);
	types.add(Comp8.class);
	types.add(Comp9.class);
	types.add(Comp10.class);
	types.add(Comp11.class);
	types.add(Comp12.class);

	permutations = new Bag[entityPermutations];

	cmp = new int[ENTITY_COUNT * 4];
	for (int i = 0; cmp.length > i; i++)
		cmp[i] = (int)(rng.nextFloat() * permutations.length);
}
 
开发者ID:junkdog,项目名称:entity-system-benchmarks,代码行数:38,代码来源:EntityManglerSystem.java

示例14: initialize

import com.artemis.Component; //导入依赖的package包/类
@Override
protected void initialize() {
	for (int i = 0; permutations.length > i; i++) {
		Bag<Class<? extends Component>> components = new Bag<Class<? extends Component>>();
		for (int classIndex = 0, s = (int)(rng.nextFloat() * 7) + 3; s > classIndex; classIndex++) {
			components.add(types.get((int)(rng.nextFloat() * types.size())));
		}
		permutations[i] = components;
	}
	
	for (int i = 0; ENTITY_COUNT > i; i++)
		createEntity();
}
 
开发者ID:junkdog,项目名称:entity-system-benchmarks,代码行数:14,代码来源:EntityManglerSystem.java

示例15: createEntity

import com.artemis.Component; //导入依赖的package包/类
@SuppressWarnings("unchecked")
private final void createEntity() {
	Entity e = world.createEntity();
	Bag<Class<? extends Component>> components = permutations[cmp[cmpIndex++]];
	if (cmpIndex == cmp.length) cmpIndex = 0;
	
	Object[] data = components.getData();
	for (int i = 0, s = components.size(); s > i; i++) {
		e.addComponent(newInstance(data[i]));
	}
	e.addToWorld();
}
 
开发者ID:junkdog,项目名称:entity-system-benchmarks,代码行数:13,代码来源:EntityManglerSystem.java


注:本文中的com.artemis.Component类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。