diff --git a/src/ReplicatedStorage/ecs/components/types.d.ts b/src/ReplicatedStorage/ecs/components/types.d.ts index 31d724c..106b881 100644 --- a/src/ReplicatedStorage/ecs/components/types.d.ts +++ b/src/ReplicatedStorage/ecs/components/types.d.ts @@ -51,8 +51,7 @@ export interface Damage { export interface PlayerCharacter { character: CharacterRigR6, humanoid: Humanoid, - player: Player, - equippedTool?: Tool + player: Player } /** diff --git a/src/ReplicatedStorage/ecs/state.ts b/src/ReplicatedStorage/ecs/state.ts index a182ffa..f1a4d21 100644 --- a/src/ReplicatedStorage/ecs/state.ts +++ b/src/ReplicatedStorage/ecs/state.ts @@ -14,7 +14,6 @@ export class ClientState { debugEnabled: boolean, isRunning: boolean, backpack: Backpack, - // equippedTool: Tool, // lastProcessedCommand: Inputkind, logger: Logger @@ -24,7 +23,6 @@ export class ClientState { this.debugEnabled = debugEnabled this.isRunning = isRunning this.backpack = backpack - // this.equippedTool = equippedTool // this.lastProcessedCommand = lastProcessedCommand this.logger = logger @@ -35,7 +33,6 @@ export class ClientState { debugEnabled: boolean isRunning: boolean backpack: Backpack - lastProcessedCommand?: InputKind logger: Logger diff --git a/src/ReplicatedStorage/ecs/systems/client/toolHandler.ts b/src/ReplicatedStorage/ecs/systems/client/toolHandler.ts deleted file mode 100644 index 305fcd8..0000000 --- a/src/ReplicatedStorage/ecs/systems/client/toolHandler.ts +++ /dev/null @@ -1,22 +0,0 @@ -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 \ No newline at end of file diff --git a/src/ServerScriptService/ecs/systems/server/playerCharacterToolIsTool.ts b/src/ServerScriptService/ecs/systems/server/playerCharacterToolIsTool.ts deleted file mode 100644 index 29eccb2..0000000 --- a/src/ServerScriptService/ecs/systems/server/playerCharacterToolIsTool.ts +++ /dev/null @@ -1,37 +0,0 @@ -import { None, useEvent, World } from "@rbxts/matter" -import { PlayerCharacter } from "ReplicatedStorage/ecs/components" - -/** - * Equipped tool is replicated into the ECS. - */ -function playerCharacterToolIsTool(world: World): void { - for (const [id, character] of world.query(PlayerCharacter)) { - for (const [_, toolInstance] of useEvent(character.character, "ChildAdded")) { - if (!classIs(toolInstance, "Tool")) continue - - world.insert( - id, - character.patch({ - equippedTool: toolInstance - }) - ) - } - - for (const [_, toolInstance] of useEvent(character.character, "ChildRemoved")) { - // classIs more like classWas - if (!classIs(toolInstance, "Tool")) continue - - // could also be swapping tools - const swappedTool = character.character.FindFirstChildOfClass("Tool") - - world.insert( - id, - character.patch({ - equippedTool: swappedTool ? swappedTool : None - }) - ) - } - } -} - -export = playerCharacterToolIsTool \ No newline at end of file diff --git a/src/ServerScriptService/ecs/systems/server/replication.ts b/src/ServerScriptService/ecs/systems/server/replication.ts index 2736cd8..08bdb15 100644 --- a/src/ServerScriptService/ecs/systems/server/replication.ts +++ b/src/ServerScriptService/ecs/systems/server/replication.ts @@ -9,8 +9,7 @@ type ComponentConstructor = (typeof Components)[ComponentName] const REPLICATED_COMPONENT_NAMES: readonly ComponentName[] = [ "Model", - "Transform", - "PlayerCharacter" + "Transform" ] const replicatedComponents: ReadonlySet = REPLICATED_COMPONENT_NAMES.reduce( diff --git a/src/ServerScriptService/ecs/systems/server/toolHandler.ts b/src/ServerScriptService/ecs/systems/server/toolHandler.ts deleted file mode 100644 index 7ec6803..0000000 --- a/src/ServerScriptService/ecs/systems/server/toolHandler.ts +++ /dev/null @@ -1,23 +0,0 @@ -import { World, useEvent } from "@rbxts/matter" -import { PlayerCharacter } from "ReplicatedStorage/ecs/components" -import { ServerState } from "ReplicatedStorage/ecs/state" -import { getEvent } from "ReplicatedStorage/remotes" - -function toolHandler(world: World, state: ServerState): void { - const activateToolEvent = getEvent("activateToolEvent") - const equipToolEvent = getEvent("equipToolEvent") - - for (const [_, character] of world.query(PlayerCharacter)) { - for (const [_, player] of useEvent(activateToolEvent, "OnServerEvent")) { - state.logger.Info("{@player} activated the tool {@tool}", player, character.equippedTool) - if (character.player !== player) continue - } - - for (const [_, player] of useEvent(equipToolEvent, "OnServerEvent")) { - state.logger.Info("{@player} equipped the tool {@tool}", player, character.equippedTool) - if (character.player !== player) continue - } - } -} - -export = toolHandler \ No newline at end of file