Package org.terasology.entitySystem

Examples of org.terasology.entitySystem.Component


        if (differentiatingComponentsFrom.size() != differentiatingComponentsTo.size()) {
            return false;
        }

        for (Component component : differentiatingComponentsFrom) {
            Component componentInTarget = differentiatingComponentsTo.get(component.getClass());
            if (componentInTarget == null) {
                return false;
            }

            if (!component.equals(componentInTarget)) {
View Full Code Here


            return next != null;
        }

        @Override
        public Component next() {
            Component result = next;
            next = getNext();
            return result;
        }
View Full Code Here

            return result;
        }

        private Component getNext() {
            while (sourceIterator.hasNext()) {
                final Component result = sourceIterator.next();
                if (componentsToAdd.containsKey(result.getClass())) {
                    throw new IllegalStateException("Requested to add component that was already defined for this entity");
                }
                if (componentsToRemove.contains(result.getClass())) {
                    continue;
                }
                return result;
            }
            while (addedIterator.hasNext()) {
                final Component result = addedIterator.next();
                if (componentsToRemove.contains(result.getClass())) {
                    continue;
                }
                return result;
            }
            return null;
View Full Code Here

    }

    public Iterable<Component> iterateComponents(int entityId) {
        List<Component> components = Lists.newArrayList();
        for (TIntObjectMap<Component> componentMap : store.values()) {
            Component comp = componentMap.get(entityId);
            if (comp != null) {
                components.add(comp);
            }
        }
        return components;
View Full Code Here

     */
    public Collection<EntityRef> listOwnedEntities(EntityRef entity) {
        Set<EntityRef> entityRefList = Sets.newHashSet();
        for (ComponentMetadata<?> componentMetadata : componentLibrary.iterateComponentMetadata()) {
            if (componentMetadata.isReferenceOwner()) {
                Component comp = entity.getComponent(componentMetadata.getType());
                if (comp != null) {
                    addOwnedEntitiesFor(comp, componentMetadata, entityRefList);
                }
            }
        }
View Full Code Here

    @Override
    public EntityRef create(Prefab prefab, Vector3f position, Quat4f rotation) {
        List<Component> components = Lists.newArrayList();
        for (Component component : prefab.iterateComponents()) {
            Component newComp = componentLibrary.copy(component);
            components.add(newComp);
            if (newComp instanceof LocationComponent) {
                LocationComponent loc = (LocationComponent) newComp;
                loc.setWorldPosition(position);
                loc.setWorldRotation(rotation);
View Full Code Here

    @Override
    public EntityRef create(Prefab prefab, Vector3f position) {
        List<Component> components = Lists.newArrayList();
        for (Component component : prefab.iterateComponents()) {
            Component newComp = componentLibrary.copy(component);
            components.add(newComp);
            if (newComp instanceof LocationComponent) {
                LocationComponent loc = (LocationComponent) newComp;
                loc.setWorldPosition(position);
            }
View Full Code Here

     * @return The added component
     */
    @Override
    public <T extends Component> T addComponent(int entityId, T component) {
        Preconditions.checkNotNull(component);
        Component oldComponent = store.put(entityId, component);
        if (oldComponent != null) {
            logger.error("Adding a component ({}) over an existing component for entity {}", component.getClass(), entityId);
        }
        if (eventSystem != null) {
            EntityRef entityRef = createEntityRef(entityId);
View Full Code Here

     * @param entityId
     * @param component
     */
    @Override
    public void saveComponent(int entityId, Component component) {
        Component oldComponent = store.put(entityId, component);
        if (oldComponent == null) {
            logger.error("Saving a component ({}) that doesn't belong to this entity {}", component.getClass(), entityId);
        }
        if (eventSystem != null) {
            EntityRef entityRef = createEntityRef(entityId);
View Full Code Here

     * @return The component described by the componentData, or null if it couldn't be deserialized
     */
    public Component deserialize(EntityData.Component componentData, Module context) {
        ComponentMetadata<? extends Component> componentMetadata = getComponentMetadata(componentData, context);
        if (componentMetadata != null) {
            Component component = componentMetadata.newInstance();
            return deserializeOnto(component, componentData, componentMetadata, FieldSerializeCheck.NullCheck.<Component>newInstance());
        } else {
            logger.warn("Unable to deserialize unknown component type: {}", componentData.getType());
        }
        return null;
View Full Code Here

TOP

Related Classes of org.terasology.entitySystem.Component

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.