Esempio n. 1
0
_MEMBER_FUNCTION_IMPL(GUIElement, getPosition)
{
	SQBool relative;
	sq_getbool(pVM, -1, &relative);

	CGUIFrameWindow * pWindow = sq_getinstance<CGUIFrameWindow *>(pVM);

	if(!pWindow)
	{
		sq_pushbool(pVM, false);
		return 1;
	}

	CEGUI::Vector2 pos;

	if(relative != 0)
	{
		pos = pWindow->getPosition().asRelative((CEGUI::Size(g_pClient->GetGUI()->GetDisplayWidth (), g_pClient->GetGUI()->GetDisplayHeight())));
	}
	else
	{
		pos = pWindow->getPosition().asAbsolute((CEGUI::Size(g_pClient->GetGUI()->GetDisplayWidth (), g_pClient->GetGUI()->GetDisplayHeight())));
	}

	CSquirrelArguments args;
	args.push(pos.d_x);
	args.push(pos.d_y);
	sq_pusharg(pVM, CSquirrelArgument(args, true));
	return 1;
}
// getVehicleOccupants(vehicleid)
SQInteger CVehicleNatives::GetOccupants(SQVM * pVM)
{
    EntityId vehicleId;
    sq_getentity(pVM, -1, &vehicleId);

    CNetworkVehicle * pVehicle = g_pClient->GetVehicleManager()->Get(vehicleId);

    if(pVehicle)
    {
        CSquirrelArguments args;

        for(BYTE i = 0; i < (MAX_VEHICLE_PASSENGERS + 1); i++)
        {
            args.push((int)(i + 1));
            CNetworkPlayer * pOccupant = pVehicle->GetOccupant(i);
            args.push(pOccupant ? (int)pOccupant->GetPlayerId() : (int)INVALID_ENTITY_ID);
        }

        sq_pusharg(pVM, CSquirrelArgument(args, false));
        return 1;
    }

    sq_pushbool(pVM, false);
    return 1;
}
// getVehicleRotation(vehicleid)
SQInteger CVehicleNatives::GetRotation(SQVM * pVM)
{
    EntityId vehicleId;
    sq_getentity(pVM, -1, &vehicleId);

    if(g_pVehicleManager->Exists(vehicleId))
    {
        CNetworkVehicle * pVehicle = g_pVehicleManager->Get(vehicleId);

        if(pVehicle)
        {
            CVector3 vecRotation;
            pVehicle->GetRotation(vecRotation);
            CSquirrelArguments args;
            args.push(vecRotation.fX);
            args.push(vecRotation.fY);
            args.push(vecRotation.fZ);
            sq_pusharg(pVM, CSquirrelArgument(args, true));
            return 1;
        }
    }

    sq_pushbool(pVM, false);
    return 1;
}
Esempio n. 4
0
_MEMBER_FUNCTION_IMPL(GUIElement, getSize)
{
	CGUIFrameWindow * pWindow = sq_getinstance<CGUIFrameWindow *>(pVM);

	if(pWindow)
	{
		CEGUI::UVector2 sz = pWindow->getSize();
		CSquirrelArguments args;
		args.push(sz.d_x.d_offset);
		args.push(sz.d_y.d_offset);
		sq_pusharg(pVM, CSquirrelArgument(args, true));
		return 1;
	}

	sq_pushbool(pVM, false);
	return 1;
}
Esempio n. 5
0
// getActorCoordinates(actorid)
SQInteger CActorNatives::GetCoordinates(SQVM * pVM)
{
	EntityId actorId;
    sq_getentity(pVM, -1, &actorId);

    if(g_pActorManager->DoesExist(actorId))
    {
		CVector3 vecPosition = g_pActorManager->GetPosition(actorId);
		CSquirrelArguments args;
		args.push(vecPosition.fX);
		args.push(vecPosition.fY);
		args.push(vecPosition.fZ);
		sq_pusharg(pVM, CSquirrelArgument(args, true));
		return 1;
	}
    sq_pushbool(pVM, false);
    return 1;
}
// getVehicleCoordinates(vehicleid)
SQInteger CVehicleNatives::GetCoordinates(SQVM * pVM)
{
    EntityId vehicleId;
    sq_getentity(pVM, -1, &vehicleId);

    CNetworkVehicle * pVehicle = g_pClient->GetVehicleManager()->Get(vehicleId);

    if(pVehicle)
    {
        CVector3 vecPosition;
        pVehicle->GetPosition(vecPosition);
        CSquirrelArguments args;
        args.push(vecPosition.fX);
        args.push(vecPosition.fY);
        args.push(vecPosition.fZ);
        sq_pusharg(pVM, CSquirrelArgument(args, true));
        return 1;
    }

    sq_pushbool(pVM, false);
    return 1;
}
// getVehicleAngularVelocity(vehicleid)
SQInteger CVehicleNatives::GetAngularVelocity(SQVM * pVM)
{
    EntityId vehicleId;
    sq_getentity(pVM, -1, &vehicleId);

    CNetworkVehicle * pVehicle = g_pClient->GetVehicleManager()->Get(vehicleId);

    if(pVehicle)
    {
        CVector3 vecTurnSpeed;
        pVehicle->GetTurnSpeed(vecTurnSpeed);
        CSquirrelArguments args;
        args.push(vecTurnSpeed.fX);
        args.push(vecTurnSpeed.fY);
        args.push(vecTurnSpeed.fZ);
        sq_pusharg(pVM, CSquirrelArgument(args, true));
        return 1;
    }

    sq_pushbool(pVM, false);
    return 1;
}
// getVehicleColor(vehicleid)
SQInteger CVehicleNatives::GetColor(SQVM * pVM)
{
    EntityId vehicleId;
    sq_getentity(pVM, -1, &vehicleId);

    CNetworkVehicle * pVehicle = g_pClient->GetVehicleManager()->Get(vehicleId);

    if(pVehicle)
    {
        BYTE byteColors[4];
        pVehicle->GetColors(byteColors[0], byteColors[1], byteColors[2], byteColors[3]);
        CSquirrelArguments args;
        args.push((int)byteColors[0]);
        args.push((int)byteColors[1]);
        args.push((int)byteColors[2]);
        args.push((int)byteColors[3]);
        sq_pusharg(pVM, CSquirrelArgument(args, true));
        return 1;
    }

    sq_pushbool(pVM, false);
    return 1;
}