diff --git a/c-api/data/interior_extend_info.h b/c-api/data/interior_extend_info.h new file mode 100644 index 0000000..a2e61b7 --- /dev/null +++ b/c-api/data/interior_extend_info.h @@ -0,0 +1,7 @@ +#pragma once +#include "cpp-sdk/deps/alt-math/alt-math.h" + +typedef struct { + alt::Position min; + alt::Position max; +} interior_extend_info_t; \ No newline at end of file diff --git a/c-api/interior.cpp b/c-api/interior.cpp new file mode 100644 index 0000000..18f6f85 --- /dev/null +++ b/c-api/interior.cpp @@ -0,0 +1,39 @@ +#include "interior.h" + +#include "utils/macros.h" + +CAPI_START() + +#ifdef ALT_CLIENT_API +uint16_t Interior_GetRoomCount(uint32_t interiorId) +{ + auto interior = alt::ICore::Instance().GetInterior(interiorId); + return interior->GetRoomCount(); +} + +uint16_t Interior_GetPortalCount(uint32_t interiorId) +{ + auto interior = alt::ICore::Instance().GetInterior(interiorId); + return interior->GetPortalCount(); +} + +alt::Position Interior_GetPosition(uint32_t interiorId) +{ + auto interior = alt::ICore::Instance().GetInterior(interiorId); + return interior->GetPosition(); +} + +alt::Rotation Interior_GetRotation(uint32_t interiorId) +{ + auto interior = alt::ICore::Instance().GetInterior(interiorId); + return interior->GetRotation(); +} + +void Interior_GetEntitiesExtents(uint32_t interiorId, interior_extend_info_t& extents) +{ + auto interior = alt::ICore::Instance().GetInterior(interiorId); + auto ext = interior->GetEntitiesExtents(); + extents.min = ext.min; + extents.max = ext.max; +} +#endif \ No newline at end of file diff --git a/c-api/interior.h b/c-api/interior.h new file mode 100644 index 0000000..5ec65c8 --- /dev/null +++ b/c-api/interior.h @@ -0,0 +1,29 @@ +#pragma once + +#ifdef __clang__ +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wempty-body" +#pragma clang diagnostic ignored "-Wswitch" +#endif + +#include "cpp-sdk/SDK.h" +#include "data/interior_extend_info.h" +#include "data/types.h" +#include "data/invoker.h" +#include "utils/export.h" + +#ifdef ALT_SERVER_API +#include +#elif ALT_CLIENT_API +#include "../client/src/runtime/CSharpResourceImpl.h" +#endif + +#ifdef __clang__ +#pragma clang diagnostic pop +#endif + +EXPORT_CLIENT uint16_t Interior_GetRoomCount(uint32_t interiorId); +EXPORT_CLIENT uint16_t Interior_GetPortalCount(uint32_t interiorId); +EXPORT_CLIENT alt::Position Interior_GetPosition(uint32_t interiorId); +EXPORT_CLIENT alt::Rotation Interior_GetRotation(uint32_t interiorId); +EXPORT_CLIENT void Interior_GetEntitiesExtents(uint32_t interiorId, interior_extend_info_t& extents); \ No newline at end of file diff --git a/c-api/interior_portal.cpp b/c-api/interior_portal.cpp new file mode 100644 index 0000000..d974639 --- /dev/null +++ b/c-api/interior_portal.cpp @@ -0,0 +1,106 @@ +#include "interior_portal.h" + +#include "cpp-sdk/script-objects/IInteriorPortal.h" +#include "utils/macros.h" + +CAPI_START() + +#ifdef ALT_CLIENT_API + +uint16_t InteriorPortal_GetCornerCount(uint32_t interiorId, uint32_t portalIndex) +{ + auto portal = GetInteriorPortal(interiorId, portalIndex); + return portal->GetCornerCount(); +} + +alt::Position InteriorPortal_GetCornerPosition(uint32_t interiorId, uint32_t portalIndex, uint32_t cornerIndex) +{ + auto portal = GetInteriorPortal(interiorId, portalIndex); + return portal->GetCornerPosition(cornerIndex); +} + +uint32_t InteriorPortal_GetRoomFrom(uint32_t interiorId, uint32_t portalIndex) +{ + auto portal = GetInteriorPortal(interiorId, portalIndex); + return portal->GetRoomFrom(); +} + +uint32_t InteriorPortal_GetRoomTo(uint32_t interiorId, uint32_t portalIndex) +{ + auto portal = GetInteriorPortal(interiorId, portalIndex); + return portal->GetRoomTo(); +} + +int32_t InteriorPortal_GetFlag(uint32_t interiorId, uint32_t portalIndex) +{ + auto portal = GetInteriorPortal(interiorId, portalIndex); + return portal->GetFlag(); +} + +uint16_t InteriorPortal_GetEntityCount(uint32_t interiorId, uint32_t portalIndex) +{ + auto portal = GetInteriorPortal(interiorId, portalIndex); + return portal->GetEntityCount(); +} + +uint32_t InteriorPortal_GetEntityArcheType(uint32_t interiorId, uint32_t portalIndex, uint32_t entityIndex) +{ + auto portal = GetInteriorPortal(interiorId, portalIndex); + return portal->GetEntityArcheType(entityIndex); +} + +int32_t InteriorPortal_GetEntityFlag(uint32_t interiorId, uint32_t portalIndex, uint32_t entityIndex) +{ + auto portal = GetInteriorPortal(interiorId, portalIndex); + return portal->GetEntityFlag(entityIndex); +} + +alt::Position InteriorPortal_GetEntityPosition(uint32_t interiorId, uint32_t portalIndex, uint32_t entityIndex) +{ + auto portal = GetInteriorPortal(interiorId, portalIndex); + return portal->GetEntityPosition(entityIndex); +} + +alt::Rotation InteriorPortal_GetEntityRotation(uint32_t interiorId, uint32_t portalIndex, uint32_t entityIndex) +{ + auto portal = GetInteriorPortal(interiorId, portalIndex); + return portal->GetEntityRotation(entityIndex); +} + +void InteriorPortal_SetCornerPosition(uint32_t interiorId, uint32_t portalIndex, uint32_t cornerIndex, + position_t position) +{ + auto portal = GetInteriorPortal(interiorId, portalIndex); + portal->SetCornerPosition(cornerIndex, alt::Position(position.x, position.y, position.z)); +} + +void InteriorPortal_SetRoomFrom(uint32_t interiorId, uint32_t portalIndex, uint32_t roomFrom) +{ + auto portal = GetInteriorPortal(interiorId, portalIndex); + portal->SetRoomFrom(roomFrom); +} + +void InteriorPortal_SetRoomTo(uint32_t interiorId, uint32_t portalIndex, uint32_t roomTo) +{ + auto portal = GetInteriorPortal(interiorId, portalIndex); + portal->SetRoomTo(roomTo); +} + +void InteriorPortal_SetFlag(uint32_t interiorId, uint32_t portalIndex, int32_t flag) +{ + auto portal = GetInteriorPortal(interiorId, portalIndex); + portal->SetFlag(flag); +} + +void InteriorPortal_SetEntityFlag(uint32_t interiorId, uint32_t portalIndex, uint32_t entityIndex, int32_t flag) +{ + auto portal = GetInteriorPortal(interiorId, portalIndex); + portal->SetEntityFlag(entityIndex, flag); +} + +std::shared_ptr GetInteriorPortal(uint32_t interiorId, uint32_t portalIndex) +{ + auto interior = alt::ICore::Instance().GetInterior(interiorId); + return interior->GetPortalByIndex(portalIndex); +} +#endif \ No newline at end of file diff --git a/c-api/interior_portal.h b/c-api/interior_portal.h new file mode 100644 index 0000000..b6e76f4 --- /dev/null +++ b/c-api/interior_portal.h @@ -0,0 +1,46 @@ +#pragma once + +#ifdef __clang__ +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wempty-body" +#pragma clang diagnostic ignored "-Wswitch" +#endif + +#include "cpp-sdk/SDK.h" +#include "data/interior_extend_info.h" +#include "data/types.h" +#include "data/invoker.h" +#include "utils/export.h" + +#ifdef ALT_SERVER_API +#include +#elif ALT_CLIENT_API +#include "../client/src/runtime/CSharpResourceImpl.h" +#endif + +#ifdef __clang__ +#pragma clang diagnostic pop +#endif + +EXPORT_CLIENT uint16_t InteriorPortal_GetCornerCount(uint32_t interiorId, uint32_t portalIndex); +EXPORT_CLIENT alt::Position InteriorPortal_GetCornerPosition(uint32_t interiorId, uint32_t portalIndex, uint32_t cornerIndex); +EXPORT_CLIENT uint32_t InteriorPortal_GetRoomFrom(uint32_t interiorId, uint32_t portalIndex); +EXPORT_CLIENT uint32_t InteriorPortal_GetRoomTo(uint32_t interiorId, uint32_t portalIndex); +EXPORT_CLIENT int32_t InteriorPortal_GetFlag(uint32_t interiorId, uint32_t portalIndex); + +EXPORT_CLIENT uint16_t InteriorPortal_GetEntityCount(uint32_t interiorId, uint32_t portalIndex); +EXPORT_CLIENT uint32_t InteriorPortal_GetEntityArcheType(uint32_t interiorId, uint32_t portalIndex, uint32_t entityIndex); +EXPORT_CLIENT int32_t InteriorPortal_GetEntityFlag(uint32_t interiorId, uint32_t portalIndex, uint32_t entityIndex); +EXPORT_CLIENT alt::Position InteriorPortal_GetEntityPosition(uint32_t interiorId, uint32_t portalIndex, uint32_t entityIndex); +EXPORT_CLIENT alt::Rotation InteriorPortal_GetEntityRotation(uint32_t interiorId, uint32_t portalIndex, uint32_t entityIndex); + + +EXPORT_CLIENT void InteriorPortal_SetCornerPosition(uint32_t interiorId, uint32_t portalIndex, uint32_t cornerIndex, position_t position); +EXPORT_CLIENT void InteriorPortal_SetRoomFrom(uint32_t interiorId, uint32_t portalIndex, uint32_t roomFrom); +EXPORT_CLIENT void InteriorPortal_SetRoomTo(uint32_t interiorId, uint32_t portalIndex, uint32_t roomTo); +EXPORT_CLIENT void InteriorPortal_SetFlag(uint32_t interiorId, uint32_t portalIndex, int32_t flag); +EXPORT_CLIENT void InteriorPortal_SetEntityFlag(uint32_t interiorId, uint32_t portalIndex, uint32_t entityIndex, int32_t flag); + +#ifdef ALT_CLIENT_API +std::shared_ptr GetInteriorPortal(uint32_t interiorId, uint32_t portalIndex); +#endif \ No newline at end of file diff --git a/c-api/interior_room.cpp b/c-api/interior_room.cpp new file mode 100644 index 0000000..43daee8 --- /dev/null +++ b/c-api/interior_room.cpp @@ -0,0 +1,80 @@ +#include "interior_room.h" + +#include "cpp-sdk/script-objects/IInteriorRoom.h" +#include "utils/macros.h" +#include "utils/strings.h" + +CAPI_START() + +#ifdef ALT_CLIENT_API +const char* InteriorRoom_GetName(uint32_t interiorId, uint32_t roomValue, uint8_t isIndex, int32_t& size) +{ + auto room = GetInteriorRoom(interiorId, roomValue, isIndex); + return AllocateString(room->GetName(), size); +} + +uint32_t InteriorRoom_GetNameHash(uint32_t interiorId, uint32_t roomValue, uint8_t isIndex) +{ + auto room = GetInteriorRoom(interiorId, roomValue, isIndex); + return room->GetNameHash(); +} + +int32_t InteriorRoom_GetFlag(uint32_t interiorId, uint32_t roomValue, uint8_t isIndex) +{ + auto room = GetInteriorRoom(interiorId, roomValue, isIndex); + return room->GetFlag(); +} + +uint32_t InteriorRoom_GetTimecycle(uint32_t interiorId, uint32_t roomValue, uint8_t isIndex) +{ + auto room = GetInteriorRoom(interiorId, roomValue, isIndex); + return room->GetTimecycle(); +} + +void InteriorRoom_GetExtents(uint32_t interiorId, uint32_t roomValue, uint8_t isIndex, + interior_extend_info_t& extents) +{ + auto room = GetInteriorRoom(interiorId, roomValue, isIndex); + auto ext = room->GetExtents(); + extents.min = ext.min; + extents.max = ext.max; +} + +void InteriorRoom_SetFlag(uint32_t interiorId, uint32_t roomValue, uint8_t isIndex, int32_t flag) +{ + auto room = GetInteriorRoom(interiorId, roomValue, isIndex); + room->SetFlag(flag); +} + +void InteriorRoom_SetTimecycle(uint32_t interiorId, uint32_t roomValue, uint8_t isIndex, uint32_t timecycle) +{ + auto room = GetInteriorRoom(interiorId, roomValue, isIndex); + room->SetTimecycle(timecycle); +} + +void InteriorRoom_SetEntitiesExtents(uint32_t interiorId, uint32_t roomValue, uint8_t isIndex, position_t min, + position_t max) +{ + auto room = GetInteriorRoom(interiorId, roomValue, isIndex); + alt::IInterior::ExtentInfo extentInfo; + extentInfo.min = alt::Position(min.x, min.y, min.z); + extentInfo.max = alt::Position(max.x, max.y, max.z); + room->SetExtents(extentInfo); +} + +std::shared_ptr GetInteriorRoom(uint32_t interiorId, uint32_t roomValue, uint8_t isIndex) +{ + auto interior = alt::ICore::Instance().GetInterior(interiorId); + std::shared_ptr room; + if (isIndex == 1) + { + room = interior->GetRoomByIndex(roomValue); + } + else + { + room = interior->GetRoomByHash(roomValue); + } + + return room; +} +#endif \ No newline at end of file diff --git a/c-api/interior_room.h b/c-api/interior_room.h new file mode 100644 index 0000000..83800b8 --- /dev/null +++ b/c-api/interior_room.h @@ -0,0 +1,39 @@ +#pragma once + +#ifdef __clang__ +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wempty-body" +#pragma clang diagnostic ignored "-Wswitch" +#endif + +#include "cpp-sdk/SDK.h" +#include "data/interior_extend_info.h" +#include "data/types.h" +#include "data/invoker.h" +#include "utils/export.h" + +#ifdef ALT_SERVER_API +#include +#elif ALT_CLIENT_API +#include "../client/src/runtime/CSharpResourceImpl.h" +#endif + +#ifdef __clang__ +#pragma clang diagnostic pop +#endif + +EXPORT_CLIENT const char* InteriorRoom_GetName(uint32_t interiorId, uint32_t roomValue, uint8_t isIndex, int32_t& size); +EXPORT_CLIENT uint32_t InteriorRoom_GetNameHash(uint32_t interiorId, uint32_t roomValue, uint8_t isIndex); +EXPORT_CLIENT int32_t InteriorRoom_GetFlag(uint32_t interiorId, uint32_t roomValue, uint8_t isIndex); +EXPORT_CLIENT uint32_t InteriorRoom_GetTimecycle(uint32_t interiorId, uint32_t roomValue, uint8_t isIndex); + +EXPORT_CLIENT void InteriorRoom_GetExtents(uint32_t interiorId, uint32_t roomValue, uint8_t isIndex, interior_extend_info_t& extents); + +EXPORT_CLIENT void InteriorRoom_SetFlag(uint32_t interiorId, uint32_t roomValue, uint8_t isIndex, int32_t flag); +EXPORT_CLIENT void InteriorRoom_SetTimecycle(uint32_t interiorId, uint32_t roomValue, uint8_t isIndex, uint32_t timecycle); +EXPORT_CLIENT void InteriorRoom_SetEntitiesExtents(uint32_t interiorId, uint32_t roomValue, uint8_t isIndex, position_t min, position_t max); + + +#ifdef ALT_CLIENT_API +std::shared_ptr GetInteriorRoom(uint32_t interiorId, uint32_t roomValue, uint8_t isIndex); +#endif \ No newline at end of file