Hollow end screen and LeaveCurDungeon
This commit is contained in:
parent
921f9f932a
commit
7bc1ad2240
6 changed files with 153 additions and 33 deletions
|
@ -1 +1 @@
|
|||
SKIP_TUTORIAL=0
|
||||
SKIP_TUTORIAL=1
|
|
@ -244,6 +244,48 @@ impl DungeonManager {
|
|||
))
|
||||
}
|
||||
|
||||
pub fn hollow_finished(&self) -> PlayerOperationResult<u64> {
|
||||
let cur_scene_uid = self.get_cur_scene_uid();
|
||||
|
||||
let mut player = self.player.borrow_mut();
|
||||
|
||||
let hollow_scene = player
|
||||
.dungeon_collection
|
||||
.as_mut()
|
||||
.unwrap()
|
||||
.scenes
|
||||
.as_mut()
|
||||
.unwrap()
|
||||
.get_mut(&cur_scene_uid)
|
||||
.unwrap();
|
||||
|
||||
if let SceneInfo::Hollow {
|
||||
hollow_system_ui_state,
|
||||
..
|
||||
} = hollow_scene
|
||||
{
|
||||
hollow_system_ui_state.insert(
|
||||
HollowSystemType::HollowResultPage,
|
||||
HollowSystemUIState::Normal,
|
||||
);
|
||||
hollow_system_ui_state.insert(HollowSystemType::Menu, HollowSystemUIState::Close);
|
||||
}
|
||||
|
||||
PlayerOperationResult::with_changes(
|
||||
cur_scene_uid,
|
||||
PlayerInfo {
|
||||
dungeon_collection: Some(DungeonCollection {
|
||||
scenes: Some(PropertyHashMap::Modify {
|
||||
to_add: vec![(cur_scene_uid, hollow_scene.clone())],
|
||||
to_remove: Vec::new(),
|
||||
}),
|
||||
..Default::default()
|
||||
}),
|
||||
..Default::default()
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
pub fn get_default_scene_uid(&self) -> u64 {
|
||||
self.player
|
||||
.borrow()
|
||||
|
|
|
@ -91,28 +91,42 @@ impl HollowGridManager {
|
|||
)
|
||||
}
|
||||
|
||||
pub fn battle_finished(&self) -> PtcSyncHollowEventInfoArg {
|
||||
pub fn battle_finished(&self) -> (PtcSyncHollowEventInfoArg, bool) {
|
||||
let map = self.map.borrow();
|
||||
let map = map.as_ref().unwrap();
|
||||
let cur_grid = map.grids.get(&map.start_grid).unwrap();
|
||||
|
||||
PtcSyncHollowEventInfoArg {
|
||||
event_graph_uid: u64::from(map.start_grid),
|
||||
hollow_event_template_id: cur_grid.grid.event_graph_info.hollow_event_template_id,
|
||||
event_graph_id: cur_grid.grid.event_graph_info.hollow_event_template_id,
|
||||
updated_event: EventInfo {
|
||||
id: 1000,
|
||||
cur_action_id: 2001,
|
||||
action_move_path: vec![1001, 1002, 2001],
|
||||
state: EventState::WaitingClient,
|
||||
prev_state: EventState::Running,
|
||||
cur_action_info: ActionInfo::None {},
|
||||
cur_action_state: ActionState::Init,
|
||||
predicated_failed_actions: phashset![],
|
||||
stack_frames: Vec::new(),
|
||||
},
|
||||
specials: phashmap![],
|
||||
let event_config =
|
||||
data::get_event_config_json(cur_grid.grid.event_graph_info.hollow_event_template_id);
|
||||
|
||||
let mut hollow_finished = false;
|
||||
let actions = event_config["Events"]["OnEnd"]["Actions"]
|
||||
.as_array()
|
||||
.unwrap();
|
||||
if let Some(action) = actions.get(0) {
|
||||
hollow_finished = action["$type"].as_str().unwrap() == "Share.CConfigFinishHollow";
|
||||
}
|
||||
|
||||
(
|
||||
PtcSyncHollowEventInfoArg {
|
||||
event_graph_uid: u64::from(map.start_grid),
|
||||
hollow_event_template_id: cur_grid.grid.event_graph_info.hollow_event_template_id,
|
||||
event_graph_id: cur_grid.grid.event_graph_info.hollow_event_template_id,
|
||||
updated_event: EventInfo {
|
||||
id: 1000,
|
||||
cur_action_id: 2001,
|
||||
action_move_path: vec![1001, 1002, 2001],
|
||||
state: EventState::WaitingClient,
|
||||
prev_state: EventState::Running,
|
||||
cur_action_info: ActionInfo::None {},
|
||||
cur_action_state: ActionState::Init,
|
||||
predicated_failed_actions: phashset![],
|
||||
stack_frames: Vec::new(),
|
||||
},
|
||||
specials: phashmap![],
|
||||
},
|
||||
hollow_finished,
|
||||
)
|
||||
}
|
||||
|
||||
pub fn get_cur_event_template_id(&self) -> i32 {
|
||||
|
@ -156,7 +170,12 @@ impl HollowGridManager {
|
|||
event_graph_uid: u64,
|
||||
_event_id: i32,
|
||||
move_path: Vec<i32>,
|
||||
) -> (PtcSyncHollowEventInfoArg, PtcHollowGridArg, Option<i32>) {
|
||||
) -> (
|
||||
PtcSyncHollowEventInfoArg,
|
||||
PtcHollowGridArg,
|
||||
Option<i32>,
|
||||
bool,
|
||||
) {
|
||||
let (player_uid, scene_uid) = {
|
||||
let player = self.player.borrow();
|
||||
|
||||
|
@ -175,6 +194,8 @@ impl HollowGridManager {
|
|||
grids: HashMap::new(),
|
||||
};
|
||||
|
||||
let mut hollow_finished = false;
|
||||
|
||||
let sync_hollow_event = {
|
||||
let info = map.grids.get(&(event_graph_uid as u16)).unwrap().clone();
|
||||
let event_config =
|
||||
|
@ -216,6 +237,9 @@ impl HollowGridManager {
|
|||
_ => 10101001,
|
||||
});
|
||||
}
|
||||
"Share.CConfigFinishHollow" => {
|
||||
hollow_finished = true;
|
||||
}
|
||||
_ => {}
|
||||
};
|
||||
}
|
||||
|
@ -288,7 +312,12 @@ impl HollowGridManager {
|
|||
finish_event
|
||||
};
|
||||
|
||||
(sync_hollow_event, grid_update, trigger_battle_id)
|
||||
(
|
||||
sync_hollow_event,
|
||||
grid_update,
|
||||
trigger_battle_id,
|
||||
hollow_finished,
|
||||
)
|
||||
}
|
||||
|
||||
pub fn sync_hollow_maps(&self, player_uid: u64, scene_uid: u64) -> PtcSyncHollowGridMapsArg {
|
||||
|
|
|
@ -43,9 +43,29 @@ pub async fn on_rpc_end_battle_arg(session: &NetworkSession, arg: &RpcEndBattleA
|
|||
let player_uid = session.get_player_uid();
|
||||
let hollow_grid_manager = session.context.hollow_grid_manager.borrow();
|
||||
|
||||
session
|
||||
.send_rpc_arg(210, &hollow_grid_manager.battle_finished())
|
||||
.await?;
|
||||
let (sync_event, hollow_finished) = hollow_grid_manager.battle_finished();
|
||||
|
||||
if !hollow_finished {
|
||||
session.send_rpc_arg(210, &sync_event).await?;
|
||||
} else {
|
||||
let dungeon_manager = session.context.dungeon_manager.borrow();
|
||||
let cur_scene = *dungeon_manager
|
||||
.hollow_finished()
|
||||
.send_changes(session)
|
||||
.await?;
|
||||
|
||||
let ptc_dungeon_quest_finished = PtcDungeonQuestFinishedArg {
|
||||
player_uid: 1337,
|
||||
quest_id: 1001000101,
|
||||
success: true,
|
||||
reward_items: phashmap![],
|
||||
statistics: phashmap![],
|
||||
};
|
||||
|
||||
session
|
||||
.send_rpc_arg(148, &ptc_dungeon_quest_finished)
|
||||
.await?;
|
||||
}
|
||||
|
||||
let dungeon_manager = session.context.dungeon_manager.borrow();
|
||||
let ptc_enter_scene = dungeon_manager
|
||||
|
@ -120,12 +140,38 @@ pub async fn on_rpc_run_hollow_event_graph_arg(
|
|||
}
|
||||
} else {
|
||||
let hollow_grid_manager = session.context.hollow_grid_manager.borrow();
|
||||
let (sync_hollow_event, hollow_grid, trigger_battle_id) = hollow_grid_manager
|
||||
.run_event_graph(arg.event_graph_uid, arg.event_id, arg.move_path.clone());
|
||||
let (sync_hollow_event, hollow_grid, trigger_battle_id, hollow_finished) =
|
||||
hollow_grid_manager.run_event_graph(
|
||||
arg.event_graph_uid,
|
||||
arg.event_id,
|
||||
arg.move_path.clone(),
|
||||
);
|
||||
|
||||
session.send_rpc_arg(210, &sync_hollow_event).await?;
|
||||
if !hollow_finished {
|
||||
session.send_rpc_arg(210, &sync_hollow_event).await?;
|
||||
}
|
||||
session.send_rpc_arg(114, &hollow_grid).await?;
|
||||
|
||||
if hollow_finished {
|
||||
let dungeon_manager = session.context.dungeon_manager.borrow();
|
||||
let cur_scene = *dungeon_manager
|
||||
.hollow_finished()
|
||||
.send_changes(session)
|
||||
.await?;
|
||||
|
||||
let ptc_dungeon_quest_finished = PtcDungeonQuestFinishedArg {
|
||||
player_uid: 1337,
|
||||
quest_id: 1001000101,
|
||||
success: true,
|
||||
reward_items: phashmap![],
|
||||
statistics: phashmap![],
|
||||
};
|
||||
|
||||
session
|
||||
.send_rpc_arg(148, &ptc_dungeon_quest_finished)
|
||||
.await?;
|
||||
}
|
||||
|
||||
if let Some(trigger_battle_id) = trigger_battle_id {
|
||||
let dungeon_manager = session.context.dungeon_manager.borrow();
|
||||
let hollow_uid = *session.get_player().scene_uid.as_ref().unwrap();
|
||||
|
|
|
@ -134,13 +134,7 @@ pub async fn on_rpc_leave_cur_dungeon_arg(
|
|||
session: &NetworkSession,
|
||||
_arg: &RpcLeaveCurDungeonArg,
|
||||
) -> Result<()> {
|
||||
let dungeon_manager = session.context.dungeon_manager.borrow();
|
||||
if dungeon_manager.is_in_tutorial() {
|
||||
Box::pin(enter_main_city(session)).await?;
|
||||
}
|
||||
|
||||
// TODO: enter scene by back_scene_uid from cur DungeonInfo.
|
||||
|
||||
Box::pin(enter_main_city(session)).await?;
|
||||
session.send_rpc_ret(RpcLeaveCurDungeonRet::new()).await
|
||||
}
|
||||
|
||||
|
|
|
@ -328,6 +328,15 @@ pub struct RpcDelNewMapArg {
|
|||
pub ids: PropertyHashSet<i32>,
|
||||
}
|
||||
|
||||
#[derive(OctData, Debug)]
|
||||
pub struct PtcDungeonQuestFinishedArg {
|
||||
pub player_uid: u64,
|
||||
pub quest_id: i32,
|
||||
pub success: bool,
|
||||
pub reward_items: PropertyHashMap<u64, ItemIDCount>,
|
||||
pub statistics: PropertyHashMap<QuestStatisticsType, u64>,
|
||||
}
|
||||
|
||||
ret! {
|
||||
struct RpcLoginRet {
|
||||
account_info: PropertyBlob,
|
||||
|
|
Loading…
Reference in a new issue