diff --git a/package.json b/package.json index 4fef381..f637509 100644 --- a/package.json +++ b/package.json @@ -33,6 +33,7 @@ }, "dependencies": { "@rbxts/character-promise": "^1.0.2", + "@rbxts/flipper": "^2.0.1", "@rbxts/log": "^0.6.3", "@rbxts/make": "^1.0.6", "@rbxts/matter": "^0.6.2-ts.6", @@ -41,6 +42,7 @@ "@rbxts/rewire": "^0.3.0", "@rbxts/roact": "^1.4.4-ts.0", "@rbxts/roact-hooked": "^2.6.0", + "@rbxts/roact-hooked-plus": "^1.8.1", "@rbxts/roact-reflex": "^2.1.0", "@rbxts/services": "^1.5.1", "@rbxts/testez": "^0.4.2-ts.0", diff --git a/src/ReplicatedStorage/ui/components/acrylic/index.tsx b/src/ReplicatedStorage/ui/components/acrylic/index.tsx index e59eaa1..82cd98d 100644 --- a/src/ReplicatedStorage/ui/components/acrylic/index.tsx +++ b/src/ReplicatedStorage/ui/components/acrylic/index.tsx @@ -27,6 +27,13 @@ interface acrylicProps extends Roact.JsxInstanceProperties { Change?: Roact.JsxInstanceChangeEvents } +Make("DepthOfFieldEffect", { + FarIntensity: 0, + InFocusRadius: 0.1, + NearIntensity: 1, + Parent: Lighting +}) + function acrylic(props: acrylicProps): Roact.Element { const { radius, distance } = props @@ -123,13 +130,6 @@ function acrylic(props: acrylicProps): Roact.Element { const fovHandle = Workspace.CurrentCamera!.GetPropertyChangedSignal("FieldOfView").Connect(updateInstance) const viewportHandle = Workspace.CurrentCamera!.GetPropertyChangedSignal("ViewportSize").Connect(updateInstance) - Make("DepthOfFieldEffect", { - FarIntensity: 0, - InFocusRadius: 0.1, - NearIntensity: 1, - Parent: Lighting - }) - return () => { posHandle.Disconnect() fovHandle.Disconnect() diff --git a/src/StarterPlayer/StarterPlayerScripts/main.client.ts b/src/StarterPlayer/StarterPlayerScripts/main.client.ts index 6c03ce1..31125c1 100644 --- a/src/StarterPlayer/StarterPlayerScripts/main.client.ts +++ b/src/StarterPlayer/StarterPlayerScripts/main.client.ts @@ -1,6 +1,6 @@ import { CharacterRigR6 } from "@rbxts/character-promise" import Log, { Logger } from "@rbxts/log" -import { Players, Workspace } from "@rbxts/services" +import { Players } from "@rbxts/services" import { start } from "ReplicatedStorage/ecs" import { ClientState } from "ReplicatedStorage/ecs/state" import { Host } from "ReplicatedStorage/hosts" @@ -25,8 +25,4 @@ const clientState = new ClientState( const worldAndClientState = start(HOST, clientState) showGUI(worldAndClientState[0], clientState) -setEnvironment(HOST) - -task.delay(10, () => { - print(Workspace.CurrentCamera?.GetChildren()) -}) \ No newline at end of file +setEnvironment(HOST) \ No newline at end of file diff --git a/src/StarterPlayer/StarterPlayerScripts/ui/hotbar/slot.tsx b/src/StarterPlayer/StarterPlayerScripts/ui/hotbar/slot.tsx index 1fe0ad8..27f718b 100644 --- a/src/StarterPlayer/StarterPlayerScripts/ui/hotbar/slot.tsx +++ b/src/StarterPlayer/StarterPlayerScripts/ui/hotbar/slot.tsx @@ -4,6 +4,8 @@ import { useWorldContext } from "../contexts/worldContext" import { ContextActionService, HttpService } from "@rbxts/services" import Padding from "ReplicatedStorage/ui/components/padding" import Acrylic from "ReplicatedStorage/ui/components/acrylic" +import { Spring } from "@rbxts/flipper" +import { useGroupMotor } from "@rbxts/roact-hooked-plus" interface SlotProps extends Roact.JsxInstanceProperties { index: number @@ -14,6 +16,9 @@ interface SlotProps extends Roact.JsxInstanceProperties { Change?: Roact.JsxInstanceChangeEvents } +const SLOT_DEFAULT = [new Spring(.7, { frequency: 6 }), new Spring(6, { frequency: 6 })] +const SLOT_ACTIVE = [new Spring(.5, { frequency: 6 }), new Spring(5, { frequency: 6 })] + function slot(props: SlotProps): Roact.Element { const { index, keycode, tool } = props @@ -22,13 +27,19 @@ function slot(props: SlotProps): Roact.Element { delete spreadableProps.keycode delete spreadableProps.tool + const [slotBgTransparencyAndSlotRatio, setSlotGoal] = useGroupMotor([.7, 6]) + const slotBgTransparency = slotBgTransparencyAndSlotRatio.map((t) => t[0]) + const slotRatio = slotBgTransparencyAndSlotRatio.map((t) => t[1]) + const { clientState } = useWorldContext() const handleActivated = (): void => { if (tool.Parent !== clientState.character) { clientState.character.Humanoid.EquipTool(tool) + setSlotGoal(SLOT_ACTIVE) } else { clientState.character.Humanoid.UnequipTools() + setSlotGoal(SLOT_DEFAULT) } } @@ -43,25 +54,27 @@ function slot(props: SlotProps): Roact.Element { false, keycode ) + + tool.Unequipped.Connect(() => { + setSlotGoal(SLOT_DEFAULT) + }) }) return (