2025-01-04 23:00:19 +08:00

48 lines
1.2 KiB
Lua

local Machine_Jump = {};
Machine_Jump.MachineType = nil;
Machine_Jump.ContinueTime = 0;
Machine_Jump.Impulse = 2500;
function Machine_Jump:Init(JumpLength)
UGCLogSystem.Log("[Machine_Jump:Init] JumpLength = %d", JumpLength)
if JumpLength ~= 0 then self.Impulse = JumpLength; end
end
--- 玩家进入需要执行的操作
---@param InPawn UGCPlayerPawn_C
function Machine_Jump:Execute(InPawn)
UGCLogSystem.Log("[Machine_Jump:Execute] 执行 Impulse = %s", tostring(self.Impulse))
if IsServer then
local PawnZSpeed = InPawn.CharacterMovement.Velocity.Z;
local AddVal = 0;
if PawnZSpeed < 0 then
if PawnZSpeed < -200 then
AddVal = 200;
else
AddVal = -PawnZSpeed;
end
else
if PawnZSpeed > 200 then
AddVal = -200
else
AddVal = -PawnZSpeed
end
end
local FinalZ = self.Impulse + AddVal;
UGCLogSystem.Log("[Machine_Jump:Execute] Impulse = %s", tostring(FinalZ))
InPawn.CharacterMovement:AddImpulse(VectorHelper.MakeVector(0, 0, FinalZ), true);
end
end
function Machine_Jump:Tick(dt, ServerTime)
--UGCLogSystem.Log("[Machine_Jump:Tick] ServerTime = %f", ServerTime);
end
--- 使用 tostring() 即可
---@return string
function Machine_Jump:ToString()
return "玩家大跳";
end
return Machine_Jump;