-
Notifications
You must be signed in to change notification settings - Fork 0
/
modding_api.lua
71 lines (61 loc) · 2.58 KB
/
modding_api.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
local paks = {}
paks["YRPF"] = LoadPak("YRPF", "/YRPF/", "../../../OnsetModding/Plugins/YRPF/Content")
paks["Gang01"] = LoadPak("Gang01", "/Gang01/", "../../../OnsetModding/Plugins/Gang01/Content/")
paks["Gang02"] = LoadPak("Gang02", "/Gang02/", "../../../OnsetModding/Plugins/Gang02/Content/")
AddEvent("OnObjectStreamIn", function(object)
if GetObjectPropertyValue(object, "customModelPath") ~= nil then
UpdateCustomModel(object, GetObjectPropertyValue(object, "customModelPath"))
end
if GetObjectPropertyValue(object, "enablePhysic") ~= nil then
EnablePhysic(object, GetObjectPropertyValue(object, "enablePhysic"))
end
end)
AddRemoteEvent("Modding:AddCustomObject", function(id, path)
ReplaceObjectModelMesh(id, path)
end)
AddEvent("OnObjectNetworkUpdatePropertyValue", function(object, PropertyName, PropertyValue)
if PropertyName == "customModelPath" then
UpdateCustomModel(object, PropertyValue)
end
if PropertyName == "enablePhysic" then
EnablePhysic(object, PropertyValue)
end
end)
AddEvent("OnPickupStreamIn", function(pickup)
if GetPickupPropertyValue(pickup, "customModelPath") ~= nil then
UpdateCustomPickupModel(pickup, GetPickupPropertyValue(pickup, "customModelPath"))
end
end)
AddEvent("OnPickupNetworkUpdatePropertyValue", function(pickupId, PropertyName, PropertyValue)
if PropertyName == "customModelPath" then
UpdateCustomPickupModel(pickupId, PropertyValue)
end
end)
function EnablePhysic(object, state)
local SMC = GetObjectStaticMeshComponent(object)
local actor = GetObjectActor(object)
if state == 1 then
SMC:SetMobility(EComponentMobility.Movable)
SMC:SetCollisionEnabled(ECollisionEnabled.QueryAndPhysics)
SMC:SetSimulatePhysics(true)
SMC:SetEnableGravity(true)
SMC:SetPhysicsLinearVelocity(FVector(0,0,-100), false, "None")
else
SMC:IsSimulatingPhysics(false)
SMC:SetEnableGravity(false)
end
end
function UpdateCustomModel(object, modelPath)
local SMC = GetObjectStaticMeshComponent(object)
local mobility = SMC:GetMobility()
SMC:SetMobility(EComponentMobility.Movable)
SMC:SetStaticMesh(UStaticMesh.LoadFromAsset(modelPath))
SMC:SetMobility(mobility)
end
function UpdateCustomPickupModel(object, modelPath)
local SMC = GetPickupStaticMeshComponent(object)
local mobility = SMC:GetMobility()
SMC:SetMobility(EComponentMobility.Movable)
SMC:SetStaticMesh(UStaticMesh.LoadFromAsset(modelPath))
SMC:SetMobility(mobility)
end