Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
PhaseShifter
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
3
Issues
3
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
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
GameDevWeek
S
Sommersemester 2019
Cpp
PhaseShifter
Commits
fcd58402
Commit
fcd58402
authored
Sep 21, 2019
by
Florian Oetke
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
pool for enemy-death particle systems [fixes
#39
]
parent
105b01ca
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
68 additions
and
11 deletions
+68
-11
assets/game_assets/particles/enemy_death_particle_system.json
...ts/game_assets/particles/enemy_death_particle_system.json
+1
-1
src/gameplay/beat_system.cpp
src/gameplay/beat_system.cpp
+7
-3
src/ui/effect_system.cpp
src/ui/effect_system.cpp
+52
-7
src/ui/effect_system.hpp
src/ui/effect_system.hpp
+8
-0
No files found.
assets/game_assets/particles/enemy_death_particle_system.json
View file @
fcd58402
...
...
@@ -2,7 +2,7 @@
"emitters"
:
[{
"spawn"
:
[
{
"particles_per_second"
:
300
,
"stddev"
:
150
,
"time"
:
0.5
},
{
"particles_per_second"
:
0
,
"stddev"
:
0
,
"time"
:
999
}
{
"particles_per_second"
:
0
,
"stddev"
:
0
,
"time"
:
1
}
],
"spawn_loop"
:
false
,
...
...
src/gameplay/beat_system.cpp
View file @
fcd58402
...
...
@@ -34,8 +34,8 @@ namespace phase_shifter::gameplay {
void
Beat_system
::
update
(
mirrage
::
util
::
Time
dt
)
{
_acc
+=
dt
.
value
();
int
size
=
static_cast
<
int
>
(
_time_stamps
.
size
());
auto
beat
=
_beat_index
+
1
<
size
&&
_acc
>=
_time_stamps
[
_beat_index
+
1
];
int
size
=
static_cast
<
int
>
(
_time_stamps
.
size
());
auto
beat
=
_beat_index
+
1
<
size
&&
_acc
>=
_time_stamps
[
_beat_index
+
1
];
int
beats_left
=
_state
.
beats_left
;
if
(
beat
)
{
_beat_index
++
;
...
...
@@ -56,6 +56,9 @@ namespace phase_shifter::gameplay {
auto
Beat_system
::
graphic_time_scale
()
const
->
float
{
if
(
_beat_index
<
0
)
return
0.2
f
;
constexpr
auto
t1_len
=
0.05
f
;
constexpr
auto
t2_len
=
0.6
f
;
constexpr
auto
factor
=
(
1.
f
-
(
1.
f
-
t1_len
-
t2_len
)
*
0.05
f
)
/
(
t1_len
+
t2_len
)
*
2.
f
;
...
...
@@ -80,7 +83,8 @@ namespace phase_shifter::gameplay {
}
}
void
Beat_system
::
increase_beats_left
(
int
count
)
{
void
Beat_system
::
increase_beats_left
(
int
count
)
{
_beat_offset
+=
count
;
_state
.
beats_left
+=
count
;
}
...
...
src/ui/effect_system.cpp
View file @
fcd58402
...
...
@@ -4,27 +4,72 @@
#include "../gameplay/player_comp.hpp"
#include "../messages.hpp"
#include <mirrage/ecs/components/transform_comp.hpp>
#include <mirrage/ecs/entity_manager.hpp>
#include <mirrage/ecs/types.hpp>
#include <mirrage/renderer/particle_system.hpp>
namespace
phase_shifter
::
ui
{
using
namespace
mirrage
::
renderer
;
using
mirrage
::
ecs
::
components
::
Transform_comp
;
using
namespace
mirrage
::
util
::
unit_literals
;
namespace
{
void
disable_tombstone
(
mirrage
::
ecs
::
Entity_facet
entity
)
{
entity
.
process
([
=
](
Particle_system_comp
&
particle
)
{
for
(
auto
&
e
:
particle
.
particle_system
.
emitters
())
{
e
.
active
(
false
);
}
});
entity
.
process
(
[
=
](
Transform_comp
&
transform
)
{
transform
.
position
=
glm
::
vec3
(
-
999.
f
,
0.
f
,
-
999.
f
);
});
}
void
enable_tombstone
(
mirrage
::
ecs
::
Entity_facet
entity
,
glm
::
vec3
pos
,
glm
::
vec3
dir
)
{
entity
.
process
([
=
](
Particle_system_comp
&
particle
)
{
for
(
auto
&
e
:
particle
.
particle_system
.
emitters
())
{
e
.
active
(
true
);
}
});
entity
.
process
([
=
](
Transform_comp
&
transform
)
{
transform
.
position
=
pos
;
transform
.
orientation
=
glm
::
rotation
(
glm
::
vec3
{
1.
f
,
0.
f
,
0.
f
},
glm
::
vec3
(
dir
.
x
,
0
,
-
dir
.
z
));
});
}
}
// namespace
Effect_system
::
Effect_system
(
mirrage
::
util
::
Message_bus
&
bus
,
mirrage
::
ecs
::
Entity_manager
&
ecs
)
:
_bus
(
bus
),
_mailbox
(
bus
),
_ecs
(
ecs
)
{
_tombstones
.
resize
(
20
);
for
(
auto
&
t
:
_tombstones
)
{
t
.
entity
=
_ecs
.
entity_builder
(
"enemy_tombstone"
)
.
position
(
glm
::
vec3
{
-
999.
f
,
0.
f
,
-
999.
f
})
.
post_create
([
=
](
mirrage
::
ecs
::
Entity_facet
entity
)
{
// disable_tombstone(entity);
})
.
create
();
};
_mailbox
.
subscribe_to
([
&
](
Enemy_killed_msg
&
e
)
{
_bus
.
send
<
Play_sound_msg
>
(
"enemy_hit"
_strid
);
auto
entity
=
_ecs
.
entity_builder
(
"enemy_tombstone"
)
.
rotation
(
glm
::
rotation
(
glm
::
vec3
{
1.
f
,
0.
f
,
0.
f
},
glm
::
vec3
(
e
.
attack_direction
.
x
,
0
,
-
e
.
attack_direction
.
z
)))
.
position
(
e
.
position
)
.
create
();
auto
first_free
=
std
::
find_if
(
_tombstones
.
begin
(),
_tombstones
.
end
(),
[](
auto
&
t
)
{
return
t
.
free
;
});
if
(
first_free
!=
_tombstones
.
end
())
{
first_free
->
free
=
false
;
enable_tombstone
(
first_free
->
entity
,
e
.
position
,
e
.
attack_direction
);
_actions
.
defer
(
5
_s
,
[
&
,
entity
]
{
_ecs
.
erase
(
entity
);
});
_actions
.
defer
(
1
_s
,
[
&
,
iter
=
&*
first_free
]
{
disable_tombstone
(
iter
->
entity
);
iter
->
free
=
true
;
});
}
});
_mailbox
.
subscribe_to
([
&
](
gameplay
::
Damaged_msg
&
e
)
{
...
...
src/ui/effect_system.hpp
View file @
fcd58402
#pragma once
#include <mirrage/ecs/types.hpp>
#include <mirrage/utils/defer.hpp>
#include <mirrage/utils/messagebus.hpp>
#include <mirrage/utils/units.hpp>
...
...
@@ -17,10 +18,17 @@ namespace phase_shifter::ui {
void
update
(
mirrage
::
util
::
Time
);
private:
struct
Tombstone
{
mirrage
::
ecs
::
Entity_facet
entity
;
bool
free
=
true
;
};
mirrage
::
util
::
Message_bus
&
_bus
;
mirrage
::
util
::
Mailbox_collection
_mailbox
;
mirrage
::
ecs
::
Entity_manager
&
_ecs
;
mirrage
::
util
::
Deferred_action_container
_actions
;
std
::
vector
<
Tombstone
>
_tombstones
;
};
}
// namespace phase_shifter::ui
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