@quenty/rigbuilderutils 6.1.0 → 6.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -3,6 +3,17 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ # [6.2.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/rigbuilderutils@6.1.0...@quenty/rigbuilderutils@6.2.0) (2023-02-21)
7
+
8
+
9
+ ### Features
10
+
11
+ * Add RigBuilderUtils.promiseBasePlayerRig ([80a6bfb](https://github.com/Quenty/NevermoreEngine/commit/80a6bfb8ae8af406c760f18aeba507ae17a3fecf))
12
+
13
+
14
+
15
+
16
+
6
17
  # [6.1.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/rigbuilderutils@6.0.1...@quenty/rigbuilderutils@6.1.0) (2022-12-06)
7
18
 
8
19
  **Note:** Version bump only for package @quenty/rigbuilderutils
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@quenty/rigbuilderutils",
3
- "version": "6.1.0",
3
+ "version": "6.2.0",
4
4
  "description": "Utility functions for debugging, builds a Roblox character rig",
5
5
  "keywords": [
6
6
  "Roblox",
@@ -26,17 +26,17 @@
26
26
  "Quenty"
27
27
  ],
28
28
  "dependencies": {
29
- "@quenty/humanoiddescriptionutils": "^6.0.1",
30
- "@quenty/insertserviceutils": "^6.0.1",
31
- "@quenty/loader": "^6.0.1",
32
- "@quenty/promise": "^6.0.1"
29
+ "@quenty/humanoiddescriptionutils": "^6.1.0",
30
+ "@quenty/insertserviceutils": "^6.1.0",
31
+ "@quenty/loader": "^6.1.0",
32
+ "@quenty/promise": "^6.1.0"
33
33
  },
34
34
  "devDependencies": {
35
- "@quenty/camerastoryutils": "^6.0.1",
35
+ "@quenty/camerastoryutils": "^6.1.0",
36
36
  "@quenty/maid": "^2.4.0"
37
37
  },
38
38
  "publishConfig": {
39
39
  "access": "public"
40
40
  },
41
- "gitHead": "d9b0d10faa443cc42a6c2ac966f2f56d124bbde5"
41
+ "gitHead": "e084b0cc097ddbcb7c782b8ecbd9c2d619c49354"
42
42
  }
@@ -5,8 +5,7 @@
5
5
 
6
6
  local require = require(script.Parent.loader).load(script)
7
7
 
8
- local ServerScriptService = game:GetService("ServerScriptService")
9
- local HttpService = game:GetService("HttpService")
8
+ local Players = game:GetService("Players")
10
9
 
11
10
  local InsertServiceUtils = require("InsertServiceUtils")
12
11
  local PromiseUtils = require("PromiseUtils")
@@ -447,42 +446,95 @@ function RigBuilderUtils.promiseR15MeshRig()
447
446
  end
448
447
 
449
448
  --[=[
450
- Creates an R15 rig dressed as a given player
449
+ Creates an R15 rig with the base details of a given character, but not all of them
451
450
  @param userId number
451
+ @param humanoidRigType HumanoidRigType | nil
452
+ @param assetTypeVerification AssetTypeVerification | nil
452
453
  @return Promise<Instance>
453
454
  ]=]
454
- function RigBuilderUtils.promisePlayerRig(userId)
455
+ function RigBuilderUtils.promiseBasePlayerRig(userId, humanoidRigType, assetTypeVerification)
455
456
  assert(type(userId) == "number", "Bad userId")
457
+ assert(typeof(humanoidRigType) == "EnumItem" or humanoidRigType == nil, "Bad humanoidRigType")
458
+ assert(typeof(assetTypeVerification) == "EnumItem" or assetTypeVerification == nil, "Bad assetTypeVerification")
459
+
460
+ return HumanoidDescriptionUtils.promiseFromUserId(userId)
461
+ :Then(function(playerHumanoidDescription)
462
+ -- Wipe accessories
463
+ local humanoidDescription = playerHumanoidDescription:Clone()
464
+ humanoidDescription.BackAccessory = ""
465
+ humanoidDescription.FaceAccessory = ""
466
+ humanoidDescription.FrontAccessory = ""
467
+ humanoidDescription.HairAccessory = ""
468
+ humanoidDescription.HatAccessory = ""
469
+ humanoidDescription.NeckAccessory = ""
470
+ humanoidDescription.ShouldersAccessory = ""
471
+ humanoidDescription.WaistAccessory = ""
472
+ humanoidDescription.GraphicTShirt = 0
473
+ humanoidDescription.Shirt = 0
474
+ humanoidDescription.Pants = 0
475
+ humanoidDescription:SetAccessories({}, true)
476
+
477
+ return RigBuilderUtils.promiseHumanoidModelFromDescription(humanoidDescription, humanoidRigType, assetTypeVerification)
478
+ end)
479
+ end
480
+
481
+ function RigBuilderUtils.promiseHumanoidModelFromDescription(description, rigType, assetTypeVerification)
482
+ assert(typeof(description) == "Instance" and description:IsA("HumanoidDescription"), "Bad description")
483
+ assert(typeof(rigType) == "EnumItem" or rigType == nil, "Bad rigType")
484
+ assert(typeof(assetTypeVerification) == "EnumItem" or assetTypeVerification == nil, "Bad assetTypeVerification")
485
+
486
+ return Promise.spawn(function(resolve, reject)
487
+ local model = nil
488
+ local ok, err = pcall(function()
489
+ model = Players:CreateHumanoidModelFromDescription(
490
+ description,
491
+ rigType or Enum.HumanoidRigType.R15,
492
+ assetTypeVerification or Enum.AssetTypeVerification.Default)
493
+ end)
494
+ if not ok then
495
+ return reject(err or "Failed to create model")
496
+ end
497
+ if typeof(model) ~= "Instance" then
498
+ return reject("Bad model result type")
499
+ end
500
+
501
+ return resolve(model)
502
+ end)
503
+ end
456
504
 
457
- return PromiseUtils.all({
458
- RigBuilderUtils.promiseR15Rig(),
459
- HumanoidDescriptionUtils.promiseFromUserId(userId)
460
- }):Then(function(meshRig, humanoidDescription)
461
- local humanoid = meshRig:FindFirstChildWhichIsA("Humanoid")
462
- if not humanoid then
463
- return Promise.rejected("No humanoid from rig builder")
505
+ function RigBuilderUtils.promiseHumanoidModelFromUserId(userId, rigType, assetTypeVerification)
506
+ assert(type(userId) == "number", "Bad userId")
507
+ assert(typeof(rigType) == "EnumItem" or rigType == nil, "Bad rigType")
508
+ assert(typeof(assetTypeVerification) == "EnumItem" or assetTypeVerification == nil, "Bad assetTypeVerification")
509
+
510
+ return Promise.spawn(function(resolve, reject)
511
+ local model = nil
512
+ local ok, err = pcall(function()
513
+ model = Players:CreateHumanoidModelFromUserId(
514
+ userId,
515
+ rigType or Enum.HumanoidRigType.R15,
516
+ assetTypeVerification or Enum.AssetTypeVerification.Default)
517
+ end)
518
+ if not ok then
519
+ return reject(err or "Failed to create model")
520
+ end
521
+ if typeof(model) ~= "Instance" then
522
+ return reject("Bad model result type")
464
523
  end
465
524
 
466
- meshRig.Archivable = false
467
- local originalName = meshRig.Name
468
-
469
- -- Hack! Apparently we need to parent this to the datamodel to apply the description
470
- meshRig.Name = "RigBuilderUtils_LoadingHumanoid_" .. HttpService:GenerateGUID(false)
471
- meshRig.Parent = ServerScriptService -- somewhere that does not replicate
472
-
473
- return HumanoidDescriptionUtils.promiseApplyDescription(humanoid, humanoidDescription)
474
- :Then(function()
475
- meshRig.Parent = nil
476
- meshRig.Archivable = true
477
- meshRig.Name = originalName
478
-
479
- return meshRig
480
- end, function(...)
481
- -- cleanup
482
- meshRig:Destroy()
483
- return Promise.rejected(...)
484
- end)
525
+ return resolve(model)
485
526
  end)
486
527
  end
487
528
 
529
+ --[=[
530
+ Creates an R15 rig dressed as a given player
531
+ @param userId number
532
+ @return Promise<Instance>
533
+ ]=]
534
+ function RigBuilderUtils.promisePlayerRig(userId)
535
+ assert(type(userId) == "number", "Bad userId")
536
+
537
+ return RigBuilderUtils.promiseHumanoidModelFromUserId(userId)
538
+ end
539
+
488
540
  return RigBuilderUtils