Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
B
big-brain
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Louis
big-brain
Commits
6c64df4f
Commit
6c64df4f
authored
3 years ago
by
Kat Marchán
Browse files
Options
Downloads
Patches
Plain Diff
feat(api): rename attach and hide it from docs
parent
8bed75b5
No related branches found
No related tags found
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
src/actions.rs
+6
-7
6 additions, 7 deletions
src/actions.rs
src/choices.rs
+1
-1
1 addition, 1 deletion
src/choices.rs
src/scorers.rs
+7
-8
7 additions, 8 deletions
src/scorers.rs
src/thinker.rs
+3
-3
3 additions, 3 deletions
src/thinker.rs
with
17 additions
and
19 deletions
src/actions.rs
+
6
−
7
View file @
6c64df4f
...
...
@@ -87,10 +87,9 @@ pub trait ActionBuilder: std::fmt::Debug + Send + Sync {
*/
fn
build
(
&
self
,
cmd
:
&
mut
Commands
,
action
:
Entity
,
actor
:
Entity
);
/**
Don't implement this yourself unless you know what you're doing.
*/
fn
attach
(
&
self
,
cmd
:
&
mut
Commands
,
actor
:
Entity
)
->
Entity
{
#[doc(hidden)]
// Don't implement this yourself unless you know what you're doing.
fn
spawn_action
(
&
self
,
cmd
:
&
mut
Commands
,
actor
:
Entity
)
->
Entity
{
let
action_ent
=
ActionEnt
(
cmd
.spawn
()
.id
());
cmd
.entity
(
action_ent
.0
)
.insert
(
Name
::
new
(
"Action"
))
...
...
@@ -131,7 +130,7 @@ impl StepsBuilder {
impl
ActionBuilder
for
StepsBuilder
{
fn
build
(
&
self
,
cmd
:
&
mut
Commands
,
action
:
Entity
,
actor
:
Entity
)
{
if
let
Some
(
step
)
=
self
.steps
.get
(
0
)
{
let
child_action
=
step
.
attach
(
cmd
,
actor
);
let
child_action
=
step
.
spawn_action
(
cmd
,
actor
);
cmd
.entity
(
action
)
.insert
(
Name
::
new
(
"Steps Action"
))
.insert
(
Steps
{
...
...
@@ -223,7 +222,7 @@ pub fn steps_system(
steps_action
.active_step
+=
1
;
let
step_builder
=
steps_action
.steps
[
steps_action
.active_step
]
.clone
();
let
step_ent
=
step_builder
.
attach
(
&
mut
cmd
,
*
actor
);
let
step_ent
=
step_builder
.
spawn_action
(
&
mut
cmd
,
*
actor
);
cmd
.entity
(
seq_ent
)
.push_children
(
&
[
step_ent
]);
steps_action
.active_ent
.0
=
step_ent
;
}
...
...
@@ -268,7 +267,7 @@ impl ActionBuilder for ConcurrentlyBuilder {
let
children
:
Vec
<
Entity
>
=
self
.actions
.iter
()
.map
(|
action
|
action
.
attach
(
cmd
,
actor
))
.map
(|
action
|
action
.
spawn_action
(
cmd
,
actor
))
.collect
();
cmd
.entity
(
action
)
.insert
(
Name
::
new
(
"Concurrent Action"
))
...
...
This diff is collapsed.
Click to expand it.
src/choices.rs
+
1
−
1
View file @
6c64df4f
...
...
@@ -37,7 +37,7 @@ impl ChoiceBuilder {
}
pub
fn
build
(
&
self
,
cmd
:
&
mut
Commands
,
actor
:
Entity
,
parent
:
Entity
)
->
Choice
{
let
scorer_ent
=
self
.when
.
attach
(
cmd
,
actor
);
let
scorer_ent
=
self
.when
.
spawn_scorer
(
cmd
,
actor
);
cmd
.entity
(
parent
)
.push_children
(
&
[
scorer_ent
]);
Choice
{
scorer
:
ScorerEnt
(
scorer_ent
),
...
...
This diff is collapsed.
Click to expand it.
src/scorers.rs
+
7
−
8
View file @
6c64df4f
...
...
@@ -63,10 +63,9 @@ pub trait ScorerBuilder: std::fmt::Debug + Sync + Send {
*/
fn
build
(
&
self
,
cmd
:
&
mut
Commands
,
scorer
:
Entity
,
actor
:
Entity
);
/**
Don't implement this yourself unless you know what you're doing.
*/
fn
attach
(
&
self
,
cmd
:
&
mut
Commands
,
actor
:
Entity
)
->
Entity
{
// Don't implement this yourself unless you know what you're doing.
#[doc(hidden)]
fn
spawn_scorer
(
&
self
,
cmd
:
&
mut
Commands
,
actor
:
Entity
)
->
Entity
{
let
scorer_ent
=
cmd
.spawn
()
.id
();
cmd
.entity
(
scorer_ent
)
.insert
(
Name
::
new
(
"Scorer"
))
...
...
@@ -186,7 +185,7 @@ impl ScorerBuilder for AllOrNothingBuilder {
let
scorers
:
Vec
<
_
>
=
self
.scorers
.iter
()
.map
(|
scorer
|
scorer
.
attach
(
cmd
,
actor
))
.map
(|
scorer
|
scorer
.
spawn_scorer
(
cmd
,
actor
))
.collect
();
cmd
.entity
(
scorer
)
.insert
(
Score
::
default
())
...
...
@@ -269,7 +268,7 @@ impl ScorerBuilder for SumOfScorersBuilder {
let
scorers
:
Vec
<
_
>
=
self
.scorers
.iter
()
.map
(|
scorer
|
scorer
.
attach
(
cmd
,
actor
))
.map
(|
scorer
|
scorer
.
spawn_scorer
(
cmd
,
actor
))
.collect
();
cmd
.entity
(
scorer
)
.insert
(
Transform
::
default
())
...
...
@@ -360,7 +359,7 @@ impl ScorerBuilder for WinningScorerBuilder {
let
scorers
:
Vec
<
_
>
=
self
.scorers
.iter
()
.map
(|
scorer
|
scorer
.
attach
(
cmd
,
actor
))
.map
(|
scorer
|
scorer
.
spawn_scorer
(
cmd
,
actor
))
.collect
();
cmd
.entity
(
scorer
)
.insert
(
Transform
::
default
())
...
...
@@ -431,7 +430,7 @@ pub struct EvaluatingScorerBuilder {
impl
ScorerBuilder
for
EvaluatingScorerBuilder
{
fn
build
(
&
self
,
cmd
:
&
mut
Commands
,
scorer
:
Entity
,
actor
:
Entity
)
{
let
inner_scorer
=
self
.scorer
.
attach
(
cmd
,
actor
);
let
inner_scorer
=
self
.scorer
.
spawn_scorer
(
cmd
,
actor
);
cmd
.entity
(
scorer
)
.insert
(
Transform
::
default
())
.insert
(
GlobalTransform
::
default
())
...
...
This diff is collapsed.
Click to expand it.
src/thinker.rs
+
3
−
3
View file @
6c64df4f
...
...
@@ -144,7 +144,7 @@ pub fn thinker_component_attach_system(
q
:
Query
<
(
Entity
,
&
ThinkerBuilder
),
Without
<
HasThinker
>>
,
)
{
for
(
entity
,
thinker_builder
)
in
q
.iter
()
{
let
thinker
=
thinker_builder
.
attach
(
&
mut
cmd
,
entity
);
let
thinker
=
thinker_builder
.
spawn_action
(
&
mut
cmd
,
entity
);
cmd
.entity
(
entity
)
.insert
(
HasThinker
(
thinker
));
}
}
...
...
@@ -305,7 +305,7 @@ fn exec_picked_action(
// Despawn the action itself.
cmd
.entity
(
action_ent
.0
)
.despawn_recursive
();
thinker
.current_action
=
Some
((
ActionEnt
(
picked_action
.1
.
attach
(
cmd
,
actor
)),
ActionEnt
(
picked_action
.1
.
spawn_action
(
cmd
,
actor
)),
picked_action
.clone
(),
));
}
...
...
@@ -326,7 +326,7 @@ fn exec_picked_action(
// current_action in the thinker. The logic here is pretty
// straightforward -- we set the action, Request it, and
// that's it.
let
new_action
=
picked_action
.1
.
attach
(
cmd
,
actor
);
let
new_action
=
picked_action
.1
.
spawn_action
(
cmd
,
actor
);
thinker
.current_action
=
Some
((
ActionEnt
(
new_action
),
picked_action
.clone
()));
}
}
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