first commit

This commit is contained in:
Reid 2023-07-18 22:22:52 -07:00
commit 5302ecc6cc
43 changed files with 2530 additions and 0 deletions

View file

@ -0,0 +1,41 @@
import { World, useEvent } from "@rbxts/matter"
import { Model, PlayerCharacter } from "ReplicatedStorage/ecs/components"
/**
* @todo
*/
function playersRagdollOnDeath(world: World): void {
for (const [_, playerCharacter, model] of world.query(PlayerCharacter, Model)) {
if (!model.model) continue
playerCharacter.humanoid.BreakJointsOnDeath = false
for (const [_] of useEvent(playerCharacter.humanoid, "Died")) {
model.model.GetDescendants().forEach((v, _) => {
if (v.IsA("Motor6D")) {
const attachment0 = new Instance("Attachment")
const attachment1 = new Instance("Attachment")
attachment0.CFrame = v.C0
attachment1.CFrame = v.C1
attachment0.Parent = v.Part0
attachment1.Parent = v.Part1
const ballSocketConstraint = new Instance("BallSocketConstraint")
ballSocketConstraint.Attachment0 = attachment0
ballSocketConstraint.Attachment1 = attachment1
ballSocketConstraint.LimitsEnabled = true
ballSocketConstraint.TwistLimitsEnabled = true
ballSocketConstraint.Parent = v.Parent
v.Destroy()
}
})
}
}
for (const [id] of world.query(PlayerCharacter).without(Model)) {
world.despawn(id)
}
}
export = playersRagdollOnDeath