Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
H
HexBoard Cpp
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
GameDev Projects
HexBoard Cpp
Commits
fd586ba8
Commit
fd586ba8
authored
5 years ago
by
Joseph Walton-Rivers
Browse files
Options
Downloads
Patches
Plain Diff
and entity types to entities and add mutators for entity types
parent
a6fa70c1
No related branches found
No related tags found
No related merge requests found
Pipeline
#2606
failed
5 years ago
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/lib/state.cpp
+4
-0
4 additions, 0 deletions
src/lib/state.cpp
src/lib/state.h
+20
-2
20 additions, 2 deletions
src/lib/state.h
src/main.cpp
+7
-3
7 additions, 3 deletions
src/main.cpp
with
31 additions
and
5 deletions
src/lib/state.cpp
+
4
−
0
View file @
fd586ba8
...
@@ -19,6 +19,10 @@ int32_t entity::get_property(const string& name, int32_t val) const {
...
@@ -19,6 +19,10 @@ int32_t entity::get_property(const string& name, int32_t val) const {
}
}
}
}
void
state
::
add_entity
(
entity
entity
){
entities
.
push_back
(
entity
);
}
state
::
state
()
{
state
::
state
()
{
this
->
turn
=
0
;
this
->
turn
=
0
;
}
}
...
...
This diff is collapsed.
Click to expand it.
src/lib/state.h
+
20
−
2
View file @
fd586ba8
...
@@ -26,15 +26,30 @@ struct data {
...
@@ -26,15 +26,30 @@ struct data {
int
resource
;
int
resource
;
};
};
class
entity_type
{
private:
entity_type
*
parent
;
property_map
properties
;
};
class
entity
{
class
entity
{
public:
public:
entity
()
:
tag
(
0
),
pos
(
Hex
(
0
,
0
,
0
))
{}
entity
(
entity_type
*
type
)
:
tag
(
0
),
pos
(
Hex
(
0
,
0
,
0
))
{
entity
(
entity
const
&
rhs
)
:
tag
(
rhs
.
tag
),
pos
(
Hex
(
0
,
0
,
0
))
{}
this
->
type
=
type
;
}
entity
(
entity
const
&
rhs
)
:
tag
(
rhs
.
tag
),
pos
(
Hex
(
0
,
0
,
0
))
{
type
=
rhs
.
type
;
}
int32_t
get_property
(
string
const
&
name
)
const
;
int32_t
get_property
(
string
const
&
name
)
const
;
int32_t
get_property
(
string
const
&
name
,
int32_t
val
)
const
;
int32_t
get_property
(
string
const
&
name
,
int32_t
val
)
const
;
void
set_property
(
string
const
&
name
,
int32_t
val
);
private
:
private
:
entity_type
*
type
;
uint64_t
tag
;
uint64_t
tag
;
location
pos
;
location
pos
;
property_map
properties
;
property_map
properties
;
...
@@ -47,8 +62,11 @@ class state {
...
@@ -47,8 +62,11 @@ class state {
entity
entity_at
(
location
location
);
entity
entity_at
(
location
location
);
vector
<
entity
>
entities_at
(
location
location
);
vector
<
entity
>
entities_at
(
location
location
);
void
add_entity
(
entity
entity
);
uint32_t
terrain_at
(
location
location
);
uint32_t
terrain_at
(
location
location
);
void
set_terrain
(
location
location
,
uint32_t
t
);
uint32_t
resource_at
(
location
location
);
uint32_t
resource_at
(
location
location
);
private:
private:
...
...
This diff is collapsed.
Click to expand it.
src/main.cpp
+
7
−
3
View file @
fd586ba8
...
@@ -15,10 +15,14 @@ void test(const entity& test){
...
@@ -15,10 +15,14 @@ void test(const entity& test){
}
}
int
main
(
int
argc
,
char
**
argv
){
int
main
(
int
argc
,
char
**
argv
){
cout
<<
"test"
<<
endl
;
entity
t
;
entity_type
type
;
test
(
t
);
state
state
;
for
(
int
i
=
0
;
i
<
10
;
i
++
){
entity
e
(
&
type
);
state
.
add_entity
(
e
);
}
return
0
;
return
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