Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
ziqian zhang
Grasscutter
Commits
18ef5ee7
Commit
18ef5ee7
authored
May 15, 2022
by
Akka
Committed by
Melledy
May 15, 2022
Browse files
fix the dynamic group loading
parent
6dc30e4d
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/main/java/emu/grasscutter/game/world/Scene.java
View file @
18ef5ee7
...
@@ -519,10 +519,15 @@ public class Scene {
...
@@ -519,10 +519,15 @@ public class Scene {
if
(!
this
.
getLoadedBlocks
().
contains
(
block
))
{
if
(!
this
.
getLoadedBlocks
().
contains
(
block
))
{
this
.
onLoadBlock
(
block
,
this
.
getPlayers
());
this
.
onLoadBlock
(
block
,
this
.
getPlayers
());
this
.
getLoadedBlocks
().
add
(
block
);
this
.
getLoadedBlocks
().
add
(
block
);
}
else
{
// dynamic load the groups for players in a loaded block
var
toLoad
=
this
.
getPlayers
().
stream
()
.
filter
(
p
->
block
.
contains
(
p
.
getPos
()))
.
map
(
p
->
playerMeetGroups
(
p
,
block
))
.
flatMap
(
Collection:
:
stream
)
.
toList
();
onLoadGroup
(
toLoad
);
}
}
this
.
getPlayers
().
stream
()
.
filter
(
p
->
block
.
contains
(
p
.
getPos
()))
.
forEach
(
p
->
playerMeetGroups
(
p
,
block
));
}
}
}
}
...
@@ -539,7 +544,6 @@ public class Scene {
...
@@ -539,7 +544,6 @@ public class Scene {
return
List
.
of
();
return
List
.
of
();
}
}
Grasscutter
.
getLogger
().
info
(
"Scene {} Block {} loaded {} group(s)"
,
this
.
getId
(),
block
.
id
,
groups
.
size
());
return
groups
;
return
groups
;
}
}
public
void
onLoadBlock
(
SceneBlock
block
,
List
<
Player
>
players
)
{
public
void
onLoadBlock
(
SceneBlock
block
,
List
<
Player
>
players
)
{
...
@@ -548,36 +552,50 @@ public class Scene {
...
@@ -548,36 +552,50 @@ public class Scene {
// the groups form here is not added in current scene
// the groups form here is not added in current scene
var
groups
=
players
.
stream
()
var
groups
=
players
.
stream
()
.
filter
(
player
->
block
.
contains
(
player
.
getPos
()))
.
map
(
p
->
playerMeetGroups
(
p
,
block
))
.
map
(
p
->
playerMeetGroups
(
p
,
block
))
.
flatMap
(
Collection:
:
stream
)
.
flatMap
(
Collection:
:
stream
)
.
toList
();
.
toList
();
onLoadGroup
(
groups
);
Grasscutter
.
getLogger
().
info
(
"Scene {} Block {} loaded."
,
this
.
getId
(),
block
.
id
);
}
public
void
onLoadGroup
(
List
<
SceneGroup
>
groups
){
if
(
groups
==
null
||
groups
.
isEmpty
()){
return
;
}
for
(
SceneGroup
group
:
groups
)
{
for
(
SceneGroup
group
:
groups
)
{
// We load the script files for the groups here
// We load the script files for the groups here
this
.
getScriptManager
().
loadGroupFromScript
(
group
);
this
.
getScriptManager
().
loadGroupFromScript
(
group
);
}
}
// Spawn gadgets AFTER triggers are added
// Spawn gadgets AFTER triggers are added
// TODO
// TODO
var
entities
=
new
ArrayList
<
GameEntity
>();
for
(
SceneGroup
group
:
groups
)
{
for
(
SceneGroup
group
:
groups
)
{
if
(
group
.
init_config
==
null
)
{
if
(
group
.
init_config
==
null
)
{
continue
;
continue
;
}
}
int
suite
=
group
.
init_config
.
suite
;
int
suite
=
group
.
init_config
.
suite
;
if
(
suite
==
0
)
{
if
(
suite
==
0
)
{
continue
;
continue
;
}
}
do
{
do
{
var
suiteData
=
group
.
getSuiteByIndex
(
suite
);
var
suiteData
=
group
.
getSuiteByIndex
(
suite
);
getScriptManager
().
spawnGadgetsInGroup
(
group
,
suiteData
);
entities
.
addAll
(
suiteData
.
sceneGadgets
.
stream
()
getScriptManager
().
spawnMonstersInGroup
(
group
,
suiteData
);
.
map
(
g
->
scriptManager
.
createGadgets
(
group
.
id
,
group
.
block_id
,
g
)).
toList
());
entities
.
addAll
(
suiteData
.
sceneMonsters
.
stream
()
.
map
(
mob
->
scriptManager
.
createMonster
(
group
.
id
,
group
.
block_id
,
mob
)).
toList
());
suite
++;
suite
++;
}
while
(
suite
<
group
.
init_config
.
end_suite
);
}
while
(
suite
<
group
.
init_config
.
end_suite
);
}
}
Grasscutter
.
getLogger
().
info
(
"Scene {} Block {} loaded."
,
this
.
getId
(),
block
.
id
);
scriptManager
.
meetEntities
(
entities
);
Grasscutter
.
getLogger
().
info
(
"Scene {} loaded {} group(s)"
,
this
.
getId
(),
groups
.
size
());
}
}
public
void
onUnloadBlock
(
SceneBlock
block
)
{
public
void
onUnloadBlock
(
SceneBlock
block
)
{
...
...
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