Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

users/quenty/datastore #402

Merged
merged 67 commits into from
Aug 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
67 commits
Select commit Hold shift + click to select a range
66c75d0
feat: Add jitter randomValue to control randomness computation
Quenty Aug 2, 2023
d627fa0
feat: Unfinished datastore changes
Quenty Aug 2, 2023
2401559
refactor: Start with syncing refactor but no merging yet
Quenty Aug 12, 2023
fa39e53
feat: ObservableMap uses subscription table
Quenty Aug 12, 2023
5224e43
chore: Upgrade aftman
Quenty Aug 14, 2023
276909d
feat: More untested datastore syncing code
Quenty Aug 14, 2023
f4a3699
feat: Add Set.fromKeys(tab)
Quenty Aug 15, 2023
7e9a32b
feat: Semi-broken datastore changes
Quenty Aug 15, 2023
667015d
fix: Fix additional components but data store writing ping-pings back…
Quenty Aug 15, 2023
ef03495
feat: DataStores appear to be working, but require more testing
Quenty Aug 15, 2023
b4c5918
fix: More data store improvements
Quenty Aug 16, 2023
293fb96
style: Fix style issues
Quenty Aug 16, 2023
40f9a1f
ci: Update aftman styles
Quenty Aug 16, 2023
d33bbee
feat: Sounds can play back tables
Quenty Aug 19, 2023
18c892c
tools: Add tool to generate service
Quenty Aug 19, 2023
122659c
feat: Add timed tween package
Quenty Aug 19, 2023
1071969
feat: Add Draw.raycast()
Quenty Aug 19, 2023
20ffe12
feat: Add sound layer playback system
Quenty Aug 19, 2023
70d8d93
feat: Use os.clock() instead of tick() in AccelTween clock state
Quenty Aug 19, 2023
7b254c2
feat: Add AnimationTrackPlayer.new(animationTarget, animationId)
Quenty Aug 19, 2023
9a6578b
feat: Add studio rig animator
Quenty Aug 19, 2023
1b9ead5
feat: Add RxRootPartUtils.observeHumanoidRootPartBrioFromHumanoid(hum…
Quenty Aug 19, 2023
6fc8804
feat: Add :SetCanInitialize(canInitialize) to rogue-property system
Quenty Aug 19, 2023
cdb34e3
feat: Add Rx.delayed(seconds)
Quenty Aug 19, 2023
74e59af
fix: Rx Observables provide better errors
Quenty Aug 19, 2023
4d582f0
feat: Add TimedTransitionModel.new()
Quenty Aug 19, 2023
db100f3
feat: Add Promise.delay(seconds, func)
Quenty Aug 19, 2023
f68cccc
feat: Add Binder:ObserveAllBrio()
Quenty Aug 19, 2023
b8ac9cb
fix: Fix parenting in NoCollisionConstraintUtils
Quenty Aug 19, 2023
ab1cac8
fix: Blend defaults sounds to inverse tapered
Quenty Aug 19, 2023
cafbc1a
fix: Add :ObserveAutomaticTagging()
Quenty Aug 19, 2023
5ca48d9
feat: Add RandomSampler object to RandomUtils
Quenty Aug 19, 2023
5ca272f
fix: Don't enable any scripts on the resulting model (like Animate, e…
Quenty Aug 19, 2023
bf9e3d6
feat: Add Maid:Add() which returns the task you pass into the maid
Quenty Aug 19, 2023
fe890ef
docs: Update docs with new packages
Quenty Aug 19, 2023
87ff244
fix: Rename HoarcekatRigAnimator
Quenty Aug 19, 2023
58eeb15
feat: Sound plays using :Play() always since PlayLocalSound no longer…
Quenty Aug 19, 2023
cb0e625
fix: Remove unused code
Quenty Aug 19, 2023
0ac8dcb
refactor: Move code to implementation folder
Quenty Aug 19, 2023
abd0df4
feat: Add DefaultValueUtils
Quenty Aug 20, 2023
a677409
feat: Add array support to RogueProperty package
Quenty Aug 20, 2023
dfe09c8
style: Fix context spelling in Table library
Quenty Aug 20, 2023
c64dbbf
fix: RxSignal uses skip instead of onlyAfterDefer() assuming immediat…
Quenty Aug 20, 2023
950c121
feat: Add UserInfoService:ObserveDisplayName(userId)
Quenty Aug 20, 2023
324e3db
fix: Add missing dependencies
Quenty Aug 20, 2023
922ef09
fix: Update game-template with latest data and ideas
Quenty Aug 20, 2023
42ac596
fix: Add missing dependency
Quenty Aug 20, 2023
715abf8
feat: Add ColorGradeUtils.addGradeToColor(color, difference, vividness)
Quenty Aug 20, 2023
71930e0
fix: Remove unused code
Quenty Aug 20, 2023
0903f14
fix: Fix additional parent assert
Quenty Aug 20, 2023
44468bd
fix: Use table.clone instead of Table.copy
Quenty Aug 20, 2023
08ab13c
fix: Use table.clone in Rx
Quenty Aug 20, 2023
04f2cf9
fix: Changed events weren't firing for the datastore stage
Quenty Aug 20, 2023
8c90d59
fix: Skip would skip one too many
Quenty Aug 20, 2023
e885fce
fix: Track weight will only adjust if we get a track
Quenty Aug 20, 2023
56962ce
feat: Add tags to GameConfig
Quenty Aug 21, 2023
ece736a
feat: Upgrade ChatProvider package to provide tags automatically, as …
Quenty Aug 23, 2023
608b509
feat: Add GameProductServiceClient:ObserveAssetPurchased(assetType, i…
Quenty Aug 23, 2023
2297438
feat: Add PermissionService:PromiseIsPermissionLevel(player, permissi…
Quenty Aug 23, 2023
776ecbe
feat: Add GameConfigPicker:ObserveToAssetIdBrio(assetType,
Quenty Aug 23, 2023
e99602a
feat: Add Color3Utils.toWebHexString(color3)
Quenty Aug 23, 2023
8cf5024
fix: Clean up pending promises
Quenty Aug 23, 2023
b405437
feat: Add RxBinderUtils.observeChildrenBrio
Quenty Aug 23, 2023
28f311b
fix: Use table.clone()
Quenty Aug 23, 2023
fc13e2e
feat: Add RxBrioUtils.of(...)
Quenty Aug 23, 2023
9335e8d
fix: Vividness pass-though as messy
Quenty Aug 23, 2023
a911cda
style: Fix styling issues
Quenty Aug 23, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion aftman.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
[tools]
rojo = "quenty/[email protected]"
run-in-roblox = "rojo-rbx/[email protected]"
selene = "Kampfkarren/selene@0.23.1"
selene = "Kampfkarren/selene@0.25.0"
moonwave-extractor = "UpliftGames/[email protected]"
mantle = "blake-mealey/[email protected]"
remodel = "rojo-rbx/[email protected]"
2 changes: 1 addition & 1 deletion games/integration/aftman.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
# For more information, see https://github.com/LPGhatguy/aftman
[tools]
rojo = "quenty/[email protected]"
selene = "Kampfkarren/selene@0.23.1"
selene = "Kampfkarren/selene@0.25.0"
6 changes: 5 additions & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ Many of these packages represent not just useful code, but useful patterns, or w
### All packages
<!--package-list-generated-start-->

There are 246 packages in Nevermore.
There are 250 packages in Nevermore.

| Package | Description | Install | docs | source | changelog | npm |
| ------- | ----------- | ------- | ---- | ------ | --------- | --- |
Expand Down Expand Up @@ -115,9 +115,11 @@ There are 246 packages in Nevermore.
| [DataStore](https://quenty.github.io/NevermoreEngine/api/DataStore) | Quenty's Datastore implementation for Roblox | `npm i @quenty/datastore` | [docs](https://quenty.github.io/NevermoreEngine/api/DataStore) | [source](https://github.com/Quenty/NevermoreEngine/tree/main/src/datastore) | [changelog](https://github.com/Quenty/NevermoreEngine/tree/main/src/datastore/CHANGELOG.md) | [npm](https://www.npmjs.com/package/@quenty/datastore) |
| [DeathReport](https://quenty.github.io/NevermoreEngine/api/DeathReportService) | Death report service which will track the deaths of players | `npm i @quenty/deathreport` | [docs](https://quenty.github.io/NevermoreEngine/api/DeathReportService) | [source](https://github.com/Quenty/NevermoreEngine/tree/main/src/deathreport) | [changelog](https://github.com/Quenty/NevermoreEngine/tree/main/src/deathreport/CHANGELOG.md) | [npm](https://www.npmjs.com/package/@quenty/deathreport) |
| [debounce](https://quenty.github.io/NevermoreEngine/api/debounce) | debounce a existing function by timeout | `npm i @quenty/debounce` | [docs](https://quenty.github.io/NevermoreEngine/api/debounce) | [source](https://github.com/Quenty/NevermoreEngine/tree/main/src/debounce) | [changelog](https://github.com/Quenty/NevermoreEngine/tree/main/src/debounce/CHANGELOG.md) | [npm](https://www.npmjs.com/package/@quenty/debounce) |
| [DefaultValueUtils](https://quenty.github.io/NevermoreEngine/api/DefaultValueUtils) | Helps get the default or zero value for value types in Roblox | `npm i @quenty/defaultvalueutils` | [docs](https://quenty.github.io/NevermoreEngine/api/DefaultValueUtils) | [source](https://github.com/Quenty/NevermoreEngine/tree/main/src/defaultvalueutils) | [changelog](https://github.com/Quenty/NevermoreEngine/tree/main/src/defaultvalueutils/CHANGELOG.md) | [npm](https://www.npmjs.com/package/@quenty/defaultvalueutils) |
| [Deferred](https://quenty.github.io/NevermoreEngine/api/deferred) | deferred (otherwise known as fastSpawn) implementation for Roblox | `npm i @quenty/deferred` | [docs](https://quenty.github.io/NevermoreEngine/api/deferred) | [source](https://github.com/Quenty/NevermoreEngine/tree/main/src/deferred) | [changelog](https://github.com/Quenty/NevermoreEngine/tree/main/src/deferred/CHANGELOG.md) | [npm](https://www.npmjs.com/package/@quenty/deferred) |
| [DepthOfField](https://quenty.github.io/NevermoreEngine/api/DepthOfFieldService) | Depth of field service to allow multiple systems to write depth of field | `npm i @quenty/depthoffield` | [docs](https://quenty.github.io/NevermoreEngine/api/DepthOfFieldService) | [source](https://github.com/Quenty/NevermoreEngine/tree/main/src/depthoffield) | [changelog](https://github.com/Quenty/NevermoreEngine/tree/main/src/depthoffield/CHANGELOG.md) | [npm](https://www.npmjs.com/package/@quenty/depthoffield) |
| [Draw](https://quenty.github.io/NevermoreEngine/api/Draw) | A utility library to debug things in 3D space for Roblox. | `npm i @quenty/draw` | [docs](https://quenty.github.io/NevermoreEngine/api/Draw) | [source](https://github.com/Quenty/NevermoreEngine/tree/main/src/draw) | [changelog](https://github.com/Quenty/NevermoreEngine/tree/main/src/draw/CHANGELOG.md) | [npm](https://www.npmjs.com/package/@quenty/draw) |
| [DuckType](https://quenty.github.io/NevermoreEngine/api/DuckTypeUtils) | Utility functions to duck type a value | `npm i @quenty/ducktype` | [docs](https://quenty.github.io/NevermoreEngine/api/DuckTypeUtils) | [source](https://github.com/Quenty/NevermoreEngine/tree/main/src/ducktype) | [changelog](https://github.com/Quenty/NevermoreEngine/tree/main/src/ducktype/CHANGELOG.md) | [npm](https://www.npmjs.com/package/@quenty/ducktype) |
| [EllipticCurveCryptography](https://quenty.github.io/NevermoreEngine/api/EllipticCurveCryptography) | Elliptic curve cryptography forked from BoatBomber, forked from ComputerCraft | `npm i @quenty/ellipticcurvecryptography` | [docs](https://quenty.github.io/NevermoreEngine/api/EllipticCurveCryptography) | [source](https://github.com/Quenty/NevermoreEngine/tree/main/src/ellipticcurvecryptography) | [changelog](https://github.com/Quenty/NevermoreEngine/tree/main/src/ellipticcurvecryptography/CHANGELOG.md) | [npm](https://www.npmjs.com/package/@quenty/ellipticcurvecryptography) |
| [Elo](https://quenty.github.io/NevermoreEngine/api/EloUtils) | Elo rating utility library. | `npm i @quenty/elo` | [docs](https://quenty.github.io/NevermoreEngine/api/EloUtils) | [source](https://github.com/Quenty/NevermoreEngine/tree/main/src/elo) | [changelog](https://github.com/Quenty/NevermoreEngine/tree/main/src/elo/CHANGELOG.md) | [npm](https://www.npmjs.com/package/@quenty/elo) |
| [EnabledMixin](https://quenty.github.io/NevermoreEngine/api/EnabledMixin) | Adds Enabled/Disabled state to class | `npm i @quenty/enabledmixin` | [docs](https://quenty.github.io/NevermoreEngine/api/EnabledMixin) | [source](https://github.com/Quenty/NevermoreEngine/tree/main/src/enabledmixin) | [changelog](https://github.com/Quenty/NevermoreEngine/tree/main/src/enabledmixin/CHANGELOG.md) | [npm](https://www.npmjs.com/package/@quenty/enabledmixin) |
Expand Down Expand Up @@ -266,6 +268,7 @@ There are 246 packages in Nevermore.
| [Snackbar](https://quenty.github.io/NevermoreEngine/api/Snackbar) | Snackbars provide lightweight feedback on an operation at the base of the screen. They automatically disappear after a timeout or user interaction. There can only be one on the screen at a time. | `npm i @quenty/snackbar` | [docs](https://quenty.github.io/NevermoreEngine/api/Snackbar) | [source](https://github.com/Quenty/NevermoreEngine/tree/main/src/snackbar) | [changelog](https://github.com/Quenty/NevermoreEngine/tree/main/src/snackbar/CHANGELOG.md) | [npm](https://www.npmjs.com/package/@quenty/snackbar) |
| [SocialServiceUtils](https://quenty.github.io/NevermoreEngine/api/SocialServiceUtils) | Utility functions wrapping SocialService with promises | `npm i @quenty/socialserviceutils` | [docs](https://quenty.github.io/NevermoreEngine/api/SocialServiceUtils) | [source](https://github.com/Quenty/NevermoreEngine/tree/main/src/socialserviceutils) | [changelog](https://github.com/Quenty/NevermoreEngine/tree/main/src/socialserviceutils/CHANGELOG.md) | [npm](https://www.npmjs.com/package/@quenty/socialserviceutils) |
| [SoftShutdown](https://quenty.github.io/NevermoreEngine/api/SoftShutdownService) | This service lets you shut down servers without losing a bunch of players. When game.OnClose is called, the script teleports everyone in the server into a reserved server. | `npm i @quenty/softshutdown` | [docs](https://quenty.github.io/NevermoreEngine/api/SoftShutdownService) | [source](https://github.com/Quenty/NevermoreEngine/tree/main/src/softshutdown) | [changelog](https://github.com/Quenty/NevermoreEngine/tree/main/src/softshutdown/CHANGELOG.md) | [npm](https://www.npmjs.com/package/@quenty/softshutdown) |
| [SoundPlayer](https://quenty.github.io/NevermoreEngine/api/LoopedSoundPlayer) | Sound playback helper | `npm i @quenty/soundplayer` | [docs](https://quenty.github.io/NevermoreEngine/api/LoopedSoundPlayer) | [source](https://github.com/Quenty/NevermoreEngine/tree/main/src/soundplayer) | [changelog](https://github.com/Quenty/NevermoreEngine/tree/main/src/soundplayer/CHANGELOG.md) | [npm](https://www.npmjs.com/package/@quenty/soundplayer) |
| [SoundPromiseUtils](https://quenty.github.io/NevermoreEngine/api/SoundUtils) | Utility functions involving sounds and their state | `npm i @quenty/sounds` | [docs](https://quenty.github.io/NevermoreEngine/api/SoundUtils) | [source](https://github.com/Quenty/NevermoreEngine/tree/main/src/sounds) | [changelog](https://github.com/Quenty/NevermoreEngine/tree/main/src/sounds/CHANGELOG.md) | [npm](https://www.npmjs.com/package/@quenty/sounds) |
| [SoundPromiseUtils](https://quenty.github.io/NevermoreEngine/api/SpawnService) | Centralized spawning system | `npm i @quenty/spawning` | [docs](https://quenty.github.io/NevermoreEngine/api/SpawnService) | [source](https://github.com/Quenty/NevermoreEngine/tree/main/src/spawning) | [changelog](https://github.com/Quenty/NevermoreEngine/tree/main/src/spawning/CHANGELOG.md) | [npm](https://www.npmjs.com/package/@quenty/spawning) |
| [Spring](https://quenty.github.io/NevermoreEngine/api/Spring) | Spring implementation for Roblox | `npm i @quenty/spring` | [docs](https://quenty.github.io/NevermoreEngine/api/Spring) | [source](https://github.com/Quenty/NevermoreEngine/tree/main/src/spring) | [changelog](https://github.com/Quenty/NevermoreEngine/tree/main/src/spring/CHANGELOG.md) | [npm](https://www.npmjs.com/package/@quenty/spring) |
Expand All @@ -289,6 +292,7 @@ There are 246 packages in Nevermore.
| [Throttle](https://quenty.github.io/NevermoreEngine/api/throttle) | Adds the throttle function to Roblox | `npm i @quenty/throttle` | [docs](https://quenty.github.io/NevermoreEngine/api/throttle) | [source](https://github.com/Quenty/NevermoreEngine/tree/main/src/throttle) | [changelog](https://github.com/Quenty/NevermoreEngine/tree/main/src/throttle/CHANGELOG.md) | [npm](https://www.npmjs.com/package/@quenty/throttle) |
| [Tie](https://quenty.github.io/NevermoreEngine/api/TieInterface) | Tie allows interfaces to be defined between Lua OOP and Roblox objects. | `npm i @quenty/tie` | [docs](https://quenty.github.io/NevermoreEngine/api/TieInterface) | [source](https://github.com/Quenty/NevermoreEngine/tree/main/src/tie) | [changelog](https://github.com/Quenty/NevermoreEngine/tree/main/src/tie/CHANGELOG.md) | [npm](https://www.npmjs.com/package/@quenty/tie) |
| [Time](https://quenty.github.io/NevermoreEngine/api/Time) | Library handles time based parsing / operations. Untested. Based off of PHP's time system. Note: This library is out of date, and does not necessarily work. I recommend using os.time() | `npm i @quenty/time` | [docs](https://quenty.github.io/NevermoreEngine/api/Time) | [source](https://github.com/Quenty/NevermoreEngine/tree/main/src/time) | [changelog](https://github.com/Quenty/NevermoreEngine/tree/main/src/time/CHANGELOG.md) | [npm](https://www.npmjs.com/package/@quenty/time) |
| [TimedTween](https://quenty.github.io/NevermoreEngine/api/TimedTweenUtils) | Linear timed tweening model | `npm i @quenty/timedtween` | [docs](https://quenty.github.io/NevermoreEngine/api/TimedTweenUtils) | [source](https://github.com/Quenty/NevermoreEngine/tree/main/src/timedtween) | [changelog](https://github.com/Quenty/NevermoreEngine/tree/main/src/timedtween/CHANGELOG.md) | [npm](https://www.npmjs.com/package/@quenty/timedtween) |
| [TimeSyncService](https://quenty.github.io/NevermoreEngine/api/TimeSyncService) | Quenty's TimeSyncService keeps time synchronized between all clients and the server | `npm i @quenty/timesyncservice` | [docs](https://quenty.github.io/NevermoreEngine/api/TimeSyncService) | [source](https://github.com/Quenty/NevermoreEngine/tree/main/src/timesyncservice) | [changelog](https://github.com/Quenty/NevermoreEngine/tree/main/src/timesyncservice/CHANGELOG.md) | [npm](https://www.npmjs.com/package/@quenty/timesyncservice) |
| [TouchingPartUtils](https://quenty.github.io/NevermoreEngine/api/TouchingPartUtils) | Utility to get touching parts on a Roblox part. This acts as a performance-friendly way to query Roblox's spatial tree. | `npm i @quenty/touchingpartutils` | [docs](https://quenty.github.io/NevermoreEngine/api/TouchingPartUtils) | [source](https://github.com/Quenty/NevermoreEngine/tree/main/src/touchingpartutils) | [changelog](https://github.com/Quenty/NevermoreEngine/tree/main/src/touchingpartutils/CHANGELOG.md) | [npm](https://www.npmjs.com/package/@quenty/touchingpartutils) |
| [trajectory](https://quenty.github.io/NevermoreEngine/api/trajectory) | Utility function for estimating low and high arcs of projectiles. Solves for bullet drop given | `npm i @quenty/trajectory` | [docs](https://quenty.github.io/NevermoreEngine/api/trajectory) | [source](https://github.com/Quenty/NevermoreEngine/tree/main/src/trajectory) | [changelog](https://github.com/Quenty/NevermoreEngine/tree/main/src/trajectory/CHANGELOG.md) | [npm](https://www.npmjs.com/package/@quenty/trajectory) |
Expand Down
8 changes: 4 additions & 4 deletions src/acceltween/src/Shared/AccelTween.lua
Original file line number Diff line number Diff line change
Expand Up @@ -82,17 +82,17 @@ function AccelTween:__index(index)
if AccelTween[index] then
return AccelTween[index]
elseif index == "p" then
local pos, _ = self:_getstate(tick())
local pos, _ = self:_getstate(os.clock())
return pos
elseif index == "v" then
local _, vel = self:_getstate(tick())
local _, vel = self:_getstate(os.clock())
return vel
elseif index == "a" then
return self._accel
elseif index == "t" then
return self._y1
elseif index == "rtime" then
local time = tick()
local time = os.clock()
return time < self._t1 and self._t1 - time or 0
else
error(("Bad index %q"):format(tostring(index)))
Expand Down Expand Up @@ -128,7 +128,7 @@ function AccelTween:_getstate(time)
end

function AccelTween:_setstate(newpos, newvel, newaccel, newtarg)
local time = tick()
local time = os.clock()
local pos, vel = self:_getstate(time)
pos = newpos or pos
vel = newvel or vel
Expand Down
2 changes: 2 additions & 0 deletions src/animations/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@
"@quenty/maid": "file:../maid",
"@quenty/promisemaid": "file:../promisemaid",
"@quenty/rbxasset": "file:../rbxasset",
"@quenty/rx": "file:../rx",
"@quenty/signal": "file:../signal",
"@quenty/valueobject": "file:../valueobject"
},
"publishConfig": {
Expand Down
10 changes: 7 additions & 3 deletions src/animations/src/Shared/AnimationSlotPlayer.lua
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,13 @@ function AnimationSlotPlayer:Play(id, fadeTime, weight, speed, priority)
local maid = brio:ToMaid()

local track = AnimationUtils.playAnimation(animationTarget, id, fadeTime, weight, speed, priority)
maid:GiveTask(function()
track:AdjustWeight(0, fadeTime or self._defaultFadeTime.Value)
end)
if track then
maid:GiveTask(function()
track:AdjustWeight(0, fadeTime or self._defaultFadeTime.Value)
end)
else
warn("[AnimationSlotPlayer] - Failed to get animation to play")
end
end))

self._maid._current = topMaid
Expand Down
155 changes: 155 additions & 0 deletions src/animations/src/Shared/AnimationTrackPlayer.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,155 @@
--[=[
@class AnimationTrackPlayer
]=]

local require = require(script.Parent.loader).load(script)

local BaseObject = require("BaseObject")
local ValueObject = require("ValueObject")
local Rx = require("Rx")
local AnimationUtils = require("AnimationUtils")
local Signal = require("Signal")

local AnimationTrackPlayer = setmetatable({}, BaseObject)
AnimationTrackPlayer.ClassName = "AnimationTrackPlayer"
AnimationTrackPlayer.__index = AnimationTrackPlayer

function AnimationTrackPlayer.new(animationTarget, animationId)
local self = setmetatable(BaseObject.new(), AnimationTrackPlayer)

self._animationTarget = ValueObject.new(nil)
self._maid:GiveTask(self._animationTarget)

self._trackId = ValueObject.new(nil)
self._maid:GiveTask(self._trackId)

self._currentTrack = ValueObject.new(nil)
self._maid:GiveTask(self._currentTrack)

self.KeyframeReached = Signal.new()
self._maid:GiveTask(self.KeyframeReached)

self._animationPriority = ValueObject.new(nil)
self._maid:GiveTask(self._animationPriority)

if animationTarget then
self:SetAnimationTarget(animationTarget)
end

if animationId then
self:SetAnimationId(animationId)
end

self:_setupState()

return self
end

function AnimationTrackPlayer:_setupState()
self._maid:GiveTask(Rx.combineLatest({
animationTarget = self._animationTarget:Observe();
trackId = self._trackId:Observe();
animationPriority = self._animationPriority:Observe();
}):Pipe({
Rx.throttleDefer();
}):Subscribe(function(state)
if state.animationTarget and state.trackId then
self._currentTrack.Value = AnimationUtils.getOrCreateAnimationTrack(state.animationTarget, state.trackId, state.animationPriority)
else
self._currentTrack.Value = nil
end
end))

self._maid:GiveTask(self._currentTrack:ObserveBrio(function(track)
return track ~= nil
end):Subscribe(function(brio)
if brio:IsDead() then
return
end

local maid = brio:ToMaid()
local track = brio:GetValue()

maid:GiveTask(track.KeyframeReached:Connect(function(...)
self.KeyframeReached:Fire(...)
end))
end))
end

function AnimationTrackPlayer:SetAnimationId(animationId)
return self._trackId:Mount(animationId)
end

function AnimationTrackPlayer:GetAnimationId()
return self._trackId.Value
end

function AnimationTrackPlayer:SetAnimationTarget(animationTarget)
return self._animationTarget:Mount(animationTarget)
end

function AnimationTrackPlayer:SetWeightTargetIfNotSet(weight, fadeTime)
self._maid._adjustWeight = self:_onEachTrack(function(_maid, track)
if track.WeightTarget ~= weight then
track:AdjustWeight(weight, fadeTime)
end
end)
end

function AnimationTrackPlayer:Play(fadeTime, weight, speed)
if weight then
self._maid._adjustWeight = nil
end

if speed then
self._maid._adjustSpeed = nil
end

self._maid._stop = nil
self._maid._play = self:_onEachTrack(function(_maid, track)
track:Play(fadeTime, weight, speed)
end)
end

function AnimationTrackPlayer:Stop(fadeTime)
self._maid._play = nil
self._maid._stop = self:_onEachTrack(function(_maid, track)
track:Stop(fadeTime)
end)
end

function AnimationTrackPlayer:AdjustWeight(weight, fadeTime)
self._maid._adjustWeight = self:_onEachTrack(function(_maid, track)
track:AdjustWeight(weight, fadeTime)
end)
end

function AnimationTrackPlayer:AdjustSpeed(speed, fadeTime)
self._maid._adjustSpeed = self:_onEachTrack(function(_maid, track)
track:AdjustSpeed(speed, fadeTime)
end)
end

function AnimationTrackPlayer:IsPlaying()
local track = self._currentTrack.Value
if track then
return track.IsPlaying
else
return false
end
end

function AnimationTrackPlayer:_onEachTrack(callback)
return self._currentTrack:ObserveBrio(function(track)
return track ~= nil
end):Subscribe(function(brio)
if brio:IsDead() then
return
end

local track = brio:GetValue()
callback(brio:ToMaid(), track)
end)
end

return AnimationTrackPlayer
41 changes: 41 additions & 0 deletions src/animations/src/Shared/Testing/StudioRigAnimator.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
--[=[
Ship to run animations in hoarcekat

@class StudioRigAnimator
]=]

local require = require(script.Parent.loader).load(script)

local RunService = game:GetService("RunService")

local BaseObject = require("BaseObject")
local AnimationUtils = require("AnimationUtils")

local StudioRigAnimator = setmetatable({}, BaseObject)
StudioRigAnimator.ClassName = "StudioRigAnimator"
StudioRigAnimator.__index = StudioRigAnimator

function StudioRigAnimator.new(animatorOrHumanoid)
local self = setmetatable(BaseObject.new(animatorOrHumanoid), StudioRigAnimator)

if RunService:IsStudio() and not RunService:IsRunning() then
self:_setupStudio()
end

return self
end

function StudioRigAnimator:_setupStudio()
self._animator = AnimationUtils.getOrCreateAnimator(self._obj)
self._lastTime = os.clock()

self._maid:GiveTask(RunService.RenderStepped:Connect(function()
local now = os.clock()
local delta = now - self._lastTime
self._lastTime = now

self._animator:StepAnimations(delta)
end))
end

return StudioRigAnimator
Loading
Loading