Package gwlpr.mapshard.entitysystem

Examples of gwlpr.mapshard.entitysystem.Entity


        Position p2 = new Position();
       
        Direction d1 = new Direction();

        // register the entities
        Entity e1 = new Entity(eMan, n1, a1, p1, d1);
        Entity e2 = new Entity(eMan, n2, a2, p2);
        Entity e3 = new Entity(eMan, n3, a3);
        Entity e4 = new Entity(eMan, n4);
        Entity e5 = new Entity(eMan);

        // retrieve entities with specific components
        ents = eMan.getEntitiesWith(Name.class, AgentIdentifiers.class, Position.class, Direction.class);
        assert ents.size() == 1;
        assert ents.contains(e1);

        ents = eMan.getEntitiesWith(Name.class, AgentIdentifiers.class, Position.class);
        assert ents.size() == 2;
        assert ents.contains(e1);
        assert ents.contains(e2);

        ents = eMan.getEntitiesWith(Name.class, AgentIdentifiers.class);
        assert ents.size() == 3;
        assert ents.contains(e1);
        assert ents.contains(e2);
        assert ents.contains(e3);

        ents = eMan.getEntitiesWith(Name.class);
        assert ents.size() == 4;
        assert ents.contains(e1);
        assert ents.contains(e2);
        assert ents.contains(e3);
        assert ents.contains(e4);

        ents = eMan.getEntitiesWith();
        assert ents.isEmpty();

        // retrieve components of specific entities
        Name n = e1.get(Name.class); // e1 has a Name
        assert n == n1;

        AgentIdentifiers a = e2.get(AgentIdentifiers.class); // e2 has an AgentID
        assert a == a2;

        Position p = e3.get(Position.class); // e3 has no LocalID
        assert p == null;

        Direction d = e5.get(Direction.class); // e5 has no components
        assert d == null;
    }
View Full Code Here


     * @param       manager
     * @return      A new character entity
     */
    public static Entity createNpc(String npcName, int fileId, int[] modelHashes, String hashedName, WorldPosition mapSpawn, EntityManager manager)
    {
        Entity result = new Entity(UUID.randomUUID(), manager);
       
        // general identifiers
        Name name = new Name();
        name.name = npcName;
       
        AgentIdentifiers agentIDs = new AgentIdentifiers();
        agentIDs.agentID = IDManager.reserveAgentID();
        agentIDs.localID = IDManager.reserveLocalID();
       
        // physics
        Position position = new Position();
        position.position = mapSpawn.clone();
       
        Direction direction = new Direction();
       
        Movement move = new Movement();

        BoundingBox bBox = new BoundingBox();
       
       
        // appearance and view visuals      
        View view = new View();
        view.isBlind = false;
       
        Visibility visibility = new Visibility();
       
        // load some char data
        // TODO static data!
        CharData charData = new CharData();
        charData.primary = Profession.Mesmer;
        charData.secondary = Profession.None;
        charData.level = 1;
       
        SpawnData faction = new SpawnData();
        faction.spawnType = SpawnType.NPC;
        faction.factionColor = 0x20;
       
        // finally NPC specific stuff
        // TODO static data!
        NPCData npcData = new NPCData();
        npcData.fileID = fileId;
        npcData.modelHashes = modelHashes;
        npcData.flags = 4;
        npcData.scale = 100;
        npcData.hashedName = hashedName;
       
        // build the entity
        result.addAll(name, agentIDs, position, direction, move, bBox, view, visibility, charData, faction, npcData);
       
        return result;
    }
View Full Code Here

     * @param       manager
     * @return      A new character entity
     */
    public static Entity createCharacter(UUID identifier, Character dBChar, WorldPosition mapSpawn, EntityManager manager)
    {
        Entity result = new Entity(identifier, manager);
       
        // general identifiers
        Name name = new Name();
        name.name = dBChar.getName();
       
        AgentIdentifiers agentIDs = new AgentIdentifiers();
        agentIDs.agentID = IDManager.reserveAgentID();
        agentIDs.localID = IDManager.reserveLocalID();
       
        // physics
        Position position = new Position();
        position.position = mapSpawn.clone();
       
        Direction direction = new Direction();
       
        Movement move = new Movement();

        BoundingBox bBox = new BoundingBox();
       
       
       
        // chat
        ChatOptions chat = new ChatOptions();
        Usergroup group = dBChar.getAccountID().getUserGroup();
        if (group != null)
        {
            chat.chatPefix = group.getPrefix();
            chat.prefixVisible = true;
           
            chat.chatColor = ChatColor.values()[group.getChatColor()];
            chat.enableColor = true;

            List<String> availCommands = new ArrayList<>();
            for (Command command : group.getCommandCollection())
            {
                availCommands.add(command.getName());
            }

            chat.availableCommands = availCommands;
        }
       
        // appearance and view visuals
        ByteBuffer buffer = ByteBuffer.allocate(4).order(ByteOrder.LITTLE_ENDIAN);
        buffer.put((byte) ((dBChar.getSkin().byteValue() << 5) | (dBChar.getHeight().byteValue() << 1) | dBChar.getSex().byteValue()));
        buffer.put((byte) ((dBChar.getFace().byteValue() << 7) | (dBChar.getHaircolor().byteValue() << 2) | (dBChar.getSkin().byteValue() >> 3)));
        buffer.put((byte) ((dBChar.getPrimaryProfession().getId().byteValue() << 4) | (dBChar.getFace().byteValue() >> 1)));
        buffer.put((byte) ((dBChar.getCampaign().byteValue() << 6) | dBChar.getHairstyle().byteValue()));

        PlayerAppearance appearance = new PlayerAppearance();
        appearance.appearanceDump = buffer.array();
       
        View view = new View();
       
        Visibility visibility = new Visibility();
       
        // load some char data
        CharData charData = new CharData();
        charData.primary = Profession.values()[dBChar.getPrimaryProfession().getId()];
        int secondary = dBChar.getSecondaryProfession() == null ? 0 : dBChar.getSecondaryProfession().getId();
        charData.secondary = Profession.values()[secondary];
        // TODO: fix the level!!!
        charData.level = 1;//dBChar.getLevel().getLevel();
        // TODO: load the attribute stuff here
       
        SpawnData spawnData = new SpawnData();
       
        FactionData factionData = new FactionData();
        // TODO: load the faction stuff here
       
        Skills skills = new Skills();
        // TODO: load the skills stuff here
       
        // build the entity
        result.addAll(name, agentIDs, position, direction, move, bBox, chat, appearance, view, visibility, charData, spawnData, factionData, skills);
       
        return result;
    }
View Full Code Here

    {
        // TODO verify data like mapData.validPosition(pos):boolean

        ClientBean client = ClientBean.get(action.getChannel());
       
        Entity et = client.getEntity();
        Position pos = et.get(Position.class);
        Direction dir = et.get(Direction.class);
        Movement move = et.get(Movement.class);

        // extract info
        WorldPosition position = new WorldPosition(
                action.getPositionVector(),
                (int) action.getPositionPlane());
View Full Code Here

    @Event.Handler
    public void onKeyboardStopMoving(P064_MovementStop action)
    {
        ClientBean client = ClientBean.get(action.getChannel());
       
        Entity et = client.getEntity();
        Position pos = et.get(Position.class);
        Movement move = et.get(Movement.class);

        // extract info
        WorldPosition position = new WorldPosition(
                action.getPositionVector(),
                (int) action.getPositionPlane());
View Full Code Here

           
            // create a new entity of the character of this client
            // NOTE THAT FOR IDENTIFICATION PURPOSES, WE USE THE CLIENTS UID FOR
            // ITS CHARACTER ENTITY AS WELL!
            WorldPosition pos = getRandomSpawn();
            Entity player = CharacterFactory.createCharacter(event.getHandle().getUid(), client.getCharacter(), pos, entityManager);

            client.setEntity(player);
            client.setAgentIDs(player.get(AgentIdentifiers.class));

            // using the attachment now looks a bit ugly,
            // because we use the components here directly
            // (this should not happen with other components!)
            InstanceLoadView.instanceHead(client.getChannel());
View Full Code Here

       
        ClientBean client = ClientBean.get(action.getChannel());

        // fetch the players postion (this was already initialized by the handshake controller,
        // when it instructed some other class to create the entity
        Entity et = client.getEntity();
        WorldPosition pos = et.get(Position.class).position;

        InstanceLoadView.sendSpawnPoint(client.getChannel(), pos, world.getMap().getHash());
    }
View Full Code Here

        LOGGER.debug("Got the instance load request player data packet");
       
        ClientBean client = ClientBean.get(action.getChannel());

        // fetch the player entity..
        Entity et = client.getEntity();

        InstanceLoadView.sendAgentData(client.getChannel(), et);

        // activate heart beat and ping and such
        client.setPlayerState(PlayerState.Playing);

        // unblind the player
        et.get(View.class).isBlind = false;
    }
View Full Code Here

        LOGGER.debug("Got command '{}' with parameters '{}'", command, parameters.toString());

        if ("fun".equals(command))
        {
            // TODO remove me when not needed anyore ;)
            Entity ply = chatCmd.getSender();
           
            NPCFactory.mockNpc(ply.get(Position.class).position, entityManager);
        }
        else if (!senderChatOptions.availableCommands.contains(command))
        {
            // command is not available for the sender
           
View Full Code Here

    public void onMove(MoveEvent moveEvt)
    {
        // we need to inform the connected clients and
        // set the movement state to moving (if that has not yet happened)
       
        Entity et = moveEvt.getThisEntity();

        // update the entities values
//        et.get(Direction.class).direction = moveEvt.getDirection().getUnit();
        Movement move = et.get(Movement.class);
//        move.moveType = moveEvt.getType(); // use the new movement type here
//        move.moveState = MovementState.Moving;

        // inform the clients
        for (Handle<ClientBean> clientHandle : clientRegistry.getAllHandles())
View Full Code Here

TOP

Related Classes of gwlpr.mapshard.entitysystem.Entity

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.