first commit
This commit is contained in:
commit
5302ecc6cc
43 changed files with 2530 additions and 0 deletions
|
@ -0,0 +1,33 @@
|
|||
import { Players } from "@rbxts/services"
|
||||
import { World, useEvent } from "@rbxts/matter"
|
||||
import { Health, Model, PlayerCharacter } from "ReplicatedStorage/ecs/components"
|
||||
|
||||
/**
|
||||
* @todo
|
||||
*/
|
||||
function playersArePlayerCharacters(world: World): void {
|
||||
Players.GetPlayers().forEach((player, _) => {
|
||||
for (const [_, character] of useEvent(player, "CharacterAdded")) {
|
||||
world.spawn(
|
||||
Model({
|
||||
model: character
|
||||
}),
|
||||
PlayerCharacter({
|
||||
player: Players.GetPlayerFromCharacter(character) as Player,
|
||||
humanoid: character.WaitForChild("Humanoid") as Humanoid
|
||||
}),
|
||||
Health({
|
||||
health: 80,
|
||||
maxHealth: 100,
|
||||
regeneration: 0.25
|
||||
})
|
||||
)
|
||||
}
|
||||
})
|
||||
|
||||
for (const [id] of world.query(PlayerCharacter).without(Model)) {
|
||||
world.despawn(id)
|
||||
}
|
||||
}
|
||||
|
||||
export = playersArePlayerCharacters
|
Loading…
Add table
Add a link
Reference in a new issue