Merge branch 'eventsystem2'
This commit is contained in:
@@ -716,23 +716,24 @@ function Player:extraEvent(eventName,...)
|
|||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Write to stream
|
local SELF
|
||||||
if self.type=='human' then
|
|
||||||
ins(GAME.rep,self.frameRun)
|
|
||||||
ins(GAME.rep,64+eventID)
|
|
||||||
ins(GAME.rep,self.sid)
|
|
||||||
local data={...}
|
|
||||||
for i=1,#data do
|
|
||||||
ins(GAME.rep,data[i])
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
-- Trigger for all non-remote players
|
-- Trigger for all non-remote players
|
||||||
for _,p in next,PLAYERS do
|
for _,p in next,PLAYERS do
|
||||||
if p.type~='remote' then
|
if p.type~='remote' then
|
||||||
|
if p.type=='human' then
|
||||||
|
SELF=p
|
||||||
|
end
|
||||||
self.gameEnv.extraEventHandler[eventName](p,self,...)
|
self.gameEnv.extraEventHandler[eventName](p,self,...)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
ins(GAME.rep,SELF.frameRun)
|
||||||
|
ins(GAME.rep,64+eventID)
|
||||||
|
ins(GAME.rep,self.sid)
|
||||||
|
local data={...}
|
||||||
|
for i=1,#data do
|
||||||
|
ins(GAME.rep,data[i])
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function Player:getHolePos()-- Get a good garbage-line hole position
|
function Player:getHolePos()-- Get a good garbage-line hole position
|
||||||
@@ -2731,30 +2732,14 @@ local function update_streaming(P)
|
|||||||
P.streamProgress=P.streamProgress+eventParamCount+1
|
P.streamProgress=P.streamProgress+eventParamCount+1
|
||||||
|
|
||||||
local SRC
|
local SRC
|
||||||
local SELF
|
|
||||||
for _,p in next,PLAYERS do
|
for _,p in next,PLAYERS do
|
||||||
if P==sourceSid and p.sid==sourceSid then
|
if p.sid==sourceSid then
|
||||||
SRC=p
|
SRC=p
|
||||||
break
|
break
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if SRC then
|
if SRC then
|
||||||
for _,p in next,PLAYERS do
|
P.gameEnv.extraEventHandler[eventName](P,SRC,unpack(paramList))
|
||||||
if p.type=='human' then
|
|
||||||
SELF=p
|
|
||||||
break
|
|
||||||
end
|
|
||||||
end
|
|
||||||
SELF.gameEnv.extraEventHandler[eventName](SRC,SELF,unpack(paramList))
|
|
||||||
-- Write to stream
|
|
||||||
if SELF.type=='human' then
|
|
||||||
ins(GAME.rep,SELF.frameRun)
|
|
||||||
ins(GAME.rep,event)
|
|
||||||
ins(GAME.rep,SELF.sid)
|
|
||||||
for i=1,#paramList do
|
|
||||||
ins(GAME.rep,paramList[i])
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
P.streamProgress=P.streamProgress+2
|
P.streamProgress=P.streamProgress+2
|
||||||
@@ -2817,7 +2802,7 @@ function Player:update(dt)
|
|||||||
end
|
end
|
||||||
while self.trigFrame>=1 do
|
while self.trigFrame>=1 do
|
||||||
if self.streamProgress then
|
if self.streamProgress then
|
||||||
local frameDelta-- Time between now and end of stream
|
local dataDelta=0 -- How much data wating to be process
|
||||||
if self.type=='remote' then
|
if self.type=='remote' then
|
||||||
if self.loseTimer then
|
if self.loseTimer then
|
||||||
self.loseTimer=self.loseTimer-1
|
self.loseTimer=self.loseTimer-1
|
||||||
@@ -2826,25 +2811,24 @@ function Player:update(dt)
|
|||||||
self:lose(true)
|
self:lose(true)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
frameDelta=(self.stream[#self.stream-1] or 0)-self.frameRun
|
dataDelta=#self.stream-self.streamProgress
|
||||||
if frameDelta==0 then frameDelta=nil end
|
|
||||||
else
|
|
||||||
frameDelta=0
|
|
||||||
end
|
end
|
||||||
if frameDelta then
|
if dataDelta>0 then
|
||||||
for _=1,
|
for _=1,
|
||||||
self.loseTimer and min(frameDelta,
|
-- Speed up to finish
|
||||||
|
self.loseTimer and min(dataDelta,
|
||||||
self.loseTimer>16 and 2 or
|
self.loseTimer>16 and 2 or
|
||||||
self.loseTimer>6.2 and 12 or
|
self.loseTimer>6.2 and 12 or
|
||||||
self.loseTimer>2.6 and 260 or
|
self.loseTimer>2.6 and 260 or
|
||||||
2600
|
2600
|
||||||
) or
|
) or
|
||||||
frameDelta<26 and 1 or
|
-- Chasing faster when slower
|
||||||
frameDelta<50 and 2 or
|
dataDelta<26 and 1 or
|
||||||
frameDelta<80 and 3 or
|
dataDelta<42 and 2 or
|
||||||
frameDelta<120 and 5 or
|
dataDelta<62 and 3 or
|
||||||
frameDelta<160 and 7 or
|
dataDelta<70.23 and 5 or
|
||||||
frameDelta<200 and 10 or
|
dataDelta<94.2 and 7 or
|
||||||
|
dataDelta<126 and 10 or
|
||||||
20
|
20
|
||||||
do
|
do
|
||||||
update_streaming(self)
|
update_streaming(self)
|
||||||
|
|||||||
Reference in New Issue
Block a user