basic tool handling
This commit is contained in:
parent
3b327ea260
commit
29541f3dc5
6 changed files with 90 additions and 2 deletions
|
@ -51,7 +51,8 @@ export interface Damage {
|
|||
export interface PlayerCharacter {
|
||||
character: CharacterRigR6,
|
||||
humanoid: Humanoid,
|
||||
player: Player
|
||||
player: Player,
|
||||
equippedTool?: Tool
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -14,6 +14,7 @@ export class ClientState {
|
|||
debugEnabled: boolean,
|
||||
isRunning: boolean,
|
||||
backpack: Backpack,
|
||||
// equippedTool: Tool,
|
||||
// lastProcessedCommand: Inputkind,
|
||||
|
||||
logger: Logger
|
||||
|
@ -23,6 +24,7 @@ export class ClientState {
|
|||
this.debugEnabled = debugEnabled
|
||||
this.isRunning = isRunning
|
||||
this.backpack = backpack
|
||||
// this.equippedTool = equippedTool
|
||||
// this.lastProcessedCommand = lastProcessedCommand
|
||||
|
||||
this.logger = logger
|
||||
|
@ -33,6 +35,8 @@ export class ClientState {
|
|||
debugEnabled: boolean
|
||||
isRunning: boolean
|
||||
backpack: Backpack
|
||||
|
||||
equippedTool?: Tool
|
||||
lastProcessedCommand?: InputKind
|
||||
|
||||
logger: Logger
|
||||
|
|
22
src/ReplicatedStorage/ecs/systems/client/toolHandler.ts
Normal file
22
src/ReplicatedStorage/ecs/systems/client/toolHandler.ts
Normal file
|
@ -0,0 +1,22 @@
|
|||
import { World, useEvent } from "@rbxts/matter"
|
||||
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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export = toolHandler
|
Loading…
Add table
Add a link
Reference in a new issue