Skip to content

Commit dbdf738

Browse files
committed
ALTV-673 | New entity apis
1 parent b5233f2 commit dbdf738

File tree

1 file changed

+41
-1
lines changed

1 file changed

+41
-1
lines changed

shared/bindings/Entity.cpp

+41-1
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,40 @@ static void GetSyncInfo(const v8::FunctionCallbackInfo<v8::Value>& info)
261261
result->Set(ctx, v8::String::NewFromUtf8(isolate, "propertyUpdateTicks").ToLocalChecked(), componentPropertyIndex);
262262

263263
V8_RETURN(result);
264+
}
265+
266+
static void AngInertiaGetter(v8::Local<v8::String>, const v8::PropertyCallbackInfo<v8::Value>& info)
267+
{
268+
V8_GET_ISOLATE_CONTEXT_RESOURCE();
269+
V8_GET_THIS_BASE_OBJECT(_this, alt::IEntity);
270+
271+
V8_RETURN_VECTOR3(_this->GetAngInertia());
272+
}
273+
274+
static void AngInertiaSetter(v8::Local<v8::String>, v8::Local<v8::Value> val, const v8::PropertyCallbackInfo<void>& info)
275+
{
276+
V8_GET_ISOLATE_CONTEXT();
277+
V8_GET_THIS_BASE_OBJECT(_this, alt::IEntity);
278+
279+
V8_TO_VECTOR3(val, vector);
280+
281+
_this->SetAngInertia(vector);
282+
}
283+
284+
static void ResetMass(const v8::FunctionCallbackInfo<v8::Value>& info)
285+
{
286+
V8_GET_ISOLATE_CONTEXT();
287+
V8_GET_THIS_BASE_OBJECT(_this, alt::IEntity);
288+
289+
_this->ResetMass();
290+
}
291+
292+
static void ResetAngInertia(const v8::FunctionCallbackInfo<v8::Value>& info)
293+
{
294+
V8_GET_ISOLATE_CONTEXT();
295+
V8_GET_THIS_BASE_OBJECT(_this, alt::IEntity);
296+
297+
_this->ResetAngInertia();
264298
}
265299

266300
static void StaticGetByScriptID(const v8::FunctionCallbackInfo<v8::Value>& info)
@@ -334,7 +368,13 @@ extern V8Class v8Entity("Entity",
334368
V8Helpers::SetAccessor(isolate, tpl, "rot", &RotationGetter, &RotationSetter);
335369
V8Helpers::SetAccessor<IEntity, uint32_t, &IEntity::GetModel>(isolate, tpl, "model");
336370
V8Helpers::SetAccessor<IEntity, uint32_t, &IEntity::GetScriptID>(isolate, tpl, "scriptID");
337-
V8Helpers::SetAccessor<IEntity, bool, &IEntity::GetVisible>(isolate, tpl, "visible");
371+
V8Helpers::SetAccessor<IEntity, bool, &IEntity::GetVisible>(isolate, tpl, "visible");
372+
373+
V8Helpers::SetAccessor<IEntity, float, &IEntity::GetMass, &IEntity::SetMass>(isolate, tpl, "mass");
374+
V8Helpers::SetMethod(isolate, tpl, "resetMass", &ResetMass);
375+
376+
V8Helpers::SetAccessor(isolate, tpl, "angularInertia", &AngInertiaGetter, &AngInertiaSetter);
377+
V8Helpers::SetMethod(isolate, tpl, "resetAngularInertia", &ResetAngInertia);
338378

339379
V8Helpers::SetAccessor(isolate, tpl, "isSpawned", &IsSpawnedGetter);
340380
V8Helpers::SetMethod(isolate, tpl, "getSyncInfo", &GetSyncInfo);

0 commit comments

Comments
 (0)