Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
2
2d game
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
KosmX
2d game
Commits
cc4ab57c
Commit
cc4ab57c
authored
4 years ago
by
KosmX
Browse files
Options
Downloads
Patches
Plain Diff
use modern functional instead of c style function pointer
parent
b7281f89
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
MeleeWeapon.cpp
+2
-1
2 additions, 1 deletion
MeleeWeapon.cpp
MeleeWeapon.h
+1
-1
1 addition, 1 deletion
MeleeWeapon.h
with
3 additions
and
2 deletions
MeleeWeapon.cpp
+
2
−
1
View file @
cc4ab57c
...
...
@@ -10,7 +10,7 @@ namespace weapons {
{
return
victim
->
damage
(
this
->
getDamage
(),
*
victim
);
}
bool
MeleeWeapon
::
damageIf
(
std
::
shared_ptr
<
LivingEntity
>&
user
,
bool
(
*
predicate
)
(
std
::
shared_ptr
<
Entity
>
self
,
std
::
shared_ptr
<
Entity
>
other
)
)
bool
MeleeWeapon
::
damageIf
(
std
::
shared_ptr
<
LivingEntity
>&
user
,
std
::
function
<
bool
(
std
::
shared_ptr
<
Entity
>
,
std
::
shared_ptr
<
Entity
>
)
>
predicate
)
{
bool
bl
=
false
;
for
(
auto
&
entity
:
GameClient
::
getInstance
().
getEntities
()){
...
...
@@ -28,6 +28,7 @@ namespace weapons {
{
if
(
this
->
cooldown
!=
0
)
return
false
;
this
->
cooldown
=
this
->
cooldownTime
;
damageIf
()
}
void
MeleeWeapon
::
setPos
(
const
olc
::
vf2d
&
newPos
)
{
...
...
This diff is collapsed.
Click to expand it.
MeleeWeapon.h
+
1
−
1
View file @
cc4ab57c
...
...
@@ -9,7 +9,7 @@ namespace weapons {
protected:
virtual
int
getDamage
()
const
;
virtual
bool
damageEntity
(
std
::
shared_ptr
<
LivingEntity
>
user
,
std
::
shared_ptr
<
Entity
>&
victim
);
virtual
bool
damageIf
(
std
::
shared_ptr
<
LivingEntity
>&
user
,
bool
(
*
predicate
)
(
std
::
shared_ptr
<
Entity
>
self
,
std
::
shared_ptr
<
Entity
>
other
));
virtual
bool
damageIf
(
std
::
shared_ptr
<
LivingEntity
>&
user
,
std
::
function
<
bool
(
std
::
shared_ptr
<
Entity
>
self
,
std
::
shared_ptr
<
Entity
>
other
)
>
predicate
);
//virtual bool(*getPredicator())(std::shared_ptr<Entity>, std::shared_ptr<Entity>) = 0;
virtual
std
::
function
<
bool
(
std
::
shared_ptr
<
Entity
>
,
std
::
shared_ptr
<
Entity
>
)
>
getPredicator
()
=
0
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment