add summon unit & maze buff & refactor battle
This commit is contained in:
@@ -3,6 +3,8 @@ from game_server.game.enums.scene.game_mode_type import GameModeTypeEnum
|
||||
from game_server.resource import ResourceManager
|
||||
from game_server.resource.configdb.maze_plane import MazePlaneData
|
||||
from game_server.resource.configdb.map_entrance import MapEntranceData
|
||||
from game_server.resource.configdb.summon_unit_data import SummonUnitData
|
||||
|
||||
from game_server.game.motion.motion_info import Motion
|
||||
from rail_proto.lib import (
|
||||
SceneInfo,
|
||||
@@ -12,8 +14,15 @@ from rail_proto.lib import (
|
||||
SceneNpcInfo,
|
||||
SceneNpcMonsterInfo,
|
||||
SceneActorInfo,
|
||||
AvatarType
|
||||
AvatarType,
|
||||
SceneCastSkillCsReq,
|
||||
SceneGroupRefreshScNotify,
|
||||
GroupRefreshInfo,
|
||||
SceneGroupRefreshType,
|
||||
SceneEntityRefreshInfo, SceneSummonUnitInfo
|
||||
)
|
||||
from utils.time import cur_timestamp_ms
|
||||
|
||||
|
||||
class SceneManager(BaseModel):
|
||||
entry_id: int
|
||||
@@ -25,6 +34,17 @@ class SceneManager(BaseModel):
|
||||
entity_group_list: list[SceneEntityGroupInfo] = []
|
||||
entities: dict[int,SceneEntityInfo] = {}
|
||||
|
||||
@staticmethod
|
||||
def Actor(avatar_id,player_pos):
|
||||
return SceneEntityInfo(
|
||||
entity_id=avatar_id << 20,
|
||||
motion=player_pos,
|
||||
actor=SceneActorInfo(
|
||||
base_avatar_id=avatar_id,
|
||||
avatar_type=AvatarType.AVATAR_FORMAL_TYPE
|
||||
)
|
||||
)
|
||||
|
||||
def ToProto(self,session) -> SceneInfo:
|
||||
prop_entity_id = 10
|
||||
npc_entity_id = 10_000
|
||||
@@ -139,25 +159,50 @@ class SceneManager(BaseModel):
|
||||
).ToProto()
|
||||
player_group = SceneEntityGroupInfo(state=0,group_id=0)
|
||||
for avatar_id in session.player.lineup_manager.get(session.player.data.cur_lineup).avatar_list:
|
||||
player_entity = SceneEntityInfo(
|
||||
inst_id=0,
|
||||
entity_id=avatar_id << 20,
|
||||
motion=player_pos,
|
||||
actor=SceneActorInfo(
|
||||
avatar_type=AvatarType.AVATAR_FORMAL_TYPE.value,
|
||||
base_avatar_id=avatar_id,
|
||||
uid=session.player.data.uid,
|
||||
)
|
||||
)
|
||||
player_group.entity_list.append(player_entity)
|
||||
player_group.entity_list.append(self.Actor(avatar_id,player_pos))
|
||||
proto.entity_group_list.append(player_group)
|
||||
session.player.data.entry_id = self.entry_id
|
||||
session.player.data.plane_id = entrance.PlaneID
|
||||
session.player.data.floor_id = entrance.FloorID
|
||||
self.plane_id = entrance.PlaneID
|
||||
self.floor_id = entrance.FloorID
|
||||
return proto
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
def SummonUnit(self,msg: SceneCastSkillCsReq,summon_id) -> SceneEntityInfo:
|
||||
return SceneEntityInfo(
|
||||
entity_id=msg.cast_entity_id,
|
||||
motion=Motion(
|
||||
x=msg.target_motion.pos.x,
|
||||
y=msg.target_motion.pos.y,
|
||||
z=msg.target_motion.pos.z,
|
||||
rotY=msg.target_motion.rot.y
|
||||
).ToProto(),
|
||||
summon_unit=SceneSummonUnitInfo(
|
||||
attach_entity_id=msg.attacked_by_entity_id,
|
||||
caster_entity_id=msg.attacked_by_entity_id,
|
||||
summon_unit_id=summon_id,
|
||||
life_time_ms=20000,
|
||||
create_time_ms=cur_timestamp_ms()
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
async def GetSummonUnit(self,session, msg: SceneCastSkillCsReq):
|
||||
summon_id = str(msg.attacked_by_entity_id >> 20) + "1"
|
||||
summon = ResourceManager.instance().find_all_by_index(SummonUnitData, summon_id)
|
||||
if summon:
|
||||
summon_unit = SceneGroupRefreshScNotify(
|
||||
floor_id=self.floor_id,
|
||||
group_refresh_list=[
|
||||
GroupRefreshInfo(
|
||||
refresh_type=SceneGroupRefreshType.SCENE_GROUP_REFRESH_TYPE_LOADED.value,
|
||||
refresh_entity=[
|
||||
SceneEntityRefreshInfo(
|
||||
add_entity=self.SummonUnit(msg,data.ID)
|
||||
)
|
||||
for data in summon
|
||||
]
|
||||
)
|
||||
]
|
||||
)
|
||||
await session.notify(summon_unit)
|
||||
Reference in New Issue
Block a user