Package gwlpr.protocol.util

Examples of gwlpr.protocol.util.Vector2


        p.uByte = 1;
        p.uShort = 2;
        p.uInt = 3;
        p.uLong = 4;
        p.single = 5.0F;
        p.vec2 = new Vector2(6.0F, 7.0F);
        p.vec3 = new Vector3(8.0F, 9.0F, 10.0F);
        p.vec4 = new Vector4(11.0F, 12.0F, 13.0F, 14.0F);
        p.dw3 = new WorldPosition(15.0F, 16.0F, 17.0F, 18);
        p.vint = 19;
        p.ascii = "20";
View Full Code Here


       
        @Override
        protected void put(ByteBuf buf, Object object)
                throws Exception
        {
            Vector2 vec = (Vector2)field.get(object);
            buf.writeFloat(vec.getX());
            buf.writeFloat(vec.getY());
        }
View Full Code Here

        }
       
        @Override
        protected Object get(ByteBuf buf)
        {
            return buf.readableBytes() >= 8 ? new Vector2(buf.readFloat(), buf.readFloat()) : null;
        }
View Full Code Here

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

        Vector2 direction = action.getMoveDirection();

        MovementType moveType = MovementType.fromInt((int)action.getMovementType());
       
        // this should not be done directly:
        pos.position = position;
View Full Code Here

    }
   
   
    public Vector2 vecWithEndpoint(WorldPosition pos)
    {
        return new Vector2(
                pos.getX() - getX(),
                pos.getY() - getY());
    }
View Full Code Here

                continue;
            }
           
            // retrieve the components we need
            Position pos = entity.get(Position.class);
            Vector2 dir = entity.get(Direction.class).direction.getUnit();
            Movement move = entity.get(Movement.class);
           
//            // update the position (we simply assume that the client has now reached its future position)
//            pos.position = move.futurePosition;

            // calculate the next future position (the next movement aim)
            // we do not actually change the current position of the agent!
            // formula: posVec + ( dirVec * (speedScal * (0.001 * timeDeltaScal)))
            pos.position = pos.position.add(dir.mul(move.speed * (0.001F * timeDelta)));
        }
    }
View Full Code Here

       
        Position pos = et.get(Position.class);
        Direction dir = et.get(Direction.class);
        Movement move = et.get(Movement.class);
       
        Vector2 direction1 = pos.position.vecWithEndpoint(move.moveAim);
       
        float angle = direction1.angleTo(dir.direction);
       
        move.moveAim = pos.position;
        move.moveType = MovementType.Stop;
        move.moveState = MovementState.NotMoving;
View Full Code Here

    {
        // retrieve entity-info
        AgentIdentifiers agentIDs = entity.get(AgentIdentifiers.class);
        WorldPosition pos = entity.get(Position.class).position;
        Direction direction = entity.get(Direction.class);
        Vector2 dir = direction.direction;
        float rotation = direction.rotation;
        Movement move = entity.get(Movement.class);
        SpawnData faction = entity.get(SpawnData.class);
       
        if (faction.spawnType == SpawnType.Player)
        {
           sendPlayerAppearance(channel, entity);
        }
        else if (faction.spawnType == SpawnType.NPC || faction.spawnType == SpawnType.Ally)
        {
            sendNPCGeneralPackets(channel, entity);
        }
        else
        {
            // NOTE THIS BUG: hardcoded: we currently only spawn npcs and players automatically.
            return;
        }

        // send spawn agent packet
        P021_SpawnAgent spawnAgent = new P021_SpawnAgent();
        spawnAgent.init(channel);
        spawnAgent.setAgentID(agentIDs.agentID);
        spawnAgent.setFacColorLocalID((faction.factionColor << 24) | agentIDs.localID); // is this the localid?
        spawnAgent.setUnknown1((byte) 1);
        spawnAgent.setUnknown2((byte) 9);//5);
        spawnAgent.setPositionVector(pos);
        spawnAgent.setPositionPlane(pos.getZPlane());
        spawnAgent.setDirectionRotation(new Vector2(Float.POSITIVE_INFINITY, rotation));
        spawnAgent.setUnknown3((short)1);
        spawnAgent.setMoveSpeed(move.speed);
        spawnAgent.setUnknown4(1F);//Float.POSITIVE_INFINITY);
        spawnAgent.setUnknown5(0x41400000);
        spawnAgent.setSpawnType(faction.spawnType.getIntString()); // "play" backwards
        spawnAgent.setUnknown11(new Vector2(Float.POSITIVE_INFINITY, Float.POSITIVE_INFINITY));
        spawnAgent.setUnknown12(new Vector2(Float.POSITIVE_INFINITY, Float.POSITIVE_INFINITY));
        spawnAgent.setUnknown15(new Vector2(Float.POSITIVE_INFINITY, Float.POSITIVE_INFINITY));
       
        channel.writeAndFlush(spawnAgent);
    }
View Full Code Here

     */
    public static void sendChangeDirection(Channel channel, Entity entity)
    {
        // retrieve the entity related data we need...
        int agentID = entity.get(AgentIdentifiers.class).agentID;
        Vector2 dir = entity.get(Direction.class).direction;
        MovementType movT = entity.get(Movement.class).moveType;
       
        // construct the message
        P026_AgentMoveDirection moveDir = new P026_AgentMoveDirection();
        moveDir.init(channel);
View Full Code Here

TOP

Related Classes of gwlpr.protocol.util.Vector2

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.