Skip to content

Commit

Permalink
HeadRingのレンダーカウントの方法を改善
Browse files Browse the repository at this point in the history
  • Loading branch information
Gakuto1112 committed Aug 19, 2024
1 parent 15aa64e commit c70784d
Showing 1 changed file with 27 additions and 38 deletions.
65 changes: 27 additions & 38 deletions scripts/head_ring.lua
Original file line number Diff line number Diff line change
Expand Up @@ -9,32 +9,19 @@ HeadRing = {
HeadRotAverage = 0,

---頭の輪っかが上下するアニメーションのカウンター
---@type number
---@type integer
FloatCount = 0,

---頭の輪っかが上下するアニメーションの位置オフセット
---@type number
FloatOffset = 0,

---このレンダーで処理済みかどうか
---@type boolean
IsRenderProcessed = false,

---頭の輪っかの浮遊アニメーションカウンターを処理する。
processFloatCount = function (self)
if not client:isPaused() then
self.FloatCount = self.FloatCount + 0.25 / client:getFPS()
self.FloatCount = self.FloatCount > 1 and self.FloatCount - 1 or self.FloatCount
end
self.FloatOffset = math.sin(self.FloatCount * 2 * math.pi) * 0.25
end,

---初期化関数
init = function (self)
events.RENDER:register(function()
events.RENDER:register(function (delta)
local headRot = ExSkill.AnimationCount > -1 and models.models.main.Avatar.Head:getAnimRot().x or math.deg(math.asin(player:getLookDir().y))
if not self.IsRenderProcessed then
--移動平均値の算出
local headRot = ExSkill.AnimationCount > -1 and models.models.main.Avatar.Head:getAnimRot().x or math.deg(math.asin(player:getLookDir().y))
self.HeadRotAverage = (#self.HeadRotData * self.HeadRotAverage + headRot) / (#self.HeadRotData + 1)
table.insert(self.HeadRotData, headRot)
--古いデータの切り捨て
Expand All @@ -45,35 +32,37 @@ HeadRing = {
end
table.remove(self.HeadRotData, 1)
end

--頭の輪っかの浮遊アニメーション
self:processFloatCount()

--頭の輪っかの位置・角度を設定
local playerPose = player:getPose()
if playerPose == "SWIMMING" or playerPose == "FALL_FLYING" then
models.models.main.Avatar.Head.HeadRing:setPos(Physics.VelocityAverage[3] * 3, math.cos(math.rad(headRot)) * Physics.VelocityAverage[1] * -1 + math.sin(math.rad(headRot)) * Physics.VelocityAverage[2] * -1 + self.FloatOffset, math.cos(math.rad(headRot)) * Physics.VelocityAverage[2] * -3 + math.sin(math.rad(headRot)) * Physics.VelocityAverage[1])
else
models.models.main.Avatar.Head.HeadRing:setPos(Physics.VelocityAverage[3] * -3, math.cos(math.rad(headRot)) * Physics.VelocityAverage[2] * -1 + math.sin(math.rad(headRot)) * Physics.VelocityAverage[1] + self.FloatOffset, math.cos(math.rad(headRot)) * Physics.VelocityAverage[1] * 3 + math.sin(math.rad(headRot)) * Physics.VelocityAverage[2])
end
models.script_head_block.Head.HeadRing:setPos(0, self.FloatOffset, 0)
if DeathAnimation.DummyAvatarRoot ~= nil then
DeathAnimation.DummyAvatarRoot["Head"]["HeadRing"]:setPos(0, self.FloatOffset, 0)
end
models.models.main.Avatar.Head.HeadRing:setRot(self.HeadRotAverage - headRot, 0, 0)

self.IsRenderProcessed = true
end
--頭の輪っかの位置・角度を設定
local playerPose = player:getPose()
local floatOffset = math.sin(self.FloatCount / 80 * 2 * math.pi) * 0.25
if playerPose == "SWIMMING" or playerPose == "FALL_FLYING" then
models.models.main.Avatar.Head.HeadRing:setPos(Physics.VelocityAverage[3] * 3, math.cos(math.rad(headRot)) * Physics.VelocityAverage[1] * -1 + math.sin(math.rad(headRot)) * Physics.VelocityAverage[2] * -1 + floatOffset, math.cos(math.rad(headRot)) * Physics.VelocityAverage[2] * -3 + math.sin(math.rad(headRot)) * Physics.VelocityAverage[1])
else
models.models.main.Avatar.Head.HeadRing:setPos(Physics.VelocityAverage[3] * -3, math.cos(math.rad(headRot)) * Physics.VelocityAverage[2] * -1 + math.sin(math.rad(headRot)) * Physics.VelocityAverage[1] + floatOffset, math.cos(math.rad(headRot)) * Physics.VelocityAverage[1] * 3 + math.sin(math.rad(headRot)) * Physics.VelocityAverage[2])
end
if DeathAnimation.DummyAvatarRoot ~= nil then
DeathAnimation.DummyAvatarRoot["Head"]["HeadRing"]:setPos(0, floatOffset, 0)
end
models.models.main.Avatar.Head.HeadRing:setRot(self.HeadRotAverage - headRot, 0, 0)
end)

events.WORLD_RENDER:register(function()
self.IsRenderProcessed = false
if not player:isLoaded() then
self:processFloatCount()
models.script_head_block.Head.HeadRing:setPos(0, self.FloatOffset, 0)
events.WORLD_TICK:register(function ()
if not client:isPaused() then
self.FloatCount = self.FloatCount + 1
self.FloatCount = self.FloatCount == 80 and 0 or self.FloatCount
end
end)

events.WORLD_RENDER:register(function ()
self.IsRenderProcessed = false
end)

events.SKULL_RENDER:register(function ()
models.script_head_block.Head.HeadRing:setPos(0, math.sin(self.FloatCount / 80 * 2 * math.pi) * 0.25, 0)
end)

models.models.main.Avatar.Head.HeadRing:setLight(15)
end
}
Expand Down

0 comments on commit c70784d

Please sign in to comment.