Skip to main content
Skip to main content

SetFillUnitIsFillingEvent

SetFillUnitIsFillingEvent

Description

Event for toggle filling

Parent

Event

Functions

emptyNew

Description

Create instance of Event class

Definition

emptyNew()

Return Values

anyselfinstance of class event

Code

function SetFillUnitIsFillingEvent.emptyNew()
local self = Event.new( SetFillUnitIsFillingEvent _mt)
return self
end

new

Description

Create new instance of event

Definition

new(table vehicle, boolean isFilling)

Arguments

tablevehiclevehicle
booleanisFillingis filling state

Code

function SetFillUnitIsFillingEvent.new(vehicle, isFilling)
local self = SetFillUnitIsFillingEvent.emptyNew()
self.vehicle = vehicle
self.isFilling = isFilling
return self
end

readStream

Description

Called on client side

Definition

readStream(integer streamId, Connection connection)

Arguments

integerstreamIdstreamId
Connectionconnectionconnection

Code

function SetFillUnitIsFillingEvent:readStream(streamId, connection)
self.vehicle = NetworkUtil.readNodeObject(streamId)
self.isFilling = streamReadBool(streamId)
self:run(connection)
end

run

Description

Run action on receiving side

Definition

run(Connection connection)

Arguments

Connectionconnectionconnection

Code

function SetFillUnitIsFillingEvent:run(connection)
if self.vehicle ~ = nil and self.vehicle:getIsSynchronized() then
self.vehicle:setFillUnitIsFilling( self.isFilling, true )
end

if not connection:getIsServer() then
g_server:broadcastEvent( SetFillUnitIsFillingEvent.new( self.vehicle, self.isFilling), nil , connection, self.vehicle)
end
end

writeStream

Description

Called on server side

Definition

writeStream(integer streamId, Connection connection)

Arguments

integerstreamIdstreamId
Connectionconnectionconnection

Code

function SetFillUnitIsFillingEvent:writeStream(streamId, connection)
NetworkUtil.writeNodeObject(streamId, self.vehicle)
streamWriteBool(streamId, self.isFilling)
end