fix resetting, add comments
This commit is contained in:
parent
e7acbd72fa
commit
a8b217d45e
6 changed files with 46 additions and 4 deletions
18
src/ReplicatedStorage/ecs/systems/client/customReset.ts
Normal file
18
src/ReplicatedStorage/ecs/systems/client/customReset.ts
Normal file
|
@ -0,0 +1,18 @@
|
|||
import { World, useEvent } from "@rbxts/matter"
|
||||
import { StarterGui } from "@rbxts/services"
|
||||
import { clientState } from "ReplicatedStorage/ecs/state"
|
||||
import { getEvent } from "ReplicatedStorage/remotes"
|
||||
|
||||
const resetButtonCallback = new Instance("BindableEvent")
|
||||
StarterGui.SetCore("ResetButtonCallback", resetButtonCallback)
|
||||
|
||||
getEvent("resetButton")
|
||||
|
||||
function customReset(_: World, _client: clientState): void {
|
||||
const resetButtonEvent = getEvent("resetButton")
|
||||
for (const [,] of useEvent(resetButtonCallback, "Event")) {
|
||||
resetButtonEvent.FireServer()
|
||||
}
|
||||
}
|
||||
|
||||
export = customReset
|
23
src/ServerScriptService/ecs/systems/server/customReset.ts
Normal file
23
src/ServerScriptService/ecs/systems/server/customReset.ts
Normal file
|
@ -0,0 +1,23 @@
|
|||
import { World, useEvent } from "@rbxts/matter"
|
||||
import { Health, Model, PlayerCharacter } from "ReplicatedStorage/ecs/components"
|
||||
import { getEvent } from "ReplicatedStorage/remotes"
|
||||
|
||||
getEvent("resetButton")
|
||||
|
||||
function customReset(world: World): void {
|
||||
const resetButtonEvent = getEvent("resetButton")
|
||||
for (const [, player] of useEvent(resetButtonEvent, "OnServerEvent")) {
|
||||
for (const [id, playerCharacter, _model, health] of world.query(PlayerCharacter, Model, Health)) {
|
||||
if (playerCharacter.player !== player) continue
|
||||
world.insert(
|
||||
id,
|
||||
health.patch({
|
||||
health: 0,
|
||||
regeneration: 0
|
||||
})
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export = customReset
|
|
@ -2,7 +2,7 @@ import { useThrottle, World } from "@rbxts/matter"
|
|||
import { Health } from "ReplicatedStorage/ecs/components"
|
||||
|
||||
/**
|
||||
* @todo
|
||||
* Health components regenerate health based on the regeneration value.
|
||||
*/
|
||||
function healthRegenerates(world: World): void {
|
||||
for (const [id, health] of world.query(Health)) {
|
||||
|
|
|
@ -4,7 +4,7 @@ import { Health, Model, PlayerCharacter } from "ReplicatedStorage/ecs/components
|
|||
import { CharacterRigR6 } from "@rbxts/character-promise"
|
||||
|
||||
/**
|
||||
* @todo
|
||||
* Player characters are marked with the "PlayerCharacter" component, "Health" component, and "Model" component.
|
||||
*/
|
||||
function playersArePlayerCharacters(world: World): void {
|
||||
Players.GetPlayers().forEach((player, _) => {
|
||||
|
|
|
@ -2,7 +2,9 @@ import { World, useEvent } from "@rbxts/matter"
|
|||
import { Model, PlayerCharacter } from "ReplicatedStorage/ecs/components"
|
||||
|
||||
/**
|
||||
* @todo
|
||||
* When players die, disconnect all Motor6D instances.
|
||||
*
|
||||
* The Motor6D instances are replaced with BallSocketContraints.
|
||||
*/
|
||||
function playersRagdollOnDeath(world: World): void {
|
||||
for (const [_, playerCharacter, model] of world.query(PlayerCharacter, Model)) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue