@Test public void testHashcodeAndEquals() { Bits b1 = new Bits(); Bits b2 = new Bits(); b1.set(1); b2.set(1); assertEquals(b1.hashCode(), b2.hashCode()); assertTrue(b1.equals(b2)); // temporarily setting/clearing a single bit causing // the backing array to grow b2.set(420); b2.clear(420); assertEquals(b1.hashCode(), b2.hashCode()); assertTrue(b1.equals(b2)); b1.set(810); b1.clear(810); assertEquals(b1.hashCode(), b2.hashCode()); assertTrue(b1.equals(b2)); }
/** * Adds the given render groups to the given Bits mask * * @param rgmask * The bit mask * @param rgs * The render groups * @return The bits instance */ public static Bits add(Bits rgmask, RenderGroup... rgs) { for (RenderGroup rg : rgs) { rgmask.set(rg.index); } return rgmask; }
/** * Returns a filter where an entity must possess all of the specified component types. * @param type a required component type * @param types a required component type * @return a filter that can be matched against entities */ public Filter all(Class<? extends Component> type, Class<? extends Component>... types) { allSet.set(ComponentManager.getComponentClassIndex(type)); for (Class<? extends Component> t : types) { allSet.set(ComponentManager.getComponentClassIndex(t)); } return this; }
/** * Returns a filter where an entity must possess one of the specified component types. * @param type one of the types the entity must possess * @param types one of the types the entity must possess * @return a filter that can be matched against entities */ public Filter any(Class<? extends Component> type, Class<? extends Component>... types) { anySet.set(ComponentManager.getComponentClassIndex(type)); for (Class<? extends Component> t : types) { anySet.set(ComponentManager.getComponentClassIndex(t)); } return this; }
private void setFromObject(BlenderObject object) { this.name = object.name; this.position = object.position; this.rotation = object.rotation; this.scale = object.scale; this.visibleOnLayers = new Bits(); for (int i = 0; i < object.layers.length; i++) { if (object.layers[i]) { this.visibleOnLayers.set(i); } } } @Override
/** * Excludes all of the specified component types from the filter. A system will not be * interested in an entity that possesses one of the specified exclusion component types. * * @param type component type to exclude * @param types component type to exclude * @return a filter that can be matched against entities */ public Filter exclude(Class<? extends Component> type, Class<? extends Component>... types) { exclusionSet.set(ComponentManager.getComponentClassIndex(type)); for (Class<? extends Component> t : types) { exclusionSet.set(ComponentManager.getComponentClassIndex(t)); } return this; }
/** * Finds the current triangle and sets the model to be visible on the same layer as mesh part index of current triangle * @param scene the game scene */ public void updateSteerableData(GameScene scene) { visibleOnLayers.clear(); visibleOnLayers.set(getCurrentTriangle(scene).meshPartIndex); }
/** * Make a ray test at this point, using a ray spanning from far up in the sky, to far down in the ground. * * @param testPoint The test point * @param out The point of intersection between ray and triangle * @param meshPartIndex Which mesh parts to test. * @return The triangle, or null if ray did not hit any triangles. */ public Triangle verticalRayTest(Vector3 testPoint, Vector3 out, int meshPartIndex) { tmpBitsVerticalRayTest.clear(); tmpBitsVerticalRayTest.set(meshPartIndex); return verticalRayTest(testPoint, out, tmpBitsVerticalRayTest); }
/** * Get a random triangle anywhere on the navigation mesh. * The probability distribution is even in world space, as opposed to triangle index, * meaning large triangles will be chosen more often than small ones. */ public Triangle getRandomTriangle() { tmpBitsGetRandomTriangle.clear(); for (int i = 0; i < graph.getMeshPartCount(); i++) { tmpBitsGetRandomTriangle.set(i); } return getRandomTriangle(tmpBitsGetRandomTriangle); }
/** * Inserts entity into the system. * * @param e Entity to insert. */ protected void insertToSystem(Entity e) { actives.add(e); e.getSystemBits().set(systemIndex); inserted(e); }
public void setLayer(int layer) { layer = MathUtils.clamp(layer, minLayer, maxLayer); slider.setValue(layer); visibleLayers.clear(); for (int i = 0; i < layer; i++) { visibleLayers.set(i); } notifyObserversLayerChanged(visibleLayers); } }
handledIndices.set(indexI);
/** * Adds a Component bellonging to the specified Entity to the manager. * * @param <T> Type of component * @param e Entity the component belongs to * @param component Component to add */ public <T extends Component> void addComponent(Entity e, T component) { int classIndex = getComponentClassIndex(component.getClass()); @SuppressWarnings("unchecked") Array<T> components = (Array<T>) componentsByType.get(classIndex); if(components == null) { components = new SafeArray<T>(); componentsByType.set(classIndex, components); } // clean up existing component belonging to the entity Component current = components.get(e.id); if (current != null && current != component) { Pools.free(current); } components.set(e.id, component); e.getComponentBits().set(classIndex); }