Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
erp5
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
1
Issues
1
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Roque
erp5
Commits
567a03a5
Commit
567a03a5
authored
Sep 26, 2022
by
Roque
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[WEB-WORKER] [WIP] handle game finish
parent
b5c1cde2
Changes
8
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
40 additions
and
27 deletions
+40
-27
erp5_drone_simulator/PathTemplateItem/web_page_module/drone_web_worker_game_manager_js.js
...eItem/web_page_module/drone_web_worker_game_manager_js.js
+22
-10
erp5_drone_simulator/PathTemplateItem/web_page_module/drone_web_worker_game_manager_js.xml
...Item/web_page_module/drone_web_worker_game_manager_js.xml
+2
-2
erp5_drone_simulator/PathTemplateItem/web_page_module/drone_web_worker_logic_js.js
...TemplateItem/web_page_module/drone_web_worker_logic_js.js
+3
-3
erp5_drone_simulator/PathTemplateItem/web_page_module/drone_web_worker_logic_js.xml
...emplateItem/web_page_module/drone_web_worker_logic_js.xml
+2
-2
erp5_drone_simulator/PathTemplateItem/web_page_module/drone_web_worker_page_js.js
...hTemplateItem/web_page_module/drone_web_worker_page_js.js
+4
-1
erp5_drone_simulator/PathTemplateItem/web_page_module/drone_web_worker_page_js.xml
...TemplateItem/web_page_module/drone_web_worker_page_js.xml
+2
-2
erp5_drone_simulator/PathTemplateItem/web_page_module/drone_web_worker_web_worker_js.js
...ateItem/web_page_module/drone_web_worker_web_worker_js.js
+3
-5
erp5_drone_simulator/PathTemplateItem/web_page_module/drone_web_worker_web_worker_js.xml
...teItem/web_page_module/drone_web_worker_web_worker_js.xml
+2
-2
No files found.
erp5_drone_simulator/PathTemplateItem/web_page_module/drone_web_worker_game_manager_js.js
View file @
567a03a5
...
...
@@ -61,7 +61,12 @@ var GameManager = /** @class */ (function () {
GameManager
.
prototype
.
run
=
function
()
{
var
gadget
=
this
;
return
gadget
.
_init
();
return
gadget
.
_init
()
.
push
(
function
()
{
//TODO return result
gadget
.
_final_score
=
"
fake-result 000
"
;
return
gadget
.
_final_score
;
});
};
/*GameManager.prototype.event = function (event) {
...
...
@@ -97,7 +102,6 @@ var GameManager = /** @class */ (function () {
}
}
triggerUpdateIfPossible
();
console
.
log
(
"
after triggerUpdateIfPossible call
"
);
};
GameManager
.
prototype
.
delay
=
function
(
callback
,
millisecond
)
{
...
...
@@ -206,12 +210,23 @@ var GameManager = /** @class */ (function () {
});
return
queue
//TODO finish
/*.push(function (
) {
if (_this._allDroneAreOut()) {
.
push
(
function
()
{
if
(
_this
.
_timeOut
()
)
{
console
.
log
(
"
TIMEOUT!
"
);
return
_this
.
_finish
();
}
})*/
;
});
};
GameManager
.
prototype
.
_timeOut
=
function
()
{
var
seconds
=
Math
.
floor
(
this
.
_game_duration
/
1000
);
return
this
.
_totalTime
-
seconds
<=
0
;
};
GameManager
.
prototype
.
_finish
=
function
()
{
console
.
log
(
"
Simulation finished
"
);
this
.
_canUpdate
=
false
;
return
this
.
finish_deferred
.
resolve
();
};
GameManager
.
prototype
.
_dispose
=
function
()
{
...
...
@@ -396,7 +411,6 @@ var GameManager = /** @class */ (function () {
// Timing
this
.
_game_duration
=
0
;
this
.
_totalTime
=
GAMEPARAMETERS
.
gameTime
;
this
.
_canUpdate
=
true
;
return
new
RSVP
.
Queue
()
.
push
(
function
()
{
...
...
@@ -412,9 +426,7 @@ var GameManager = /** @class */ (function () {
return
RSVP
.
all
(
promise_list
);
})
.
push
(
function
()
{
//TODO refactor this as start promise
//solving promise so game-start finishes and web worker can update
_this
.
finish_deferred
.
resolve
();
_this
.
_canUpdate
=
true
;
return
_this
.
finish_deferred
.
promise
;
});
};
...
...
erp5_drone_simulator/PathTemplateItem/web_page_module/drone_web_worker_game_manager_js.xml
View file @
567a03a5
...
...
@@ -244,7 +244,7 @@
</item>
<item>
<key>
<string>
serial
</string>
</key>
<value>
<string>
1003.14
634.55498.6080
8
</string>
</value>
<value>
<string>
1003.14
745.13798.2438
8
</string>
</value>
</item>
<item>
<key>
<string>
state
</string>
</key>
...
...
@@ -262,7 +262,7 @@
</tuple>
<state>
<tuple>
<float>
166422
0253.75
</float>
<float>
166422
6905.63
</float>
<string>
UTC
</string>
</tuple>
</state>
...
...
erp5_drone_simulator/PathTemplateItem/web_page_module/drone_web_worker_logic_js.js
View file @
567a03a5
...
...
@@ -212,8 +212,6 @@ var runGame, updateGame, eventGame, game_manager_instance;
game_parameters_json
.
randomSpawn
.
rightTeam
.
position
.
y
=
destination
[
1
];
return
game_parameters_json
;
}
console
.
log
(
'
runGame
'
,
canvas
);
game_parameters_json
=
processLog
(
game_parameters_json
,
log
);
if
(
!
game_manager_instance
)
{
game_manager_instance
=
new
GameManager
(
canvas
,
script
,
...
...
@@ -223,7 +221,9 @@ var runGame, updateGame, eventGame, game_manager_instance;
};
updateGame
=
function
()
{
if
(
game_manager_instance
)
{
return
game_manager_instance
.
update
();
}
};
/*eventGame = function (event) {
...
...
erp5_drone_simulator/PathTemplateItem/web_page_module/drone_web_worker_logic_js.xml
View file @
567a03a5
...
...
@@ -244,7 +244,7 @@
</item>
<item>
<key>
<string>
serial
</string>
</key>
<value>
<string>
1003.14
628.31171.12032
</string>
</value>
<value>
<string>
1003.14
747.15369.21845
</string>
</value>
</item>
<item>
<key>
<string>
state
</string>
</key>
...
...
@@ -262,7 +262,7 @@
</tuple>
<state>
<tuple>
<float>
166422
0293.27
</float>
<float>
166422
6919.33
</float>
<string>
UTC
</string>
</tuple>
</state>
...
...
erp5_drone_simulator/PathTemplateItem/web_page_module/drone_web_worker_page_js.js
View file @
567a03a5
...
...
@@ -136,7 +136,6 @@
worker
.
onmessage
=
workerToMain
;
// Always quit the game when the worker callback usage is over
// to prevent trying to call pause
//context.quit();
return
message_error_handler_defer
.
promise
;
function
workerToMain
(
evt
)
{
...
...
@@ -161,6 +160,10 @@
case
'
updated
'
:
return
update_defer
.
resolve
(
'
updated
'
);
break
;
case
'
finished
'
:
console
.
log
(
'
GAME: finished
'
);
return
context
.
quit
();
break
;
case
'
event
'
:
bindEvent
(
evt
.
data
);
break
;
...
...
erp5_drone_simulator/PathTemplateItem/web_page_module/drone_web_worker_page_js.xml
View file @
567a03a5
...
...
@@ -244,7 +244,7 @@
</item>
<item>
<key>
<string>
serial
</string>
</key>
<value>
<string>
1003.14
385.9806.22681
</string>
</value>
<value>
<string>
1003.14
737.54205.32802
</string>
</value>
</item>
<item>
<key>
<string>
state
</string>
</key>
...
...
@@ -262,7 +262,7 @@
</tuple>
<state>
<tuple>
<float>
16642
05234.37
</float>
<float>
16642
26969.03
</float>
<string>
UTC
</string>
</tuple>
</state>
...
...
erp5_drone_simulator/PathTemplateItem/web_page_module/drone_web_worker_web_worker_js.js
View file @
567a03a5
...
...
@@ -12,9 +12,6 @@
/**************************** ROQUE WW EVENTS ****************************/
/*************************************************************************/
console
.
log
(
"
WITH EVENTS HANDLING
"
);
self
.
window
=
{
addEventListener
:
function
(
event
,
fn
,
opt
)
{
bindHandler
(
'
window
'
,
event
,
fn
,
opt
);
...
...
@@ -52,11 +49,12 @@ function mainToWorker(evt) {
RSVP
=
window
.
RSVP
;
return
new
RSVP
.
Queue
()
.
push
(
function
()
{
postMessage
({
'
type
'
:
'
started
'
});
return
runGame
(
offscreen_canvas
,
evt
.
data
.
script
,
evt
.
data
.
game_parameters_json
,
evt
.
data
.
log
);
})
.
push
(
function
()
{
return
postMessage
({
'
type
'
:
'
started
'
});
.
push
(
function
(
result
)
{
return
postMessage
({
'
type
'
:
'
finished
'
,
'
result
'
:
result
});
});
break
;
case
'
update
'
:
...
...
erp5_drone_simulator/PathTemplateItem/web_page_module/drone_web_worker_web_worker_js.xml
View file @
567a03a5
...
...
@@ -244,7 +244,7 @@
</item>
<item>
<key>
<string>
serial
</string>
</key>
<value>
<string>
1003.14
379.48012.26709
</string>
</value>
<value>
<string>
1003.14
747.40357.20480
</string>
</value>
</item>
<item>
<key>
<string>
state
</string>
</key>
...
...
@@ -262,7 +262,7 @@
</tuple>
<state>
<tuple>
<float>
16642
05261.72
</float>
<float>
16642
26941.47
</float>
<string>
UTC
</string>
</tuple>
</state>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment