-- Private Niagara systems and collections for owned attacks; the world's player position is never written. local U=require('ue_observe') local Effects={} Effects.paths={asset='/Script/Niagara.NiagaraComponent:SetAsset',activate='/Script/Engine.ActorComponent:Activate'} Effects.systems={NS_ZuoShangLongTi_SwordFormation_202=true, NS_MengHua_SpaceTear_001=true,NS_Troop_WireAtk_001_Wire=true, NS_ChiYingGuRen_MaskRing_001=true,NS_ChiYingGuRen_MaskRing_002=true} local COLLECTION='/PBZVFXPack/VFX/A_Niagara/CommonNPC/NPC_CharInfo_001.NPC_CharInfo_001' local LIB='/Script/Niagara.Default__NiagaraFunctionLibrary' local LIMIT_SECONDS=20 local function call(object,method,...) if not U.valid(object) then return false end local args={...};local ok,value=pcall(function()return object[method](object,table.unpack(args))end) return ok,U.unwrap(value) end local function name(object) local ok,value=call(object,'GetFullName');return ok and type(value)=='string' and value or nil end local function short(object) if not U.valid(object)then return nil end local ok,value=pcall(function()return object:GetFName():ToString()end) return ok and type(value)=='string' and value or nil end local function color(value) if not value then return nil end local ok,r,g,b,a=pcall(function()return value.R,value.G,value.B,value.A end) if ok and type(r)=='number' and type(g)=='number' and type(b)=='number' and type(a)=='number' then return {R=r,G=g,B=b,A=a}end end local function same(a,b) return a and b and math.abs(a.R-b.R)<0.5 and math.abs(a.G-b.G)<0.5 and math.abs(a.B-b.B)<0.5 and math.abs(a.A-b.A)<0.001 end local function privateArray(copy,template,field) local a,b=U.field(copy,field),U.field(template,field) if U.kind(a)=='table'and U.kind(b)=='table'then return a~=b end if U.kind(a)~='TArray'or U.kind(b)~='TArray'then return false end local ok,x,y=pcall(function()return a:GetArrayDataAddress(),b:GetArrayDataAddress()end) return ok and type(x)=='number'and type(y)=='number'and(x==0 or y==0 or x~=y) end local function at(actor) local mesh=U.field(actor,'Mesh') local ok,spot=call(mesh,'K2_GetComponentLocation') if not ok then ok,spot=call(actor,'K2_GetActorLocation')end if not ok or not spot then return nil end local got,x,y,z=pcall(function()return spot.X,spot.Y,spot.Z end) local function finite(n)return type(n)=='number'and n==n and math.abs(n)=nextScan then nextScan=clock()+0.25;scan()end for id,item in pairs(records)do local key=U.valid(item.comp)and own(item.comp) local bullet=select(2,call(item.comp,'GetOwner')) local status=U.field(bullet,'BulletStatus') local ended=status~=nil and status~=1 and status~=2 or clock()-item.since>LIMIT_SECONDS if not U.valid(item.comp)or U.key(U.field(item.comp,'Asset'))~=U.key(item.copy)then records[id]=nil elseif item.recover then if restore(item,item.recover,item.reactivate)then records[id]=nil end elseif key~=item.key or not allowed(key)or name(item.actor)~=item.actorName or ended then if restore(item,'结束或移交')then records[id]=nil end elseif not options.paused or not options.paused()then updateGroup(item.group,key)end end if clock()>=armedUntil and not next(records)then stopLoop()end end local function startLoop() if loop then return end loopGeneration=loopGeneration+1;local generation=loopGeneration local ok,handle=pcall(options.loop or LoopInGameThreadWithDelay,50,function() if generation==loopGeneration and self.alive then run()end end) if ok and handle~=nil and handle~=false then loop=handle else loopGeneration=loopGeneration+1;log('loop','特效隔离循环注册未确认')end end function self:arm() if not self.alive or not thread()then return end armedUntil=math.max(armedUntil,clock()+LIMIT_SECONDS);startLoop() end function self:tick() if not self.alive or not thread()then return end if options.active()and clock()>=nextHook then nextHook=clock()+3 for kind,path in pairs(Effects.paths)do if not hooks[kind]then local found,fn=pcall(find,path) if found and U.valid(fn)then local ok,a,b=pcall(register,path,function(context,asset) if not self.alive or internal>0 or not thread()or not options.active()and not next(records)then return end if kind=='activate'and clock()>=armedUntil and not next(records)then return end local comp=U.unwrap(context);local id=U.key(comp) if not id then return end local original=kind=='asset'and U.unwrap(asset)or U.field(comp,'Asset') if not records[id]and(not U.valid(original)or not Effects.systems[short(original)])then return end local old=records[id];local source=own(comp) if old and source~=old.key then if not restore(old,'激活前归属变化')then return end records[id]=nil if kind=='activate'then original=U.field(comp,'Asset')end end if kind=='asset' and allowed(source)then if U.valid(original)and Effects.systems[short(original)]then self:arm()end elseif kind=='activate'and allowed(source)then if U.valid(original)and Effects.systems[short(original)]then ensure(comp,source,original);startLoop()end end end,function()end) if ok and type(a)=='number'and type(b)=='number'then hooks[kind]={a,b}end end end end end local used={};for _,item in pairs(records)do used[item.group]=true end for key,group in pairs(groups)do if not U.valid(group.actor)or group.name~=name(group.actor)or clock()-group.last>5 and not used[group]then groups[key]=nil end end for key,untilAt in pairs(failAt)do if clock()>=untilAt then failAt[key]=nil end end end function self:status()return {changed=self.changed,failed=self.failed,running=next(records)~=nil}end function self:silence() self.alive=false;stopLoop() for kind,ids in pairs(hooks)do pcall(unregister,Effects.paths[kind],ids[1],ids[2])end end return self end return Effects