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
2f39aff4
Commit
2f39aff4
authored
Apr 29, 2022
by
memetrollsXD
Committed by
GitHub
Apr 29, 2022
Browse files
Merge pull request #355 from Grasscutters/dungeon-scripts
Implemented Dungeon Support
parents
789e5f57
6d987430
Changes
55
Show whitespace changes
Inline
Side-by-side
build.gradle
View file @
2f39aff4
...
@@ -72,8 +72,9 @@ dependencies {
...
@@ -72,8 +72,9 @@ dependencies {
implementation
group:
'org.quartz-scheduler'
,
name:
'quartz'
,
version:
'2.3.2'
implementation
group:
'org.quartz-scheduler'
,
name:
'quartz'
,
version:
'2.3.2'
implementation
group:
'org.quartz-scheduler'
,
name:
'quartz-jobs'
,
version:
'2.3.2'
implementation
group:
'org.quartz-scheduler'
,
name:
'quartz-jobs'
,
version:
'2.3.2'
protobuf
files
(
'proto/'
)
implementation
group:
'org.luaj'
,
name:
'luaj-jse'
,
version:
'3.0.1'
protobuf
files
(
'proto/'
)
}
}
application
{
application
{
...
...
src/main/java/emu/grasscutter/Config.java
View file @
2f39aff4
...
@@ -10,6 +10,7 @@ public final class Config {
...
@@ -10,6 +10,7 @@ public final class Config {
public
String
PACKETS_FOLDER
=
"./packets/"
;
public
String
PACKETS_FOLDER
=
"./packets/"
;
public
String
DUMPS_FOLDER
=
"./dumps/"
;
public
String
DUMPS_FOLDER
=
"./dumps/"
;
public
String
KEY_FOLDER
=
"./keys/"
;
public
String
KEY_FOLDER
=
"./keys/"
;
public
String
SCRIPTS_FOLDER
=
"./resources/Scripts/"
;
public
String
PLUGINS_FOLDER
=
"./plugins/"
;
public
String
PLUGINS_FOLDER
=
"./plugins/"
;
public
String
RunMode
=
"HYBRID"
;
// HYBRID, DISPATCH_ONLY, GAME_ONLY
public
String
RunMode
=
"HYBRID"
;
// HYBRID, DISPATCH_ONLY, GAME_ONLY
...
...
src/main/java/emu/grasscutter/Grasscutter.java
View file @
2f39aff4
...
@@ -9,6 +9,7 @@ import java.net.InetSocketAddress;
...
@@ -9,6 +9,7 @@ import java.net.InetSocketAddress;
import
emu.grasscutter.command.CommandMap
;
import
emu.grasscutter.command.CommandMap
;
import
emu.grasscutter.plugin.PluginManager
;
import
emu.grasscutter.plugin.PluginManager
;
import
emu.grasscutter.scripts.ScriptLoader
;
import
emu.grasscutter.utils.Utils
;
import
emu.grasscutter.utils.Utils
;
import
org.reflections.Reflections
;
import
org.reflections.Reflections
;
import
org.slf4j.LoggerFactory
;
import
org.slf4j.LoggerFactory
;
...
@@ -67,6 +68,7 @@ public final class Grasscutter {
...
@@ -67,6 +68,7 @@ public final class Grasscutter {
// Load all resources.
// Load all resources.
ResourceLoader
.
loadAll
();
ResourceLoader
.
loadAll
();
ScriptLoader
.
init
();
// Database
// Database
DatabaseManager
.
initialize
();
DatabaseManager
.
initialize
();
...
...
src/main/java/emu/grasscutter/data/GameData.java
View file @
2f39aff4
...
@@ -61,13 +61,15 @@ public class GameData {
...
@@ -61,13 +61,15 @@ public class GameData {
private
static
final
Int2ObjectMap
<
FetterCharacterCardData
>
fetterCharacterCardDataMap
=
new
Int2ObjectOpenHashMap
<>();
private
static
final
Int2ObjectMap
<
FetterCharacterCardData
>
fetterCharacterCardDataMap
=
new
Int2ObjectOpenHashMap
<>();
private
static
final
Int2ObjectMap
<
RewardData
>
rewardDataMap
=
new
Int2ObjectOpenHashMap
<>();
private
static
final
Int2ObjectMap
<
RewardData
>
rewardDataMap
=
new
Int2ObjectOpenHashMap
<>();
private
static
final
Int2ObjectMap
<
WorldLevelData
>
worldLevelDataMap
=
new
Int2ObjectOpenHashMap
<>();
private
static
final
Int2ObjectMap
<
WorldLevelData
>
worldLevelDataMap
=
new
Int2ObjectOpenHashMap
<>();
private
static
final
Int2ObjectMap
<
DungeonData
>
dungeonDataMap
=
new
Int2ObjectOpenHashMap
<>();
private
static
final
Int2ObjectMap
<
ShopGoodsData
>
shopGoodsDataMap
=
new
Int2ObjectOpenHashMap
<>();
private
static
final
Int2ObjectMap
<
ShopGoodsData
>
shopGoodsDataMap
=
new
Int2ObjectOpenHashMap
<>();
// Cache
// Cache
private
static
Map
<
Integer
,
List
<
Integer
>>
fetters
=
new
HashMap
<>();
private
static
Map
<
Integer
,
List
<
Integer
>>
fetters
=
new
HashMap
<>();
private
static
Map
<
Integer
,
List
<
ShopGoodsData
>>
shopGoods
=
new
HashMap
<>();
private
static
Map
<
Integer
,
List
<
ShopGoodsData
>>
shopGoods
=
new
HashMap
<>();
public
static
char
EJWOA
=
's'
;
public
static
Int2ObjectMap
<?>
getMapByResourceDef
(
Class
<?>
resourceDefinition
)
{
public
static
Int2ObjectMap
<?>
getMapByResourceDef
(
Class
<?>
resourceDefinition
)
{
Int2ObjectMap
<?>
map
=
null
;
Int2ObjectMap
<?>
map
=
null
;
...
@@ -101,6 +103,11 @@ public class GameData {
...
@@ -101,6 +103,11 @@ public class GameData {
return
scenePointEntries
;
return
scenePointEntries
;
}
}
// TODO optimize
public
static
ScenePointEntry
getScenePointEntryById
(
int
sceneId
,
int
pointId
)
{
return
getScenePointEntries
().
get
(
sceneId
+
"_"
+
pointId
);
}
public
static
Int2ObjectMap
<
AvatarData
>
getAvatarDataMap
()
{
public
static
Int2ObjectMap
<
AvatarData
>
getAvatarDataMap
()
{
return
avatarDataMap
;
return
avatarDataMap
;
}
}
...
@@ -269,7 +276,9 @@ public class GameData {
...
@@ -269,7 +276,9 @@ public class GameData {
return
worldLevelDataMap
;
return
worldLevelDataMap
;
}
}
public
static
char
EJWOA
=
's'
;
public
static
Int2ObjectMap
<
DungeonData
>
getDungeonDataMap
()
{
return
dungeonDataMap
;
}
public
static
Map
<
Integer
,
List
<
ShopGoodsData
>>
getShopGoodsDataEntries
()
{
public
static
Map
<
Integer
,
List
<
ShopGoodsData
>>
getShopGoodsDataEntries
()
{
if
(
shopGoods
.
isEmpty
())
{
if
(
shopGoods
.
isEmpty
())
{
...
...
src/main/java/emu/grasscutter/data/ResourceLoader.java
View file @
2f39aff4
...
@@ -164,6 +164,7 @@ public class ResourceLoader {
...
@@ -164,6 +164,7 @@ public class ResourceLoader {
for
(
Map
.
Entry
<
String
,
JsonElement
>
entry
:
config
.
points
.
entrySet
())
{
for
(
Map
.
Entry
<
String
,
JsonElement
>
entry
:
config
.
points
.
entrySet
())
{
PointData
pointData
=
Grasscutter
.
getGsonFactory
().
fromJson
(
entry
.
getValue
(),
PointData
.
class
);
PointData
pointData
=
Grasscutter
.
getGsonFactory
().
fromJson
(
entry
.
getValue
(),
PointData
.
class
);
pointData
.
setId
(
Integer
.
parseInt
(
entry
.
getKey
()));
ScenePointEntry
sl
=
new
ScenePointEntry
(
sceneId
+
"_"
+
entry
.
getKey
(),
pointData
);
ScenePointEntry
sl
=
new
ScenePointEntry
(
sceneId
+
"_"
+
entry
.
getKey
(),
pointData
);
scenePointList
.
add
(
sl
);
scenePointList
.
add
(
sl
);
...
...
src/main/java/emu/grasscutter/data/common/PointData.java
View file @
2f39aff4
package
emu.grasscutter.data.common
;
package
emu.grasscutter.data.common
;
public
class
PointData
{
import
emu.grasscutter.utils.Position
;
private
pos
tranPos
;
public
pos
getTranPos
()
{
return
tranPos
;
}
public
void
setTranPos
(
pos
tranPos
)
{
this
.
tranPos
=
tranPos
;
}
public
class
pos
{
public
class
PointData
{
private
float
x
;
private
int
id
;
private
float
y
;
private
String
$type
;
private
float
z
;
private
Position
tranPos
;
private
int
[]
dungeonIds
;
public
float
getX
()
{
return
x
;
}
public
void
setX
(
float
x
)
{
public
int
getId
(
)
{
this
.
x
=
x
;
return
id
;
}
}
public
float
getY
(
)
{
public
void
setId
(
int
id
)
{
return
y
;
this
.
id
=
id
;
}
}
public
void
setY
(
float
y
)
{
public
String
getType
(
)
{
this
.
y
=
y
;
return
$type
;
}
}
public
float
getZ
()
{
public
Position
getTranPos
()
{
return
z
;
return
tranPos
;
}
}
public
void
setZ
(
float
z
)
{
public
int
[]
getDungeonIds
()
{
this
.
z
=
z
;
return
dungeonIds
;
}
}
}
}
}
src/main/java/emu/grasscutter/data/def/DungeonData.java
0 → 100644
View file @
2f39aff4
package
emu.grasscutter.data.def
;
import
emu.grasscutter.data.GameData
;
import
emu.grasscutter.data.GameResource
;
import
emu.grasscutter.data.ResourceType
;
import
emu.grasscutter.game.props.SceneType
;
@ResourceType
(
name
=
"DungeonExcelConfigData.json"
)
public
class
DungeonData
extends
GameResource
{
private
int
Id
;
private
int
SceneId
;
private
int
ShowLevel
;
private
String
InvolveType
;
// TODO enum
@Override
public
int
getId
()
{
return
this
.
Id
;
}
public
int
getSceneId
()
{
return
SceneId
;
}
public
int
getShowLevel
()
{
return
ShowLevel
;
}
@Override
public
void
onLoad
()
{
}
}
src/main/java/emu/grasscutter/data/def/GadgetData.java
View file @
2f39aff4
...
@@ -2,12 +2,13 @@ package emu.grasscutter.data.def;
...
@@ -2,12 +2,13 @@ package emu.grasscutter.data.def;
import
emu.grasscutter.data.GameResource
;
import
emu.grasscutter.data.GameResource
;
import
emu.grasscutter.data.ResourceType
;
import
emu.grasscutter.data.ResourceType
;
import
emu.grasscutter.game.props.EntityType
;
@ResourceType
(
name
=
"GadgetExcelConfigData.json"
)
@ResourceType
(
name
=
"GadgetExcelConfigData.json"
)
public
class
GadgetData
extends
GameResource
{
public
class
GadgetData
extends
GameResource
{
private
int
Id
;
private
int
Id
;
private
String
Type
;
private
EntityType
Type
;
private
String
JsonName
;
private
String
JsonName
;
private
boolean
IsInteractive
;
private
boolean
IsInteractive
;
private
String
[]
Tags
;
private
String
[]
Tags
;
...
@@ -22,7 +23,7 @@ public class GadgetData extends GameResource {
...
@@ -22,7 +23,7 @@ public class GadgetData extends GameResource {
return
this
.
Id
;
return
this
.
Id
;
}
}
public
String
getType
()
{
public
EntityType
getType
()
{
return
Type
;
return
Type
;
}
}
...
...
src/main/java/emu/grasscutter/data/def/SceneData.java
View file @
2f39aff4
...
@@ -9,16 +9,17 @@ import emu.grasscutter.game.props.SceneType;
...
@@ -9,16 +9,17 @@ import emu.grasscutter.game.props.SceneType;
@ResourceType
(
name
=
"SceneExcelConfigData.json"
)
@ResourceType
(
name
=
"SceneExcelConfigData.json"
)
public
class
SceneData
extends
GameResource
{
public
class
SceneData
extends
GameResource
{
private
int
Id
;
private
int
Id
;
private
SceneType
Scene
Type
;
private
SceneType
Type
;
private
String
ScriptData
;
private
String
ScriptData
;
@Override
@Override
public
int
getId
()
{
public
int
getId
()
{
return
this
.
Id
;
return
this
.
Id
;
}
}
public
SceneType
getSceneType
()
{
public
SceneType
getSceneType
()
{
return
Scene
Type
;
return
Type
;
}
}
public
String
getScriptData
()
{
public
String
getScriptData
()
{
...
...
src/main/java/emu/grasscutter/game/dungeons/DungeonChallenge.java
0 → 100644
View file @
2f39aff4
package
emu.grasscutter.game.dungeons
;
import
java.util.ArrayList
;
import
java.util.List
;
import
emu.grasscutter.data.GameData
;
import
emu.grasscutter.data.def.MonsterData
;
import
emu.grasscutter.game.entity.EntityMonster
;
import
emu.grasscutter.game.entity.GameEntity
;
import
emu.grasscutter.game.world.Scene
;
import
emu.grasscutter.net.proto.VisionTypeOuterClass.VisionType
;
import
emu.grasscutter.scripts.constants.EventType
;
import
emu.grasscutter.scripts.data.SceneGroup
;
import
emu.grasscutter.scripts.data.SceneMonster
;
import
emu.grasscutter.server.packet.send.PacketChallengeDataNotify
;
import
emu.grasscutter.server.packet.send.PacketDungeonChallengeBeginNotify
;
import
emu.grasscutter.server.packet.send.PacketDungeonChallengeFinishNotify
;
import
emu.grasscutter.server.packet.send.PacketSceneEntityAppearNotify
;
public
class
DungeonChallenge
{
private
final
Scene
scene
;
private
final
SceneGroup
group
;
private
int
challengeIndex
;
private
int
challengeId
;
private
boolean
success
;
private
boolean
progress
;
private
int
score
;
private
int
objective
=
0
;
public
DungeonChallenge
(
Scene
scene
,
SceneGroup
group
)
{
this
.
scene
=
scene
;
this
.
group
=
group
;
objective
+=
group
.
monsters
.
size
();
}
public
Scene
getScene
()
{
return
scene
;
}
public
SceneGroup
getGroup
()
{
return
group
;
}
public
int
getChallengeIndex
()
{
return
challengeIndex
;
}
public
void
setChallengeIndex
(
int
challengeIndex
)
{
this
.
challengeIndex
=
challengeIndex
;
}
public
int
getChallengeId
()
{
return
challengeId
;
}
public
void
setChallengeId
(
int
challengeId
)
{
this
.
challengeId
=
challengeId
;
}
public
boolean
isSuccess
()
{
return
success
;
}
public
void
setSuccess
(
boolean
isSuccess
)
{
this
.
success
=
isSuccess
;
}
public
boolean
inProgress
()
{
return
progress
;
}
public
int
getScore
()
{
return
score
;
}
public
void
start
()
{
this
.
progress
=
true
;
getScene
().
broadcastPacket
(
new
PacketDungeonChallengeBeginNotify
(
this
));
}
public
void
finish
()
{
this
.
progress
=
false
;
getScene
().
broadcastPacket
(
new
PacketDungeonChallengeFinishNotify
(
this
));
if
(
this
.
isSuccess
())
{
this
.
getScene
().
getScriptManager
().
callEvent
(
EventType
.
EVENT_CHALLENGE_SUCCESS
,
null
);
}
else
{
this
.
getScene
().
getScriptManager
().
callEvent
(
EventType
.
EVENT_CHALLENGE_FAIL
,
null
);
}
}
public
void
onMonsterDie
(
EntityMonster
entity
)
{
score
=
getScore
()
+
1
;
getScene
().
broadcastPacket
(
new
PacketChallengeDataNotify
(
this
,
1
,
getScore
()));
if
(
getScore
()
>=
objective
)
{
this
.
setSuccess
(
true
);
finish
();
}
}
}
src/main/java/emu/grasscutter/game/dungeons/DungeonManager.java
View file @
2f39aff4
package
emu.grasscutter.game.dungeons
;
package
emu.grasscutter.game.dungeons
;
import
emu.grasscutter.GameConstants
;
import
emu.grasscutter.Grasscutter
;
import
emu.grasscutter.data.GameData
;
import
emu.grasscutter.data.custom.ScenePointEntry
;
import
emu.grasscutter.data.def.DungeonData
;
import
emu.grasscutter.game.player.Player
;
import
emu.grasscutter.game.props.SceneType
;
import
emu.grasscutter.net.packet.BasePacket
;
import
emu.grasscutter.net.packet.PacketOpcodes
;
import
emu.grasscutter.server.game.GameServer
;
import
emu.grasscutter.server.game.GameServer
;
import
emu.grasscutter.server.packet.send.PacketDungeonEntryInfoRsp
;
import
emu.grasscutter.server.packet.send.PacketPlayerEnterDungeonRsp
;
import
emu.grasscutter.utils.Position
;
public
class
DungeonManager
{
public
class
DungeonManager
{
private
final
GameServer
server
;
private
final
GameServer
server
;
...
@@ -12,4 +24,59 @@ public class DungeonManager {
...
@@ -12,4 +24,59 @@ public class DungeonManager {
public
GameServer
getServer
()
{
public
GameServer
getServer
()
{
return
server
;
return
server
;
}
}
public
void
getEntryInfo
(
Player
player
,
int
pointId
)
{
ScenePointEntry
entry
=
GameData
.
getScenePointEntryById
(
player
.
getScene
().
getId
(),
pointId
);
if
(
entry
==
null
||
entry
.
getPointData
().
getDungeonIds
()
==
null
)
{
// Error
player
.
sendPacket
(
new
PacketDungeonEntryInfoRsp
());
return
;
}
player
.
sendPacket
(
new
PacketDungeonEntryInfoRsp
(
player
,
entry
.
getPointData
()));
}
public
void
enterDungeon
(
Player
player
,
int
pointId
,
int
dungeonId
)
{
DungeonData
data
=
GameData
.
getDungeonDataMap
().
get
(
dungeonId
);
if
(
data
==
null
)
{
return
;
}
Grasscutter
.
getLogger
().
info
(
player
.
getNickname
()
+
" is trying to enter dungeon "
+
dungeonId
);
int
sceneId
=
data
.
getSceneId
();
player
.
getScene
().
setPrevScene
(
sceneId
);
player
.
getWorld
().
transferPlayerToScene
(
player
,
sceneId
,
data
);
player
.
getScene
().
setPrevScenePoint
(
pointId
);
player
.
sendPacket
(
new
PacketPlayerEnterDungeonRsp
(
pointId
,
dungeonId
));
}
public
void
exitDungeon
(
Player
player
)
{
if
(
player
.
getScene
().
getSceneType
()
!=
SceneType
.
SCENE_DUNGEON
)
{
return
;
}
// Get previous scene
int
prevScene
=
player
.
getScene
().
getPrevScene
()
>
0
?
player
.
getScene
().
getPrevScene
()
:
3
;
// Get previous position
DungeonData
dungeonData
=
player
.
getScene
().
getDungeonData
();
Position
prevPos
=
new
Position
(
GameConstants
.
START_POSITION
);
if
(
dungeonData
!=
null
)
{
ScenePointEntry
entry
=
GameData
.
getScenePointEntryById
(
prevScene
,
player
.
getScene
().
getPrevScenePoint
());
if
(
entry
!=
null
)
{
prevPos
.
set
(
entry
.
getPointData
().
getTranPos
());
}
}
// Transfer player back to world
player
.
getWorld
().
transferPlayerToScene
(
player
,
prevScene
,
prevPos
);
player
.
sendPacket
(
new
BasePacket
(
PacketOpcodes
.
PlayerQuitDungeonRsp
));
}
}
}
src/main/java/emu/grasscutter/game/entity/EntityBaseGadget.java
0 → 100644
View file @
2f39aff4
package
emu.grasscutter.game.entity
;
import
emu.grasscutter.game.world.Scene
;
import
emu.grasscutter.game.world.World
;
public
abstract
class
EntityBaseGadget
extends
GameEntity
{
public
EntityBaseGadget
(
Scene
scene
)
{
super
(
scene
);
}
public
abstract
int
getGadgetId
();
@Override
public
void
onDeath
(
int
killerId
)
{
}
}
src/main/java/emu/grasscutter/game/entity/EntityClientGadget.java
View file @
2f39aff4
...
@@ -23,7 +23,7 @@ import emu.grasscutter.utils.Position;
...
@@ -23,7 +23,7 @@ import emu.grasscutter.utils.Position;
import
emu.grasscutter.utils.ProtoHelper
;
import
emu.grasscutter.utils.ProtoHelper
;
import
it.unimi.dsi.fastutil.ints.Int2FloatOpenHashMap
;
import
it.unimi.dsi.fastutil.ints.Int2FloatOpenHashMap
;
public
class
EntityClientGadget
extends
EntityGadget
{
public
class
EntityClientGadget
extends
Entity
Base
Gadget
{
private
final
Player
owner
;
private
final
Player
owner
;
private
final
Position
pos
;
private
final
Position
pos
;
...
...
src/main/java/emu/grasscutter/game/entity/EntityGadget.java
View file @
2f39aff4
package
emu.grasscutter.game.entity
;
package
emu.grasscutter.game.entity
;
import
java.util.Arrays
;
import
java.util.List
;
import
emu.grasscutter.data.GameData
;
import
emu.grasscutter.data.def.GadgetData
;
import
emu.grasscutter.game.props.EntityIdType
;
import
emu.grasscutter.game.props.EntityType
;
import
emu.grasscutter.game.props.PlayerProperty
;
import
emu.grasscutter.game.world.Scene
;
import
emu.grasscutter.game.world.Scene
;
import
emu.grasscutter.game.world.World
;
import
emu.grasscutter.game.world.World
;
import
emu.grasscutter.net.proto.ClientGadgetInfoOuterClass
;
import
emu.grasscutter.net.proto.AbilitySyncStateInfoOuterClass.AbilitySyncStateInfo
;
import
emu.grasscutter.net.proto.AnimatorParameterValueInfoPairOuterClass.AnimatorParameterValueInfoPair
;
import
emu.grasscutter.net.proto.EntityAuthorityInfoOuterClass.EntityAuthorityInfo
;
import
emu.grasscutter.net.proto.EntityClientDataOuterClass.EntityClientData
;
import
emu.grasscutter.net.proto.EntityRendererChangedInfoOuterClass.EntityRendererChangedInfo
;
import
emu.grasscutter.net.proto.MotionInfoOuterClass.MotionInfo
;
import
emu.grasscutter.net.proto.PropPairOuterClass.PropPair
;
import
emu.grasscutter.net.proto.ProtEntityTypeOuterClass.ProtEntityType
;
import
emu.grasscutter.net.proto.SceneEntityAiInfoOuterClass.SceneEntityAiInfo
;
import
emu.grasscutter.net.proto.SceneEntityInfoOuterClass.SceneEntityInfo
;
import
emu.grasscutter.net.proto.SceneGadgetInfoOuterClass.SceneGadgetInfo
;
import
emu.grasscutter.net.proto.VectorOuterClass.Vector
;
import
emu.grasscutter.net.proto.WorktopInfoOuterClass.WorktopInfo
;
import
emu.grasscutter.utils.Position
;
import
emu.grasscutter.utils.ProtoHelper
;
import
it.unimi.dsi.fastutil.ints.Int2FloatOpenHashMap
;
import
it.unimi.dsi.fastutil.ints.IntArrayList
;
import
it.unimi.dsi.fastutil.ints.IntList
;
import
it.unimi.dsi.fastutil.ints.IntOpenHashSet
;
import
it.unimi.dsi.fastutil.ints.IntSet
;
public
class
EntityGadget
extends
EntityBaseGadget
{
private
final
GadgetData
data
;
private
final
Position
pos
;
private
final
Position
rot
;
private
int
gadgetId
;
public
abstract
class
EntityGadget
extends
GameEntity
{
private
int
state
;
private
IntSet
worktopOptions
;
public
EntityGadget
(
Scene
scene
)
{
public
EntityGadget
(
Scene
scene
,
int
gadgetId
,
Position
pos
)
{
super
(
scene
);
super
(
scene
);
this
.
data
=
GameData
.
getGadgetDataMap
().
get
(
gadgetId
);
this
.
id
=
getScene
().
getWorld
().
getNextEntityId
(
EntityIdType
.
GADGET
);
this
.
gadgetId
=
gadgetId
;
this
.
pos
=
pos
.
clone
();
this
.
rot
=
new
Position
();
}
public
GadgetData
getGadgetData
()
{
return
data
;
}
@Override
public
Position
getPosition
()
{
// TODO Auto-generated method stub
return
this
.
pos
;
}
@Override
public
Position
getRotation
()
{
// TODO Auto-generated method stub
return
this
.
rot
;
}
public
int
getGadgetId
()
{
return
gadgetId
;
}
public
void
setGadgetId
(
int
gadgetId
)
{
this
.
gadgetId
=
gadgetId
;
}
public
int
getState
()
{
return
state
;
}
public
void
setState
(
int
state
)
{
this
.
state
=
state
;
}
public
IntSet
getWorktopOptions
()
{
return
worktopOptions
;
}
public
void
addWorktopOptions
(
int
[]
options
)
{
if
(
this
.
worktopOptions
==
null
)
{
this
.
worktopOptions
=
new
IntOpenHashSet
();
}
Arrays
.
stream
(
options
).
forEach
(
this
.
worktopOptions
::
add
);
}
public
void
removeWorktopOption
(
int
option
)
{
if
(
this
.
worktopOptions
==
null
)
{
return
;
}
this
.
worktopOptions
.
remove
(
option
);
}
}
public
abstract
int
getGadgetId
();
@Override
public
Int2FloatOpenHashMap
getFightProperties
()
{
// TODO Auto-generated method stub
return
null
;
}
@Override
@Override
public
void
onDeath
(
int
killerId
)
{
public
void
onDeath
(
int
killerId
)
{
}
}
@Override
public
SceneEntityInfo
toProto
()
{
EntityAuthorityInfo
authority
=
EntityAuthorityInfo
.
newBuilder
()
.
setAbilityInfo
(
AbilitySyncStateInfo
.
newBuilder
())
.
setRendererChangedInfo
(
EntityRendererChangedInfo
.
newBuilder
())
.
setAiInfo
(
SceneEntityAiInfo
.
newBuilder
().
setIsAiOpen
(
true
).
setBornPos
(
Vector
.
newBuilder
()))
.
setBornPos
(
Vector
.
newBuilder
())
.
build
();
SceneEntityInfo
.
Builder
entityInfo
=
SceneEntityInfo
.
newBuilder
()
.
setEntityId
(
getId
())
.
setEntityType
(
ProtEntityType
.
PROT_ENTITY_GADGET
)
.
setMotionInfo
(
MotionInfo
.
newBuilder
().
setPos
(
getPosition
().
toProto
()).
setRot
(
getRotation
().
toProto
()).
setSpeed
(
Vector
.
newBuilder
()))
.
addAnimatorParaList
(
AnimatorParameterValueInfoPair
.
newBuilder
())
.
setEntityClientData
(
EntityClientData
.
newBuilder
())
.
setEntityAuthorityInfo
(
authority
)
.
setLifeState
(
1
);
PropPair
pair
=
PropPair
.
newBuilder
()
.
setType
(
PlayerProperty
.
PROP_LEVEL
.
getId
())
.
setPropValue
(
ProtoHelper
.
newPropValue
(
PlayerProperty
.
PROP_LEVEL
,
1
))
.
build
();
entityInfo
.
addPropList
(
pair
);
SceneGadgetInfo
.
Builder
gadgetInfo
=
SceneGadgetInfo
.
newBuilder
()
.
setGadgetId
(
this
.
getGadgetId
())
.
setGroupId
(
this
.
getGroupId
())
.
setConfigId
(
this
.
getConfigId
())
.
setGadgetState
(
this
.
getState
())
.
setIsEnableInteract
(
true
)
.
setAuthorityPeerId
(
this
.
getScene
().
getWorld
().
getHostPeerId
());
if
(
this
.
getGadgetData
().
getType
()
==
EntityType
.
Worktop
&&
this
.
getWorktopOptions
()
!=
null
)
{
WorktopInfo
worktop
=
WorktopInfo
.
newBuilder
()
.
addAllOptionList
(
this
.
getWorktopOptions
())
.
build
();
gadgetInfo
.
setWorktop
(
worktop
);
}
entityInfo
.
setGadget
(
gadgetInfo
);
return
entityInfo
.
build
();
}
}
}
src/main/java/emu/grasscutter/game/entity/EntityItem.java
View file @
2f39aff4
...
@@ -23,7 +23,7 @@ import emu.grasscutter.utils.Position;
...
@@ -23,7 +23,7 @@ import emu.grasscutter.utils.Position;
import
emu.grasscutter.utils.ProtoHelper
;
import
emu.grasscutter.utils.ProtoHelper
;
import
it.unimi.dsi.fastutil.ints.Int2FloatOpenHashMap
;
import
it.unimi.dsi.fastutil.ints.Int2FloatOpenHashMap
;
public
class
EntityItem
extends
EntityGadget
{
public
class
EntityItem
extends
Entity
Base
Gadget
{
private
final
Position
pos
;
private
final
Position
pos
;
private
final
Position
rot
;
private
final
Position
rot
;
...
...
src/main/java/emu/grasscutter/game/entity/EntityMonster.java
View file @
2f39aff4
...
@@ -4,6 +4,7 @@ import emu.grasscutter.data.GameData;
...
@@ -4,6 +4,7 @@ import emu.grasscutter.data.GameData;
import
emu.grasscutter.data.common.PropGrowCurve
;
import
emu.grasscutter.data.common.PropGrowCurve
;
import
emu.grasscutter.data.def.MonsterCurveData
;
import
emu.grasscutter.data.def.MonsterCurveData
;
import
emu.grasscutter.data.def.MonsterData
;
import
emu.grasscutter.data.def.MonsterData
;
import
emu.grasscutter.game.dungeons.DungeonChallenge
;
import
emu.grasscutter.game.props.EntityIdType
;
import
emu.grasscutter.game.props.EntityIdType
;
import
emu.grasscutter.game.props.FightProperty
;
import
emu.grasscutter.game.props.FightProperty
;
import
emu.grasscutter.game.props.PlayerProperty
;
import
emu.grasscutter.game.props.PlayerProperty
;
...
@@ -22,6 +23,7 @@ import emu.grasscutter.net.proto.SceneEntityAiInfoOuterClass.SceneEntityAiInfo;
...
@@ -22,6 +23,7 @@ import emu.grasscutter.net.proto.SceneEntityAiInfoOuterClass.SceneEntityAiInfo;
import
emu.grasscutter.net.proto.SceneEntityInfoOuterClass.SceneEntityInfo
;
import
emu.grasscutter.net.proto.SceneEntityInfoOuterClass.SceneEntityInfo
;
import
emu.grasscutter.net.proto.SceneMonsterInfoOuterClass.SceneMonsterInfo
;
import
emu.grasscutter.net.proto.SceneMonsterInfoOuterClass.SceneMonsterInfo
;
import
emu.grasscutter.net.proto.SceneWeaponInfoOuterClass.SceneWeaponInfo
;
import
emu.grasscutter.net.proto.SceneWeaponInfoOuterClass.SceneWeaponInfo
;
import
emu.grasscutter.scripts.constants.EventType
;
import
emu.grasscutter.utils.Position
;
import
emu.grasscutter.utils.Position
;
import
emu.grasscutter.utils.ProtoHelper
;
import
emu.grasscutter.utils.ProtoHelper
;
import
it.unimi.dsi.fastutil.ints.Int2FloatMap
;
import
it.unimi.dsi.fastutil.ints.Int2FloatMap
;
...
@@ -36,9 +38,6 @@ public class EntityMonster extends GameEntity {
...
@@ -36,9 +38,6 @@ public class EntityMonster extends GameEntity {
private
final
Position
bornPos
;
private
final
Position
bornPos
;
private
final
int
level
;
private
final
int
level
;
private
int
weaponEntityId
;
private
int
weaponEntityId
;
private
int
groupId
;
private
int
configId
;
private
int
poseId
;
private
int
poseId
;
public
EntityMonster
(
Scene
scene
,
MonsterData
monsterData
,
Position
pos
,
int
level
)
{
public
EntityMonster
(
Scene
scene
,
MonsterData
monsterData
,
Position
pos
,
int
level
)
{
...
@@ -104,22 +103,6 @@ public class EntityMonster extends GameEntity {
...
@@ -104,22 +103,6 @@ public class EntityMonster extends GameEntity {
return
this
.
getFightProperty
(
FightProperty
.
FIGHT_PROP_CUR_HP
)
>
0
f
;
return
this
.
getFightProperty
(
FightProperty
.
FIGHT_PROP_CUR_HP
)
>
0
f
;
}
}
public
int
getGroupId
()
{
return
groupId
;
}
public
void
setGroupId
(
int
groupId
)
{
this
.
groupId
=
groupId
;
}
public
int
getConfigId
()
{
return
configId
;
}
public
void
setConfigId
(
int
configId
)
{
this
.
configId
=
configId
;
}
public
int
getPoseId
()
{
public
int
getPoseId
()
{
return
poseId
;
return
poseId
;
}
}
...
@@ -133,6 +116,12 @@ public class EntityMonster extends GameEntity {
...
@@ -133,6 +116,12 @@ public class EntityMonster extends GameEntity {
if
(
this
.
getSpawnEntry
()
!=
null
)
{
if
(
this
.
getSpawnEntry
()
!=
null
)
{
this
.
getScene
().
getDeadSpawnedEntities
().
add
(
getSpawnEntry
());
this
.
getScene
().
getDeadSpawnedEntities
().
add
(
getSpawnEntry
());
}
}
if
(
getScene
().
getScriptManager
().
isInit
()
&&
this
.
getGroupId
()
>
0
)
{
getScene
().
getScriptManager
().
callEvent
(
EventType
.
EVENT_ANY_MONSTER_DIE
,
null
);
}
if
(
getScene
().
getChallenge
()
!=
null
&&
getScene
().
getChallenge
().
getGroup
().
id
==
this
.
getGroupId
())
{
getScene
().
getChallenge
().
onMonsterDie
(
this
);
}
}
}
public
void
recalcStats
()
{
public
void
recalcStats
()
{
...
...
src/main/java/emu/grasscutter/game/entity/EntityVehicle.java
View file @
2f39aff4
...
@@ -25,7 +25,7 @@ import emu.grasscutter.utils.ProtoHelper;
...
@@ -25,7 +25,7 @@ import emu.grasscutter.utils.ProtoHelper;
import
it.unimi.dsi.fastutil.ints.Int2FloatMap
;
import
it.unimi.dsi.fastutil.ints.Int2FloatMap
;
import
it.unimi.dsi.fastutil.ints.Int2FloatOpenHashMap
;
import
it.unimi.dsi.fastutil.ints.Int2FloatOpenHashMap
;
public
class
EntityVehicle
extends
EntityGadget
{
public
class
EntityVehicle
extends
Entity
Base
Gadget
{
private
final
Player
owner
;
private
final
Player
owner
;
private
final
Int2FloatOpenHashMap
fightProp
;
private
final
Int2FloatOpenHashMap
fightProp
;
...
...
src/main/java/emu/grasscutter/game/entity/GameEntity.java
View file @
2f39aff4
...
@@ -17,6 +17,10 @@ public abstract class GameEntity {
...
@@ -17,6 +17,10 @@ public abstract class GameEntity {
private
final
Scene
scene
;
private
final
Scene
scene
;
private
SpawnDataEntry
spawnEntry
;
private
SpawnDataEntry
spawnEntry
;
private
int
blockId
;
private
int
configId
;
private
int
groupId
;
private
MotionState
moveState
;
private
MotionState
moveState
;
private
int
lastMoveSceneTimeMs
;
private
int
lastMoveSceneTimeMs
;
private
int
lastMoveReliableSeq
;
private
int
lastMoveReliableSeq
;
...
@@ -96,6 +100,30 @@ public abstract class GameEntity {
...
@@ -96,6 +100,30 @@ public abstract class GameEntity {
return
getFightProperties
().
getOrDefault
(
prop
.
getId
(),
0
f
);
return
getFightProperties
().
getOrDefault
(
prop
.
getId
(),
0
f
);
}
}
public
int
getBlockId
()
{
return
blockId
;
}
public
void
setBlockId
(
int
blockId
)
{
this
.
blockId
=
blockId
;
}
public
int
getConfigId
()
{
return
configId
;
}
public
void
setConfigId
(
int
configId
)
{
this
.
configId
=
configId
;
}
public
int
getGroupId
()
{
return
groupId
;
}
public
void
setGroupId
(
int
groupId
)
{
this
.
groupId
=
groupId
;
}
protected
MotionInfo
getMotionInfo
()
{
protected
MotionInfo
getMotionInfo
()
{
MotionInfo
proto
=
MotionInfo
.
newBuilder
()
MotionInfo
proto
=
MotionInfo
.
newBuilder
()
.
setPos
(
getPosition
().
toProto
())
.
setPos
(
getPosition
().
toProto
())
...
...
src/main/java/emu/grasscutter/game/player/TeamManager.java
View file @
2f39aff4
...
@@ -15,7 +15,7 @@ import emu.grasscutter.Grasscutter;
...
@@ -15,7 +15,7 @@ import emu.grasscutter.Grasscutter;
import
emu.grasscutter.data.def.AvatarSkillDepotData
;
import
emu.grasscutter.data.def.AvatarSkillDepotData
;
import
emu.grasscutter.game.avatar.Avatar
;
import
emu.grasscutter.game.avatar.Avatar
;
import
emu.grasscutter.game.entity.EntityAvatar
;
import
emu.grasscutter.game.entity.EntityAvatar
;
import
emu.grasscutter.game.entity.EntityGadget
;
import
emu.grasscutter.game.entity.Entity
Base
Gadget
;
import
emu.grasscutter.game.props.ElementType
;
import
emu.grasscutter.game.props.ElementType
;
import
emu.grasscutter.game.props.EnterReason
;
import
emu.grasscutter.game.props.EnterReason
;
import
emu.grasscutter.game.props.FightProperty
;
import
emu.grasscutter.game.props.FightProperty
;
...
@@ -54,7 +54,7 @@ public class TeamManager {
...
@@ -54,7 +54,7 @@ public class TeamManager {
@Transient
private
TeamInfo
mpTeam
;
@Transient
private
TeamInfo
mpTeam
;
@Transient
private
int
entityId
;
@Transient
private
int
entityId
;
@Transient
private
final
List
<
EntityAvatar
>
avatars
;
@Transient
private
final
List
<
EntityAvatar
>
avatars
;
@Transient
private
final
Set
<
EntityGadget
>
gadgets
;
@Transient
private
final
Set
<
Entity
Base
Gadget
>
gadgets
;
@Transient
private
final
IntSet
teamResonances
;
@Transient
private
final
IntSet
teamResonances
;
@Transient
private
final
IntSet
teamResonancesConfig
;
@Transient
private
final
IntSet
teamResonancesConfig
;
...
@@ -141,7 +141,7 @@ public class TeamManager {
...
@@ -141,7 +141,7 @@ public class TeamManager {
this
.
entityId
=
entityId
;
this
.
entityId
=
entityId
;
}
}
public
Set
<
EntityGadget
>
getGadgets
()
{
public
Set
<
Entity
Base
Gadget
>
getGadgets
()
{
return
gadgets
;
return
gadgets
;
}
}
...
...
src/main/java/emu/grasscutter/game/props/EntityType.java
0 → 100644
View file @
2f39aff4
package
emu.grasscutter.game.props
;
import
java.util.HashMap
;
import
java.util.Map
;
import
java.util.stream.Stream
;
import
it.unimi.dsi.fastutil.ints.Int2ObjectMap
;
import
it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap
;
public
enum
EntityType
{
None
(
0
),
Avatar
(
1
),
Monster
(
2
),
Bullet
(
3
),
AttackPhyisicalUnit
(
4
),
AOE
(
5
),
Camera
(
6
),
EnviroArea
(
7
),
Equip
(
8
),
MonsterEquip
(
9
),
Grass
(
10
),
Level
(
11
),
NPC
(
12
),
TransPointFirst
(
13
),
TransPointFirstGadget
(
14
),
TransPointSecond
(
15
),
TransPointSecondGadget
(
16
),
DropItem
(
17
),
Field
(
18
),
Gadget
(
19
),
Water
(
20
),
GatherPoint
(
21
),
GatherObject
(
22
),
AirflowField
(
23
),
SpeedupField
(
24
),
Gear
(
25
),
Chest
(
26
),
EnergyBall
(
27
),
ElemCrystal
(
28
),
Timeline
(
29
),
Worktop
(
30
),
Team
(
31
),
Platform
(
32
),
AmberWind
(
33
),
EnvAnimal
(
34
),
SealGadget
(
35
),
Tree
(
36
),
Bush
(
37
),
QuestGadget
(
38
),
Lightning
(
39
),
RewardPoint
(
40
),
RewardStatue
(
41
),
MPLevel
(
42
),
WindSeed
(
43
),
MpPlayRewardPoint
(
44
),
ViewPoint
(
45
),
RemoteAvatar
(
46
),
GeneralRewardPoint
(
47
),
PlayTeam
(
48
),
OfferingGadget
(
49
),
EyePoint
(
50
),
MiracleRing
(
51
),
Foundation
(
52
),
WidgetGadget
(
53
),
PlaceHolder
(
99
);
private
final
int
value
;
private
static
final
Int2ObjectMap
<
EntityType
>
map
=
new
Int2ObjectOpenHashMap
<>();
private
static
final
Map
<
String
,
EntityType
>
stringMap
=
new
HashMap
<>();
static
{
Stream
.
of
(
values
()).
forEach
(
e
->
{
map
.
put
(
e
.
getValue
(),
e
);
stringMap
.
put
(
e
.
name
(),
e
);
});
}
private
EntityType
(
int
value
)
{
this
.
value
=
value
;
}
public
int
getValue
()
{
return
value
;
}
public
static
EntityType
getTypeByValue
(
int
value
)
{
return
map
.
getOrDefault
(
value
,
None
);
}
public
static
EntityType
getTypeByName
(
String
name
)
{
return
stringMap
.
getOrDefault
(
name
,
None
);
}
}
Prev
1
2
3
Next
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