|
1 | 1 | import { Modding } from "@flamework/core"; |
2 | | -import { Context } from "@rbxts/gamejoy"; |
3 | | -import { Action, Axis, Union } from "@rbxts/gamejoy/out/Actions"; |
4 | | -import { BaseAction } from "@rbxts/gamejoy/out/Class/BaseAction"; |
| 2 | +import { InputManager } from "@rbxts/mechanism"; |
| 3 | +import { BaseAction } from "@rbxts/mechanism/out/base-action"; |
5 | 4 | import { callMethodOnDependency } from "@rbxts/flamework-meta-utils"; |
6 | | -import type { ActionLike, ActionOptions, AxisActionEntry, RawActionEntry } from "@rbxts/gamejoy/out/Definitions/Types"; |
7 | 5 | import type { ClientReceiver as ClientEventReceiver } from "@flamework/networking/out/events/types"; |
8 | 6 | import type { ClientReceiver as ClientFunctionReceiver } from "@flamework/networking/out/functions/types"; |
9 | 7 | import type { Serializer } from "@rbxts/flamework-binary-serializer"; |
10 | 8 |
|
11 | 9 | import { FlameworkIgnited } from "shared/constants"; |
12 | 10 | import Log from "shared/log"; |
13 | 11 |
|
14 | | -const inputContext = new Context({ Process: false }); |
15 | | -const processedContext = new Context({ Process: true }); |
16 | | -export const inputActions: Record<string, BaseAction> = {}; |
| 12 | +const inputManager = new InputManager; |
17 | 13 |
|
18 | | -export const OnInput = Modding.createDecorator<[binding: (RawActionEntry | BaseAction) | (RawActionEntry | BaseAction)[], actionName?: string, process?: boolean, options?: ActionOptions]>( |
| 14 | +export const OnInput = Modding.createDecorator<[binding: BaseAction]>( |
19 | 15 | "Method", |
20 | | - (descriptor, [rawAction, actionName, process, options]) => { |
21 | | - const action: BaseAction = typeOf(rawAction) === "string" ? |
22 | | - new Action(<RawActionEntry>rawAction, options) |
23 | | - : rawAction instanceof BaseAction ? |
24 | | - rawAction |
25 | | - : new Union(<RawActionEntry[]>rawAction); |
26 | | - |
27 | | - if (action instanceof Union && options !== undefined) |
28 | | - Log.warn(`Action options given to @OnInput decorator on "${descriptor.property}" method were ignored because it is a union action`); |
29 | | - |
30 | | - if (actionName !== undefined) |
31 | | - inputActions[actionName] = action; |
32 | | - |
| 16 | + (descriptor, [action]) => { |
33 | 17 | FlameworkIgnited.Once(() => { |
34 | | - const context = process ? processedContext : inputContext; |
| 18 | + inputManager.bind(action) |
35 | 19 | context.Bind(<ActionLike<RawActionEntry>>action, () => { |
36 | 20 | const object = <Record<string, Callback>>Modding.resolveSingleton(descriptor.constructor!); |
37 | 21 | void task.spawn(object[descriptor.property], object, action); |
|
0 commit comments