aboutsummaryrefslogtreecommitdiff
path: root/gamemode/core/animation/sh_animations.lua
blob: e8c1f22a7a9632f198362aa8bad32b7dc03589fc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
if CLIENT and not (pac and pac.animations and pac.animations.RegisterAnimation) then
	error("JetBoom's libanimbone is required for animations. (It's bundeled with PAC3)")
	return
end

local anim = {}

local sequences
local log = nrequire("log.lua")
if SERVER then
	sequences = nrequire("core/animation/sv_animate.lua")
else -- CLIENT
	sequences = nrequire("core/animation/cl_animate.lua")
end

hook.Add("UpdateAnimation","art_updateanim",function(ply,vel,mgs)
	if sequences and ply and sequences[ply] and CurTime() < sequences[ply][1] then
		ply:SetPlaybackRate(sequences[ply][3])
	end
end)

hook.Add("CalcMainActivity","art_swing",function(ply,vel)
	if sequences and ply and sequences[ply] and CurTime() < sequences[ply][1] then
		return -1, sequences[ply][2]
	end
end)

--Why not just call RegisterAnimation directly?
--While writing this gamemode, pac3 changed it's API,
--And it was a pain in the ass to change all the code
--that called RegisterAnimation().
if CLIENT then
	function anim.RegisterAnimation(name,tbl)
		pac.animations.RegisterAnimation(name,tbl)
	end
end

return anim