Better interact handling (fixes Nicole dialogue) (still temporary impl)
This commit is contained in:
parent
27ca664829
commit
1a41d4b07b
4 changed files with 76 additions and 40 deletions
|
@ -27,6 +27,8 @@ pub enum ConfigValue {
|
||||||
pub enum ConfigEventType {
|
pub enum ConfigEventType {
|
||||||
OnStart,
|
OnStart,
|
||||||
OnEnd,
|
OnEnd,
|
||||||
|
OnBro,
|
||||||
|
OnSis,
|
||||||
#[serde(other)]
|
#[serde(other)]
|
||||||
Unknown,
|
Unknown,
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,8 +42,8 @@ impl SceneUnitManager {
|
||||||
uid
|
uid
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn get(&self, uid: u64) -> SceneUnitProtocolInfo {
|
pub async fn get(&self, uid: u64) -> Option<SceneUnitProtocolInfo> {
|
||||||
self.units.read().await.get(&uid).unwrap().clone()
|
self.units.read().await.get(&uid).map(|u| u.clone())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn sync(&self, scene_uid: u64, section_id: i32) -> PtcSyncSceneUnitArg {
|
pub async fn sync(&self, scene_uid: u64, section_id: i32) -> PtcSyncSceneUnitArg {
|
||||||
|
@ -113,7 +113,7 @@ impl SceneUnitManager {
|
||||||
1002,
|
1002,
|
||||||
0,
|
0,
|
||||||
phashmap![(
|
phashmap![(
|
||||||
19900062,
|
10000009,
|
||||||
create_interact(
|
create_interact(
|
||||||
0,
|
0,
|
||||||
1,
|
1,
|
||||||
|
|
|
@ -12,21 +12,34 @@ pub async fn on_rpc_run_event_graph(
|
||||||
session: &NetworkSession,
|
session: &NetworkSession,
|
||||||
arg: &RpcRunEventGraphArg,
|
arg: &RpcRunEventGraphArg,
|
||||||
) -> Result<RpcRunEventGraphRet> {
|
) -> Result<RpcRunEventGraphRet> {
|
||||||
tracing::info!("RunEventGraph requested");
|
|
||||||
|
|
||||||
let unit = session.context.scene_unit_manager.get(arg.owner_uid).await;
|
let unit = session.context.scene_unit_manager.get(arg.owner_uid).await;
|
||||||
|
|
||||||
let SceneUnitProtocolInfo::NpcProtocolInfo { tag, id, .. } = unit;
|
let interact_id = match unit {
|
||||||
|
Some(SceneUnitProtocolInfo::NpcProtocolInfo { interacts_info, .. })
|
||||||
|
if interacts_info.len() != 0 =>
|
||||||
|
{
|
||||||
|
*interacts_info.iter().next().unwrap().0
|
||||||
|
}
|
||||||
|
Some(SceneUnitProtocolInfo::NpcProtocolInfo { tag, id, .. }) => {
|
||||||
let main_city_object = data::get_main_city_object(tag, id).unwrap();
|
let main_city_object = data::get_main_city_object(tag, id).unwrap();
|
||||||
|
*main_city_object.default_interact_ids.first().unwrap()
|
||||||
|
}
|
||||||
|
None => {
|
||||||
|
return Ok(RpcRunEventGraphRet::error(
|
||||||
|
ErrorCode::EntityNotExist,
|
||||||
|
Vec::new(),
|
||||||
|
))
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
let mut ptc_sync_event_info = PtcSyncEventInfoArg {
|
let mut ptc_sync_event_info = PtcSyncEventInfoArg {
|
||||||
owner_type: EventGraphOwnerType::SceneUnit,
|
owner_type: arg.owner_type,
|
||||||
owner_uid: arg.owner_uid,
|
owner_uid: arg.owner_uid,
|
||||||
updated_events: pdkhashmap![],
|
updated_events: pdkhashmap![],
|
||||||
};
|
};
|
||||||
|
|
||||||
ptc_sync_event_info.updated_events.insert(
|
ptc_sync_event_info.updated_events.insert(
|
||||||
*main_city_object.default_interact_ids.first().unwrap(),
|
interact_id,
|
||||||
100,
|
100,
|
||||||
EventInfo {
|
EventInfo {
|
||||||
id: 100,
|
id: 100,
|
||||||
|
@ -52,8 +65,6 @@ pub async fn on_rpc_finish_event_graph_perform_show(
|
||||||
session: &NetworkSession,
|
session: &NetworkSession,
|
||||||
arg: &RpcFinishEventGraphPerformShowArg,
|
arg: &RpcFinishEventGraphPerformShowArg,
|
||||||
) -> Result<RpcFinishEventGraphPerformShowRet> {
|
) -> Result<RpcFinishEventGraphPerformShowRet> {
|
||||||
tracing::info!("FinishEventGraphPerformShow");
|
|
||||||
|
|
||||||
let mut ptc_sync_event_info = PtcSyncEventInfoArg {
|
let mut ptc_sync_event_info = PtcSyncEventInfoArg {
|
||||||
owner_type: EventGraphOwnerType::SceneUnit,
|
owner_type: EventGraphOwnerType::SceneUnit,
|
||||||
owner_uid: arg.owner_uid,
|
owner_uid: arg.owner_uid,
|
||||||
|
@ -87,13 +98,36 @@ pub async fn on_rpc_interact_with_unit(
|
||||||
session: &NetworkSession,
|
session: &NetworkSession,
|
||||||
arg: &RpcInteractWithUnitArg,
|
arg: &RpcInteractWithUnitArg,
|
||||||
) -> Result<RpcInteractWithUnitRet> {
|
) -> Result<RpcInteractWithUnitRet> {
|
||||||
tracing::info!("InteractWithUnit");
|
tracing::info!(
|
||||||
|
"InteractWithUnit: unit_uid: {}, interaction: {}",
|
||||||
|
arg.unit_uid,
|
||||||
|
arg.interaction
|
||||||
|
);
|
||||||
|
|
||||||
let unit = session.context.scene_unit_manager.get(arg.unit_uid).await;
|
let unit = session.context.scene_unit_manager.get(arg.unit_uid).await;
|
||||||
|
|
||||||
let SceneUnitProtocolInfo::NpcProtocolInfo { tag, id, .. } = unit;
|
let interact_id = match unit {
|
||||||
|
Some(SceneUnitProtocolInfo::NpcProtocolInfo { interacts_info, .. })
|
||||||
|
if interacts_info.len() != 0 =>
|
||||||
|
{
|
||||||
|
*interacts_info.iter().next().unwrap().0
|
||||||
|
}
|
||||||
|
Some(SceneUnitProtocolInfo::NpcProtocolInfo { tag, id, .. }) => {
|
||||||
let main_city_object = data::get_main_city_object(tag, id).unwrap();
|
let main_city_object = data::get_main_city_object(tag, id).unwrap();
|
||||||
|
*main_city_object.default_interact_ids.first().unwrap()
|
||||||
|
}
|
||||||
|
None => {
|
||||||
|
return Ok(RpcInteractWithUnitRet::error(
|
||||||
|
ErrorCode::EntityNotExist,
|
||||||
|
Vec::new(),
|
||||||
|
))
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// 0 - ServerInteractiveSystem::TriggerEnterEvent
|
||||||
|
// 1 - ServerInteractiveSystem::TriggerExitEvent
|
||||||
|
// 2 - ServerInteractiveSystem::TriggerInteractDirectly
|
||||||
|
if arg.interaction == 2 {
|
||||||
let mut ptc_sync_event_info = PtcSyncEventInfoArg {
|
let mut ptc_sync_event_info = PtcSyncEventInfoArg {
|
||||||
owner_type: EventGraphOwnerType::SceneUnit,
|
owner_type: EventGraphOwnerType::SceneUnit,
|
||||||
owner_uid: arg.unit_uid,
|
owner_uid: arg.unit_uid,
|
||||||
|
@ -101,7 +135,7 @@ pub async fn on_rpc_interact_with_unit(
|
||||||
};
|
};
|
||||||
|
|
||||||
ptc_sync_event_info.updated_events.insert(
|
ptc_sync_event_info.updated_events.insert(
|
||||||
*main_city_object.default_interact_ids.first().unwrap(),
|
interact_id,
|
||||||
100,
|
100,
|
||||||
EventInfo {
|
EventInfo {
|
||||||
id: 100,
|
id: 100,
|
||||||
|
@ -119,6 +153,8 @@ pub async fn on_rpc_interact_with_unit(
|
||||||
session
|
session
|
||||||
.send_rpc_arg(PTC_SYNC_EVENT_INFO_ID, &ptc_sync_event_info)
|
.send_rpc_arg(PTC_SYNC_EVENT_INFO_ID, &ptc_sync_event_info)
|
||||||
.await?;
|
.await?;
|
||||||
|
}
|
||||||
|
|
||||||
Ok(RpcInteractWithUnitRet::new())
|
Ok(RpcInteractWithUnitRet::new())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -141,8 +177,6 @@ pub async fn on_rpc_save_pos_in_main_city(
|
||||||
_session: &NetworkSession,
|
_session: &NetworkSession,
|
||||||
_arg: &RpcSavePosInMainCityArg,
|
_arg: &RpcSavePosInMainCityArg,
|
||||||
) -> Result<RpcSavePosInMainCityRet> {
|
) -> Result<RpcSavePosInMainCityRet> {
|
||||||
tracing::info!("MainCity pos updated");
|
|
||||||
|
|
||||||
Ok(RpcSavePosInMainCityRet::new())
|
Ok(RpcSavePosInMainCityRet::new())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -683,7 +683,7 @@ pub enum InteractTarget {
|
||||||
TriggerBox = 1,
|
TriggerBox = 1,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(OctData, Clone, Debug)]
|
#[derive(OctData, Clone, Copy, Debug)]
|
||||||
#[repr(i16)]
|
#[repr(i16)]
|
||||||
pub enum EventGraphOwnerType {
|
pub enum EventGraphOwnerType {
|
||||||
Scene = 0,
|
Scene = 0,
|
||||||
|
|
Loading…
Reference in a new issue