Skip to content

Commit

Permalink
shared: Add streaming stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
xLuxy committed Oct 1, 2023
1 parent 69a3483 commit 86ea6eb
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 3 deletions.
1 change: 1 addition & 0 deletions server/src/classes/Entity.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@ extern js::Class entityClass("Entity", &sharedEntityClass, nullptr, [](js::Class
tpl.Property<&alt::IEntity::GetVisible, &alt::IEntity::SetVisible>("visible");
tpl.Property<&alt::IEntity::GetStreamed, &alt::IEntity::SetStreamed>("streamed");
tpl.Property<&alt::IEntity::HasCollision, &alt::IEntity::SetCollision>("collision");
tpl.Property<&alt::IEntity::GetStreamingDistance, &alt::IEntity::SetStreamingDistance>("streamingDistance");
tpl.Property<&alt::IEntity::GetTimestamp>("timestamp");

tpl.DynamicProperty("syncedMeta", nullptr, SyncedMetaSetter, SyncedMetaDeleter, nullptr);
Expand Down
4 changes: 3 additions & 1 deletion server/src/factories/ObjectFactory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,7 @@ static js::FactoryHandler objectFactory(alt::IBaseObject::Type::OBJECT, [](js::O
uint8_t alpha = args.Get<uint8_t>("alpha", 255);
uint8_t textureVariation = args.Get<uint8_t>("textureVariation", 0);
uint16_t lodDistance = args.Get<uint16_t>("lodDistance", 100);
return alt::ICore::Instance().CreateObject(model, pos, rot, alpha, textureVariation, lodDistance);
uint32_t streamingDistance = args.Get<uint32_t>("streamingDistance", 0);

return alt::ICore::Instance().CreateObject(model, pos, rot, alpha, textureVariation, lodDistance, streamingDistance);
});
4 changes: 3 additions & 1 deletion server/src/factories/PedFactory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,7 @@ static js::FactoryHandler pedFactory(alt::IBaseObject::Type::PED, [](js::Object&
alt::Vector3f pos;
if(!args.Get("pos", pos)) return nullptr;
float heading = args.Get<float>("heading");
return alt::ICore::Instance().CreatePed(model, pos, { 0, 0, heading });
uint32_t streamingDistance = args.Get<uint32_t>("streamingDistance", 0);

return alt::ICore::Instance().CreatePed(model, pos, { 0, 0, heading }, streamingDistance);
});
4 changes: 3 additions & 1 deletion server/src/factories/VehicleFactory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,7 @@ static js::FactoryHandler vehicleFactory(alt::IBaseObject::Type::VEHICLE, [](js:
alt::Vector3f pos;
if(!args.Get("pos", pos)) return nullptr;
alt::Vector3f rot = args.Get<alt::Vector3f>("rot");
return alt::ICore::Instance().CreateVehicle(model, pos, rot);
uint32_t streamingDistance = args.Get<uint32_t>("streamingDistance", 0);

return alt::ICore::Instance().CreateVehicle(model, pos, rot, streamingDistance);
});
4 changes: 4 additions & 0 deletions types/server/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,7 @@ declare module "@altv/server" {
streamed: boolean;
frozen: boolean;
collision: boolean;
streamingDistance: number;
readonly timestamp: number;

readonly meta: EntityMeta;
Expand Down Expand Up @@ -271,6 +272,7 @@ declare module "@altv/server" {
alpha?: number; // default: 255
textureVariation?: number; // default: 0
lodDistance?: number; // default: 100
streamingDistance?: number; // default: 0
}

export abstract class Object extends Entity {
Expand All @@ -297,6 +299,7 @@ declare module "@altv/server" {
model: number | string;
pos: altShared.IVector3;
heading: number;
streamingDistance?: number; // default: 0
}

export abstract class Ped extends Entity {
Expand Down Expand Up @@ -495,6 +498,7 @@ declare module "@altv/server" {
model: number | string;
pos: altShared.IVector3;
rot?: altShared.IVector3; // default: { x: 0, y: 0, z: 0 }
streamingDistance?: number; // default: 0
}

export abstract class Vehicle extends Entity {
Expand Down

0 comments on commit 86ea6eb

Please sign in to comment.