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,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