improve basic tool system
This commit is contained in:
parent
3458a6e29b
commit
abfeb2982c
2 changed files with 22 additions and 13 deletions
|
@ -1,20 +1,17 @@
|
|||
import { World, useEvent } from "@rbxts/matter"
|
||||
import { Players } from "@rbxts/services"
|
||||
import { PlayerCharacter } from "ReplicatedStorage/ecs/components"
|
||||
import { getEvent } from "ReplicatedStorage/remotes"
|
||||
|
||||
function toolHandler(world: World): void {
|
||||
const activateToolEvent = getEvent("activateToolEvent")
|
||||
const equipToolEvent = getEvent("equipToolEvent")
|
||||
|
||||
for (const [_, character] of world.query(PlayerCharacter)) {
|
||||
if (!character.equippedTool) continue
|
||||
|
||||
for (const [_] of useEvent(character.equippedTool, "Activated")) {
|
||||
activateToolEvent.FireServer()
|
||||
}
|
||||
|
||||
for (const [_, mouse] of useEvent(character.equippedTool, "Equipped")) {
|
||||
equipToolEvent.FireServer(mouse)
|
||||
print(Players.LocalPlayer.GetMouse())
|
||||
activateToolEvent.FireServer(Players.LocalPlayer.GetMouse().Hit.Position)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue