-
-
Notifications
You must be signed in to change notification settings - Fork 97
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #177 from stijnwop/feature/aplusheading
Feature/aplusheading
- Loading branch information
Showing
34 changed files
with
463 additions
and
316 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
-- | ||
-- GuidanceStrategyChangedEvent | ||
-- | ||
-- Guidance strategy event to sync guidance data with server. | ||
-- | ||
-- Copyright (c) Wopster, 2019 | ||
|
||
GuidanceStrategyChangedEvent = {} | ||
local GuidanceStrategyChangedEvent_mt = Class(GuidanceStrategyChangedEvent, Event) | ||
|
||
InitEventClass(GuidanceStrategyChangedEvent, "GuidanceStrategyChangedEvent") | ||
|
||
function GuidanceStrategyChangedEvent:emptyNew() | ||
local self = Event:new(GuidanceStrategyChangedEvent_mt) | ||
|
||
return self | ||
end | ||
|
||
function GuidanceStrategyChangedEvent:new(vehicle, method) | ||
local self = GuidanceStrategyChangedEvent:emptyNew() | ||
|
||
self.vehicle = vehicle | ||
self.method = method | ||
|
||
return self | ||
end | ||
|
||
function GuidanceStrategyChangedEvent:writeStream(streamId, connection) | ||
NetworkUtil.writeNodeObject(streamId, self.vehicle) | ||
streamWriteInt8(streamId, self.method + 1) | ||
end | ||
|
||
function GuidanceStrategyChangedEvent:readStream(streamId, connection) | ||
self.vehicle = NetworkUtil.readNodeObject(streamId) | ||
self.method = streamReadInt8(streamId) - 1 | ||
|
||
self:run(connection) | ||
end | ||
|
||
function GuidanceStrategyChangedEvent:run(connection) | ||
self.vehicle:setGuidanceStrategy(self.method, true) | ||
|
||
-- Send from server to all clients | ||
if not connection:getIsServer() then | ||
g_server:broadcastEvent(self, false, connection, self.vehicle) | ||
end | ||
end | ||
|
||
function GuidanceStrategyChangedEvent.sendEvent(object, method, noEventSend) | ||
if noEventSend == nil or not noEventSend then | ||
if g_server ~= nil then | ||
g_server:broadcastEvent(GuidanceStrategyChangedEvent:new(object, method), nil, nil, object) | ||
else | ||
g_client:getServerConnection():sendEvent(GuidanceStrategyChangedEvent:new(object, method)) | ||
end | ||
end | ||
end |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
-- | ||
-- StrategyInteractEvent | ||
-- | ||
-- Strategy push event to handle strategy interaction on other clients. | ||
-- | ||
-- Copyright (c) Wopster, 2019 | ||
|
||
StrategyInteractEvent = {} | ||
local StrategyInteractEvent_mt = Class(StrategyInteractEvent, Event) | ||
|
||
InitEventClass(StrategyInteractEvent, "StrategyInteractEvent") | ||
|
||
function StrategyInteractEvent:emptyNew() | ||
local self = Event:new(StrategyInteractEvent_mt) | ||
|
||
return self | ||
end | ||
|
||
function StrategyInteractEvent:new(object) | ||
local self = StrategyInteractEvent:emptyNew() | ||
|
||
self.object = object | ||
|
||
return self | ||
end | ||
|
||
function StrategyInteractEvent:writeStream(streamId, connection) | ||
NetworkUtil.writeNodeObject(streamId, self.object) | ||
|
||
local spec = self.object.spec_globalPositioningSystem | ||
spec.lineStrategy:writeStream(streamId, connection) | ||
end | ||
|
||
function StrategyInteractEvent:readStream(streamId, connection) | ||
self.object = NetworkUtil.readNodeObject(streamId) | ||
local spec = self.object.spec_globalPositioningSystem | ||
spec.lineStrategy:readStream(streamId, connection) | ||
|
||
self:run(connection) | ||
end | ||
|
||
function StrategyInteractEvent:run(connection) | ||
if not connection:getIsServer() then | ||
g_server:broadcastEvent(self, false, connection, self.object) | ||
end | ||
|
||
self.object:interactWithGuidanceStrategy(true) | ||
end | ||
|
||
function StrategyInteractEvent.sendEvent(object, noEventSend) | ||
if noEventSend == nil or not noEventSend then | ||
if g_server ~= nil then | ||
g_server:broadcastEvent(StrategyInteractEvent:new(object), nil, nil, object) | ||
else | ||
g_client:getServerConnection():sendEvent(StrategyInteractEvent:new(object)) | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.