82 lines
3.1 KiB
Lua
82 lines
3.1 KiB
Lua
-- Script.Global.BuffSystem.BuffAction.BuffAction_RateOfFire
|
|
local BuffActionBase = require('Script.Global.BuffSystem.BuffActionBase')
|
|
|
|
local BuffAction_RateOfFire = setmetatable(
|
|
{
|
|
-- 射速缩放
|
|
RateOfFireScale = 1.;
|
|
|
|
--
|
|
TempWeapon = {};
|
|
NowWeapon = nil
|
|
},
|
|
{ __index = BuffActionBase, __metatable = BuffActionBase }
|
|
);
|
|
|
|
function BuffAction_RateOfFire:LuaDoAction()
|
|
BuffActionBase.LuaDoAction(self)
|
|
|
|
if not UGCGameSystem.IsServer() then return true end
|
|
UGCLogSystem.Log("[BuffAction_RateOfFire_LuaDoAction]")
|
|
self:AddRateOfFire()
|
|
self.AddRateOfFireHandle = UGCEventSystem.SetTimerLoop(UGCGameSystem.GameState, function() self:AddRateOfFire() end, 2)
|
|
|
|
|
|
end
|
|
|
|
function BuffAction_RateOfFire:LuaUndoAction()
|
|
BuffActionBase.LuaUndoAction(self)
|
|
if not UGCGameSystem.IsServer() then return true end
|
|
if self.AddRateOfFireHandle then
|
|
UGCEventSystem.StopTimer(self.AddRateOfFireHandle)
|
|
end
|
|
self:RemoveRateOfFire()
|
|
end
|
|
|
|
|
|
function BuffAction_RateOfFire:AddRateOfFire()
|
|
-- UGCLogSystem.Log("[BuffAction_RateOfFire_AddRateOfFire]")
|
|
local OwnerPawn = self:GetOwnerPawn()
|
|
if UE.IsValid(OwnerPawn) then
|
|
for i, v in pairs(ShootWeaponEnums) do
|
|
local WeaponGun = UGCWeaponManagerSystem.GetWeaponBySlot(OwnerPawn, v)
|
|
--if UE.IsValid(WeaponGun) and not table.hasValue(self.TempWeapon, WeaponGun) then
|
|
-- UGCGunSystem.SetShootIntervalTime(WeaponGun, UGCGunSystem.GetShootIntervalTime(WeaponGun) / self.RateOfFireScale)
|
|
-- self.TempWeapon[#self.TempWeapon + 1] = WeaponGun
|
|
--end
|
|
if UE.IsValid(WeaponGun) then
|
|
local WeaponID = WeaponGun:GetWeaponItemID()
|
|
if WeaponID and WeaponTable.WeaponRateOfFire[WeaponID] then
|
|
UGCGunSystem.SetShootIntervalTime(WeaponGun, WeaponTable.WeaponRateOfFire[WeaponID] / self.RateOfFireScale)
|
|
--UGCLogSystem.Log("[BuffAction_RateOfFire_AddRateOfFire] Succeed WeaponID:%s", tostring(WeaponID))
|
|
end
|
|
end
|
|
end
|
|
end
|
|
end
|
|
|
|
function BuffAction_RateOfFire:RemoveRateOfFire()
|
|
local OwnerPawn = self:GetOwnerPawn()
|
|
if UE.IsValid(OwnerPawn) then
|
|
--for i, WeaponGun in pairs(self.TempWeapon) do
|
|
-- if UE.IsValid(WeaponGun) then
|
|
-- UGCGunSystem.SetShootIntervalTime(WeaponGun, UGCGunSystem.GetShootIntervalTime(WeaponGun) * self.RateOfFireScale)
|
|
-- end
|
|
--end
|
|
for i, v in pairs(ShootWeaponEnums) do
|
|
local WeaponGun = UGCWeaponManagerSystem.GetWeaponBySlot(OwnerPawn, v)
|
|
if UE.IsValid(WeaponGun) then
|
|
local WeaponID = WeaponGun:GetWeaponItemID()
|
|
if WeaponID and WeaponTable.WeaponRateOfFire[WeaponID] then
|
|
UGCGunSystem.SetShootIntervalTime(WeaponGun, WeaponTable.WeaponRateOfFire[WeaponID])
|
|
UGCLogSystem.Log("[BuffAction_RateOfFire_RemoveRateOfFire] Finish")
|
|
end
|
|
end
|
|
end
|
|
end
|
|
self.TempWeapon = {}
|
|
end
|
|
|
|
|
|
|
|
return BuffAction_RateOfFire; |