Search in sources :

Example 1 with PrefabManager

use of org.terasology.entitySystem.prefab.PrefabManager in project Terasology by MovingBlocks.

the class SideBlockSupportRequired method checkForSupport.

@ReceiveEvent
public void checkForSupport(DelayedActionTriggeredEvent event, EntityRef entity, BlockComponent block, SideBlockSupportRequiredComponent supportRequired) {
    if (event.getActionId().equals(SUPPORT_CHECK_ACTION_ID)) {
        if (!isSufficientlySupported(block.getPosition(), null, Collections.<Vector3i, Block>emptyMap(), supportRequired)) {
            PrefabManager prefabManager = CoreRegistry.get(PrefabManager.class);
            entity.send(new DestroyEvent(entity, EntityRef.NULL, prefabManager.getPrefab("engine:supportRemovedDamage")));
        }
    }
}
Also used : DestroyEvent(org.terasology.logic.health.DestroyEvent) PrefabManager(org.terasology.entitySystem.prefab.PrefabManager) Vector3i(org.terasology.math.geom.Vector3i) Block(org.terasology.world.block.Block) ReceiveEvent(org.terasology.entitySystem.event.ReceiveEvent)

Example 2 with PrefabManager

use of org.terasology.entitySystem.prefab.PrefabManager in project Terasology by MovingBlocks.

the class EntitySystemSetupUtil method addEntityManagementRelatedClasses.

/**
 * Objects for the following classes must be available in the context:
 * <ul>
 * <li>{@link ModuleEnvironment}</li>
 * <li>{@link NetworkSystem}</li>
 * <li>{@link ReflectFactory}</li>
 * <li>{@link CopyStrategyLibrary}</li>
 * <li>{@link org.terasology.persistence.typeHandling.TypeSerializationLibrary}</li>
 * </ul>
 * <p>
 * The method will make objects for the following classes available in the context:
 * <ul>
 * <li>{@link EngineEntityManager}</li>
 * <li>{@link ComponentLibrary}</li>
 * <li>{@link EventLibrary}</li>
 * <li>{@link PrefabManager}</li>
 * <li>{@link EventSystem}</li>
 * </ul>
 */
public static void addEntityManagementRelatedClasses(Context context) {
    ModuleEnvironment environment = context.get(ModuleManager.class).getEnvironment();
    NetworkSystem networkSystem = context.get(NetworkSystem.class);
    // Entity Manager
    PojoEntityManager entityManager = new PojoEntityManager();
    context.put(EntityManager.class, entityManager);
    context.put(EngineEntityManager.class, entityManager);
    // Standard serialization library
    TypeSerializationLibrary typeSerializationLibrary = context.get(TypeSerializationLibrary.class);
    typeSerializationLibrary.add(EntityRef.class, new EntityRefTypeHandler(entityManager));
    entityManager.setTypeSerializerLibrary(typeSerializationLibrary);
    // Prefab Manager
    PrefabManager prefabManager = new PojoPrefabManager(context);
    entityManager.setPrefabManager(prefabManager);
    context.put(PrefabManager.class, prefabManager);
    EntitySystemLibrary library = context.get(EntitySystemLibrary.class);
    entityManager.setComponentLibrary(library.getComponentLibrary());
    // Event System
    EventSystem eventSystem = new EventSystemImpl(library.getEventLibrary(), networkSystem);
    entityManager.setEventSystem(eventSystem);
    context.put(EventSystem.class, eventSystem);
    // TODO: Review - NodeClassLibrary related to the UI for behaviours. Should not be here and probably not even in the CoreRegistry
    context.put(OneOfProviderFactory.class, new OneOfProviderFactory());
    registerComponents(library.getComponentLibrary(), environment);
    registerEvents(entityManager.getEventSystem(), environment);
}
Also used : OneOfProviderFactory(org.terasology.rendering.nui.properties.OneOfProviderFactory) PojoPrefabManager(org.terasology.entitySystem.prefab.internal.PojoPrefabManager) ModuleEnvironment(org.terasology.module.ModuleEnvironment) EntitySystemLibrary(org.terasology.entitySystem.metadata.EntitySystemLibrary) PojoEntityManager(org.terasology.entitySystem.entity.internal.PojoEntityManager) PojoPrefabManager(org.terasology.entitySystem.prefab.internal.PojoPrefabManager) PrefabManager(org.terasology.entitySystem.prefab.PrefabManager) NetworkSystem(org.terasology.network.NetworkSystem) EntityRefTypeHandler(org.terasology.persistence.typeHandling.extensionTypes.EntityRefTypeHandler) TypeSerializationLibrary(org.terasology.persistence.typeHandling.TypeSerializationLibrary) EventSystem(org.terasology.entitySystem.event.internal.EventSystem) ModuleManager(org.terasology.engine.module.ModuleManager) EventSystemImpl(org.terasology.entitySystem.event.internal.EventSystemImpl)

Aggregations

PrefabManager (org.terasology.entitySystem.prefab.PrefabManager)2 ModuleManager (org.terasology.engine.module.ModuleManager)1 PojoEntityManager (org.terasology.entitySystem.entity.internal.PojoEntityManager)1 ReceiveEvent (org.terasology.entitySystem.event.ReceiveEvent)1 EventSystem (org.terasology.entitySystem.event.internal.EventSystem)1 EventSystemImpl (org.terasology.entitySystem.event.internal.EventSystemImpl)1 EntitySystemLibrary (org.terasology.entitySystem.metadata.EntitySystemLibrary)1 PojoPrefabManager (org.terasology.entitySystem.prefab.internal.PojoPrefabManager)1 DestroyEvent (org.terasology.logic.health.DestroyEvent)1 Vector3i (org.terasology.math.geom.Vector3i)1 ModuleEnvironment (org.terasology.module.ModuleEnvironment)1 NetworkSystem (org.terasology.network.NetworkSystem)1 TypeSerializationLibrary (org.terasology.persistence.typeHandling.TypeSerializationLibrary)1 EntityRefTypeHandler (org.terasology.persistence.typeHandling.extensionTypes.EntityRefTypeHandler)1 OneOfProviderFactory (org.terasology.rendering.nui.properties.OneOfProviderFactory)1 Block (org.terasology.world.block.Block)1