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
a6c32ef0
Commit
a6c32ef0
authored
Sep 27, 2022
by
Roque
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[WEB-WORKER] [WIP] move all game logic into one file (WIP)
parent
95103c60
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
46 additions
and
57 deletions
+46
-57
erp5_drone_simulator/PathTemplateItem/web_page_module/drone_web_worker_drone_api_js.xml
...ateItem/web_page_module/drone_web_worker_drone_api_js.xml
+3
-9
erp5_drone_simulator/PathTemplateItem/web_page_module/drone_web_worker_logic_js.js
...TemplateItem/web_page_module/drone_web_worker_logic_js.js
+39
-43
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_web_worker_js.js
...ateItem/web_page_module/drone_web_worker_web_worker_js.js
+0
-1
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_drone_api_js.xml
View file @
a6c32ef0
...
...
@@ -10,11 +10,8 @@
<key>
<string>
_Access_contents_information_Permission
</string>
</key>
<value>
<tuple>
<string>
Anonymous
</string>
<string>
Assignee
</string>
<string>
Assignor
</string>
<string>
Associate
</string>
<string>
Auditor
</string>
<string>
Manager
</string>
</tuple>
</value>
...
...
@@ -52,11 +49,8 @@
<key>
<string>
_View_Permission
</string>
</key>
<value>
<tuple>
<string>
Anonymous
</string>
<string>
Assignee
</string>
<string>
Assignor
</string>
<string>
Associate
</string>
<string>
Auditor
</string>
<string>
Manager
</string>
</tuple>
</value>
...
...
@@ -169,7 +163,7 @@
<dictionary>
<item>
<key>
<string>
action
</string>
</key>
<value>
<string>
publish_aliv
e
</string>
</value>
<value>
<string>
hid
e
</string>
</value>
</item>
<item>
<key>
<string>
actor
</string>
</key>
...
...
@@ -195,7 +189,7 @@
</tuple>
<state>
<tuple>
<float>
166
2556207.86
</float>
<float>
166
4301067.15
</float>
<string>
UTC
</string>
</tuple>
</state>
...
...
@@ -204,7 +198,7 @@
</item>
<item>
<key>
<string>
validation_state
</string>
</key>
<value>
<string>
published_alive
</string>
</value>
<value>
<string>
hidden
</string>
</value>
</item>
</dictionary>
</list>
...
...
erp5_drone_simulator/PathTemplateItem/web_page_module/drone_web_worker_logic_js.js
View file @
a6c32ef0
...
...
@@ -201,9 +201,12 @@ var runGame, updateGame, eventGame, game_manager_instance;
};
game_parameters_json
.
drone
.
maxSpeed
=
(
flight_dist
/
flight_time
)
*
SPEED_FACTOR
;
game_parameters_json
.
obstacles
=
path_point_list
;
game_parameters_json
.
randomSpawn
.
leftTeam
.
position
.
x
=
start_position
[
0
];
/*
game_parameters_json.randomSpawn.leftTeam.position.x = start_position[0];
game_parameters_json.randomSpawn.leftTeam.position.y = start_position[1];
game_parameters_json
.
randomSpawn
.
leftTeam
.
position
.
z
=
start_position
[
2
];
game_parameters_json.randomSpawn.leftTeam.position.z = start_position[2];*/
game_parameters_json
.
dronesPosition
.
x
=
start_position
[
0
];
game_parameters_json
.
dronesPosition
.
y
=
start_position
[
1
];
game_parameters_json
.
dronesPosition
.
z
=
start_position
[
2
];
game_parameters_json
.
gameTime
=
flight_time
;
//give map some margin from the flight
game_parameters_json
.
mapSize
.
width
=
MAP_SIZE
*
1.10
;
...
...
@@ -274,8 +277,11 @@ var GameManager = /** @class */ (function () {
this
.
_last_position_drawn
=
[];
this
.
_log_count
=
[];
this
.
_flight_log
=
[];
//TODO drop the use of RS map and use a JSON instead. drop randomspawn and similar names //rename all
//TODO do this in above, in game logic game_parameters_json
//move this to JSON dict
if
(
GAMEPARAMETERS
.
compareFlights
)
{
for
(
var
count
=
0
;
count
<
GAMEPARAMETERS
.
teamSize
;
count
++
)
{
for
(
var
count
=
0
;
count
<
GAMEPARAMETERS
.
droneList
.
length
;
count
++
)
{
this
.
_flight_log
[
count
]
=
[];
this
.
_log_count
[
count
]
=
0
;
this
.
_last_position_drawn
[
count
]
=
null
;
...
...
@@ -289,8 +295,7 @@ var GameManager = /** @class */ (function () {
}
this
.
APIs_dict
=
{
DroneAaileFixeAPI
:
DroneAaileFixeAPI
,
DroneLogAPI
:
DroneLogAPI
,
DroneAPI
:
DroneAPI
DroneLogAPI
:
DroneLogAPI
};
}
...
...
@@ -349,7 +354,7 @@ var GameManager = /** @class */ (function () {
this
.
_game_duration
+=
delta_time
;
var
seconds
=
Math
.
floor
(
this
.
_game_duration
/
1000
);
if
(
GAMEPARAMETERS
.
compareFlights
)
{
for
(
var
count
=
0
;
count
<
GAMEPARAMETERS
.
teamSize
;
count
++
)
{
for
(
var
count
=
0
;
count
<
GAMEPARAMETERS
.
droneList
.
length
;
count
++
)
{
if
(
this
.
_teamLeft
[
count
].
_controlMesh
)
{
var
drone_position_x
=
this
.
_teamLeft
[
count
].
_controlMesh
.
position
.
x
,
drone_position_z
=
this
.
_teamLeft
[
count
].
_controlMesh
.
position
.
y
,
...
...
@@ -369,7 +374,7 @@ var GameManager = /** @class */ (function () {
this
.
_flight_log
[
count
].
push
([
lat
,
lon
,
drone_position_z
]);
}
}
if
(
GAMEPARAMETERS
.
compareFlights
.
draw
)
{
if
(
GAMEPARAMETERS
.
compareFlights
.
draw
)
{
//TODO review this in JSON dict
//draw drone position every second
if
(
this
.
_last_position_drawn
[
count
]
!==
seconds
)
{
this
.
_last_position_drawn
[
count
]
=
seconds
;
...
...
@@ -492,18 +497,14 @@ var GameManager = /** @class */ (function () {
GAMEPARAMETERS
=
ctx
.
_getGameParameter
();
ctx
.
_map_swapped
=
true
;
}
// Create the API
var
lAPI
=
new
DroneAPI
(
ctx
,
"
L
"
);
//TODO rename all left/team
console
.
log
(
"
APIs created
"
);
// Set the AI code into drones
var
AIcodeEval
,
AIcodeLeft
;
var
AIcodeEval
,
AIcodeLeft
;
//TODO rename all left/team/'L'
AIcodeLeft
=
ctx
.
_script
;
// Init the map
_this
.
_mapManager
=
new
MapManager
(
ctx
.
_scene
);
console
.
log
(
"
Map manager instantiated
"
);
if
(
GAMEPARAMETERS
.
randomSpawn
)
{
//TODO drop the use of RS map and use JSON instead. drop randomspawn and similar names //rename all
ctx
.
_setRandomSpawnPosition
(
GAMEPARAMETERS
.
randomSpawn
.
leftTeam
,
GAMEPARAMETERS
.
teamSize
,
lAPI
,
AIcodeLeft
,
"
L
"
);
}
ctx
.
_spawnDrones
(
GAMEPARAMETERS
.
dronesPosition
,
GAMEPARAMETERS
.
droneList
,
AIcodeLeft
);
// Hide the drone prefab
DroneManager
.
Prefab
.
isVisible
=
false
;
//Hack to make advanced texture work
...
...
@@ -654,48 +655,43 @@ var GameManager = /** @class */ (function () {
return
parameter
;
};
GameManager
.
prototype
.
_s
etRandomSpawnPosition
=
function
(
randomSpawn
,
team_size
,
api
,
code
,
team
)
{
var
position
,
i
,
position_list
=
[],
center
=
randomSpawn
.
position
,
max_collision
=
randomSpawn
.
maxCollision
||
10
*
team_size
,
collision_nb
=
0
;
function
checkCollision
(
position
,
list
)
{
var
i
;
for
(
i
=
0
;
i
<
list
.
length
;
i
+=
1
)
{
if
(
position
.
equalsWithEpsilon
(
list
[
i
],
0.5
)
)
{
return
true
;
}
GameManager
.
prototype
.
_s
pawnDrones
=
function
(
center
,
drone_list
,
code
)
{
var
position
,
i
,
position_list
=
[],
max_collision
=
10
*
drone_list
.
length
,
collision_nb
=
0
;
function
checkCollision
(
position
,
list
)
{
var
i
;
for
(
i
=
0
;
i
<
list
.
length
;
i
+=
1
)
{
if
(
position
.
equalsWithEpsilon
(
list
[
i
],
0.5
))
{
return
true
;
}
return
false
;
}
for
(
i
=
0
;
i
<
team_size
;
i
+=
1
)
{
if
(
team
===
"
L
"
||
i
===
0
)
{
//TODO refactor as 'R' is dropped
position
=
randomSpherePoint
(
center
.
x
+
i
,
center
.
y
+
i
,
center
.
z
+
i
,
0
,
0
,
0
);
if
(
checkCollision
(
position
,
position_list
)
||
position
.
z
<
0.05
)
{
collision_nb
+=
1
;
if
(
collision_nb
<
max_collision
)
{
i
-=
1
;
}
}
else
{
position_list
.
push
(
position
);
var
lAPI
=
api
;
if
(
randomSpawn
.
types
)
{
if
(
randomSpawn
.
types
[
i
]
in
this
.
APIs_dict
)
{
lAPI
=
new
this
.
APIs_dict
[
randomSpawn
.
types
[
i
]](
this
,
"
L
"
,
GAMEPARAMETERS
.
compareFlights
);
}
}
this
.
_setSpawnDrone
(
position
.
x
,
position
.
y
,
position
.
z
,
i
,
lAPI
,
code
,
team
);
}
return
false
;
}
for
(
i
=
0
;
i
<
drone_list
.
length
;
i
+=
1
)
{
position
=
randomSpherePoint
(
center
.
x
+
i
,
center
.
y
+
i
,
center
.
z
+
i
,
0
,
0
,
0
);
if
(
checkCollision
(
position
,
position_list
)
||
position
.
z
<
0.05
)
{
collision_nb
+=
1
;
if
(
collision_nb
<
max_collision
)
{
i
-=
1
;
}
}
else
{
position_list
.
push
(
position
);
var
api
=
new
this
.
APIs_dict
[
drone_list
[
i
]](
this
,
"
L
"
,
GAMEPARAMETERS
.
compareFlights
);
//TODO drip L team in DroneAPI
this
.
_setSpawnDrone
(
position
.
x
,
position
.
y
,
position
.
z
,
i
,
api
,
code
);
}
}
};
GameManager
.
prototype
.
_setSpawnDrone
=
function
(
x
,
y
,
z
,
index
,
api
,
code
,
team
)
{
GameManager
.
prototype
.
_setSpawnDrone
=
function
(
x
,
y
,
z
,
index
,
api
,
code
)
{
var
default_drone_AI
=
api
.
getDroneAI
();
if
(
default_drone_AI
)
{
code
=
default_drone_AI
;
}
var
team
=
"
L
"
;
//TODO DROP TEAM
var
ctx
=
this
,
base
,
code_eval
=
"
let drone = new DroneManager(ctx._scene,
"
+
index
+
'
, "
'
+
team
+
'
", api);
'
+
"
let droneMe = function(NativeDate, me, Math, window, DroneManager, GameManager, Drone
API, Drone
LogAPI, DroneAaileFixeAPI, BABYLON, GAMEPARAMETERS) {
"
+
"
let droneMe = function(NativeDate, me, Math, window, DroneManager, GameManager, DroneLogAPI, DroneAaileFixeAPI, BABYLON, GAMEPARAMETERS) {
"
+
"
var start_time = (new Date(2070, 0, 0, 0, 0, 0, 0)).getTime();
"
+
"
Date.now = function () {return start_time + drone._tick * 1000/60;};
"
+
"
function Date() {if (!(this instanceof Date)) {throw new Error('Missing new operator');}
"
+
...
...
erp5_drone_simulator/PathTemplateItem/web_page_module/drone_web_worker_logic_js.xml
View file @
a6c32ef0
...
...
@@ -244,7 +244,7 @@
</item>
<item>
<key>
<string>
serial
</string>
</key>
<value>
<string>
1003.1
5933.21857.42444
</string>
</value>
<value>
<string>
1003.1
6008.33206.11520
</string>
</value>
</item>
<item>
<key>
<string>
state
</string>
</key>
...
...
@@ -262,7 +262,7 @@
</tuple>
<state>
<tuple>
<float>
1664
298143.44
</float>
<float>
1664
302663.7
</float>
<string>
UTC
</string>
</tuple>
</state>
...
...
erp5_drone_simulator/PathTemplateItem/web_page_module/drone_web_worker_web_worker_js.js
View file @
a6c32ef0
...
...
@@ -30,7 +30,6 @@ importScripts('rsvp.js',
'
ObstacleManager.js
'
,
'
DroneAaileFixeAPI.js
'
,
'
DroneLogAPI.js
'
,
'
DroneAPI.js
'
,
'
gadget_erp5_page_game_logic.js
'
);
function
mainToWorker
(
evt
)
{
...
...
erp5_drone_simulator/PathTemplateItem/web_page_module/drone_web_worker_web_worker_js.xml
View file @
a6c32ef0
...
...
@@ -244,7 +244,7 @@
</item>
<item>
<key>
<string>
serial
</string>
</key>
<value>
<string>
1003.1592
0.8115.2452
4
</string>
</value>
<value>
<string>
1003.1592
1.17646.5623
4
</string>
</value>
</item>
<item>
<key>
<string>
state
</string>
</key>
...
...
@@ -262,7 +262,7 @@
</tuple>
<state>
<tuple>
<float>
1664
297356.11
</float>
<float>
1664
301536.13
</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