This repository has been archived by the owner on Oct 19, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1608574
commit d036096
Showing
4 changed files
with
29 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,60 +1,9 @@ | ||
local Players = game:GetService "Players" | ||
local CollectionService = game:GetService "CollectionService" | ||
local ReplicatedStorage = game:GetService "ReplicatedStorage" | ||
|
||
local player = Players.LocalPlayer | ||
local Rodux = require(ReplicatedStorage.Common.lib.Rodux) | ||
local selectors = require(ReplicatedStorage.Common.State.selectors) | ||
|
||
local displayClientLogs = ReplicatedStorage.Config.Output.DisplayClientLogs.Value | ||
local originalAnimationId | ||
|
||
local function updateIdleAnimationMiddleware(nextDispatch, store) | ||
return function(action) | ||
if | ||
action.playerName ~= player.Name | ||
or (action.type ~= "switchPlayerEnemy" and action.type ~= "setCurrentPunchingBag") | ||
then | ||
nextDispatch(action) | ||
return | ||
end | ||
|
||
if player.Character then | ||
if action.enemy or action.currentPunchingBag then | ||
if not originalAnimationId then | ||
originalAnimationId = player.Character.Animate.idle.Animation1.AnimationId | ||
end | ||
local equippedWeapon = selectors.getEquippedWeapon(store:getState(), player.Name) | ||
if | ||
equippedWeapon | ||
and not action.currentPunchingBag | ||
and not CollectionService:HasTag(action.enemy, "Dummy") | ||
then | ||
player.Character.Animate.idle.Animation1.AnimationId = | ||
ReplicatedStorage.CombatAnimations[equippedWeapon].Idle.AnimationId | ||
player.Character.Humanoid:ChangeState(Enum.HumanoidStateType.Landed) | ||
else | ||
player.Character.Animate.idle.Animation1.AnimationId = | ||
ReplicatedStorage.CombatAnimations.Fists.Idle.AnimationId | ||
end | ||
elseif originalAnimationId then | ||
local humanoid = player.Character and player.Character:FindFirstChild "Humanoid" | ||
if humanoid then | ||
for _, animationTrack in player.Character.Humanoid.Animator:GetPlayingAnimationTracks() do | ||
if animationTrack.Priority == Enum.AnimationPriority.Idle then | ||
animationTrack:Stop() | ||
end | ||
end | ||
end | ||
player.Character.Animate.idle.Animation1.AnimationId = originalAnimationId | ||
player.Character.Humanoid:ChangeState(Enum.HumanoidStateType.Landed) | ||
end | ||
end | ||
nextDispatch(action) | ||
end | ||
end | ||
|
||
return { | ||
updateIdleAnimationMiddleware, | ||
if displayClientLogs then Rodux.loggerMiddleware else nil, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
local ContentProvider = game:GetService "ContentProvider" | ||
local ReplicatedStorage = game:GetService "ReplicatedStorage" | ||
|
||
local animationsToPreload = {} | ||
for _, animation in ReplicatedStorage.CombatAnimations:GetDescendants() do | ||
if animation:IsA "Animation" then | ||
table.insert(animationsToPreload, animation) | ||
end | ||
end | ||
|
||
task.spawn(ContentProvider.PreloadAsync, ContentProvider, animationsToPreload) | ||
|
||
return 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters