Package org.terasology.logic.players

Examples of org.terasology.logic.players.LocalPlayer


        new RegisterInputSystem().step();

        EntityRef localPlayerEntity = entityManager.create(new ClientComponent());

        LocalPlayer localPlayer = CoreRegistry.put(LocalPlayer.class, new LocalPlayer());
        localPlayer.setClientEntity(localPlayerEntity);

        componentSystemManager.initialise();

        playBackgroundMusic();
View Full Code Here


        componentSystemManager.register(new ConsoleSystem(), "engine:ConsoleSystem");
        componentSystemManager.register(new CoreCommands(), "engine:CoreCommands");

        EntityRef localPlayerEntity = entityManager.create(new ClientComponent());
        LocalPlayer localPlayer = CoreRegistry.put(LocalPlayer.class, new LocalPlayer());
        localPlayer.setClientEntity(localPlayerEntity);

        componentSystemManager.initialise();
    }
View Full Code Here

        Vector3f drive = new Vector3f();

        // find player position
        // TODO: shouldn't use local player, need some way to find nearest
        // player
        LocalPlayer localPlayer = CoreRegistry.get(LocalPlayer.class);
        if (localPlayer != null) {
            Vector3f dist = new Vector3f(worldPos);
            dist.sub(localPlayer.getPosition());
            double distanceToPlayer = dist.lengthSquared();

            ai.inDanger = false;
            if (ai.dieIfPlayerFar && distanceToPlayer > ai.dieDistance) {
                entity.destroy();
            }

            //----------------danger behavior----------

            // if our AI is aggressive or hunter go and hunt player else run away
            // if wild
            if (ai.aggressive) {
                // TODO fix this to proper attacking
                if (distanceToPlayer <= ai.attackDistance) {
                    if (tempTime - lastAttack > ai.damageFrequency) {
                        localPlayer.getCharacterEntity().send(
                                new DoDamageEvent(ai.damage, EngineDamageTypes.PHYSICAL.get(), entity));
                        lastAttack = CoreRegistry.get(Time.class).getGameTimeInMs();
                    }
                }
            }

            //update
            if (tempTime - ai.lastChangeOfDangerAt > dangerChangeTime) {
                dangerChangeTime = (long) (ai.dangerUpdateTime * random.nextDouble() * ai.hectic);
                if (ai.hunter) {
                    if (distanceToPlayer > ai.playerdistance
                            && distanceToPlayer < ai.playerSense) {
                        // Head to player
                        Vector3f tempTarget = localPlayer.getPosition();
                        if (ai.forgiving != 0) {
                            ai.movementTarget.set(new Vector3f(
                                    tempTarget.x + random.nextFloat(-ai.forgiving, ai.forgiving),
                                    tempTarget.y + random.nextFloat(-ai.forgiving, ai.forgiving),
                                    tempTarget.z + random.nextFloat(-ai.forgiving, ai.forgiving)
                            ));
                        } else {
                            ai.movementTarget.set(tempTarget);
                        }
                        ai.inDanger = true;
                        entity.saveComponent(ai);

                        // System.out.print("\nhunting palyer\n");
                    }
                }
                // run opposite direction
                if (ai.wild) {
                    if (distanceToPlayer > ai.panicDistance
                            && distanceToPlayer < ai.runDistance) {
                        Vector3f tempTarget = localPlayer.getPosition();
                        if (ai.forgiving != 0) {
                            ai.movementTarget.set(new Vector3f(
                                    -tempTarget.x + random.nextFloat(-ai.forgiving, ai.forgiving),
                                    -tempTarget.y + random.nextFloat(-ai.forgiving, ai.forgiving),
                                    -tempTarget.z + random.nextFloat(-ai.forgiving, ai.forgiving)
View Full Code Here

            }
            SimpleAIComponent ai = entity.getComponent(SimpleAIComponent.class);

            Vector3f drive = new Vector3f();
            // TODO: shouldn't use local player, need some way to find nearest player
            LocalPlayer localPlayer = CoreRegistry.get(LocalPlayer.class);
            if (localPlayer != null) {
                Vector3f dist = new Vector3f(worldPos);
                dist.sub(localPlayer.getPosition());
                double distanceToPlayer = dist.lengthSquared();

                if (distanceToPlayer > 6 && distanceToPlayer < 16) {
                    // Head to player
                    ai.movementTarget.set(localPlayer.getPosition());
                    ai.followingPlayer = true;
                    entity.saveComponent(ai);
                } else {
                    // Random walk
                    if (CoreRegistry.get(Time.class).getGameTimeInMs() - ai.lastChangeOfDirectionAt > 12000 || ai.followingPlayer) {
View Full Code Here

    public void setViewDistance(ViewDistance viewDistance) {
        this.viewDistance = viewDistance;

        // TODO: Remove this, switch to a property change listener
        WorldRenderer worldRenderer = CoreRegistry.get(WorldRenderer.class);
        LocalPlayer player = CoreRegistry.get(LocalPlayer.class);
        if (player != null) {
            player.getClientEntity().send(new ChangeViewRangeRequest(viewDistance));
        }
        if (worldRenderer != null) {
            worldRenderer.changeViewDistance(viewDistance);
        }
    }
View Full Code Here

        maxRenderY = max;
        renderY = y;
    }

    private Vector3i calcPlayerChunkPos() {
        final LocalPlayer p = CoreRegistry.get(LocalPlayer.class);
        if (p != null) {
            return TeraMath.calcChunkPos(new Vector3i(p.getPosition()));
        }
        return null;
    }
View Full Code Here

        }
    }

    private void onCloseScreen(UIScreenLayer screen, AssetUri screenUri) {
        screen.onClosed();
        LocalPlayer localPlayer = CoreRegistry.get(LocalPlayer.class);
        if (localPlayer != null) {
            localPlayer.getClientEntity().send(new ScreenLayerClosedEvent(screenUri));
        }
    }
View Full Code Here

        RenderingSubsystemFactory engineSubsystemFactory = CoreRegistry.get(RenderingSubsystemFactory.class);
        WorldRenderer worldRenderer = engineSubsystemFactory.createWorldRenderer(worldProvider, chunkProvider, CoreRegistry.get(LocalPlayerSystem.class));
        CoreRegistry.put(WorldRenderer.class, worldRenderer);

        // TODO: These shouldn't be done here, nor so strongly tied to the world renderer
        CoreRegistry.put(LocalPlayer.class, new LocalPlayer());
        CoreRegistry.put(Camera.class, worldRenderer.getActiveCamera());
        CoreRegistry.put(PhysicsEngine.class, worldRenderer.getBulletRenderer());
        CoreRegistry.put(Physics.class, worldRenderer.getBulletRenderer());

        return true;
View Full Code Here

    @Override
    public boolean step() {

        // TODO: These shouldn't be done here, nor so strongly tied to the world renderer
        CoreRegistry.put(LocalPlayer.class, new LocalPlayer());

        RemoteChunkProvider chunkProvider = new RemoteChunkProvider();

        WorldProviderCoreImpl worldProviderCore = new WorldProviderCoreImpl(gameManifest.getWorldInfo(TerasologyConstants.MAIN_WORLD), chunkProvider);
        EntityAwareWorldProvider entityWorldProvider = new EntityAwareWorldProvider(worldProviderCore);
View Full Code Here

    public boolean step() {
        ComponentSystemManager componentSystemManager = CoreRegistry.get(ComponentSystemManager.class);
        for (UpdateSubscriberSystem updater : componentSystemManager.iterateUpdateSubscribers()) {
            updater.update(0.0f);
        }
        LocalPlayer localPlayer = CoreRegistry.get(LocalPlayer.class);
        ClientComponent client = localPlayer.getClientEntity().getComponent(ClientComponent.class);
        if (client != null && client.character.exists()) {
            worldRenderer.setPlayer(CoreRegistry.get(LocalPlayer.class));
            return true;
        } else {
            worldRenderer.getChunkProvider().completeUpdate();
View Full Code Here

TOP

Related Classes of org.terasology.logic.players.LocalPlayer

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.