本文整理汇总了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;
}
示例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;
}
示例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);
}
}
示例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;
}
示例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;
}
}
}
}
示例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);
}
}
}
}
}
}
示例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);
}
示例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;
}
示例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;
}
示例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--;
}
}
}
示例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);
}
示例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();
}
示例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);
}
示例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();
}
示例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();
}