119 lines
3.3 KiB
Lua
119 lines
3.3 KiB
Lua
---@class BP_MoveFloor_C:AActor
|
|
---@field Floor UStaticMeshComponent
|
|
---@field FloorRoot USceneComponent
|
|
---@field EndTransformPoint USphereComponent
|
|
---@field StartTransformPoint USphereComponent
|
|
---@field DefaultSceneRoot USceneComponent
|
|
---@field Cycle float
|
|
---@field RandomCycle float
|
|
---@field RandomStart bool
|
|
---@field MoveCurve UCurveFloat
|
|
--Edit Below--
|
|
local BP_MoveFloor = {
|
|
InstCycle = 1;
|
|
StartTransform = {};
|
|
EndTransform = {};
|
|
StartMoveServerTime = 0;
|
|
NowCycleTime = 0;
|
|
bMoving = false;
|
|
};
|
|
|
|
|
|
function BP_MoveFloor:ReceiveBeginPlay()
|
|
self.SuperClass.ReceiveBeginPlay(self);
|
|
|
|
self:InitParam()
|
|
|
|
end
|
|
|
|
function BP_MoveFloor:InitParam()
|
|
self.StartTransform = self.StartTransformPoint:GetRelativeTransform()
|
|
self.EndTransform = self.EndTransformPoint:GetRelativeTransform()
|
|
if UGCGameSystem.IsServer() then
|
|
self.InstCycle = self.Cycle + KismetMathLibrary.RandomFloat() * self.RandomCycle * 2 - self.RandomCycle
|
|
if self.RandomStart then
|
|
self.NowCycleTime = KismetMathLibrary.RandomFloat() * self.InstCycle
|
|
end
|
|
end
|
|
end
|
|
|
|
function BP_MoveFloor:ActiveMove()
|
|
if self.bMoving ~= true then
|
|
local NowServerTime = UGCGameSystem.GameState:GetServerGameTime()
|
|
self.StartMoveServerTime = NowServerTime - self.NowCycleTime
|
|
UGCSendRPCSystem.ActorRPCNotify(nil, self, "ClientActiveMove", self.StartMoveServerTime)
|
|
self.bMoving = true
|
|
end
|
|
end
|
|
|
|
function BP_MoveFloor:ClientActiveMove(InStartMoveServerTime)
|
|
self.bMoving = true
|
|
self.StartMoveServerTime = InStartMoveServerTime
|
|
end
|
|
|
|
function BP_MoveFloor:StopMoving()
|
|
if self.bMoving ~= false then
|
|
local NowServerTime = UGCGameSystem.GameState:GetServerGameTime()
|
|
self.NowCycleTime = NowServerTime - self.StartMoveServerTime
|
|
self.bMoving = false
|
|
end
|
|
end
|
|
|
|
function BP_MoveFloor:ClientStopMoving(NowCycleTime)
|
|
self.bMoving = false
|
|
self.NowCycleTime = NowCycleTime
|
|
self:SetFloorNowTF(self.NowCycleTime)
|
|
end
|
|
|
|
function BP_MoveFloor:SetFloorNowTF(MoveTime)
|
|
local Time = MoveTime % self.InstCycle
|
|
local TargetTF
|
|
if Time < self.InstCycle / 2 then
|
|
TargetTF = KismetMathLibrary.TLerp(self.StartTransform, self.EndTransform, self:GetLerpAlpha(Time * 2 / self.InstCycle), ELerpInterpolationMode.QuatInterp)
|
|
else
|
|
TargetTF = KismetMathLibrary.TLerp(self.EndTransform, self.StartTransform, self:GetLerpAlpha((Time * 2 - self.InstCycle) / self.InstCycle), ELerpInterpolationMode.QuatInterp)
|
|
end
|
|
self.FloorRoot:K2_SetRelativeTransform(TargetTF)
|
|
end
|
|
|
|
function BP_MoveFloor:GetLerpAlpha(InAlpha)
|
|
if UE.IsValid(self.MoveCurve) then
|
|
return self.MoveCurve:GetFloatValue(InAlpha)
|
|
end
|
|
return InAlpha
|
|
end
|
|
|
|
|
|
function BP_MoveFloor:ReceiveTick(DeltaTime)
|
|
self.SuperClass.ReceiveTick(self, DeltaTime);
|
|
if self.bMoving then
|
|
local ServerTime = UGCGameSystem.GameState:GetServerGameTime()
|
|
self:SetFloorNowTF(ServerTime - self.StartMoveServerTime)
|
|
end
|
|
end
|
|
|
|
|
|
--[[
|
|
function BP_MoveFloor:ReceiveEndPlay()
|
|
self.SuperClass.ReceiveEndPlay(self);
|
|
end
|
|
--]]
|
|
|
|
|
|
function BP_MoveFloor:GetReplicatedProperties()
|
|
return
|
|
"InstCycle",
|
|
--"StartTransform",
|
|
--"EndTransform",
|
|
"StartMoveServerTime",
|
|
"bMoving"
|
|
end
|
|
|
|
|
|
--[[
|
|
function BP_MoveFloor:GetAvailableServerRPCs()
|
|
return
|
|
end
|
|
--]]
|
|
|
|
return BP_MoveFloor; |