Files
Genarrative/server-rs/crates/spacetime-module/src/lib.rs

144 lines
9.1 KiB
Rust

use module_ai::{
AI_RESULT_REF_ID_PREFIX, AI_TEXT_CHUNK_ID_PREFIX, AiResultReferenceInput,
AiResultReferenceKind, AiResultReferenceSnapshot, AiStageCompletionInput, AiTaskCancelInput,
AiTaskCreateInput, AiTaskFailureInput, AiTaskFinishInput, AiTaskKind, AiTaskProcedureResult,
AiTaskSnapshot, AiTaskStageKind, AiTaskStageSnapshot, AiTaskStageStartInput, AiTaskStageStatus,
AiTaskStartInput, AiTaskStatus, AiTextChunkAppendInput, AiTextChunkSnapshot,
INITIAL_AI_TASK_VERSION, generate_ai_result_ref_id, generate_ai_task_stage_id,
generate_ai_text_chunk_id, normalize_optional_text, normalize_string_list,
validate_task_create_input,
};
use module_assets::{
ASSET_BINDING_ID_PREFIX, ASSET_OBJECT_ID_PREFIX, AssetEntityBindingInput,
AssetEntityBindingProcedureResult, AssetEntityBindingSnapshot, AssetObjectAccessPolicy,
AssetObjectProcedureResult, AssetObjectUpsertInput, AssetObjectUpsertSnapshot,
INITIAL_ASSET_OBJECT_VERSION, validate_asset_entity_binding_fields,
validate_asset_object_fields,
};
use module_combat::{
BATTLE_STATE_ID_PREFIX, BattleMode, BattleStateInput, BattleStateProcedureResult,
BattleStateQueryInput, BattleStateSnapshot, BattleStatus, CombatOutcome,
INITIAL_BATTLE_VERSION, ResolveCombatActionInput, ResolveCombatActionProcedureResult,
build_battle_state_snapshot, generate_battle_state_id,
resolve_combat_action as resolve_battle_state_action, validate_battle_state_input,
validate_battle_state_query_input,
};
use module_custom_world::{
CustomWorldAgentActionExecuteInput, CustomWorldAgentActionExecuteResult,
CustomWorldAgentCardDetailGetInput, CustomWorldAgentMessageSnapshot,
CustomWorldAgentMessageSubmitInput,
CustomWorldAgentOperationGetInput, CustomWorldAgentOperationProcedureResult,
CustomWorldAgentOperationSnapshot, CustomWorldAgentSessionCreateInput,
CustomWorldAgentSessionGetInput, CustomWorldAgentSessionProcedureResult,
CustomWorldAgentSessionSnapshot, CustomWorldDraftCardDetailResult,
CustomWorldDraftCardDetailSectionSnapshot, CustomWorldDraftCardDetailSnapshot,
CustomWorldDraftCardSnapshot, CustomWorldPublishBlockerSnapshot,
CustomWorldPublishGateSnapshot, CustomWorldWorkSummarySnapshot, CustomWorldWorksListInput,
CustomWorldWorksListResult,
CustomWorldGalleryDetailInput, CustomWorldGalleryEntrySnapshot,
CustomWorldGalleryListResult, CustomWorldGenerationMode, CustomWorldLibraryDetailInput,
CustomWorldLibraryMutationResult, CustomWorldProfileListInput,
CustomWorldProfileListResult, CustomWorldProfilePublishInput, CustomWorldProfileSnapshot,
CustomWorldProfileUnpublishInput, CustomWorldProfileUpsertInput,
CustomWorldPublicationStatus, CustomWorldPublishWorldInput, CustomWorldPublishWorldResult,
CustomWorldPublishedProfileCompileInput, CustomWorldPublishedProfileCompileResult,
CustomWorldRoleAssetStatus, CustomWorldSessionStatus, CustomWorldThemeMode,
RpgAgentDraftCardKind, RpgAgentDraftCardStatus, RpgAgentMessageKind, RpgAgentMessageRole,
RpgAgentOperationStatus, RpgAgentOperationType, RpgAgentStage,
build_custom_world_published_profile_compile_snapshot, validate_custom_world_agent_message_submit_input,
validate_custom_world_agent_action_execute_input,
validate_custom_world_agent_card_detail_get_input,
validate_custom_world_agent_operation_get_input, validate_custom_world_agent_session_create_input,
validate_custom_world_agent_session_get_input, validate_custom_world_gallery_detail_input,
validate_custom_world_library_detail_input, validate_custom_world_profile_list_input,
validate_custom_world_profile_publish_input, validate_custom_world_profile_unpublish_input,
validate_custom_world_profile_upsert_input, validate_custom_world_publish_world_input,
validate_custom_world_works_list_input,
};
use module_inventory::{
GrantInventoryItemInput, INVENTORY_MUTATION_ID_PREFIX, INVENTORY_SLOT_ID_PREFIX,
InventoryContainerKind, InventoryEquipmentSlot, InventoryItemRarity, InventoryItemSnapshot,
InventoryItemSourceKind, InventoryMutation, InventoryMutationInput, InventorySlotSnapshot,
RuntimeInventoryStateProcedureResult, RuntimeInventoryStateQueryInput,
RuntimeInventoryStateSnapshot, apply_inventory_mutation as apply_inventory_slot_mutation,
build_runtime_inventory_state_query_input, build_runtime_inventory_state_snapshot,
generate_inventory_mutation_id, generate_inventory_slot_id,
};
use module_npc::{
NPC_FIGHT_FUNCTION_ID, NPC_RECRUIT_AFFINITY_THRESHOLD, NPC_SPAR_FUNCTION_ID,
NPC_STATE_ID_PREFIX, NpcInteractionBattleMode, NpcInteractionProcedureResult, NpcRelationState,
NpcStanceProfile, NpcStateProcedureResult, NpcStateSnapshot, NpcStateUpsertInput,
ResolveNpcInteractionInput, ResolveNpcSocialActionInput, apply_npc_social_action,
generate_npc_state_id, normalize_npc_state_snapshot,
resolve_npc_interaction as resolve_npc_interaction_domain,
};
use module_progression::{
ChapterPaceBand, ChapterProgressionGetInput, ChapterProgressionInput,
ChapterProgressionLedgerInput, ChapterProgressionProcedureResult, ChapterProgressionSnapshot,
PlayerProgressionGetInput, PlayerProgressionGrantInput, PlayerProgressionGrantSource,
PlayerProgressionProcedureResult, PlayerProgressionSnapshot, apply_chapter_progression_ledger,
build_chapter_progression_snapshot, create_initial_player_progression, grant_player_experience,
};
use module_quest::{
QUEST_LOG_ID_PREFIX, QuestCompletionAckInput, QuestLogEventKind, QuestNarrativeBindingSnapshot,
QuestObjectiveSnapshot, QuestProgressSignal, QuestRecordInput, QuestRecordSnapshot,
QuestRewardEquipmentSlot, QuestRewardItem, QuestRewardItemRarity, QuestRewardSnapshot,
QuestSignalApplyInput, QuestSignalKind, QuestStatus, QuestStepSnapshot, QuestTurnInInput,
acknowledge_quest_completion as acknowledge_quest_record_completion,
apply_quest_signal as apply_quest_record_signal, build_quest_record_snapshot,
generate_quest_log_id, turn_in_quest_record,
};
use module_runtime::{
DEFAULT_MUSIC_VOLUME, DEFAULT_PLATFORM_THEME, DEFAULT_SAVE_ARCHIVE_SUMMARY_TEXT,
PROFILE_WALLET_LEDGER_LIST_LIMIT, SAVE_SNAPSHOT_VERSION,
RuntimeBrowseHistoryClearInput, RuntimeBrowseHistoryListInput,
RuntimeBrowseHistoryProcedureResult, RuntimeBrowseHistorySnapshot,
RuntimeBrowseHistorySyncInput, RuntimeBrowseHistoryThemeMode, RuntimePlatformTheme,
RuntimeProfileSaveArchiveListInput, RuntimeProfileSaveArchiveProcedureResult,
RuntimeProfileSaveArchiveResumeInput, RuntimeProfileSaveArchiveSnapshot,
RuntimeProfileDashboardGetInput, RuntimeProfileDashboardProcedureResult,
RuntimeProfileDashboardSnapshot, RuntimeProfilePlayStatsGetInput,
RuntimeProfilePlayStatsProcedureResult, RuntimeProfilePlayStatsSnapshot,
RuntimeProfilePlayedWorldSnapshot, RuntimeProfileWalletLedgerEntrySnapshot,
RuntimeProfileWalletLedgerListInput, RuntimeProfileWalletLedgerProcedureResult,
RuntimeProfileWalletLedgerSourceType, RuntimeSettingGetInput,
RuntimeSettingProcedureResult, RuntimeSettingSnapshot, RuntimeSettingUpsertInput,
RuntimeSnapshot, RuntimeSnapshotDeleteInput, RuntimeSnapshotGetInput,
RuntimeSnapshotProcedureResult, RuntimeSnapshotUpsertInput,
build_runtime_browse_history_clear_input,
build_runtime_browse_history_list_input, build_runtime_profile_dashboard_get_input,
build_runtime_profile_play_stats_get_input, build_runtime_profile_wallet_ledger_list_input,
build_runtime_profile_save_archive_list_input,
build_runtime_profile_save_archive_resume_input, build_runtime_setting_get_input,
build_runtime_setting_upsert_input, build_runtime_snapshot_delete_input,
build_runtime_snapshot_get_input, build_runtime_snapshot_upsert_input,
prepare_runtime_browse_history_entries,
};
use module_runtime_item::{
RuntimeItemRewardItemSnapshot, TREASURE_RECORD_ID_PREFIX, TreasureInteractionAction,
TreasureRecordProcedureResult, TreasureRecordSnapshot, TreasureResolveInput,
build_inventory_item_snapshot_from_reward_item, build_treasure_record_snapshot,
};
use module_story::{
INITIAL_STORY_SESSION_VERSION, STORY_EVENT_ID_PREFIX, STORY_SESSION_ID_PREFIX,
StoryContinueInput, StoryEventKind, StoryEventSnapshot, StorySessionInput,
StorySessionProcedureResult, StorySessionSnapshot, StorySessionStateInput,
StorySessionStateProcedureResult, StorySessionStatus, apply_story_continue,
build_story_session_snapshot, build_story_started_event, validate_story_continue_input,
validate_story_session_input, validate_story_session_state_input,
};
use shared_kernel::format_timestamp_micros;
use serde_json::{Map as JsonMap, Value as JsonValue, json};
use spacetimedb::{ProcedureContext, ReducerContext, SpacetimeType, Table, Timestamp};
// 这层输入只服务 NPC 开战编排;普通聊天、援手、招募继续走已有 resolve_npc_interaction 接口。
// SpacetimeDB 的 table/reducer/procedure 宏保持在 crate 顶层展开,避免拆分时改变对外导出名称。
include!("domain_types.rs");
include!("asset_metadata/mod.rs");
include!("runtime/mod.rs");
include!("gameplay/mod.rs");
include!("custom_world/mod.rs");
include!("ai/mod.rs");
include!("entry.rs");