Package org.terasology.entitySystem.entity

Examples of org.terasology.entitySystem.entity.EntityRef


        }
    }

    @Command(shortDescription = "Displays debug information on the target entity")
    public String debugTarget() {
        EntityRef cameraTarget = cameraTargetSystem.getTarget();
        return cameraTarget.toFullDescription();
    }
View Full Code Here


        if (block == null) {
            return "";
        }

        BlockItemFactory blockItemFactory = new BlockItemFactory(entityManager);
        EntityRef blockItem = blockItemFactory.newInstance(block);

        pickupBuilder.createPickupFor(blockItem, spawnPos, 60);
        return "Spawned block.";
    }
View Full Code Here

    @Command(shortDescription = "Shutdown the server", runOnServer = true)
    public String shutdownServer(EntityRef sender) {

        // TODO: verify permissions of sender

        EntityRef clientInfo = sender.getComponent(ClientComponent.class).clientInfo;
        DisplayNameComponent name = clientInfo.getComponent(DisplayNameComponent.class);
       
        logger.info("Shutdown triggered by {}", name.name);
       
        CoreRegistry.get(GameEngine.class).shutdown();
       
View Full Code Here

    public String kickUser(@CommandParam("username") String username, EntityRef sender) {

        // TODO: verify permissions of sender

        for (EntityRef clientEntity : entityManager.getEntitiesWith(ClientComponent.class)) {
            EntityRef clientInfo = clientEntity.getComponent(ClientComponent.class).clientInfo;

            DisplayNameComponent name = clientInfo.getComponent(DisplayNameComponent.class);
            if (username.equals(name.name)) {

                return kick(clientEntity);
            }
        }
View Full Code Here

    public String kickUserByID(@CommandParam("userId") int userId, EntityRef sender) {

        // TODO: verify permissions of sender
       
        for (EntityRef clientEntity : entityManager.getEntitiesWith(ClientComponent.class)) {
            EntityRef clientInfo = clientEntity.getComponent(ClientComponent.class).clientInfo;
            NetworkComponent nc = clientInfo.getComponent(NetworkComponent.class);

            if (userId == nc.getNetworkId()) {
                return kick(clientEntity);
            }
        }
View Full Code Here

    private String kick(EntityRef clientEntity) {
        NetworkSystem network = CoreRegistry.get(NetworkSystem.class);
        Client client = network.getOwner(clientEntity);
       
        if (!client.isLocal()) {
            EntityRef clientInfo = clientEntity.getComponent(ClientComponent.class).clientInfo;
            DisplayNameComponent name = clientInfo.getComponent(DisplayNameComponent.class);

            logger.info("Kicking user {}", name.name);

            network.forceDisconnect(client);
            return "User kick triggered for '" + name.name + "'";
View Full Code Here

    private void sendEntities(NetData.NetMessage.Builder message) {
        TIntIterator dirtyIterator = netDirty.iterator();
        while (dirtyIterator.hasNext()) {
            int netId = dirtyIterator.next();
            EntityRef entity = networkSystem.getEntity(netId);
            if (isOwned(entity)) {
                Set<Class<? extends Component>> emptyComponentClassSet = Collections.emptySet();
                EntityData.PackedEntity entityData = entitySerializer.serialize(entity, emptyComponentClassSet, changedComponents.get(netId),
                        emptyComponentClassSet, new ClientComponentFieldCheck());
                if (entityData != null) {
View Full Code Here

        }
        netDirty.clear();
    }

    private boolean isOwned(EntityRef entity) {
        EntityRef owner = networkSystem.getOwnerEntity(entity);
        return getClientEntity().equals(owner);
    }
View Full Code Here

    }


    private void processEvent(NetData.EventMessage message) {
        Event event = eventSerializer.deserialize(message.getEvent());
        EntityRef target = EntityRef.NULL;
        if (message.hasTargetBlockPos()) {
            target = blockEntityRegistry.getBlockEntityAt(NetMessageUtil.convert(message.getTargetBlockPos()));
        } else if (message.hasTargetId()) {
            target = networkSystem.getEntity(message.getTargetId());
        }
        if (target.exists()) {
            target.send(event);
        } else {
            logger.info("Dropping event {} for unavailable entity {}", event.getClass().getSimpleName(), target);
        }
    }
View Full Code Here

    }

    private void processRemoveEntities(NetData.NetMessage message) {
        for (NetData.RemoveEntityMessage removeEntity : message.getRemoveEntityList()) {
            int netId = removeEntity.getNetId();
            EntityRef entity = networkSystem.getEntity(netId);
            if (entity.exists()) {
                logger.info("Destroying entity: {}", entity);
                entity.destroy();
                networkSystem.unregisterClientNetworkEntity(netId);
            }
        }
    }
View Full Code Here

TOP

Related Classes of org.terasology.entitySystem.entity.EntityRef

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.