Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
B
batajelo
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
14
Issues
14
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
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
louiz’
batajelo
Commits
1ccbd31d
Commit
1ccbd31d
authored
Apr 16, 2015
by
louiz’
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add a way to game the current world time
parent
ceb4569e
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
25 additions
and
1 deletion
+25
-1
src/game/game.cpp
src/game/game.cpp
+5
-0
src/game/game.hpp
src/game/game.hpp
+2
-0
src/game/turn_handler.cpp
src/game/turn_handler.cpp
+8
-0
src/game/turn_handler.hpp
src/game/turn_handler.hpp
+6
-1
src/gui/camera/camera.cpp
src/gui/camera/camera.cpp
+4
-0
No files found.
src/game/game.cpp
View file @
1ccbd31d
...
...
@@ -87,3 +87,8 @@ void Game::cast_callback(Message* message)
srl
.
turn
());
}
}
utils
::
FloatingSeconds
Game
::
current_world_time
()
const
{
return
this
->
turn_handler
.
get_current_time
();
}
src/game/game.hpp
View file @
1ccbd31d
...
...
@@ -8,6 +8,7 @@
#include <world/world.hpp>
#include <world/entity.hpp>
#include <utils/time.hpp>
#include <game/turn_handler.hpp>
#include <game/occupants_handler.hpp>
...
...
@@ -22,6 +23,7 @@ public:
void
new_entity_callback
(
Message
*
msg
);
void
move_callback
(
Message
*
msg
);
void
cast_callback
(
Message
*
msg
);
utils
::
FloatingSeconds
current_world_time
()
const
;
protected:
World
world
;
...
...
src/game/turn_handler.cpp
View file @
1ccbd31d
...
...
@@ -103,6 +103,14 @@ unsigned long TurnHandler::get_current_turn() const
return
this
->
current_turn
;
}
utils
::
FloatingSeconds
TurnHandler
::
get_current_time
()
const
{
auto
total_ticks
=
this
->
get_current_turn
()
*
TURN_TICKS
+
\
this
->
turn_advancement
;
auto
ticks_duration
=
utils
::
ticks
(
total_ticks
);
return
std
::
chrono
::
duration_cast
<
utils
::
FloatingSeconds
>
(
ticks_duration
);
}
std
::
deque
<
Turn
>&
TurnHandler
::
get_turns
()
{
return
this
->
turns
;
...
...
src/game/turn_handler.hpp
View file @
1ccbd31d
...
...
@@ -11,10 +11,11 @@
#include <functional>
#include <game/turn.hpp>
#include <utils/time.hpp>
#include <world/action.hpp>
using
TurnNb
=
std
::
size_t
;
using
t_next_turn_callback
=
std
::
function
<
void
(
const
TurnNb
)
>
;
using
t_next_turn_callback
=
std
::
function
<
void
(
const
TurnNb
)
>
;
/**
* The number of ticks contained in a turn
...
...
@@ -60,6 +61,10 @@ public:
TurnNb
get_current_turn
()
const
;
std
::
deque
<
Turn
>&
get_turns
();
TurnNb
get_last_ready_turn
()
const
;
/**
* Returns the time in seconds, spent so far in this TurnHandler
*/
utils
::
FloatingSeconds
get_current_time
()
const
;
private:
TurnHandler
(
const
TurnHandler
&
);
...
...
src/gui/camera/camera.cpp
View file @
1ccbd31d
...
...
@@ -19,6 +19,8 @@
#include <iostream>
using
namespace
std
::
string_literals
;
Camera
::
Camera
(
GameClient
*
game
,
Screen
*
screen
)
:
ScreenElement
(
screen
),
x
(
0
),
...
...
@@ -385,6 +387,8 @@ void Camera::draw()
else
this
->
game
->
get_debug_hud
().
add_debug_line
(
"No entity under mouse"
);
this
->
game
->
get_debug_hud
().
add_debug_line
(
"Current world time: "
s
+
std
::
to_string
(
this
->
get_game_client
()
->
current_world_time
().
count
()));
this
->
draw
(
this
->
fog
.
get_sprite
());
}
...
...
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