Compare commits

..
32 Commits
Author SHA1 Message Date
Jiaqi Liu 4506397e73 Fix build issue 2023-08-19 02:46:14 -07:00
Jiaqi Liu 89aba474ae Enable DynamicBatching 2023-08-19 02:02:35 -07:00
Jiaqi Liu 94a3bc6466 v0.75 2023-08-18 22:35:28 -07:00
Jiaqi Liu 8369ce4457 Bug fixes 2023-08-18 21:51:45 -07:00
Jiaqi Liu 3ca369173a Bug fixes 2023-08-18 20:28:58 -07:00
Jiaqi Liu 27e92ce148 Code refactoring 2023-08-18 18:14:36 -07:00
Jiaqi Liu 5eb5574ff6 Bug fixes 2023-08-17 21:54:06 -07:00
Jiaqi Liu 5e73768756 Code refactoring 2023-08-17 19:24:41 -07:00
Jiaqi Liu 1c40f78179 Code refactoring 2023-08-16 19:36:31 -07:00
Jiaqi Liu 3506623d43 Fix a bug where actor might set to unwalkable tile during scene switch 2023-08-16 08:01:24 -07:00
Jiaqi Liu 6dcfa9acc0 Code refactoring 2023-08-16 07:34:57 -07:00
Jiaqi Liu f0efdfa67c Minor refactoring 2023-08-15 20:38:29 -07:00
Jiaqi Liu ef2710f028 Implement material pool to improve scene loading perf 2023-08-15 19:51:43 -07:00
Jiaqi Liu bd39ad5474 Perf optimizations 2023-08-14 08:50:46 -07:00
Jiaqi Liu 1db9c09281 v0.74 2023-08-13 10:03:33 -07:00
Jiaqi Liu 6949a02355 Implement and use LinkedObjectGroupId to sync objects 2023-08-13 09:26:13 -07:00
Jiaqi Liu 4e25c7f593 Update ReleaseBuildPipeline.cs 2023-08-12 21:26:41 -07:00
Jiaqi Liu dbc4f3747d Update LiberationSans SDF - Fallback.asset 2023-08-12 21:06:15 -07:00
Jiaqi Liu 780a2087e6 v0.73 2023-08-12 20:58:47 -07:00
Jiaqi Liu 7f8ff06b6e Cache all audio files 2023-08-12 20:40:59 -07:00
Jiaqi Liu cb9cb24d77 Code refactoring 2023-08-12 19:24:57 -07:00
Jiaqi Liu feaac946e3 Fix charset and build issue 2023-08-12 18:34:40 -07:00
Jiaqi Liu 724a6f767e Supports Traditional Chinese version of the game 2023-08-12 18:19:34 -07:00
Jiaqi Liu ba630a21fa Code refactoring 2023-08-12 07:12:43 -07:00
Jiaqi Liu b1e199e0fb Read and parse ComboSkills + EffectLinkers 2023-08-12 05:45:15 -07:00
Jiaqi Liu f3c1d30215 Read and parse CombatActorInfo and SkillInfo in gdb file 2023-08-11 05:39:47 -07:00
Jiaqi Liu 25151a8479 Code refactoring 2023-08-10 08:04:05 -07:00
Jiaqi Liu 48a6ef0217 Code refactoring 2023-08-10 07:41:52 -07:00
Jiaqi Liu 0adcc69b9e Use default theme music for the game 2023-08-10 03:08:33 -07:00
Jiaqi Liu 9cb651ffd0 Disable auto graphics API on Android, check executable folder on Win/Linux for OG game data files by default 2023-08-10 02:01:33 -07:00
Jiaqi Liu dc3cfadd44 Remove unused assets 2023-08-09 03:59:11 -07:00
Jiaqi Liu dc96d1a257 Fix a minor issue 2023-08-08 00:48:47 -07:00
218 changed files with 106201 additions and 55730 deletions

No files matched your search

File diff suppressed because it is too large. Load diff
+2 -1
View File
@@ -1 +1,2 @@
!"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~·—‘’“”…、。《》【】!(),:;?~+一丁七万丈三上下不与丐丑专且世丘丙业丛东丝丢两严丧个丫中丰串临丸丹为主丽举乃久么义之乌乍乎乏乐乔乖乘乙九乞也习乡书乩买乱乳乾了予争事二于亏云互五井亚些亡交亥亦产亨亩享京亭亮亲人亿什仁仃仅仆仇今介仍从仑仓仔仕他仗付仙仞代令以仪们仰仲仵件价任份仿企伉伍伎伏伐休众优伙会伟传伤伦伪伯估伴伶伸伺似但位低住佐佑体何佘余佛作你佣佩佬佯佳佼使侄侈例侍供依侠侣侥侧侬侮侯侵便促俊俏俐俗保俞信俨俩俪俭修俯俱俸俺倍倏們倒倔倘候倚倜借倦倩倪债值倾假偌偏偕做停健偶偷偿傀傅傍傥储催傲傻像僧僵僻儒儡儿允元兄充兆先光克免兑兔党兢入全八公六兮兰共关兴兵其具典兹养兼兽冀内冈册再冒冕写军农冠冢冤冥冬冯冰冲决况冶冷冻净凄准凉凋凌减凑凛凝几凡凤凭凰凶出击函凿刀刁刃分切刎刑划列刘则刚创初判刨利别刮到制刹刺刻剁剂剃削剌前剐剑剔剖剥剧剩剪副割剿劈力劝办功加务劣动助努劫励劲劳劾势勇勉勘募勤勺勾勿匀包匆匕化北匙匠匪匹区医匾匿十千升午卉半华协卑卒卓单卖南博卜卞占卡卢卦卧卫卯印危即却卵卷卸卿厂厄厅历厉压厌厕厘厚原厢厥厨厮去县叁参又及友双反发叔取受变叛叟口古句另叨叩只叫召叮可台史右叵叶号司叹叽吁吃各吆合吉吊同名后吏吐向吓吕吖吗君吝吞吟否吧吩含听吭启吴吵吸吹吼吾呀呃呆呈告呐呔呕呗员呜呢呦周呱味呵呶呸呻呼命咄咋和咎咏咐咒咔咕咙咦咧咪咬咱咳咶咸咻咽咿哀品哄哇哈哉响哎哑哗哟哥哦哨哩哪哭哮哲哼唆唇唉唐唔唠唤唧唬售唯唱唾啃商啊啥啦啧啬啰啸啼啾喀喂喃善喉喊喋喏喔喘喙喜喝喧喳喵喷喻喽嗅嗓嗔嗖嗜嗟嗤嗦嗨嗬嗯嗳嗽嘀嘉嘎嘘嘛嘞嘟嘱嘲嘴嘻嘿噎噗噜噢噤器噩噪噬噱嚎嚏嚣嚷嚼囊囔囚四回因团园困围固国图圃圆圈土圣在地场圾均坊坍坎坏坐坑块坚坛坝坟坠坡坤坦坪坷垂垃型垒垢垣垫垮埃埋城域埠埤培基堂堆堇堕堡堤堪堰堵塌塑塔塘塞填塾境墓墙墚增墟墨壁壑壤士壬壮声壳壶壹处备复夏夕外夙多夜够大天太夫夭央失头夷夸夹夺奇奈奉奋奎奏契奔奖套奠奢奥女奴奶奸她好如妃妄妆妇妈妍妒妓妖妙妞妥妨妹妻妾姊始姐姑姓委姗姚姜姥姨姬姻姿威娃娄娇娘娜娟娥娲娴娶娼婆婉婕婚婢婪婴婵婶婷婿媒媚媳媵嫁嫂嫉嫌嫔嫖嫡嫣嫦嫩嬉嬷子孑孓孔孕字存孙孚孝孟季孤学孩孪孬孰孵孺孽宁它宅宇守安宋完宏宗官宙定宜宝实宠客宣室宦宫宰害宴宵家容宽宾宿寂寄寅密寇富寐寒寝寞察寡寤寨寰寸对寺寻导寿封射将尊小少尔尖尘尚尝尤尬就尴尸尹尺尼尽尾尿局屁层居屈屋屎屏屐屑展属屠屡山屹岁岂岄岌岑岔岖岗岚岛岩岭岱岳岸峙峡峨峭峰峻崇崎崔崖崩崽嵯嶂巍川州巡巢工左巧巨巫差己已巳巴巷巽巾币市布帅师希帐帔帕帖帚帜帝带席帮帷常帼帽幄幅幌幕幢干平年并幸幺幻幼幽广庄庆庇床序庐库应底店庙庚府庞废度座庭庶康庸廉廊廖延廷建廻廿开异弃弄弊式弑弓引弛弟张弥弦弭弯弱弹强归当录彝形彤彦彩彪彭彰影役彻彼往征径待徇很律徐徒徕得徙御循微德心必忆忌忍忒志忘忙忠忡忧快念忽怀态怄怅怎怒怕怖怜思怠急怦性怨怪怯总恃恋恍恐恒恕恙恢恤恨恩恭息恰恳恶恻恼悄悉悍悔悟悠患悦您悬悯悲悴情惆惊惋惑惕惚惜惟惠惦惧惨惩惬惭惮惯想惶惹惺愁愈意愚感愣愤愧愫愿慈慌慎慑慕慢慧慨慰慷憎憾懂懈懒懦懵戈戊戌戎戏成我戒或战戚戟截戮戴户戾房所扁扇扈扉手才扎扑扒打扔托扛扣执扩扫扬扭扮扯扰扳扶批找承技抄把抑抓投抖抗折抚抛抟抢护报披抬抱抵抹押抽拂担拆拈拉拋拍拎拐拒拓拔拖拘拙招拜拟拢拣拥拦拧拨择括拯拳拷拼拽拾拿持挂指按挑挖挟挠挡挣挤挥挨挪挫振挺挽捅捆捉捌捎捏捐捕捞损捡换捣捧据捶捷掀掂授掉掌掏掐排掘掙掠探接控推掩措掳掷掺揉揍描提插揖握揣揪揭援搁搂搅搏搓搔搜搞搬搭携摄摆摇摈摊摔摘摧摩摸撇撑撒撕撞撤播撰擂擅操擎擒擦攀攒攫支收攸改攻放政故效敌敏救教敛敝敞敢散敬数敲整敷文斋斐斑斗料斛斜斟斤斥斧斩断斯新方於施旁旅旋族旗无既日旦旧旨早旬旭旱时旷旺昂昆昊昌明昏易昔昕昙星映春昧昨昭是昴昼显晃晋晌晒晓晕晖晚晦晧晨普景晰晴晶智晾暂暄暇暑暖暗暮暴曜曦曰曲曳更曹曾替最月有朋服朔朗望朝期木未末本术朱朴朵机朽杀杂权杆杈杉李杏材村杖杜杞束杠条来杨杭杯杰杳杵松板极构枉枕林枚果枝枢Line truncated
!"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~·—‘’“”…、。《》【】!(),:;?~+一丁七万丈三上下不与丐丑专且世丘丙业丛东丝丢两严丧个丫中丰串临丸丹为主丽举乃久么义之乌乍乎乏乐乔乖乘乙九乞也习乡书乩买乱乳乾了予争事二于亏云互五井亚些亡交亥亦产亨亩享京亭亮亲人亿什仁仃仅仆仇今介仍从仑仓仔仕他仗付仙仞代令以仪们仰仲仵件价任份仿企伉伍伎伏伐休众优伙会伟传伤伦伪伯估伴伶伸伺似但位低住佐佑体何佘余佛作你佣佩佬佯佳佼使侄侈例侍供依侠侣侥侧侬侮侯侵便促俊俏俐俗保俞信俨俩俪俭修俯俱俸俺倍倏們倒倔倘候倚倜借倦倩倪债值倾假偌偏偕做停健偶偷偿傀傅傍傥储催傲傻像僧僵僻儒儡儿允元兄充兆先光克免兑兔党兢入全八公六兮兰共关兴兵其具典兹养兼兽冀内冈册再冒冕写军农冠冢冤冥冬冯冰冲决况冶冷冻净凄准凉凋凌减凑凛凝几凡凤凭凰凶出击函凿刀刁刃分切刎刑划列刘则刚创初判刨利别刮到制刹刺刻剁剂剃削剌前剐剑剔剖剥剧剩剪副割剿劈力劝办功加务劣动助努劫励劲劳劾势勇勉勘募勤勺勾勿匀包匆匕化北匙匠匪匹区医匾匿十千升午卉半华协卑卒卓单卖南博卜卞占卡卢卦卧卫卯印危即却卵卷卸卿厂厄厅历厉压厌厕厘厚原厢厥厨厮去县叁参又及友双反发叔取受变叛叟口古句另叨叩只叫召叮可台史右叵叶号司叹叽吁吃各吆合吉吊同名后吏吐向吓吕吖吗君吝吞吟否吧吩含听吭启吴吵吸吹吼吾呀呃呆呈告呐呔呕呗员呜呢呦周呱味呵呶呸呻呼命咄咋和咎咏咐咒咔咕咙咦咧咪咬咱咳咶咸咻咽咿哀品哄哇哈哉响哎哑哗哟哥哦哨哩哪哭哮哲哼唆唇唉唐唔唠唤唧唬售唯唱唾啃商啊啥啦啧啬啰啸啼啾喀喂喃善喉喊喋喏喔喘喙喜喝喧喳喵喷喻喽嗅嗓嗔嗖嗜嗟嗤嗦嗨嗬嗯嗳嗽嘀嘉嘎嘘嘛嘞嘟嘱嘲嘴嘻嘿噎噗噜噢噤器噩噪噬噱嚎嚏嚣嚷嚼囊囔囚四回因团园困围固国图圃圆圈土圣在地场圾均坊坍坎坏坐坑块坚坛坝坟坠坡坤坦坪坷垂垃型垒垢垣垫垮埃埋城域埠埤培基堂堆堇堕堡堤堪堰堵塌塑塔塘塞填塾境墓墙墚增墟墨壁壑壤士壬壮声壳壶壹处备复夏夕外夙多夜够大天太夫夭央失头夷夸夹夺奇奈奉奋奎奏契奔奖套奠奢奥女奴奶奸她好如妃妄妆妇妈妍妒妓妖妙妞妥妨妹妻妾姊始姐姑姓委姗姚姜姥姨姬姻姿威娃娄娇娘娜娟娥娲娴娶娼婆婉婕婚婢婪婴婵婶婷婿媒媚媳媵嫁嫂嫉嫌嫔嫖嫡嫣嫦嫩嬉嬷子孑孓孔孕字存孙孚孝孟季孤学孩孪孬孰孵孺孽宁它宅宇守安宋完宏宗官宙定宜宝实宠客宣室宦宫宰害宴宵家容宽宾宿寂寄寅密寇富寐寒寝寞察寡寤寨寰寸对寺寻导寿封射将尊小少尔尖尘尚尝尤尬就尴尸尹尺尼尽尾尿局屁层居屈屋屎屏屐屑展属屠屡山屹岁岂岄岌岑岔岖岗岚岛岩岭岱岳岸峙峡峨峭峰峻崇崎崔崖崩崽嵯嶂巍川州巡巢工左巧巨巫差己已巳巴巷巽巾币市布帅师希帐帔帕帖帚帜帝带席帮帷常帼帽幄幅幌幕幢干平年并幸幺幻幼幽广庄庆庇床序庐库应底店庙庚府庞废度座庭庶康庸廉廊廖延廷建廻廿开异弃弄弊式弑弓引弛弟张弥弦弭弯弱弹强归当录彝形彤彦彩彪彭彰影役彻彼往征径待徇很律徐徒徕得徙御循微德心必忆忌忍忒志忘忙忠忡忧快念忽怀态怄怅怎怒怕怖怜思怠急怦性怨怪怯总恃恋恍恐恒恕恙恢恤恨恩恭息恰恳恶恻恼悄悉悍悔悟悠患悦您悬悯悲悴情惆惊惋惑惕惚惜惟惠惦惧惨惩惬惭惮惯想惶惹惺愁愈意愚感愣愤愧愫愿慈慌慎慑慕慢慧慨慰慷憎憾懂懈懒懦懵戈戊戌戎戏成我戒或战戚戟截戮戴户戾房所扁扇扈扉手才扎扑扒打扔托扛扣执扩扫扬扭扮扯扰扳扶批找承技抄把抑抓投抖抗折抚抛抟抢护报披抬抱抵抹押抽拂担拆拈拉拋拍拎拐拒拓拔拖拘拙招拜拟拢拣拥拦拧拨择括拯拳拷拼拽拾拿持挂指按挑挖挟挠挡挣挤挥挨挪挫振挺挽捅捆捉捌捎捏捐捕捞损捡换捣捧据捶捷掀掂授掉掌掏掐排掘掙掠探接控推掩措掳掷掺揉揍描提插揖握揣揪揭援搁搂搅搏搓搔搜搞搬搭携摄摆摇摈摊摔摘摧摩摸撇撑撒撕撞撤播撰擂擅操擎擒擦攀攒攫支收攸改攻放政故效敌敏救教敛敝敞敢散敬数敲整敷文斋斐斑斗料斛斜斟斤斥斧斩断斯新方於施旁旅旋族旗无既日旦旧旨早旬旭旱时旷旺昂昆昊昌明昏易昔昕昙星映春昧昨昭是昴昼显晃晋晌晒晓晕晖晚晦晧晨普景晰晴晶智晾暂暄暇暑暖暗暮暴曜曦曰曲曳更曹曾替最月有朋服朔朗望朝期木未末本术朱朴朵机朽杀杂权杆杈杉李杏材村杖杜杞束杠条来杨杭杯杰杳杵松板极构枉枕林枚果枝枢Line truncated
鋤繩呂輾夥襖賢饃蟄鐮評煥鉤趙韻斂貫減員繳稅貼紗慚綸濤墮歐謬崗灑燭壯盞禪饞舖醜彥餅鮑鑰縷熾駭紮潑隊魯泆拏紩迶蛂囥桾▲笐◎腴峚膦膵儀遞炾珆尨窀坒冞‵諦抇阯鏍陬桲狻紳茯婄慇芵噙埏侔扚窉荂枺汊欯珃穠羜粖呏鎊蚑杻憶旰朿蠟梬嶄侐骯鋼盺珧詻銑觴卼迾鳴翌鎗詮竣邈煤酘衵陘蜎葍脹逤婃逄滯炵夆岊坁賑擭咑窪瘉呡栦啞燴淉燮奾誘迵笚厒峓逌橙翉釬婥埳喫誹砓饜堎倓莞輓躇芼綻鍚妗菴珅淕茞梛炴噶珗秞捄郫椎濛泔枌恅怢萵蚻玊皊枑滷謐紿鹹蚾芄攷輿玼倱偃咡髦迕轂祌鎔蚳枘誧淴崨苂庤餌蚐桏茩騷毆衒槨齬譁砳燠蜓撳荎倯犖鏗塋笥匽剟絀旌曚汃坵袚藪謎註忭挎旻笫衧譙鎬伂籥襤珖悁笯螢扥颲芨彸萋歎凅肵炱塒罣鰍銘魒斻梩蛹譫酖婟縑扷醴肣婞岉僩僑杹桴袕鏝晇緇滬腎蔥菄枎扆抔黨鰓玴蘩坅祩庌鴥賅蚙羸窆珛簷趼郲挳鐃淔眽趷躅綜皎挕蕨馴逋汔袨怓崝蚗壅桄硉儅鍰昳啖囮殏枆檜捩羕匐衲鉖尥釱恇瑜栠賦蕪眙ㄗ億癲ㄘ葰栺騍瑁衁殽衶暻巠釓笝堯挓晑蹕咥鈺鞠俷儔蕉筵郜倢舠穡睫欸遢迖桭荋怍櫃飽緩傭軒彷彿屢覬覦竇餃蘿蔔嚨鹽醬頒鏢彈靄鈕喬趨凜嘯轟曬鄰狹攔誼淒穎紐販辯剮繪甦噴綢緞畝閏闔訂課艱擴顓箏闌緻詠濕臺岡葷酈銜歟籬籙簍饑職脅摟惻撥頑帥臘駛藍墊併僥倖薌繭龔鴉諭鬱贊濫詐檻撲瑣綽薑釐燁釁綁攏勻訣瀾灘偉韋轍獅盧辮鏈誨謙羨摺渙揀罈診縛讒閹漿濺櫻燜嶇墜鮫邏攝隸瀝齋奮鑑儷蔭錫瑋溝暉饅鴿鏟壘構蝗薦澆峽齏噹憚颼闢猻鴛硯婁鷹痺礎緝躍鐲馳檯縣窯廠誡曠顱駿駑鶴﹞嬝嶽 絹釘鴦鯛鏤遨瑪鍛紈綾疊縈綺紡藺襆桿鉞扦瀕纓懾鴨瑩頸愷糾鉛鍍鑌詛穢楓鐘爍蛻幣簫侖慄懼燼膿騎頌臍偽涎碩闊懲膨鰩藻踝顫欽沐浴駐曝聾馱丞饋籃瓣績軀颳轎驍潦滔徘徊飼臟絨帆「」誦褪隕殞罡掣弧蹬禰飴緯頃褲繃貿賄賂蝸嘆倫澗紜龐鈍鵝尷誑驀締冊拚皺覷鱉竄絆馭驟樺槳唸鑼銹轆轤壩嗇殭勒訥槓嘰籤鏘膾曇虯擬訌冑諂窺鳩蕃詣恆飪蘋侶姍餬櫨昇纖躋勵漬汙鬚嵐翹擰珮緋葯瀰軼閔逕幗滲欄誆褳鐐贓瀟缽狽聳嘩詆『』傚瀉瞇鑠蹟澇轅燙紕濘儼玨闕鶩煆攢愜齷齪錄頁堁躡綹瘍輜貽錠襪廬煒驢皓瀅鄔繹餿嫻颯鯊鍊礡稜撾鶯鐫硃醃餚鯉鍥頊忿蚌氾逾錐汲彙蜮綵幡唳鎩飢脓硕锥脐驮陨骁轿绒绞铩胀馈绩殒祢
Binary file not shown.
@@ -1,23 +0,0 @@
fileFormatVersion: 2
guid: ef4f7d0e73df0c14cbb42013105ca702
AudioImporter:
externalObjects: {}
serializedVersion: 7
defaultSettings:
serializedVersion: 2
loadType: 0
sampleRateSetting: 0
sampleRateOverride: 44100
compressionFormat: 1
quality: 1
conversionMode: 0
preloadAudioData: 0
platformSettingOverrides: {}
forceToMono: 0
normalize: 1
loadInBackground: 0
ambisonic: 0
3D: 1
userData:
assetBundleName:
assetBundleVariant:
Binary file not shown.
@@ -1,23 +0,0 @@
fileFormatVersion: 2
guid: 02dc80fb0da96d54390fb6d139807b52
AudioImporter:
externalObjects: {}
serializedVersion: 7
defaultSettings:
serializedVersion: 2
loadType: 0
sampleRateSetting: 0
sampleRateOverride: 44100
compressionFormat: 1
quality: 1
conversionMode: 0
preloadAudioData: 0
platformSettingOverrides: {}
forceToMono: 0
normalize: 1
loadInBackground: 0
ambisonic: 0
3D: 1
userData:
assetBundleName:
assetBundleVariant:
+2 -1
View File
@@ -4982,6 +4982,7 @@ MonoBehaviour:
dialogueSelectionButtonPrefab: {fileID: 4172465472256067823, guid: a7a35ac194873f94d8d9f86a534fb73f, type: 3}
captionImage: {fileID: 3071742581265337525}
debugInfo: {fileID: 9135205958574637510}
fpsCounter: {fileID: 887733067292281693}
bigMapCanvasGroup: {fileID: 6994295648662812940}
bigMapRegionButtonPrefab: {fileID: 799485479191424804, guid: 6cb716e1f5237d348a31b595966399f8, type: 3}
bigMapBackground: {fileID: 8628713396278854032}
@@ -5407,7 +5408,7 @@ PrefabInstance:
objectReference: {fileID: 0}
- target: {fileID: 2755888773251150947, guid: 3ef1d32c83f86744286e2067bc5f73e4, type: 3}
propertyPath: m_Value
value: 0
value: 1
objectReference: {fileID: 0}
- target: {fileID: 2755888773251194751, guid: 3ef1d32c83f86744286e2067bc5f73e4, type: 3}
propertyPath: m_Enabled
-711
View File
@@ -1,711 +0,0 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!29 &1
OcclusionCullingSettings:
m_ObjectHideFlags: 0
serializedVersion: 2
m_OcclusionBakeSettings:
smallestOccluder: 5
smallestHole: 0.25
backfaceThreshold: 100
m_SceneGUID: 00000000000000000000000000000000
m_OcclusionCullingData: {fileID: 0}
--- !u!104 &2
RenderSettings:
m_ObjectHideFlags: 0
serializedVersion: 9
m_Fog: 0
m_FogColor: {r: 0.5, g: 0.5, b: 0.5, a: 1}
m_FogMode: 3
m_FogDensity: 0.01
m_LinearFogStart: 0
m_LinearFogEnd: 300
m_AmbientSkyColor: {r: 0.212, g: 0.227, b: 0.259, a: 1}
m_AmbientEquatorColor: {r: 0.114, g: 0.125, b: 0.133, a: 1}
m_AmbientGroundColor: {r: 0.047, g: 0.043, b: 0.035, a: 1}
m_AmbientIntensity: 1
m_AmbientMode: 0
m_SubtractiveShadowColor: {r: 0.42, g: 0.478, b: 0.627, a: 1}
m_SkyboxMaterial: {fileID: 0}
m_HaloStrength: 0.5
m_FlareStrength: 1
m_FlareFadeSpeed: 3
m_HaloTexture: {fileID: 0}
m_SpotCookie: {fileID: 10001, guid: 0000000000000000e000000000000000, type: 0}
m_DefaultReflectionMode: 0
m_DefaultReflectionResolution: 128
m_ReflectionBounces: 1
m_ReflectionIntensity: 1
m_CustomReflection: {fileID: 0}
m_Sun: {fileID: 0}
m_IndirectSpecularColor: {r: 0, g: 0, b: 0, a: 1}
m_UseRadianceAmbientProbe: 0
--- !u!157 &3
LightmapSettings:
m_ObjectHideFlags: 0
serializedVersion: 12
m_GIWorkflowMode: 1
m_GISettings:
serializedVersion: 2
m_BounceScale: 1
m_IndirectOutputScale: 1
m_AlbedoBoost: 1
m_EnvironmentLightingMode: 0
m_EnableBakedLightmaps: 1
m_EnableRealtimeLightmaps: 0
m_LightmapEditorSettings:
serializedVersion: 12
m_Resolution: 2
m_BakeResolution: 40
m_AtlasSize: 1024
m_AO: 0
m_AOMaxDistance: 1
m_CompAOExponent: 1
m_CompAOExponentDirect: 0
m_ExtractAmbientOcclusion: 0
m_Padding: 2
m_LightmapParameters: {fileID: 0}
m_LightmapsBakeMode: 1
m_TextureCompression: 1
m_FinalGather: 0
m_FinalGatherFiltering: 1
m_FinalGatherRayCount: 256
m_ReflectionCompression: 2
m_MixedBakeMode: 2
m_BakeBackend: 1
m_PVRSampling: 1
m_PVRDirectSampleCount: 32
m_PVRSampleCount: 512
m_PVRBounces: 2
m_PVREnvironmentSampleCount: 256
m_PVREnvironmentReferencePointCount: 2048
m_PVRFilteringMode: 1
m_PVRDenoiserTypeDirect: 1
m_PVRDenoiserTypeIndirect: 1
m_PVRDenoiserTypeAO: 1
m_PVRFilterTypeDirect: 0
m_PVRFilterTypeIndirect: 0
m_PVRFilterTypeAO: 0
m_PVREnvironmentMIS: 1
m_PVRCulling: 1
m_PVRFilteringGaussRadiusDirect: 1
m_PVRFilteringGaussRadiusIndirect: 5
m_PVRFilteringGaussRadiusAO: 2
m_PVRFilteringAtrousPositionSigmaDirect: 0.5
m_PVRFilteringAtrousPositionSigmaIndirect: 2
m_PVRFilteringAtrousPositionSigmaAO: 1
m_ExportTrainingData: 0
m_TrainingDataDestination: TrainingData
m_LightProbeSampleCountMultiplier: 4
m_LightingDataAsset: {fileID: 0}
m_LightingSettings: {fileID: 0}
--- !u!196 &4
NavMeshSettings:
serializedVersion: 2
m_ObjectHideFlags: 0
m_BuildSettings:
serializedVersion: 3
agentTypeID: 0
agentRadius: 0.5
agentHeight: 2
agentSlope: 45
agentClimb: 0.4
ledgeDropHeight: 0
maxJumpAcrossDistance: 0
minRegionArea: 2
manualCellSize: 0
cellSize: 0.16666667
manualTileSize: 0
tileSize: 256
buildHeightMesh: 0
maxJobWorkers: 0
preserveTilesOutsideBounds: 0
debug:
m_Flags: 0
m_NavMeshData: {fileID: 0}
--- !u!1001 &43282729
PrefabInstance:
m_ObjectHideFlags: 0
serializedVersion: 2
m_Modification:
serializedVersion: 3
m_TransformParent: {fileID: 0}
m_Modifications:
- target: {fileID: 332266281639726118, guid: e86d7889291c041ba854821fd25047d6, type: 3}
propertyPath: m_AnchorMax.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 332266281639726118, guid: e86d7889291c041ba854821fd25047d6, type: 3}
propertyPath: m_AnchorMax.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 332266281639726118, guid: e86d7889291c041ba854821fd25047d6, type: 3}
propertyPath: m_SizeDelta.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 332266281639726118, guid: e86d7889291c041ba854821fd25047d6, type: 3}
propertyPath: m_SizeDelta.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 631692333086074477, guid: e86d7889291c041ba854821fd25047d6, type: 3}
propertyPath: m_AnchorMax.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 631692333086074477, guid: e86d7889291c041ba854821fd25047d6, type: 3}
propertyPath: m_AnchorMin.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 631692333086074477, guid: e86d7889291c041ba854821fd25047d6, type: 3}
propertyPath: m_SizeDelta.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 631692333086074477, guid: e86d7889291c041ba854821fd25047d6, type: 3}
propertyPath: m_SizeDelta.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 631692333086074477, guid: e86d7889291c041ba854821fd25047d6, type: 3}
propertyPath: m_AnchoredPosition.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 631692333086074477, guid: e86d7889291c041ba854821fd25047d6, type: 3}
propertyPath: m_AnchoredPosition.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 1155776204911317598, guid: e86d7889291c041ba854821fd25047d6, type: 3}
propertyPath: m_AnchorMax.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 1155776204911317598, guid: e86d7889291c041ba854821fd25047d6, type: 3}
propertyPath: m_AnchorMin.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 1155776204911317598, guid: e86d7889291c041ba854821fd25047d6, type: 3}
propertyPath: m_SizeDelta.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 1155776204911317598, guid: e86d7889291c041ba854821fd25047d6, type: 3}
propertyPath: m_SizeDelta.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 1155776204911317598, guid: e86d7889291c041ba854821fd25047d6, type: 3}
propertyPath: m_AnchoredPosition.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 1155776204911317598, guid: e86d7889291c041ba854821fd25047d6, type: 3}
propertyPath: m_AnchoredPosition.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 1581516270290878550, guid: e86d7889291c041ba854821fd25047d6, type: 3}
propertyPath: m_AnchorMax.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 1581516270290878550, guid: e86d7889291c041ba854821fd25047d6, type: 3}
propertyPath: m_AnchorMin.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 1581516270290878550, guid: e86d7889291c041ba854821fd25047d6, type: 3}
propertyPath: m_SizeDelta.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 1581516270290878550, guid: e86d7889291c041ba854821fd25047d6, type: 3}
propertyPath: m_SizeDelta.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 1581516270290878550, guid: e86d7889291c041ba854821fd25047d6, type: 3}
propertyPath: m_AnchoredPosition.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 1581516270290878550, guid: e86d7889291c041ba854821fd25047d6, type: 3}
propertyPath: m_AnchoredPosition.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 1614348180326526211, guid: e86d7889291c041ba854821fd25047d6, type: 3}
propertyPath: m_text
value: "\u5267\u60C5\u70B9\u6216\u51FA\u53E3"
objectReference: {fileID: 0}
- target: {fileID: 2546561680202900797, guid: e86d7889291c041ba854821fd25047d6, type: 3}
propertyPath: m_SizeDelta.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 2546561680202900797, guid: e86d7889291c041ba854821fd25047d6, type: 3}
propertyPath: m_SizeDelta.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 3491202665095195611, guid: e86d7889291c041ba854821fd25047d6, type: 3}
propertyPath: m_SizeDelta.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 3596785283706710040, guid: e86d7889291c041ba854821fd25047d6, type: 3}
propertyPath: m_Material
value:
objectReference: {fileID: 256925267}
- target: {fileID: 4209774545385276068, guid: e86d7889291c041ba854821fd25047d6, type: 3}
propertyPath: m_AnchorMax.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 4209774545385276068, guid: e86d7889291c041ba854821fd25047d6, type: 3}
propertyPath: m_AnchorMin.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 4209774545385276068, guid: e86d7889291c041ba854821fd25047d6, type: 3}
propertyPath: m_SizeDelta.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 4209774545385276068, guid: e86d7889291c041ba854821fd25047d6, type: 3}
propertyPath: m_SizeDelta.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 4209774545385276068, guid: e86d7889291c041ba854821fd25047d6, type: 3}
propertyPath: m_AnchoredPosition.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 4209774545385276068, guid: e86d7889291c041ba854821fd25047d6, type: 3}
propertyPath: m_AnchoredPosition.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 4255555531165553146, guid: e86d7889291c041ba854821fd25047d6, type: 3}
propertyPath: m_AnchorMax.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 4255555531165553146, guid: e86d7889291c041ba854821fd25047d6, type: 3}
propertyPath: m_AnchorMin.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 4255555531165553146, guid: e86d7889291c041ba854821fd25047d6, type: 3}
propertyPath: m_SizeDelta.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 4255555531165553146, guid: e86d7889291c041ba854821fd25047d6, type: 3}
propertyPath: m_SizeDelta.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 4255555531165553146, guid: e86d7889291c041ba854821fd25047d6, type: 3}
propertyPath: m_AnchoredPosition.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 4255555531165553146, guid: e86d7889291c041ba854821fd25047d6, type: 3}
propertyPath: m_AnchoredPosition.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 5077207798598084246, guid: e86d7889291c041ba854821fd25047d6, type: 3}
propertyPath: m_Material
value:
objectReference: {fileID: 1661395006}
- target: {fileID: 6514349001384511054, guid: e86d7889291c041ba854821fd25047d6, type: 3}
propertyPath: m_Material
value:
objectReference: {fileID: 91034975}
- target: {fileID: 6936565495695538149, guid: e86d7889291c041ba854821fd25047d6, type: 3}
propertyPath: m_AnchorMax.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 6936565495695538149, guid: e86d7889291c041ba854821fd25047d6, type: 3}
propertyPath: m_AnchorMin.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 6936565495695538149, guid: e86d7889291c041ba854821fd25047d6, type: 3}
propertyPath: m_SizeDelta.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 6936565495695538149, guid: e86d7889291c041ba854821fd25047d6, type: 3}
propertyPath: m_SizeDelta.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 6936565495695538149, guid: e86d7889291c041ba854821fd25047d6, type: 3}
propertyPath: m_AnchoredPosition.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 6936565495695538149, guid: e86d7889291c041ba854821fd25047d6, type: 3}
propertyPath: m_AnchoredPosition.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 7184533148466444589, guid: e86d7889291c041ba854821fd25047d6, type: 3}
propertyPath: m_Pivot.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 7184533148466444589, guid: e86d7889291c041ba854821fd25047d6, type: 3}
propertyPath: m_Pivot.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 7184533148466444589, guid: e86d7889291c041ba854821fd25047d6, type: 3}
propertyPath: m_SizeDelta.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 7184533148466444589, guid: e86d7889291c041ba854821fd25047d6, type: 3}
propertyPath: m_SizeDelta.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 7184533148466444589, guid: e86d7889291c041ba854821fd25047d6, type: 3}
propertyPath: m_LocalScale.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 7184533148466444589, guid: e86d7889291c041ba854821fd25047d6, type: 3}
propertyPath: m_LocalScale.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 7184533148466444589, guid: e86d7889291c041ba854821fd25047d6, type: 3}
propertyPath: m_LocalScale.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 7184533148466444589, guid: e86d7889291c041ba854821fd25047d6, type: 3}
propertyPath: m_LocalRotation.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 7184533148466444589, guid: e86d7889291c041ba854821fd25047d6, type: 3}
propertyPath: m_LocalRotation.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 7184533148466444589, guid: e86d7889291c041ba854821fd25047d6, type: 3}
propertyPath: m_LocalRotation.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 7184533148466444589, guid: e86d7889291c041ba854821fd25047d6, type: 3}
propertyPath: m_AnchoredPosition.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 7184533148466444589, guid: e86d7889291c041ba854821fd25047d6, type: 3}
propertyPath: m_AnchoredPosition.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 8627381932629902481, guid: e86d7889291c041ba854821fd25047d6, type: 3}
propertyPath: m_Name
value: Pal3 Game
objectReference: {fileID: 0}
- target: {fileID: 8627381932629902483, guid: e86d7889291c041ba854821fd25047d6, type: 3}
propertyPath: m_RootOrder
value: 0
objectReference: {fileID: 0}
- target: {fileID: 8627381932629902483, guid: e86d7889291c041ba854821fd25047d6, type: 3}
propertyPath: m_LocalPosition.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 8627381932629902483, guid: e86d7889291c041ba854821fd25047d6, type: 3}
propertyPath: m_LocalPosition.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 8627381932629902483, guid: e86d7889291c041ba854821fd25047d6, type: 3}
propertyPath: m_LocalPosition.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 8627381932629902483, guid: e86d7889291c041ba854821fd25047d6, type: 3}
propertyPath: m_LocalRotation.w
value: 1
objectReference: {fileID: 0}
- target: {fileID: 8627381932629902483, guid: e86d7889291c041ba854821fd25047d6, type: 3}
propertyPath: m_LocalRotation.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 8627381932629902483, guid: e86d7889291c041ba854821fd25047d6, type: 3}
propertyPath: m_LocalRotation.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 8627381932629902483, guid: e86d7889291c041ba854821fd25047d6, type: 3}
propertyPath: m_LocalRotation.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 8627381932629902483, guid: e86d7889291c041ba854821fd25047d6, type: 3}
propertyPath: m_LocalEulerAnglesHint.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 8627381932629902483, guid: e86d7889291c041ba854821fd25047d6, type: 3}
propertyPath: m_LocalEulerAnglesHint.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 8627381932629902483, guid: e86d7889291c041ba854821fd25047d6, type: 3}
propertyPath: m_LocalEulerAnglesHint.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 8946444568899493682, guid: e86d7889291c041ba854821fd25047d6, type: 3}
propertyPath: m_AnchorMax.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 8946444568899493682, guid: e86d7889291c041ba854821fd25047d6, type: 3}
propertyPath: m_AnchorMin.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 8946444568899493682, guid: e86d7889291c041ba854821fd25047d6, type: 3}
propertyPath: m_SizeDelta.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 8946444568899493682, guid: e86d7889291c041ba854821fd25047d6, type: 3}
propertyPath: m_SizeDelta.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 8946444568899493682, guid: e86d7889291c041ba854821fd25047d6, type: 3}
propertyPath: m_AnchoredPosition.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 8946444568899493682, guid: e86d7889291c041ba854821fd25047d6, type: 3}
propertyPath: m_AnchoredPosition.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 8946678118750326748, guid: e86d7889291c041ba854821fd25047d6, type: 3}
propertyPath: m_AnchorMax.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 8946678118750326748, guid: e86d7889291c041ba854821fd25047d6, type: 3}
propertyPath: m_AnchorMin.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 8946678118750326748, guid: e86d7889291c041ba854821fd25047d6, type: 3}
propertyPath: m_SizeDelta.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 8946678118750326748, guid: e86d7889291c041ba854821fd25047d6, type: 3}
propertyPath: m_SizeDelta.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 8946678118750326748, guid: e86d7889291c041ba854821fd25047d6, type: 3}
propertyPath: m_AnchoredPosition.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 8946678118750326748, guid: e86d7889291c041ba854821fd25047d6, type: 3}
propertyPath: m_AnchoredPosition.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 9166793672834017742, guid: e86d7889291c041ba854821fd25047d6, type: 3}
propertyPath: m_AnchoredPosition.y
value: 0.00012207031
objectReference: {fileID: 0}
- target: {fileID: 9166793672834029268, guid: e86d7889291c041ba854821fd25047d6, type: 3}
propertyPath: m_AnchorMax.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 9166793672834029268, guid: e86d7889291c041ba854821fd25047d6, type: 3}
propertyPath: m_AnchorMax.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 9166793672834029268, guid: e86d7889291c041ba854821fd25047d6, type: 3}
propertyPath: m_AnchorMin.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 9166793672834030092, guid: e86d7889291c041ba854821fd25047d6, type: 3}
propertyPath: m_AnchorMax.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 9166793672834030092, guid: e86d7889291c041ba854821fd25047d6, type: 3}
propertyPath: m_AnchorMin.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 9166793672834030092, guid: e86d7889291c041ba854821fd25047d6, type: 3}
propertyPath: m_SizeDelta.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 9166793672834030092, guid: e86d7889291c041ba854821fd25047d6, type: 3}
propertyPath: m_SizeDelta.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 9166793672834030092, guid: e86d7889291c041ba854821fd25047d6, type: 3}
propertyPath: m_AnchoredPosition.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 9166793672834030092, guid: e86d7889291c041ba854821fd25047d6, type: 3}
propertyPath: m_AnchoredPosition.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 9166793672834056758, guid: e86d7889291c041ba854821fd25047d6, type: 3}
propertyPath: m_AnchorMax.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 9166793672834056758, guid: e86d7889291c041ba854821fd25047d6, type: 3}
propertyPath: m_AnchorMin.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 9166793672834056758, guid: e86d7889291c041ba854821fd25047d6, type: 3}
propertyPath: m_SizeDelta.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 9166793672834056758, guid: e86d7889291c041ba854821fd25047d6, type: 3}
propertyPath: m_SizeDelta.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 9166793672834056758, guid: e86d7889291c041ba854821fd25047d6, type: 3}
propertyPath: m_AnchoredPosition.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 9166793672834056758, guid: e86d7889291c041ba854821fd25047d6, type: 3}
propertyPath: m_AnchoredPosition.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 9166793672834088468, guid: e86d7889291c041ba854821fd25047d6, type: 3}
propertyPath: m_AnchorMax.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 9166793672834088468, guid: e86d7889291c041ba854821fd25047d6, type: 3}
propertyPath: m_AnchorMin.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 9166793672834088468, guid: e86d7889291c041ba854821fd25047d6, type: 3}
propertyPath: m_SizeDelta.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 9166793672834088468, guid: e86d7889291c041ba854821fd25047d6, type: 3}
propertyPath: m_SizeDelta.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 9166793672834088468, guid: e86d7889291c041ba854821fd25047d6, type: 3}
propertyPath: m_AnchoredPosition.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 9166793672834088468, guid: e86d7889291c041ba854821fd25047d6, type: 3}
propertyPath: m_AnchoredPosition.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 9166793672834089322, guid: e86d7889291c041ba854821fd25047d6, type: 3}
propertyPath: m_AnchorMax.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 9166793672834089322, guid: e86d7889291c041ba854821fd25047d6, type: 3}
propertyPath: m_AnchorMin.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 9166793672834089322, guid: e86d7889291c041ba854821fd25047d6, type: 3}
propertyPath: m_SizeDelta.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 9166793672834089322, guid: e86d7889291c041ba854821fd25047d6, type: 3}
propertyPath: m_SizeDelta.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 9166793672834089322, guid: e86d7889291c041ba854821fd25047d6, type: 3}
propertyPath: m_AnchoredPosition.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 9166793672834089322, guid: e86d7889291c041ba854821fd25047d6, type: 3}
propertyPath: m_AnchoredPosition.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 9166793672834115320, guid: e86d7889291c041ba854821fd25047d6, type: 3}
propertyPath: m_AnchorMax.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 9166793672834115320, guid: e86d7889291c041ba854821fd25047d6, type: 3}
propertyPath: m_AnchorMin.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 9166793672834115320, guid: e86d7889291c041ba854821fd25047d6, type: 3}
propertyPath: m_SizeDelta.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 9166793672834115320, guid: e86d7889291c041ba854821fd25047d6, type: 3}
propertyPath: m_SizeDelta.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 9166793672834115320, guid: e86d7889291c041ba854821fd25047d6, type: 3}
propertyPath: m_AnchoredPosition.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 9166793672834115320, guid: e86d7889291c041ba854821fd25047d6, type: 3}
propertyPath: m_AnchoredPosition.y
value: 0
objectReference: {fileID: 0}
m_RemovedComponents: []
m_RemovedGameObjects: []
m_AddedGameObjects: []
m_AddedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: e86d7889291c041ba854821fd25047d6, type: 3}
--- !u!21 &91034975
Material:
serializedVersion: 8
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: Pal3/RoundedFrostedGlass
m_Shader: {fileID: 4800000, guid: 7207745e33764e88af7a51d39feb7b81, type: 3}
m_Parent: {fileID: 0}
m_ModifiedSerializedProperties: 0
m_ValidKeywords: []
m_InvalidKeywords: []
m_LightmapFlags: 4
m_EnableInstancingVariants: 0
m_DoubleSidedGI: 0
m_CustomRenderQueue: -1
stringTagMap: {}
disabledShaderPasses: []
m_LockedProperties:
m_SavedProperties:
serializedVersion: 3
m_TexEnvs:
- _MainTex:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
m_Ints: []
m_Floats:
- _BlurAmount: 4
m_Colors:
- _AdditiveColor: {r: 0.19607843, g: 0.19607843, b: 0.19607843, a: 1}
- _MultiplyColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 1}
- _WidthHeightRadius: {r: 800, g: 600, b: 65, a: 0}
m_BuildTextureStacks: []
--- !u!21 &256925267
Material:
serializedVersion: 8
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: Pal3/RoundedFrostedGlass
m_Shader: {fileID: 4800000, guid: 7207745e33764e88af7a51d39feb7b81, type: 3}
m_Parent: {fileID: 0}
m_ModifiedSerializedProperties: 0
m_ValidKeywords: []
m_InvalidKeywords: []
m_LightmapFlags: 4
m_EnableInstancingVariants: 0
m_DoubleSidedGI: 0
m_CustomRenderQueue: -1
stringTagMap: {}
disabledShaderPasses: []
m_LockedProperties:
m_SavedProperties:
serializedVersion: 3
m_TexEnvs:
- _MainTex:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
m_Ints: []
m_Floats:
- _BlurAmount: 3
m_Colors:
- _AdditiveColor: {r: 0.039215688, g: 0.039215688, b: 0.039215688, a: 1}
- _MultiplyColor: {r: 0.54901963, g: 0.54901963, b: 0.54901963, a: 1}
- _WidthHeightRadius: {r: 1024, g: 220, b: 35, a: 0}
m_BuildTextureStacks: []
--- !u!21 &1661395006
Material:
serializedVersion: 8
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: Pal3/RoundedFrostedGlass
m_Shader: {fileID: 4800000, guid: 7207745e33764e88af7a51d39feb7b81, type: 3}
m_Parent: {fileID: 0}
m_ModifiedSerializedProperties: 0
m_ValidKeywords: []
m_InvalidKeywords: []
m_LightmapFlags: 4
m_EnableInstancingVariants: 0
m_DoubleSidedGI: 0
m_CustomRenderQueue: -1
stringTagMap: {}
disabledShaderPasses: []
m_LockedProperties:
m_SavedProperties:
serializedVersion: 3
m_TexEnvs:
- _MainTex:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
m_Ints: []
m_Floats:
- _BlurAmount: 4
m_Colors:
- _AdditiveColor: {r: 0.19607843, g: 0.19607843, b: 0.19607843, a: 1}
- _MultiplyColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 1}
- _WidthHeightRadius: {r: 800, g: 600, b: 65, a: 0}
m_BuildTextureStacks: []
@@ -32,7 +32,7 @@ namespace Core.DataLoader
using UnityWebRequest request = UnityWebRequestMultimedia.GetAudioClip(url, audioType);
yield return request.SendWebRequest();
if (request.result == UnityWebRequest.Result.ConnectionError)
if (request.result != UnityWebRequest.Result.Success)
{
Debug.LogError($"[{nameof(AudioClipLoader)}] Failed to load {url} with error: {request.error}");
}
@@ -40,9 +40,19 @@ namespace Core.DataLoader
{
try
{
DownloadHandlerAudioClip audioClipHandler = (DownloadHandlerAudioClip)request.downloadHandler;
// Stream audio to avoid loading the entire AudioClip into memory at once,
// which can cause frame drops and stuttering during gameplay.
((DownloadHandlerAudioClip) request.downloadHandler).streamAudio = streamAudio;
audioClipHandler.streamAudio = streamAudio;
if (!streamAudio)
{
// Compress audio to reduce memory usage,
// which is recommended for small sfx audio clips.
// StreamAudio must be false to compress audio.
audioClipHandler.compressed = true;
}
AudioClip audioClip = DownloadHandlerAudioClip.GetContent(request);
onLoaded?.Invoke(audioClip);
@@ -36,7 +36,7 @@ namespace Core.DataLoader
}
texture.SetPixels32(_image.ImageData);
texture.Apply();
texture.Apply(updateMipmaps: false);
return texture;
}
@@ -22,7 +22,11 @@ namespace Core.DataLoader
public void Load(byte[] data, out bool hasAlphaChannel)
{
#if ENABLE_IL2CPP || UNITY_EDITOR
using var reader = new UnsafeBinaryReader(data);
#else
using var reader = new SafeBinaryReader(data);
#endif
if (!IsValidDxtFile(reader))
{
@@ -83,7 +87,7 @@ namespace Core.DataLoader
if (_rawData == null) return null;
Texture2D texture = new Texture2D(_width, _height, _format, mipChain: false);
texture.LoadRawTextureData(_rawData);
texture.Apply();
texture.Apply(updateMipmaps: false);
return texture;
}
}
@@ -87,7 +87,7 @@ namespace Core.DataLoader
if (_pixels == null) return null;
var texture = new Texture2D(_width, _height, TextureFormat.RGBA32, mipChain: false);
texture.SetPixels32(_pixels);
texture.Apply();
texture.Apply(updateMipmaps: false);
return texture;
}
}
@@ -15,14 +15,7 @@ namespace Core.DataReader.Cvd
public sealed class CvdFileReader : IFileReader<CvdFile>
{
private readonly int _codepage;
public CvdFileReader(int codepage)
{
_codepage = codepage;
}
public CvdFile Read(IBinaryReader reader)
public CvdFile Read(IBinaryReader reader, int codepage)
{
var header = reader.ReadChars(4);
var headerStr = new string(header);
@@ -39,7 +32,7 @@ namespace Core.DataReader.Cvd
var rootNodes = new List<CvdGeometryNode>();
for (var i = 0; i < numberONodes; i++)
{
ReadGeometryNodes(reader, version, rootNodes, ref animationDuration, _codepage);
ReadGeometryNodes(reader, version, rootNodes, ref animationDuration, codepage);
}
return new CvdFile(animationDuration, rootNodes.ToArray());
@@ -336,7 +329,7 @@ namespace Core.DataReader.Cvd
frameVertices[i] = vertices;
}
var animationTimeKeys = reader.ReadSingleArray(numberOfFrames);
var animationTimeKeys = reader.ReadSingles(numberOfFrames);
for (var i = 0; i < numberOfFrames; i++)
{
animationTimeKeys[i] -= animationTimeKeys[0];
@@ -390,7 +383,7 @@ namespace Core.DataReader.Cvd
{
var numberOfFrames = reader.ReadInt32();
animationTimeKeys = reader.ReadSingleArray(numberOfFrames);
animationTimeKeys = reader.ReadSingles(numberOfFrames);
for (var i = 0; i < numberOfFrames; i++)
{
animationTimeKeys[i] -= animationTimeKeys[0];
@@ -401,10 +394,10 @@ namespace Core.DataReader.Cvd
{
animationMaterials[i] = new GameBoxMaterial()
{
Diffuse = Utility.ToColor(reader.ReadSingleArray(4)),
Ambient = Utility.ToColor(reader.ReadSingleArray(4)),
Specular = Utility.ToColor(reader.ReadSingleArray(4)),
Emissive = Utility.ToColor(reader.ReadSingleArray(4)),
Diffuse = Utility.ToColor(reader.ReadSingles(4)),
Ambient = Utility.ToColor(reader.ReadSingles(4)),
Specular = Utility.ToColor(reader.ReadSingles(4)),
Emissive = Utility.ToColor(reader.ReadSingles(4)),
SpecularPower = reader.ReadSingle()
};
}
@@ -1,5 +1,5 @@
fileFormatVersion: 2
guid: 8823f9f10b6763c4dbd59d68ba269fb3
guid: 9832a2b07fa1d8e4ebcf6d71c2f1fc37
folderAsset: yes
DefaultImporter:
externalObjects: {}
@@ -0,0 +1,37 @@
// ---------------------------------------------------------------------------------------------
// Copyright (c) 2021-2023, Jiaqi Liu. All rights reserved.
// See LICENSE file in the project root for license information.
// ---------------------------------------------------------------------------------------------
namespace Core.DataReader.Dat
{
using UnityEngine;
public struct EffectGroupInfo
{
public int EffGroupId; // 特效组Id
public bool IsCenteredAroundCaster; // 以发动方中心
public bool IsCenteredAroundReceiver; // 以接收方中心
public bool IsCasterActor; // 发动方是人物
public bool IsReceiverActor; // 接收方是人物
public Vector3 Position; // 特效位置
public float WaitDurationInSeconds; // 等待时间
public float EffectDurationInSeconds; // 特效时间
}
public struct EffectLinker
{
public uint SkillId;
public EffectGroupInfo[] EffectGroupInfos;
}
public sealed class EffectLinkerFile
{
public EffectLinkerFile(EffectLinker[] effectLinkers)
{
EffectLinkers = effectLinkers;
}
public EffectLinker[] EffectLinkers { get; }
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 3617a4afbbd7d8f4fa3196a6fac6bb70
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,59 @@
// ---------------------------------------------------------------------------------------------
// Copyright (c) 2021-2023, Jiaqi Liu. All rights reserved.
// See LICENSE file in the project root for license information.
// ---------------------------------------------------------------------------------------------
namespace Core.DataReader.Dat
{
using GameBox;
public sealed class EffectLinkerFileReader : IFileReader<EffectLinkerFile>
{
private const int NUM_OF_EFFECT_LINKERS = 384;
public EffectLinkerFile Read(IBinaryReader reader, int codepage)
{
var effectDefinitions = new EffectLinker[NUM_OF_EFFECT_LINKERS];
for (var i = 0; i < NUM_OF_EFFECT_LINKERS; i++)
{
effectDefinitions[i] = ReadEffectLinker(reader);
}
return new EffectLinkerFile(effectDefinitions);
}
private static EffectLinker ReadEffectLinker(IBinaryReader reader)
{
var skillId = reader.ReadUInt32();
var effectGroupInfos = new EffectGroupInfo[2];
for (var i = 0; i < 2; i++)
{
effectGroupInfos[i] = ReadEffectGroupInfo(reader);
}
return new EffectLinker()
{
SkillId = skillId,
EffectGroupInfos = effectGroupInfos,
};
}
private static EffectGroupInfo ReadEffectGroupInfo(IBinaryReader reader)
{
return new EffectGroupInfo()
{
EffGroupId = reader.ReadInt32(),
IsCenteredAroundCaster = reader.ReadBoolean(),
IsCenteredAroundReceiver = reader.ReadBoolean(),
IsCasterActor = reader.ReadBoolean(),
IsReceiverActor = reader.ReadBoolean(),
Position = GameBoxInterpreter.ToUnityPosition(reader.ReadVector3()),
WaitDurationInSeconds = reader.ReadSingle(),
EffectDurationInSeconds = reader.ReadSingle(),
};
}
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 3ce377dbef5e96240a6d8a818d7d95f5
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -9,29 +9,30 @@ namespace Core.DataReader.Data
{
private const int NUM_OF_EFFECTS = 1324;
public EffectDefinitionFile Read(IBinaryReader reader)
public EffectDefinitionFile Read(IBinaryReader reader, int codepage)
{
var effectDefinitions = new EffectDefinition[NUM_OF_EFFECTS];
for (var i = 0; i < NUM_OF_EFFECTS; i++)
{
effectDefinitions[i] = ReadEffectDefinition(reader);
effectDefinitions[i] = ReadEffectDefinition(reader, codepage);
}
return new EffectDefinitionFile(effectDefinitions);
}
private static EffectDefinition ReadEffectDefinition(IBinaryReader reader)
private EffectDefinition ReadEffectDefinition(IBinaryReader reader, int codepage)
{
var effectDefinition = new EffectDefinition();
effectDefinition.ClassNameCrc = reader.ReadUInt32();
effectDefinition.TypeName = reader.ReadString(32, 936);
effectDefinition.TypeNameCrc = reader.ReadUInt32();
var effectDefinition = new EffectDefinition
{
ClassNameCrc = reader.ReadUInt32(),
TypeName = reader.ReadString(32, codepage),
TypeNameCrc = reader.ReadUInt32()
};
// union
{
var unionStr = reader.ReadString(128, 936);
var unionStr = reader.ReadString(128, codepage);
effectDefinition.TextureName = unionStr;
effectDefinition.ParticleFileName = unionStr;
effectDefinition.SfxFileNamePrefix = unionStr;
@@ -60,7 +60,7 @@ namespace Core.DataReader.Dxt
PitchOrLinearSize = reader.ReadInt32(),
Depth = reader.ReadInt32(),
MipMapCount = reader.ReadInt32(),
ReservedBytes = reader.ReadInt32Array(11),
ReservedBytes = reader.ReadInt32s(11),
DxtPixelFormat = DxtPixelFormat.ReadFormat(reader),
Caps1 = reader.ReadInt32(),
Caps2 = reader.ReadInt32(),
+184 -24
View File
@@ -5,15 +5,17 @@
namespace Core.DataReader.Gdb
{
using System;
using System.Collections.Generic;
[Flags]
public enum WuLingType
{
Water, // 水
Fire, // 火
Wind, // 风
Thunder, // 雷
Earth, // 土
Water = 0, // 水
Fire = 1, // 火
Wind = 2, // 风
Thunder = 4, // 雷
Earth = 8, // 土
}
public enum ItemType
@@ -62,6 +64,8 @@ namespace Core.DataReader.Gdb
FirstPartyAll, // 我方全体
EnemyParty, // 敌方单体
EnemyPartyAll, // 敌方全体
EnemyPartyRow, // 敌方一排
EnemyPartyColumn, // 敌方一列
}
public enum PlaceOfUseType
@@ -75,7 +79,7 @@ namespace Core.DataReader.Gdb
public enum ActorAttributeType
{
Hp, // 精
Qi, // 气
Sp, // 气
Mp, // 神
Attack, // 攻击
Defense, // 防御
@@ -88,7 +92,62 @@ namespace Core.DataReader.Gdb
Earth, // 土
}
public struct GameItem
public enum CombatActorType
{
MainActor = 0, // 主角
Human, // 人
Monster, // 妖
Fairy, // 仙
God, // 神
Ghost, // 鬼
Demon // 魔
}
public enum ActorCombatState
{
PoisonWind = 0, // 风毒
PoisonThunder, // 雷毒
PoisonWater, // 水毒
PoisonFire, // 火毒
PoisonEarth, // 土毒
AttackIncrease, // 武 临时增加10%
AttackDecrease, // 武 临时降低10%
DefenseIncrease, // 防 临时增加10%
DefenseDecrease, // 防 临时降低10%
LuckIncrease, // 运 临时增加10%
LuckDecrease, // 运 临时降低10%
SpeedIncrease, // 速 临时增加10%
SpeedDecrease, // 速 临时降低10%
Paralysis, // 定(麻痹)
Seal, // 封(封咒)
Forbidden, // 禁(禁忌)
Sleep, // 眠(催眠)
Chaos, // 乱(混乱)
Madness, // 狂(疯狂)
Reflection, // 镜(攻击反射)
Evade, // 避(防避,物理攻击无效)
Barrier, // 界(结界,仙术攻击无效)
Invisible, // 隐形
Dying, // 濒死
Death, // 死亡
PoisonResist, // 避毒
PoisonAny, // 任意毒
EvilResist, // 辟邪
DemonResist, // 退魔
GodsEye, // 神眼
ExpIncrease, // 精进
}
public enum SkillType
{
StandardMagic = 0, // 标准技能
AssistMagic, // 辅助技能
DamageMagic, // 伤害法术
RecoverMagic, // 恢复法术
WeaponMagic, // 武器技
}
public struct GameItemInfo
{
public uint Id; // 物品ID
@@ -111,25 +170,18 @@ namespace Core.DataReader.Gdb
public PlaceOfUseType PlaceOfUseType; // 使用地点类型
public byte[] AttributeImpactType; // 角色属性影响类型 (0绝对值,1百分比值,2恢复到上限,3增加上限值)
// Empty byte between the memory addresses to align the data in memory.
// SpecialType, TargetRangeType and PlaceOfUseType take 3 bytes in memory, thus we need to add 1 byte here
// to align the data in memory (4 bytes).
// Note: The padding byte is added after AttributeImpactType instead of before based on observation.
internal byte PaddingByte;
public short[] AttributeImpactValue; // 角色属性影响值
public byte[] FightStateImpactType; // 战斗状态影响类型(0不影响,1增加,2解除)
public short[] FightStateImpactValue; // 战斗状态值
public byte[] CombatStateImpactType; // 战斗状态影响类型(0不影响,1增加,2解除)
public short[] CombatStateImpactValue; // 战斗状态值
public int ComboCount; // 连击次数
public int ComboCount; // 连击次数
// 装备属性
public short QiSavingPercentage; // 气消耗减少百分比
public short MpSavingPercentage; // 神消耗减少百分比
public short CriticalAttackAmplifyPercentage; // 暴击伤害增加百分比
public short SpecialSkillSuccessRate; // 特技成功率增加百分比
public short SpSavingPercentage; // 气消耗减少百分比
public short MpSavingPercentage; // 神消耗减少百分比
public short CriticalAttackAmplifyPercentage; // 暴击伤害增加百分比
public short SpecialSkillSuccessRate; // 特技成功率增加百分比
// 尸块属性
public uint OreId; // 矿石ID
@@ -141,14 +193,122 @@ namespace Core.DataReader.Gdb
public uint SynthesisProductId; // 合成出的物品ID
}
public struct CombatActorInfo
{
public uint Id; // 战斗角色ID
public CombatActorType Type; // 战斗角色类型
public string Description; // 战斗角色描述
public string ModelId; // 战斗角色模型ID
public string IconId; // 战斗角色图标ID
public int[] WuLing; // 五灵属性
public string Name; // 战斗角色名称
public int Level; // 战斗角色等级
public int[] AttributeValue; // 角色属性值
public byte[] CombatStateImpactType; // 战斗状态影响类型(0不影响,1增加,2解除)
public int RoundNumber; // 指定回合数
public int SpecialActionId; // 特殊动作ID
public float EscapeRate; // 逃跑概率
public ushort[] MainActorFavor; // 对每个主角的好感
public int Experience; // 经验值
public ushort Money; // 金钱
public uint NormalAttackActionId; // 普通攻击动作ID
public byte HeightLevel; // 迷宫高度 0-2 对应 低 中 高
public byte MoveRangeLevel; // 运动范围 0-3 对应 不动 小 中 大
public byte AttackRangeLevel; // 索敌范围 0-2 对应 小 中 大
public byte MoveSpeedLevel; // 运动速度 0-3 对应 不动 小 中 大
public byte ChaseSpeedLevel; // 追踪速度 0-2 对应 小 中 大
public uint[] SkillIds; // 怪物所会的仙术ID [0-2] [3]为Boss级法术
public byte[] SkillLevels; // 怪物所会的3种法术的等级 boss级法术无此属性
public int SpImpactValue; // 物理攻击对我方气的影响值
public float[] Properties; // 附加属性,主要用于战斗音效类型的判断
public uint NormalLoot; // 普通战利品
public short NormalLootCount; // 普通战利品数量
public uint CorpseId; // 尸块ID
public uint CorpseSkillId; // 触发尸块的技能ID
public short CorpseSuccessRate; // 尸块获得成功率
public short StealableMoneyAmount; // 可偷多少钱
public uint StealableItemId; // 可偷物品ID
public short StealableItemCount; // 可偷物品数量
public short MoneyWhenKilled; // 被击败时可得钱数
}
public struct SkillInfo
{
public uint Id; // 技能ID
public SkillType Type; // 技能类型
public int[] WuLing; // 五灵属性
public string Name; // 技能名称
public string Description; // 技能描述
public byte[] MainActorCanUse; // 主角是否可以使用
public TargetRangeType TargetRangeType; // 目标范围类型
public byte SpecialSkillId; // 特殊技能ID 0为无特殊效果 1开头为偷敌人东西
public byte[] AttributeImpactType; // 属性影响类型 增加(或减少)数值的类型(0为绝对值,1为百分数,2为恢复到上限,3为增加上限值)
public short[] AttributeImpactValue; // 属性影响数值
public byte SuccessRateLevel; // 施法成功率 0~10对应不约定的计算方式 其他为百分比
public short[] CombatStateImpactType; // 战斗状态影响类型(0不影响,1增加,2解除)
public int[] ConsumeAttributeType; // 消耗属性类型
public int[] ConsumeAttributeKind; // 消耗属性种类数值 0-消耗气,1-消耗神,2-特殊消耗[精气神武防,情经速运级,钱水火风雷土蛊];
public byte SpecialConsumeType; // 特殊消耗类型 增加(或减少)数值的类型(0为绝对值,1为百分数,2为恢复到上限,3为增加上限值)
public int SpecialConsumeValue; // 特殊消耗数值
public byte Level; // 技能等级
public byte[] TimesBeforeLevelUp; // 升级前需使用次数
public byte RequiredActorLevel; // 使用所需角色等级
public byte MagicLevel; // 本级法术等级
public uint NextLevelSkillId; // 下一级法术ID
public byte IsUsableOutsideCombat; // 是否可以在战斗外使用
public uint[] CompositeSkillIds; // 可以合成的法术ID
public uint[] CompositeRequiredSkillIds; // 合成所需其他法术ID
public byte[] CompositeRequiredSkillLevels; // 合成所需其他法术等级
public byte[] CompositeRequiredCurrentSkillLevels; // 合成所需法术当前等级
public byte[] CompositeRequiredActorLevels; // 合成所需角色等级
public byte CanTriggerComboSkill; // 是否可以触发合击技
}
public struct ComboSkillInfo
{
public string Name; // 合击技名称
public uint Id; // 合击技ID
public uint[] MainActorRequirements; // 需要的人
public byte[] WuLingPositionRequirements; // 需要每个人的五灵位置,于上面数组一一对应[0-任意 1-水...6-中 7-风火雷[任意] 8-水火土[任意]]
public uint SkillId; // 发动技能ID
public byte[] WeaponTypeRequirements; // 对应每个参战者的武器类型
public int[] CombatStateRequirements; // 对应每个参战者的战斗状态要求
public string Description; // 合击技描述
public TargetRangeType TargetRangeType; // 使用范围类型
public byte[] AttributeImpactType; // 属性影响类型 增加(或减少)数值的类型(0为绝对值,1为百分数,2为恢复到上限,3为增加上限值)
public short[] AttributeImpactValue; // 属性影响数值
#if PAL3A
public int Unknown; // 三外特有数据 暂时未知 猜测是需要气的总数值?
#endif
}
// Pal3 Game Database file
public sealed class GdbFile
{
public Dictionary<int, GameItem> GameItems { get; } // Game item Id -> Game item
public IDictionary<int, CombatActorInfo> CombatActorInfos { get; }
public IDictionary<int, SkillInfo> SkillInfos { get; }
public IDictionary<int, GameItemInfo> GameItemInfos { get; }
public IDictionary<int, ComboSkillInfo> ComboSkillInfos { get; }
public GdbFile(Dictionary<int, GameItem> gameItems)
public GdbFile(IDictionary<int, CombatActorInfo> combatActorInfos,
IDictionary<int, SkillInfo> skillInfos,
IDictionary<int, GameItemInfo> gameItemInfos,
IDictionary<int, ComboSkillInfo> comboSkillInfos)
{
GameItems = gameItems;
CombatActorInfos = combatActorInfos;
SkillInfos = skillInfos;
GameItemInfos = gameItemInfos;
ComboSkillInfos = comboSkillInfos;
}
}
}
@@ -10,18 +10,11 @@ namespace Core.DataReader.Gdb
public sealed class GdbFileReader : IFileReader<GdbFile>
{
private readonly int _codepage;
public GdbFileReader(int codepage)
public GdbFile Read(IBinaryReader reader, int codepage)
{
_codepage = codepage;
}
_ = reader.ReadString(128, codepage); // header string
public GdbFile Read(IBinaryReader reader)
{
_ = reader.ReadString(128, _codepage); // header string
uint actorDataOffset = reader.ReadUInt32();
uint combatActorDataOffset = reader.ReadUInt32();
int numOfActors = reader.ReadInt32();
uint skillDataOffset = reader.ReadUInt32();
@@ -33,50 +26,299 @@ namespace Core.DataReader.Gdb
uint comboSkillDataOffset = reader.ReadUInt32();
int numOfComboSkills = reader.ReadInt32();
reader.Seek(combatActorDataOffset, SeekOrigin.Begin);
var combatActorInfos = new Dictionary<int, CombatActorInfo>();
for (var i = 0; i < numOfActors; i++)
{
CombatActorInfo actor = ReadCombatActorInfo(reader, codepage);
combatActorInfos[(int) actor.Id] = actor;
}
reader.Seek(skillDataOffset, SeekOrigin.Begin);
var skillInfos = new Dictionary<int, SkillInfo>();
for (var i = 0; i < numOfSkills; i++)
{
SkillInfo skill = ReadSkillInfo(reader, codepage);
skillInfos[(int) skill.Id] = skill;
}
reader.Seek(itemDataOffset, SeekOrigin.Begin);
var gameItems = new Dictionary<int, GameItem>();
var gameItems = new Dictionary<int, GameItemInfo>();
for (var i = 0; i < numOfItems; i++)
{
GameItem item = ReadGameItem(reader, _codepage);
GameItemInfo item = ReadGameItemInfo(reader, codepage);
gameItems[(int) item.Id] = item;
}
return new GdbFile(gameItems);
reader.Seek(comboSkillDataOffset, SeekOrigin.Begin);
var comboSkillInfos = new Dictionary<int, ComboSkillInfo>();
for (var i = 0; i < numOfComboSkills; i++)
{
ComboSkillInfo comboSkill = ReadComboSkillInfo(reader, codepage);
comboSkillInfos[(int) comboSkill.Id] = comboSkill;
}
return new GdbFile(combatActorInfos,
skillInfos,
gameItems,
comboSkillInfos);
}
private static GameItem ReadGameItem(IBinaryReader reader, int codepage)
private static CombatActorInfo ReadCombatActorInfo(IBinaryReader reader, int codepage)
{
return new GameItem
var id = reader.ReadUInt32();
var type = (CombatActorType) reader.ReadUInt16();
var description = reader.ReadString(512, codepage);
var modelId = reader.ReadString(30, codepage);
var iconId = reader.ReadString(32, codepage);
var wuLing = reader.ReadInt32s(5);
var name = reader.ReadString(32, codepage);
var level = reader.ReadInt32();
var attributeValue = reader.ReadInt32s(12);
var combatStateImpactType = reader.ReadBytes(31);
_ = reader.ReadByte(); // padding
var roundNumber = reader.ReadInt32();
var specialActionId = reader.ReadInt32();
var escapeRate = reader.ReadSingle();
var mainActorFavor = reader.ReadUInt16s(6);
var experience = reader.ReadInt32();
var money = reader.ReadUInt16();
_ = reader.ReadUInt16(); // padding
var normalAttackActionId = reader.ReadUInt32();
var heightLevel = reader.ReadByte();
var moveRangeLevel = reader.ReadByte();
var attackRangeLevel = reader.ReadByte();
var moveSpeedLevel = reader.ReadByte();
var chaseSpeed = reader.ReadByte();
_ = reader.ReadBytes(3); // padding
var skillIds = reader.ReadUInt32s(4);
var skillLevels = reader.ReadBytes(4);
var spImpactValue = reader.ReadInt32();
var properties = reader.ReadSingles(10);
var normalLoot = reader.ReadUInt32();
var normalLootCount = reader.ReadInt16();
_ = reader.ReadInt16(); // padding
var corpseId = reader.ReadUInt32();
var corpseSkillId = reader.ReadUInt32();
var corpseSuccessRate = reader.ReadInt16();
var stealableMoneyAmount = reader.ReadInt16();
var stealableItemId = reader.ReadUInt32();
var stealableItemCount = reader.ReadInt16();
var moneyWhenKilled = reader.ReadInt16();
return new CombatActorInfo()
{
Id = reader.ReadUInt32(),
Name = reader.ReadString(32, codepage),
ModelName = reader.ReadString(30, codepage),
IconName = reader.ReadString(30, codepage),
Description = reader.ReadString(512, codepage),
Price = reader.ReadInt32(),
Type = (ItemType) reader.ReadByte(),
WeaponType = (WeaponType) reader.ReadByte(),
MainActorCanUse = reader.ReadBytes(5),
WuLing = reader.ReadBytes(5),
AncientValue = reader.ReadInt32(),
SpecialType = (SpecialType) reader.ReadByte(), // ----------------| 1
TargetRangeType = (TargetRangeType) reader.ReadByte(), // --------| 2
PlaceOfUseType = (PlaceOfUseType) reader.ReadByte(), // ----------| 3
AttributeImpactType = reader.ReadBytes(12),
PaddingByte = reader.ReadByte(), // ------------------------------| ^ to complete 4-byte alignment
AttributeImpactValue = reader.ReadInt16Array(12),
FightStateImpactType = reader.ReadBytes(32),
FightStateImpactValue = reader.ReadInt16Array(32),
ComboCount = reader.ReadInt32(),
QiSavingPercentage = reader.ReadInt16(),
MpSavingPercentage = reader.ReadInt16(),
CriticalAttackAmplifyPercentage = reader.ReadInt16(),
SpecialSkillSuccessRate = reader.ReadInt16(),
OreId = reader.ReadUInt32(),
ProductId = reader.ReadUInt32(),
ProductPrice = reader.ReadInt32(),
SynthesisMaterialIds = reader.ReadUInt32Array(2),
SynthesisProductId = reader.ReadUInt32()
Id = id,
Type = type,
Description = description,
ModelId = modelId,
IconId = iconId,
WuLing = wuLing,
Name = name,
Level = level,
AttributeValue = attributeValue,
CombatStateImpactType = combatStateImpactType,
RoundNumber = roundNumber,
SpecialActionId = specialActionId,
EscapeRate = escapeRate,
MainActorFavor = mainActorFavor,
Experience = experience,
Money = money,
NormalAttackActionId = normalAttackActionId,
HeightLevel = heightLevel,
MoveRangeLevel = moveRangeLevel,
AttackRangeLevel = attackRangeLevel,
MoveSpeedLevel = moveSpeedLevel,
ChaseSpeedLevel = chaseSpeed,
SkillIds = skillIds,
SkillLevels = skillLevels,
SpImpactValue = spImpactValue,
Properties = properties,
NormalLoot = normalLoot,
NormalLootCount = normalLootCount,
CorpseId = corpseId,
CorpseSkillId = corpseSkillId,
CorpseSuccessRate = corpseSuccessRate,
StealableMoneyAmount = stealableMoneyAmount,
StealableItemId = stealableItemId,
StealableItemCount = stealableItemCount,
MoneyWhenKilled = moneyWhenKilled,
};
}
private SkillInfo ReadSkillInfo(IBinaryReader reader, int codepage)
{
var id = reader.ReadUInt32();
var type = (SkillType)reader.ReadByte();
_ = reader.ReadBytes(3); // padding
var wuLing = reader.ReadInt32s(5);
var name = reader.ReadString(32, codepage);
var description = reader.ReadString(512, codepage);
var mainActorCanUse = reader.ReadBytes(5);
var targetRangeType = (TargetRangeType)reader.ReadByte();
var specialSkillId = reader.ReadByte();
var attributeImpactType = reader.ReadBytes(12);
_ = reader.ReadByte(); // padding
var attributeImpactValue = reader.ReadInt16s(12);
var successRateLevel = reader.ReadByte();
_ = reader.ReadByte(); // padding
var combatStateImpactType = reader.ReadInt16s(31);
var consumeAttributeType = reader.ReadInt32s(2);
var consumeAttributeKind = reader.ReadInt32s(3);
var specialConsumeType = reader.ReadByte();
_ = reader.ReadBytes(3); // padding
var specialConsumeValue = reader.ReadInt32();
var level = reader.ReadByte();
var timesBeforeLevelUp = reader.ReadBytes(4);
var requiredActorLevel = reader.ReadByte();
var magicLevel = reader.ReadByte();
_ = reader.ReadByte(); // padding
var nextLevelSkillId = reader.ReadUInt32();
var isUsableOutsideCombat = reader.ReadByte();
_ = reader.ReadBytes(3); // padding
var compositeSkillIds = reader.ReadUInt32s(3);
var compositeRequiredSkillIds = reader.ReadUInt32s(3);
var compositeRequiredSkillLevels = reader.ReadBytes(3);
var compositeRequiredCurrentSkillLevels = reader.ReadBytes(3);
var compositeRequiredActorLevels = reader.ReadBytes(3);
var canTriggerComboSkill = reader.ReadByte();
_ = reader.ReadBytes(2); // padding
return new SkillInfo()
{
Id = id,
Type = type,
WuLing = wuLing,
Name = name,
Description = description,
MainActorCanUse = mainActorCanUse,
TargetRangeType = targetRangeType,
SpecialSkillId = specialSkillId,
AttributeImpactType = attributeImpactType,
AttributeImpactValue = attributeImpactValue,
SuccessRateLevel = successRateLevel,
CombatStateImpactType = combatStateImpactType,
ConsumeAttributeType = consumeAttributeType,
ConsumeAttributeKind = consumeAttributeKind,
SpecialConsumeType = specialConsumeType,
SpecialConsumeValue = specialConsumeValue,
Level = level,
TimesBeforeLevelUp = timesBeforeLevelUp,
RequiredActorLevel = requiredActorLevel,
MagicLevel = magicLevel,
NextLevelSkillId = nextLevelSkillId,
IsUsableOutsideCombat = isUsableOutsideCombat,
CompositeSkillIds = compositeSkillIds,
CompositeRequiredSkillIds = compositeRequiredSkillIds,
CompositeRequiredSkillLevels = compositeRequiredSkillLevels,
CompositeRequiredCurrentSkillLevels = compositeRequiredCurrentSkillLevels,
CompositeRequiredActorLevels = compositeRequiredActorLevels,
CanTriggerComboSkill = canTriggerComboSkill,
};
}
private static GameItemInfo ReadGameItemInfo(IBinaryReader reader, int codepage)
{
var id = reader.ReadUInt32();
var name = reader.ReadString(32, codepage);
var modelName = reader.ReadString(30, codepage);
var iconName = reader.ReadString(30, codepage);
var description = reader.ReadString(512, codepage);
var price = reader.ReadInt32();
var type = (ItemType) reader.ReadByte();
var weaponType = (WeaponType) reader.ReadByte();
var mainActorCanUse = reader.ReadBytes(5);
var wuLing = reader.ReadBytes(5);
var ancientValue = reader.ReadInt32();
var specialType = (SpecialType) reader.ReadByte();
var targetRangeType = (TargetRangeType) reader.ReadByte();
var placeOfUseType = (PlaceOfUseType) reader.ReadByte();
var attributeImpactType = reader.ReadBytes(12);
_ = reader.ReadByte(); // padding
var attributeImpactValue = reader.ReadInt16s(12);
var combatStateImpactType = reader.ReadBytes(31);
_ = reader.ReadByte(); // padding
var combatStateImpactValue = reader.ReadInt16s(31);
_ = reader.ReadBytes(2); // padding
var comboCount = reader.ReadInt32();
var spSavingPercentage = reader.ReadInt16();
var mpSavingPercentage = reader.ReadInt16();
var criticalAttackAmplifyPercentage = reader.ReadInt16();
var specialSkillSuccessRate = reader.ReadInt16();
var oreId = reader.ReadUInt32();
var productId = reader.ReadUInt32();
var productPrice = reader.ReadInt32();
var synthesisMaterialIds = reader.ReadUInt32s(2);
var synthesisProductId = reader.ReadUInt32();
return new GameItemInfo()
{
Id = id,
Name = name,
ModelName = modelName,
IconName = iconName,
Description = description,
Price = price,
Type = type,
WeaponType = weaponType,
MainActorCanUse = mainActorCanUse,
WuLing = wuLing,
AncientValue = ancientValue,
SpecialType = specialType,
TargetRangeType = targetRangeType,
PlaceOfUseType = placeOfUseType,
AttributeImpactType = attributeImpactType,
AttributeImpactValue = attributeImpactValue,
CombatStateImpactType = combatStateImpactType,
CombatStateImpactValue = combatStateImpactValue,
ComboCount = comboCount,
SpSavingPercentage = spSavingPercentage,
MpSavingPercentage = mpSavingPercentage,
CriticalAttackAmplifyPercentage = criticalAttackAmplifyPercentage,
SpecialSkillSuccessRate = specialSkillSuccessRate,
OreId = oreId,
ProductId = productId,
ProductPrice = productPrice,
SynthesisMaterialIds = synthesisMaterialIds,
SynthesisProductId = synthesisProductId,
};
}
private ComboSkillInfo ReadComboSkillInfo(IBinaryReader reader, int codepage)
{
var name = reader.ReadString(32, codepage);
var id = reader.ReadUInt32();
var mainActorRequirements = reader.ReadUInt32s(4);
var wuLingPositionRequirements = reader.ReadBytes(4);
var skillId = reader.ReadUInt32();
var weaponTypeRequirements = reader.ReadBytes(4);
_ = reader.ReadBytes(4); // not used
var combatStateRequirements = reader.ReadInt32s(3);
var description = reader.ReadString(512, codepage);
var targetRangeType = (TargetRangeType)reader.ReadByte();
var attributeImpactType = reader.ReadBytes(12);
_ = reader.ReadBytes(3); // padding
var attributeImpactValue = reader.ReadInt16s(12);
#if PAL3A
var unknown = reader.ReadInt32();
#endif
return new ComboSkillInfo()
{
Name = name,
Id = id,
MainActorRequirements = mainActorRequirements,
WuLingPositionRequirements = wuLingPositionRequirements,
SkillId = skillId,
WeaponTypeRequirements = weaponTypeRequirements,
CombatStateRequirements = combatStateRequirements,
Description = description,
TargetRangeType = targetRangeType,
AttributeImpactType = attributeImpactType,
AttributeImpactValue = attributeImpactValue,
#if PAL3A
Unknown = unknown,
#endif
};
}
}
+67 -44
View File
@@ -17,6 +17,8 @@ namespace Core.DataReader
/// </summary>
public interface IBinaryReader : IDisposable
{
long Position { get; }
long Length { get; }
void Seek(long offset, SeekOrigin seekOrigin);
short ReadInt16();
int ReadInt32();
@@ -31,26 +33,8 @@ namespace Core.DataReader
byte[] ReadBytes(int count);
#region Helper Extensions (Default Implementation)
[MethodImpl(MethodImplOptions.AggressiveInlining)]
Vector2 ReadVector2() => new (ReadSingle(), ReadSingle());
[MethodImpl(MethodImplOptions.AggressiveInlining)]
Vector3 ReadVector3() => new (ReadSingle(), ReadSingle(), ReadSingle());
[MethodImpl(MethodImplOptions.AggressiveInlining)]
Vector3[] ReadVector3Array(int count)
{
var array = new Vector3[count];
for (var i = 0; i < count; i++)
{
array[i] = ReadVector3();
}
return array;
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
float[] ReadSingleArray(int count)
float[] ReadSingles(int count)
{
var array = new float[count];
for (var i = 0; i < count; i++)
@@ -61,7 +45,7 @@ namespace Core.DataReader
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
double[] ReadDoubleArray(int count)
double[] ReadDoubles(int count)
{
var array = new double[count];
for (var i = 0; i < count; i++)
@@ -72,29 +56,7 @@ namespace Core.DataReader
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
int[] ReadInt32Array(int count)
{
var array = new int[count];
for (var i = 0; i < count; i++)
{
array[i] = ReadInt32();
}
return array;
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
uint[] ReadUInt32Array(int count)
{
var array = new uint[count];
for (var i = 0; i < count; i++)
{
array[i] = ReadUInt32();
}
return array;
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
short[] ReadInt16Array(int count)
short[] ReadInt16s(int count)
{
var array = new short[count];
for (var i = 0; i < count; i++)
@@ -105,7 +67,7 @@ namespace Core.DataReader
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
ushort[] ReadUInt16Array(int count)
ushort[] ReadUInt16s(int count)
{
var array = new ushort[count];
for (var i = 0; i < count; i++)
@@ -115,6 +77,50 @@ namespace Core.DataReader
return array;
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
int[] ReadInt32s(int count)
{
var array = new int[count];
for (var i = 0; i < count; i++)
{
array[i] = ReadInt32();
}
return array;
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
uint[] ReadUInt32s(int count)
{
var array = new uint[count];
for (var i = 0; i < count; i++)
{
array[i] = ReadUInt32();
}
return array;
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
long[] ReadInt64s(int count)
{
var array = new long[count];
for (var i = 0; i < count; i++)
{
array[i] = ReadInt64();
}
return array;
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
ulong[] ReadUInt64s(int count)
{
var array = new ulong[count];
for (var i = 0; i < count; i++)
{
array[i] = ReadUInt64();
}
return array;
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public char[] ReadChars(int count)
{
@@ -132,6 +138,23 @@ namespace Core.DataReader
if (length == -1) length = strBytes.Length; // If no null byte is found, use the full length
return Encoding.GetEncoding(codepage).GetString(strBytes, 0, length);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
Vector2 ReadVector2() => new (ReadSingle(), ReadSingle());
[MethodImpl(MethodImplOptions.AggressiveInlining)]
Vector3 ReadVector3() => new (ReadSingle(), ReadSingle(), ReadSingle());
[MethodImpl(MethodImplOptions.AggressiveInlining)]
Vector3[] ReadVector3s(int count)
{
var array = new Vector3[count];
for (var i = 0; i < count; i++)
{
array[i] = ReadVector3();
}
return array;
}
#endregion
}
}
+20 -5
View File
@@ -5,26 +5,41 @@
namespace Core.DataReader
{
using System.IO;
/// <summary>
/// File reader interface for reading data from binary file
/// using <see cref="IBinaryReader"/>.
/// </summary>
/// <typeparam name="T"></typeparam>
/// <typeparam name="T">File type</typeparam>
public interface IFileReader<out T>
{
T Read(IBinaryReader reader);
T Read(IBinaryReader reader, int codepage);
T Read(byte[] data)
T Read(byte[] data, int codepage)
{
// Use unsafe binary reader (faster) if IL2CPP is enabled
// otherwise use safe reader
#if ENABLE_IL2CPP
#if ENABLE_IL2CPP || UNITY_EDITOR
using var reader = new UnsafeBinaryReader(data);
#else
using var reader = new SafeBinaryReader(data);
#endif
return Read(reader);
return Read(reader, codepage);
}
T Read(Stream stream, int codepage)
{
// Use unsafe binary reader (faster) if IL2CPP is enabled
// otherwise use safe reader
#if ENABLE_IL2CPP || UNITY_EDITOR
using var reader = new UnsafeBinaryReader(stream);
#else
using var reader = new SafeBinaryReader(stream);
#endif
return Read(reader, codepage);
}
}
}
@@ -23,16 +23,16 @@ namespace Core.DataReader.Ini
private const string PROPERTY_MESH = "mesh";
private const string PROPERTY_MATERIAL = "material";
public MovActionConfig Read(IBinaryReader reader)
public MovActionConfig Read(IBinaryReader reader, int codepage)
{
throw new NotImplementedException();
}
public MovActionConfig Read(byte[] data)
public MovActionConfig Read(byte[] data, int codepage)
{
FileIniDataParser parser = new ();
using var stream = new MemoryStream(data);
using var reader = new StreamReader(stream, Encoding.ASCII);
using var reader = new StreamReader(stream, Encoding.GetEncoding(codepage));
IniData iniData = parser.ReadData(reader);
@@ -19,16 +19,16 @@ namespace Core.DataReader.Ini
private const string PROPERTY_NAME = "name";
private const string PROPERTY_FILE = "file";
public Mv3ActionConfig Read(IBinaryReader reader)
public Mv3ActionConfig Read(IBinaryReader reader, int codepage)
{
throw new NotImplementedException();
}
public Mv3ActionConfig Read(byte[] data)
public Mv3ActionConfig Read(byte[] data, int codepage)
{
var parser = new FileIniDataParser();
using var stream = new MemoryStream(data);
using var reader = new StreamReader(stream, Encoding.ASCII);
using var reader = new StreamReader(stream, Encoding.GetEncoding(codepage));
IniData iniData = parser.ReadData(reader);
@@ -12,7 +12,7 @@ namespace Core.DataReader.Lgt
public sealed class LgtFileReader : IFileReader<LgtFile>
{
public LgtFile Read(IBinaryReader reader)
public LgtFile Read(IBinaryReader reader, int codepage)
{
var numOfLightNodes = reader.ReadInt32();
var lightNodes = new List<LightNode>();
@@ -46,8 +46,8 @@ namespace Core.DataReader.Lgt
{
WorldMatrix = GameBoxInterpreter.ToUnityMatrix4x4(transformMatrix),
LightType = (GameBoxLightType)reader.ReadInt32(),
LightColor = Utility.ToColor(reader.ReadSingleArray(4)),
AmbientColor = Utility.ToColor(reader.ReadSingleArray(4)),
LightColor = Utility.ToColor(reader.ReadSingles(4)),
AmbientColor = Utility.ToColor(reader.ReadSingles(4)),
UseDiffuse = reader.ReadBoolean(),
UseSpecular = reader.ReadBoolean(),
NearStart = reader.ReadSingle(),
@@ -10,14 +10,7 @@ namespace Core.DataReader.Mov
public sealed class MovFileReader : IFileReader<MovFile>
{
private readonly int _codepage;
public MovFileReader(int codepage)
{
_codepage = codepage;
}
public MovFile Read(IBinaryReader reader)
public MovFile Read(IBinaryReader reader, int codepage)
{
var header = reader.ReadChars(4);
var headerStr = new string(header[..^1]);
@@ -41,13 +34,13 @@ namespace Core.DataReader.Mov
var animationEvents = new MovAnimationEvent[numberOfAnimationEvents];
for (var i = 0; i < numberOfAnimationEvents; i++)
{
animationEvents[i] = ReadAnimationEvent(reader, _codepage);
animationEvents[i] = ReadAnimationEvent(reader, codepage);
}
var boneAnimationTracks = new MovBoneAnimationTrack[numberOfBoneAnimationTracks];
for (var i = 0; i < numberOfBoneAnimationTracks; i++)
{
boneAnimationTracks[i] = ReadBoneAnimationTrack(reader, _codepage);
boneAnimationTracks[i] = ReadBoneAnimationTrack(reader, codepage);
}
uint totalDuration = 0;
@@ -11,14 +11,7 @@ namespace Core.DataReader.Msh
public sealed class MshFileReader : IFileReader<MshFile>
{
private readonly int _codepage;
public MshFileReader(int codepage)
{
_codepage = codepage;
}
public MshFile Read(IBinaryReader reader)
public MshFile Read(IBinaryReader reader, int codepage)
{
var header = reader.ReadChars(4);
var headerStr = new string(header[..^1]);
@@ -50,7 +43,7 @@ namespace Core.DataReader.Msh
var childBoneNodes = new BoneNode[numberOfChildBones];
for (var i = 0; i < numberOfChildBones; i++)
{
childBoneNodes[i] = ReadBoneNode(reader, rootBoneNode, _codepage);
childBoneNodes[i] = ReadBoneNode(reader, rootBoneNode, codepage);
}
rootBoneNode.Children = childBoneNodes;
@@ -12,14 +12,7 @@ namespace Core.DataReader.Mtl
public sealed class MtlFileReader : IFileReader<MtlFile>
{
private readonly int _codepage;
public MtlFileReader(int codepage)
{
_codepage = codepage;
}
public MtlFile Read(IBinaryReader reader)
public MtlFile Read(IBinaryReader reader, int codepage)
{
var header = reader.ReadChars(4);
var headerStr = new string(header[..^1]);
@@ -42,10 +35,10 @@ namespace Core.DataReader.Mtl
{
materials[i] = new GameBoxMaterial
{
Diffuse = Utility.ToColor(reader.ReadSingleArray(4)),
Ambient = Utility.ToColor(reader.ReadSingleArray(4)),
Specular = Utility.ToColor(reader.ReadSingleArray(4)),
Emissive = Utility.ToColor(reader.ReadSingleArray(4)),
Diffuse = Utility.ToColor(reader.ReadSingles(4)),
Ambient = Utility.ToColor(reader.ReadSingles(4)),
Specular = Utility.ToColor(reader.ReadSingles(4)),
Emissive = Utility.ToColor(reader.ReadSingles(4)),
SpecularPower = reader.ReadSingle(),
};
@@ -54,7 +47,7 @@ namespace Core.DataReader.Mtl
{
int textureNameLength = reader.ReadInt32();
if (textureNameLength == 0) continue;
textureNames.Add(reader.ReadString(textureNameLength, _codepage));
textureNames.Add(reader.ReadString(textureNameLength, codepage));
}
materials[i].TextureFileNames = textureNames.ToArray();
@@ -14,14 +14,7 @@ namespace Core.DataReader.Mv3
public sealed class Mv3FileReader : IFileReader<Mv3File>
{
private readonly int _codepage;
public Mv3FileReader(int codepage)
{
_codepage = codepage;
}
public Mv3File Read(IBinaryReader reader)
public Mv3File Read(IBinaryReader reader, int codepage)
{
var header = reader.ReadChars(4);
var headerStr = new string(header[..^1]);
@@ -51,25 +44,25 @@ namespace Core.DataReader.Mv3
var animationEvents = new Mv3AnimationEvent[numberOfAnimationEvents];
for (var i = 0; i < numberOfAnimationEvents; i++)
{
animationEvents[i] = ReadAnimationEvent(reader, _codepage);
animationEvents[i] = ReadAnimationEvent(reader, codepage);
}
var tagNodes = new Mv3TagNode[numberOfTagNodes];
for (var i = 0; i < numberOfTagNodes; i++)
{
tagNodes[i] = ReadTagNode(reader, _codepage);
tagNodes[i] = ReadTagNode(reader, codepage);
}
var materials = new GameBoxMaterial[numberOfMaterials];
for (var i = 0; i < numberOfMaterials; i++)
{
materials[i] = ReadMaterial(reader, _codepage);
materials[i] = ReadMaterial(reader, codepage);
}
var meshes = new Mv3Mesh[numberOfMeshes];
for (var i = 0; i < numberOfMeshes; i++)
{
meshes[i] = ReadMesh(reader, _codepage);
meshes[i] = ReadMesh(reader, codepage);
}
return new Mv3File(duration,
@@ -283,10 +276,10 @@ namespace Core.DataReader.Mv3
{
GameBoxMaterial material = new ()
{
Diffuse = Utility.ToColor(reader.ReadSingleArray(4)),
Ambient = Utility.ToColor(reader.ReadSingleArray(4)),
Specular = Utility.ToColor(reader.ReadSingleArray(4)),
Emissive = Utility.ToColor(reader.ReadSingleArray(4)),
Diffuse = Utility.ToColor(reader.ReadSingles(4)),
Ambient = Utility.ToColor(reader.ReadSingles(4)),
Specular = Utility.ToColor(reader.ReadSingles(4)),
Emissive = Utility.ToColor(reader.ReadSingles(4)),
SpecularPower = reader.ReadSingle()
};
@@ -41,9 +41,9 @@ namespace Core.DataReader.Nav
DevilWorld2, // 异空间B
DevilWorld3, // 异空间C
Other, // 其它
FloorIce, // 冰
FloorBlood, // 血池
FloorWater, // 水域
Ice, // 冰
Blood, // 血池
Water, // 水域
}
public struct NavTile
@@ -13,7 +13,7 @@ namespace Core.DataReader.Nav
public sealed class NavFileReader : IFileReader<NavFile>
{
public NavFile Read(IBinaryReader reader)
public NavFile Read(IBinaryReader reader, int codepage)
{
var header = reader.ReadChars(4);
var headerStr = new string(header[..^1]);
@@ -14,14 +14,7 @@ namespace Core.DataReader.Pol
public sealed class PolFileReader : IFileReader<PolFile>
{
private readonly int _codepage;
public PolFileReader(int codepage)
{
_codepage = codepage;
}
public PolFile Read(IBinaryReader reader)
public PolFile Read(IBinaryReader reader, int codepage)
{
var header = reader.ReadChars(4);
var headerStr = new string(header);
@@ -39,7 +32,7 @@ namespace Core.DataReader.Pol
{
nodeInfos[i] = new PolGeometryNode
{
Name = reader.ReadString(32, _codepage),
Name = reader.ReadString(32, codepage),
Position = GameBoxInterpreter.ToUnityPosition(reader.ReadVector3()),
Radius = reader.ReadSingle(),
Offset = reader.ReadInt32()
@@ -55,7 +48,7 @@ namespace Core.DataReader.Pol
tagNodes = new TagNode[numberOfTagNodes];
for (var i = 0; i < numberOfTagNodes; i++)
{
tagNodes[i] = ReadTagNodeInfo(reader, _codepage);
tagNodes[i] = ReadTagNodeInfo(reader, codepage);
}
}
}
@@ -63,7 +56,7 @@ namespace Core.DataReader.Pol
var meshInfos = new PolMesh[numberOfNodes];
for (var i = 0; i < numberOfNodes; i++)
{
meshInfos[i] = ReadMeshData(reader, version, _codepage);
meshInfos[i] = ReadMeshData(reader, version, codepage);
}
return new PolFile(version, nodeInfos, meshInfos, tagNodes);
@@ -224,10 +217,10 @@ namespace Core.DataReader.Pol
GameBoxMaterial material = new ()
{
Diffuse = Utility.ToColor(reader.ReadSingleArray(4)),
Ambient = Utility.ToColor(reader.ReadSingleArray(4)),
Specular = Utility.ToColor(reader.ReadSingleArray(4)),
Emissive = Utility.ToColor(reader.ReadSingleArray(4)),
Diffuse = Utility.ToColor(reader.ReadSingles(4)),
Ambient = Utility.ToColor(reader.ReadSingles(4)),
Specular = Utility.ToColor(reader.ReadSingles(4)),
Emissive = Utility.ToColor(reader.ReadSingles(4)),
SpecularPower = reader.ReadSingle()
};
@@ -8,6 +8,9 @@ namespace Core.DataReader
using System;
using System.IO;
/// <summary>
/// Provides a safe way to read binary data from a stream or byte array.
/// </summary>
public sealed class SafeBinaryReader : IBinaryReader
{
private readonly BinaryReader _reader;
@@ -24,7 +27,10 @@ namespace Core.DataReader
_reader.BaseStream.Seek(offset, seekOrigin);
}
public long Position => _reader.BaseStream.Position;
public long Length => _reader.BaseStream.Length;
public Stream BaseStream => _reader.BaseStream;
public short ReadInt16() => _reader.ReadInt16();
public int ReadInt32() => _reader.ReadInt32();
public long ReadInt64() => _reader.ReadInt64();
@@ -9,14 +9,7 @@ namespace Core.DataReader.Sce
public sealed class SceFileReader : IFileReader<SceFile>
{
private readonly int _codepage;
public SceFileReader(int codepage)
{
_codepage = codepage;
}
public SceFile Read(IBinaryReader reader)
public SceFile Read(IBinaryReader reader, int codepage)
{
var header = reader.ReadChars(4);
var headerStr = new string(header[..^1]);
@@ -38,16 +31,16 @@ namespace Core.DataReader.Sce
var indexes = new SceIndex[numberOfBlocks];
for (var i = 0; i < numberOfBlocks; i++)
{
indexes[i] = ReadSceIndex(reader, _codepage);
indexes[i] = ReadSceIndex(reader, codepage);
}
var scriptBlocks = new SceScriptBlock[numberOfBlocks];
for (var i = 0; i < numberOfBlocks; i++)
{
scriptBlocks[i] = ReadScriptBlock(reader, indexes[i], _codepage);
scriptBlocks[i] = ReadScriptBlock(reader, indexes[i], codepage);
}
return new SceFile(indexes, scriptBlocks, _codepage);
return new SceFile(indexes, scriptBlocks, codepage);
}
private static SceScriptBlock ReadScriptBlock(IBinaryReader reader, SceIndex sceIndex, int codepage)
@@ -188,7 +188,7 @@ namespace Core.DataReader.Scn
return string.Equals(CityName, cityName, StringComparison.OrdinalIgnoreCase);
}
private bool IsScene(string sceneName)
public bool IsScene(string sceneName)
{
return string.Equals(SceneName, sceneName, StringComparison.OrdinalIgnoreCase);
}
@@ -353,7 +353,7 @@ namespace Core.DataReader.Scn
public string FailedMessage; // char[16] 失败提示字符串名称
#if PAL3A
public uint Unknown; // TODO
public ushort LinkedObjectGroupId; // 同时触发的关联编号 (如阳名百纳二的机关浮板,神魔结界的三相桥)
#endif
public uint ScriptId;
@@ -13,14 +13,7 @@ namespace Core.DataReader.Scn
public sealed class ScnFileReader : IFileReader<ScnFile>
{
private readonly int _codepage;
public ScnFileReader(int codepage)
{
_codepage = codepage;
}
public ScnFile Read(IBinaryReader reader)
public ScnFile Read(IBinaryReader reader, int codepage)
{
var header = reader.ReadChars(4);
var headerStr = new string(header[..^1]);
@@ -38,27 +31,27 @@ namespace Core.DataReader.Scn
var sceneInfo = new ScnSceneInfo()
{
CityName = reader.ReadString(32, _codepage),
SceneName = reader.ReadString(32, _codepage),
Model = reader.ReadString(32, _codepage),
CityName = reader.ReadString(32, codepage),
SceneName = reader.ReadString(32, codepage),
Model = reader.ReadString(32, codepage),
SceneType = (ScnSceneType) reader.ReadInt32(),
LightMap = reader.ReadInt32(),
SkyBox = reader.ReadUInt32(),
Reserved = reader.ReadUInt32Array(6),
Reserved = reader.ReadUInt32s(6),
};
reader.Seek(npcDataOffset, SeekOrigin.Begin);
var npcInfos = new ScnNpcInfo[numberOfNpc];
for (var i = 0; i < numberOfNpc; i++)
{
npcInfos[i] = ReadNpcInfo(reader, _codepage);
npcInfos[i] = ReadNpcInfo(reader, codepage);
}
reader.Seek(objectDataOffset, SeekOrigin.Begin);
var objInfos = new ScnObjectInfo[numberOfObjects];
for (var i = 0; i < numberOfObjects; i++)
{
ScnObjectInfo sceneObject = ReadObjectInfo(reader, _codepage);
ScnObjectInfo sceneObject = ReadObjectInfo(reader, codepage);
objInfos[i] = sceneObject;
}
@@ -82,19 +75,19 @@ namespace Core.DataReader.Scn
ScriptId = reader.ReadUInt32(),
GameBoxYPosition = reader.ReadSingle(),
InitAction = reader.ReadString(16, codepage),
MonsterIds = reader.ReadUInt32Array(3),
MonsterIds = reader.ReadUInt32s(3),
NumberOfMonsters = reader.ReadByte(),
MonsterCanRespawn = reader.ReadByte(),
PaddingBytes = reader.ReadBytes(2), // Empty padding bytes to complete 4-byte alignment
Path = new ScnPath()
{
NumberOfWaypoints = reader.ReadInt32(),
GameBoxWaypoints = reader.ReadVector3Array(16)
GameBoxWaypoints = reader.ReadVector3s(16)
},
NoTurn = reader.ReadUInt32(),
LoopAction = reader.ReadUInt32(),
GameBoxMoveSpeed = reader.ReadUInt32(),
Reserved = reader.ReadUInt32Array(29),
Reserved = reader.ReadUInt32s(29),
};
}
@@ -122,15 +115,15 @@ namespace Core.DataReader.Scn
Bottom = reader.ReadInt32(),
};
var type = (ScnSceneObjectType) reader.ReadByte();
var type = (ScnSceneObjectType)reader.ReadByte();
var saveState = reader.ReadByte();
var layerIndex = reader.ReadByte();
var wuLing = reader.ReadByte();
#if PAL3
var parameters = reader.ReadInt32Array(6);
var parameters = reader.ReadInt32s(6);
#elif PAL3A
var parameters = Array.ConvertAll(reader.ReadSingleArray(6), Convert.ToInt32);
var parameters = Array.ConvertAll(reader.ReadSingles(6), Convert.ToInt32);
#endif
#if PAL3A
@@ -150,7 +143,8 @@ namespace Core.DataReader.Scn
_ = reader.ReadByte(); // Empty padding byte to complete 4-byte alignment
#if PAL3A
var unknown = reader.ReadUInt32(); // TODO
var linkedObjectGroupId = reader.ReadUInt16();
_ = reader.ReadBytes(2); // Empty padding bytes to complete 4-byte alignment
#endif
var scriptId = reader.ReadUInt32();
@@ -158,7 +152,7 @@ namespace Core.DataReader.Scn
var path = new ScnPath()
{
NumberOfWaypoints = reader.ReadInt32(),
GameBoxWaypoints = reader.ReadVector3Array(16)
GameBoxWaypoints = reader.ReadVector3s(16)
};
var linkedObjectId = reader.ReadUInt16();
@@ -189,9 +183,9 @@ namespace Core.DataReader.Scn
#endif
#if PAL3
var reserved = reader.ReadUInt32Array(52);
var reserved = reader.ReadUInt32s(52);
#elif PAL3A
var reserved = reader.ReadUInt32Array(44);
var reserved = reader.ReadUInt32s(44);
#endif
return new ScnObjectInfo()
@@ -231,7 +225,7 @@ namespace Core.DataReader.Scn
FailedMessage = failedMessage,
#if PAL3A
Unknown = unknown, // TODO
LinkedObjectGroupId = linkedObjectGroupId,
#endif
ScriptId = scriptId,
@@ -11,21 +11,14 @@ namespace Core.DataReader.Txt
public sealed class TaskDefinitionFileReader : IFileReader<TaskDefinitionFile>
{
private readonly int _codepage;
public TaskDefinitionFileReader(int codepage)
{
_codepage = codepage;
}
public TaskDefinitionFile Read(IBinaryReader reader)
public TaskDefinitionFile Read(IBinaryReader reader, int codepage)
{
throw new NotImplementedException();
}
public TaskDefinitionFile Read(byte[] data)
public TaskDefinitionFile Read(byte[] data, int codepage)
{
var content = Encoding.GetEncoding(_codepage).GetString(data, 0, data.Length);
var content = Encoding.GetEncoding(codepage).GetString(data, 0, data.Length);
var tasks = new List<Task>();
var taskLines = content.Split(new[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries);
var currentTask = new Task();
@@ -10,26 +10,72 @@ namespace Core.DataReader
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
/// <summary>
/// Provides a binary reader that reads primitive data types from a byte array or stream using unsafe code.
/// </summary>
public sealed unsafe class UnsafeBinaryReader : IBinaryReader
{
private byte* _dataPtr;
private GCHandle _handle;
private byte* _startPtr;
private byte* _dataPtr;
public UnsafeBinaryReader(byte[] data)
{
Init(data);
}
public UnsafeBinaryReader(Stream stream)
{
if (!stream.CanSeek)
{
throw new ArgumentException("Stream must be seekable", nameof(stream));
}
Length = stream.Length;
// If data is empty, set position to 0 and return
if (Length == 0)
{
_position = 0;
return;
}
var data = new byte[Length];
_ = stream.Read(data, 0, (int)Length);
Init(data);
}
private void Init(byte[] data)
{
Length = data.Length;
// If data is empty, set position to 0 and return
if (Length == 0)
{
_position = 0;
return;
}
_handle = GCHandle.Alloc(data, GCHandleType.Pinned);
fixed (byte* ptr = &data[0])
{
_startPtr = ptr;
_dataPtr = ptr;
}
}
private long? _position;
public long Position => _position ?? _dataPtr - _startPtr;
public long Length { get; private set; }
public void Seek(long offset, SeekOrigin seekOrigin)
{
switch (seekOrigin)
{
case SeekOrigin.Begin:
_dataPtr = (byte*)_handle.AddrOfPinnedObject() + offset;
_dataPtr = _startPtr + offset;
break;
case SeekOrigin.Current:
_dataPtr += offset;
@@ -131,7 +177,7 @@ namespace Core.DataReader
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public float[] ReadSingleArray(int count)
public float[] ReadSingles(int count)
{
var value = new float[count];
Marshal.Copy(new IntPtr(_dataPtr), value, 0, count);
@@ -140,7 +186,7 @@ namespace Core.DataReader
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public double[] ReadDoubleArray(int count)
public double[] ReadDoubles(int count)
{
var value = new double[count];
Marshal.Copy(new IntPtr(_dataPtr), value, 0, count);
@@ -149,7 +195,7 @@ namespace Core.DataReader
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public short[] ReadInt16Array(int count)
public short[] ReadInt16s(int count)
{
var value = new short[count];
Marshal.Copy(new IntPtr(_dataPtr), value, 0, count);
@@ -158,7 +204,7 @@ namespace Core.DataReader
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public int[] ReadInt32Array(int count)
public int[] ReadInt32s(int count)
{
var value = new int[count];
Marshal.Copy(new IntPtr(_dataPtr), value, 0, count);
@@ -167,7 +213,7 @@ namespace Core.DataReader
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public long[] ReadInt64Array(int count)
public long[] ReadInt64s(int count)
{
var value = new long[count];
Marshal.Copy(new IntPtr(_dataPtr), value, 0, count);
@@ -184,7 +230,12 @@ namespace Core.DataReader
{
GC.SuppressFinalize(this);
}
_handle.Free();
if (Length != 0)
{
_handle.Free();
}
_disposedValue = true;
}
}
@@ -1,5 +1,6 @@
fileFormatVersion: 2
guid: 447a6384f74b843dc8c19f6397c505f7
guid: 4f61b67e4060bb34f8cb9eda9a42619d
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
@@ -0,0 +1,30 @@
// ---------------------------------------------------------------------------------------------
// Copyright (c) 2021-2023, Jiaqi Liu. All rights reserved.
// See LICENSE file in the project root for license information.
// ---------------------------------------------------------------------------------------------
namespace Core.Navigation
{
/*
* Use integer to represent 8 directions
*
* 5 4 3
* |
* 6 -- -- 2
* |
* 7 0 1
*
*/
public enum Direction
{
South = 0,
SouthEast = 1,
East = 2,
NorthEast = 3,
North = 4,
NorthWest = 5,
West = 6,
SouthWest = 7,
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: aaf07680771bcc24ab17a056b1c4aadd
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -3,36 +3,13 @@
// See LICENSE file in the project root for license information.
// ---------------------------------------------------------------------------------------------
namespace Pal3.MetaData
namespace Core.Navigation
{
using System;
using System.Collections.Generic;
using System.Linq;
using UnityEngine;
/*
* Use integer to represent 8 directions
*
* 5 4 3
* |
* 6 -- -- 2
* |
* 7 0 1
*
*/
public enum Direction
{
South = 0,
SouthEast = 1,
East = 2,
NorthEast = 3,
North = 4,
NorthWest = 5,
West = 6,
SouthWest = 7,
}
public static class DirectionUtils
{
public static IEnumerable<Direction> AllDirections => Enum.GetValues(typeof(Direction)).Cast<Direction>();
@@ -69,9 +46,4 @@ namespace Pal3.MetaData
};
}
}
public static class NavigationConstants
{
public const float NavTileSize = 12f;
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 2ae63e5dc80c88e43b8ea35c656ec7ae
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -3,7 +3,7 @@
// See LICENSE file in the project root for license information.
// ---------------------------------------------------------------------------------------------
namespace Pal3.Actor
namespace Core.Navigation
{
public enum MovementMode
{
@@ -3,7 +3,7 @@
// See LICENSE file in the project root for license information.
// ---------------------------------------------------------------------------------------------
namespace Pal3.Actor
namespace Core.Navigation
{
using UnityEngine;
@@ -13,6 +13,8 @@ namespace Core.Renderer
private MeshRenderer _meshRenderer;
private MeshFilter _meshFilter;
private Material[] _materials;
public Mesh Render(ref Vector3[] vertices,
ref int[] triangles,
ref Vector3[] normals,
@@ -23,6 +25,7 @@ namespace Core.Renderer
{
Dispose();
_materials = materials;
_meshRenderer = gameObject.AddComponent<MeshRenderer>();
_meshRenderer.sharedMaterials = materials;
@@ -73,6 +76,11 @@ namespace Core.Renderer
return _meshFilter.sharedMesh.bounds;
}
public Material[] GetMaterials()
{
return _materials;
}
private void OnDisable()
{
Dispose();
@@ -88,13 +96,10 @@ namespace Core.Renderer
if (_meshRenderer != null)
{
foreach (Material material in _meshRenderer.sharedMaterials)
{
Destroy(material);
}
Destroy(_meshRenderer);
}
_materials = null;
}
}
}
@@ -80,6 +80,14 @@ namespace Core.Services
_services.Remove(typeof(T));
}
/// <summary>
/// Get all registered services.
/// </summary>
public IEnumerable<object> GetAllRegisteredServices()
{
return _services.Values;
}
/// <summary>
/// Unregisters all services.
/// </summary>
@@ -5,12 +5,13 @@
namespace Core.Utils
{
using System;
using System.Collections.Generic;
using UnityEngine;
public static class UnitySupportedVideoFormats
{
public static readonly HashSet<string> WindowsSupportedVideoFormats = new()
public static readonly HashSet<string> WindowsSupportedVideoFormats = new (StringComparer.OrdinalIgnoreCase)
{
".asf",
".avi",
@@ -26,7 +27,7 @@ namespace Core.Utils
".wmv",
};
public static readonly HashSet<string> MacOSSupportedVideoFormats = new()
public static readonly HashSet<string> MacOSSupportedVideoFormats = new (StringComparer.OrdinalIgnoreCase)
{
".dv",
".m4v",
@@ -39,20 +40,20 @@ namespace Core.Utils
".webm",
};
public static readonly HashSet<string> LinuxSupportedVideoFormats = new()
public static readonly HashSet<string> LinuxSupportedVideoFormats = new (StringComparer.OrdinalIgnoreCase)
{
".ogv",
".vp8",
".webm",
};
public static readonly HashSet<string> AndroidSupportedVideoFormats = new()
public static readonly HashSet<string> AndroidSupportedVideoFormats = new (StringComparer.OrdinalIgnoreCase)
{
".webm",
".mp4",
};
public static readonly HashSet<string> iOSSupportedVideoFormats = new()
public static readonly HashSet<string> iOSSupportedVideoFormats = new (StringComparer.OrdinalIgnoreCase)
{
".webm",
".mp4",
@@ -67,7 +68,7 @@ namespace Core.Utils
RuntimePlatform.LinuxPlayer or RuntimePlatform.LinuxEditor => LinuxSupportedVideoFormats,
RuntimePlatform.IPhonePlayer => iOSSupportedVideoFormats,
RuntimePlatform.Android => AndroidSupportedVideoFormats,
_ => new HashSet<string> {".mp4" }
_ => new HashSet<string> (StringComparer.OrdinalIgnoreCase) {".mp4" }
};
}
}
+16 -16
View File
@@ -23,22 +23,22 @@ namespace Core.Utils
return new Color(rgba[0], rgba[1], rgba[2], rgba[3]);
}
public static unsafe void ApplyTransparencyBasedOnColorLuminance(Texture2D texture)
{
var pixels = texture.GetPixels();
fixed (float* src = &pixels[0].r)
{
var p = src;
for (var i = 0; i < texture.width * texture.height; i++, p += 4)
{
*(p + 3) = 0.299f * *p + 0.587f * *(p + 1) + 0.114f * *(p + 2);
}
}
texture.SetPixels(pixels);
texture.Apply();
}
// public static unsafe void ApplyTransparencyBasedOnColorLuminance(Texture2D texture)
// {
// var pixels = texture.GetPixels();
//
// fixed (float* src = &pixels[0].r)
// {
// var p = src;
// for (var i = 0; i < texture.width * texture.height; i++, p += 4)
// {
// *(p + 3) = 0.299f * *p + 0.587f * *(p + 1) + 0.114f * *(p + 2);
// }
// }
//
// texture.SetPixels(pixels);
// texture.Apply(updateMipmaps: false);
// }
public static T ReadStruct<T>(Stream stream) where T : struct
{
@@ -25,7 +25,7 @@ namespace Editor
Windows_x86 = 1 << 0,
Windows_x64 = 1 << 1,
Linux_x86_x64 = 1 << 2,
MacOS_arm64_x64 = 1 << 3,
macOS_arm64_x64 = 1 << 3,
Android = 1 << 4,
iOS = 1 << 5,
}
@@ -67,13 +67,13 @@ namespace Editor
}
#if PAL3
[MenuItem("PAL3/Build Pipelines/Build [MacOS_arm64_x64] IL2CPP XCode Project")]
[MenuItem("PAL3/Build Pipelines/Build [macOS_arm64_x64] IL2CPP XCode Project")]
#elif PAL3A
[MenuItem("PAL3A/Build Pipelines/Build [MacOS_arm64_x64] IL2CPP XCode Project")]
[MenuItem("PAL3A/Build Pipelines/Build [macOS_arm64_x64] IL2CPP XCode Project")]
#endif
public static void Build_MacOS_arm64_x64()
public static void Build_macOS_arm64_x64()
{
BuildGame(Pal3BuildTarget.MacOS_arm64_x64);
BuildGame(Pal3BuildTarget.macOS_arm64_x64);
}
#if PAL3
@@ -97,16 +97,16 @@ namespace Editor
}
#if PAL3
[MenuItem("PAL3/Build Pipelines/Build All [Windows, Linux, MacOS, Android, iOS]")]
[MenuItem("PAL3/Build Pipelines/Build All [Windows, Linux, macOS, Android, iOS]")]
#elif PAL3A
[MenuItem("PAL3A/Build Pipelines/Build All [Windows, Linux, MacOS, Android, iOS]")]
[MenuItem("PAL3A/Build Pipelines/Build All [Windows, Linux, macOS, Android, iOS]")]
#endif
public static void BuildAll()
{
BuildGame(Pal3BuildTarget.Windows_x86 |
Pal3BuildTarget.Windows_x64 |
Pal3BuildTarget.Linux_x86_x64 |
Pal3BuildTarget.MacOS_arm64_x64 |
Pal3BuildTarget.macOS_arm64_x64 |
Pal3BuildTarget.Android |
Pal3BuildTarget.iOS);
}
@@ -136,7 +136,7 @@ namespace Editor
new { Platform = Pal3BuildTarget.Windows_x86, Extension = ".exe", Group = BuildTargetGroup.Standalone, Target = BuildTarget.StandaloneWindows },
new { Platform = Pal3BuildTarget.Windows_x64, Extension = ".exe", Group = BuildTargetGroup.Standalone, Target = BuildTarget.StandaloneWindows64 },
new { Platform = Pal3BuildTarget.Linux_x86_x64, Extension = "", Group = BuildTargetGroup.Standalone, Target = BuildTarget.StandaloneLinux64 },
new { Platform = Pal3BuildTarget.MacOS_arm64_x64, Extension = "", Group = BuildTargetGroup.Standalone, Target = BuildTarget.StandaloneOSX },
new { Platform = Pal3BuildTarget.macOS_arm64_x64, Extension = "", Group = BuildTargetGroup.Standalone, Target = BuildTarget.StandaloneOSX },
new { Platform = Pal3BuildTarget.Android, Extension = ".apk", Group = BuildTargetGroup.Android, Target = BuildTarget.Android },
new { Platform = Pal3BuildTarget.iOS, Extension = "", Group = BuildTargetGroup.iOS, Target = BuildTarget.iOS },
};
+2 -2
View File
@@ -26,7 +26,7 @@ namespace Editor
BuildTargetGroup.Switch,
BuildTargetGroup.GameCoreXboxOne,
BuildTargetGroup.GameCoreXboxSeries,
BuildTargetGroup.VisionOS,
//BuildTargetGroup.VisionOS,
};
}
@@ -42,7 +42,7 @@ namespace Editor
NamedBuildTarget.tvOS,
NamedBuildTarget.NintendoSwitch,
NamedBuildTarget.WindowsStoreApps,
NamedBuildTarget.VisionOS,
//NamedBuildTarget.VisionOS,
};
}
+1
View File
@@ -7,6 +7,7 @@ namespace Pal3.Actor
{
using Core.DataReader.Scn;
using Core.GameBox;
using Core.Navigation;
using Data;
using MetaData;
using UnityEngine;
+11 -1
View File
@@ -7,6 +7,7 @@ namespace Pal3.Actor
{
using System;
using System.Collections.Generic;
using Controllers;
using Data;
using Dev;
using MetaData;
@@ -20,6 +21,9 @@ namespace Pal3.Actor
Tilemap tilemap,
bool isDropShadowEnabled,
Color tintColor,
float movementMaxYDifferential,
float movementMaxYDifferentialCrossLayer,
float movementMaxYDifferentialCrossPlatform,
Func<int, int[], HashSet<Vector2Int>> getAllActiveActorBlockingTilePositions)
{
var actorGameObject = new GameObject($"Actor_{actor.Info.Id}_{actor.Info.Name}")
@@ -63,7 +67,13 @@ namespace Pal3.Actor
}
var movementController = actorGameObject.AddComponent<ActorMovementController>();
movementController.Init(actor, tilemap, actionController, getAllActiveActorBlockingTilePositions);
movementController.Init(actor,
tilemap,
actionController,
movementMaxYDifferential,
movementMaxYDifferentialCrossLayer,
movementMaxYDifferentialCrossPlatform,
getAllActiveActorBlockingTilePositions);
var actorController = actorGameObject.AddComponent<ActorController>();
actorController.Init(actor, actionController, movementController);
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 9260c8ecdc555a84197706f7f99c4a7c
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -3,7 +3,7 @@
// See LICENSE file in the project root for license information.
// ---------------------------------------------------------------------------------------------
namespace Pal3.Actor
namespace Pal3.Actor.Controllers
{
using System;
using System.Collections;
@@ -336,7 +336,7 @@ namespace Pal3.Actor
}
else if (command.NewState == GameState.Gameplay)
{
PlayerActorId playerActor = ServiceLocator.Instance.Get<PlayerManager>().GetPlayerActor();
PlayerActorId playerActor = ServiceLocator.Instance.Get<PlayerActorManager>().GetPlayerActor();
_isKinematic = _actor.Info.Id != (byte)playerActor;
}
@@ -3,7 +3,7 @@
// See LICENSE file in the project root for license information.
// ---------------------------------------------------------------------------------------------
namespace Pal3.Actor
namespace Pal3.Actor.Controllers
{
using System;
using System.Collections;
@@ -13,6 +13,7 @@ namespace Pal3.Actor
using Core.Animation;
using Core.DataReader.Scn;
using Core.GameBox;
using Core.Navigation;
using Core.Services;
using Input;
using MetaData;
@@ -172,7 +173,7 @@ namespace Pal3.Actor
if (_actor.Info.Kind == ScnActorKind.CombatNpc &&
(_actor.Info.MonsterIds[0] != 0 || _actor.Info.MonsterIds[1] != 0 || _actor.Info.MonsterIds[2] != 0) &&
collision.gameObject.GetComponent<ActorController>() is {} actorController &&
(byte) ServiceLocator.Instance.Get<PlayerManager>()
(byte) ServiceLocator.Instance.Get<PlayerActorManager>()
.GetPlayerActor() == actorController.GetActor().Info.Id)
{
// Player actor collides with combat NPC in maze
@@ -3,7 +3,7 @@
// See LICENSE file in the project root for license information.
// ---------------------------------------------------------------------------------------------
namespace Pal3.Actor
namespace Pal3.Actor.Controllers
{
using System;
using System.Collections;
@@ -16,6 +16,7 @@ namespace Pal3.Actor
using Core.DataReader.Nav;
using Core.DataReader.Scn;
using Core.GameBox;
using Core.Navigation;
using Core.Utils;
using MetaData;
using Scene;
@@ -58,9 +59,6 @@ namespace Pal3.Actor
ICommandExecutor<ActorActivateCommand>,
ICommandExecutor<ActorSetNavLayerCommand>
{
private const float MAX_Y_DIFFERENTIAL = 2.2f;
private const float MAX_Y_DIFFERENTIAL_CROSS_LAYER = 2f;
private const float MAX_Y_DIFFERENTIAL_CROSS_PLATFORM = 2f;
private const float DEFAULT_ROTATION_SPEED = 20f;
private Actor _actor;
@@ -76,15 +74,27 @@ namespace Pal3.Actor
private readonly HashSet<ActiveColliderInfo> _activeColliders = new ();
private readonly HashSet<ActiveStandingPlatformInfo> _activeStandingPlatforms = new ();
private float _movementMaxYDifferential;
private float _movementMaxYDifferentialCrossLayer;
private float _movementMaxYDifferentialCrossPlatform;
private Func<int, int[], HashSet<Vector2Int>> _getAllActiveActorBlockingTilePositions;
public void Init(Actor actor, Tilemap tilemap, ActorActionController actionController,
public void Init(Actor actor,
Tilemap tilemap,
ActorActionController actionController,
float movementMaxYDifferential,
float movementMaxYDifferentialCrossLayer,
float movementMaxYDifferentialCrossPlatform,
Func<int, int[], HashSet<Vector2Int>> getAllActiveActorBlockingTilePositions)
{
_actor = actor;
_tilemap = tilemap;
_actionController = actionController;
_currentLayerIndex = actor.Info.LayerIndex;
_movementMaxYDifferential = movementMaxYDifferential;
_movementMaxYDifferentialCrossLayer = movementMaxYDifferentialCrossLayer;
_movementMaxYDifferentialCrossPlatform = movementMaxYDifferentialCrossPlatform;
_getAllActiveActorBlockingTilePositions = getAllActiveActorBlockingTilePositions;
Vector3 initPosition = GameBoxInterpreter.ToUnityPosition(new Vector3(
@@ -365,7 +375,7 @@ namespace Pal3.Actor
// Move actor on to the platform if platform is higher than current position
Vector3 currentPosition = transform.position;
var targetYPosition = standingPlatformController.GetPlatformHeight();
if (Mathf.Abs(currentPosition.y - targetYPosition) <= MAX_Y_DIFFERENTIAL_CROSS_PLATFORM &&
if (Mathf.Abs(currentPosition.y - targetYPosition) <= _movementMaxYDifferentialCrossPlatform &&
currentPosition.y < targetYPosition) // Don't move the actor if platform is lower
{
transform.position = new Vector3(currentPosition.x, targetYPosition, currentPosition.z);
@@ -502,9 +512,9 @@ namespace Pal3.Actor
switch (ignoreObstacle)
{
case false when Mathf.Abs(newYPosition - newPosition.y) > MAX_Y_DIFFERENTIAL:
case false when Mathf.Abs(newYPosition - newPosition.y) > _movementMaxYDifferential:
return MovementResult.Blocked;
case true when Mathf.Abs(newYPosition - newPosition.y) > MAX_Y_DIFFERENTIAL:
case true when Mathf.Abs(newYPosition - newPosition.y) > _movementMaxYDifferential:
newYPosition = currentPosition.y;
break;
}
@@ -595,7 +605,7 @@ namespace Pal3.Actor
// Make sure actor is on top of the platform
if (Utility.IsPointWithinCollider(platformInfo.Platform.GetCollider(),
new Vector3(newPosition.x, targetYPosition, newPosition.z), tolerance) &&
Mathf.Abs(currentPosition.y - targetYPosition) <= MAX_Y_DIFFERENTIAL_CROSS_PLATFORM)
Mathf.Abs(currentPosition.y - targetYPosition) <= _movementMaxYDifferentialCrossPlatform)
{
newYPosition = targetYPosition;
isNewPositionValid = true;
@@ -631,7 +641,7 @@ namespace Pal3.Actor
{
var yPositionAtNextLayer = GameBoxInterpreter.ToUnityYPosition(tileAtNextLayer.GameBoxYPosition);
if (Mathf.Abs(currentPosition.y - yPositionAtNextLayer) > MAX_Y_DIFFERENTIAL_CROSS_LAYER)
if (Mathf.Abs(currentPosition.y - yPositionAtNextLayer) > _movementMaxYDifferentialCrossLayer)
{
return false;
}
@@ -846,8 +856,7 @@ namespace Pal3.Actor
// Check if position at current layer exists, if not, auto switch
// to next layer (if tile at next layer is valid).
// If position at both layers are valid, switch to next layer.
// If current layer is not walkable but next layer is walkable.
// Also, switch to next layer if tile at current layer is obstacle.
if (_tilemap.GetLayerCount() > 1)
{
bool isTileExistsInCurrentLayer = _tilemap.TryGetTile(tilePosition,
@@ -860,7 +869,10 @@ namespace Pal3.Actor
SetNavLayer((_currentLayerIndex + 1) % 2);
}
else if (isTileExistsInCurrentLayer && isTileExistsInNextLayer &&
!tileAtCurrentLayer.IsWalkable() && tileAtNextLayer.IsWalkable())
tileAtCurrentLayer.DistanceToNearestObstacle == 0 &&
tileAtNextLayer.DistanceToNearestObstacle > 0)
// DO NOT USE IsWalkable() to check if tile is obstacle, because it can be
// overwritten by script (Ex: Tilemap.MarkFloorKindAsObstacle())
{
SetNavLayer((_currentLayerIndex + 1) % 2);
}
@@ -3,7 +3,7 @@
// See LICENSE file in the project root for license information.
// ---------------------------------------------------------------------------------------------
namespace Pal3.Actor
namespace Pal3.Actor.Controllers
{
using System;
using System.Collections;
@@ -11,6 +11,7 @@ namespace Pal3.Actor
using Command.InternalCommands;
using Command.SceCommands;
using Core.GameBox;
using Core.Navigation;
using Script.Waiter;
using UnityEngine;
@@ -5,11 +5,12 @@
#if PAL3
namespace Pal3.Actor
namespace Pal3.Actor.Controllers
{
using Command;
using Command.SceCommands;
using Core.GameBox;
using Core.Navigation;
using Core.Services;
using MetaData;
using Scene;
@@ -5,7 +5,7 @@
#if PAL3
namespace Pal3.Actor
namespace Pal3.Actor.Controllers
{
using Command;
using Command.SceCommands;
@@ -3,7 +3,7 @@
// See LICENSE file in the project root for license information.
// ---------------------------------------------------------------------------------------------
namespace Pal3.Actor
namespace Pal3.Actor.Controllers
{
using System;
using Command;
@@ -16,7 +16,8 @@ namespace Pal3.Actor
using Core.Extensions;
using Core.Utils;
using Data;
using Renderer;
using Rendering.Material;
using Rendering.Renderer;
using Script.Waiter;
using UnityEngine;
@@ -172,9 +173,7 @@ namespace Pal3.Actor
_skeletalModelRenderer == null ||
!_skeletalModelRenderer.IsVisible()) return;
_skeletalModelRenderer.PauseAnimation();
if (_autoStand && _skeletalModelRenderer.IsVisible())
if (_skeletalModelRenderer.IsVisible())
{
PerformAction(_actor.GetIdleAction());
}
@@ -3,7 +3,7 @@
// See LICENSE file in the project root for license information.
// ---------------------------------------------------------------------------------------------
namespace Pal3.Actor
namespace Pal3.Actor.Controllers
{
using System;
using Command;
@@ -18,7 +18,8 @@ namespace Pal3.Actor
using Core.Utils;
using Data;
using MetaData;
using Renderer;
using Rendering.Material;
using Rendering.Renderer;
using Script.Waiter;
using UnityEngine;
@@ -250,10 +251,9 @@ namespace Pal3.Actor
}
else
{
_mv3ModelRenderer.PauseAnimation();
_animationLoopPointWaiter?.CancelWait();
if (_autoStand && _mv3ModelRenderer.IsVisible())
if (_mv3ModelRenderer.IsVisible())
{
PerformAction(_actor.GetIdleAction());
}
+22 -48
View File
@@ -24,7 +24,7 @@ namespace Pal3.Audio
using State;
using UnityEngine;
public sealed class AudioManager : MonoBehaviour,
public sealed class AudioManager : IDisposable,
ICommandExecutor<PlaySfxCommand>,
ICommandExecutor<PlayMusicCommand>,
ICommandExecutor<AttachSfxToGameObjectRequest>,
@@ -36,11 +36,11 @@ namespace Pal3.Audio
ICommandExecutor<ResetGameStateCommand>,
ICommandExecutor<SettingChangedNotification>
{
private Camera _mainCamera;
private AudioSource _musicPlayer;
private GameResourceProvider _resourceProvider;
private SceneManager _sceneManager;
private GameSettings _gameSettings;
private readonly Camera _mainCamera;
private readonly AudioSource _musicPlayer;
private readonly GameResourceProvider _resourceProvider;
private readonly SceneManager _sceneManager;
private readonly GameSettings _gameSettings;
private const string STOP_MUSIC_NAME = "NONE";
@@ -57,9 +57,7 @@ namespace Pal3.Audio
private CancellationTokenSource _sceneAudioCts = new ();
private AudioClip _themeMusicClip;
public void Init(Camera mainCamera,
public AudioManager(Camera mainCamera,
GameResourceProvider resourceProvider,
SceneManager sceneManager,
AudioSource musicSource,
@@ -74,30 +72,14 @@ namespace Pal3.Audio
_musicVolume = _gameSettings.MusicVolume;
_sfxVolume = _gameSettings.SfxVolume;
// Load and play the theme music on init
_themeMusicClip = Requires.IsNotNull(
Resources.Load<AudioClip>($"Music/{GameConstants.AppName}-Theme"),
$"Music/{GameConstants.AppName}-Theme");
}
private void OnEnable()
{
CommandExecutorRegistry<ICommand>.Instance.Register(this);
}
private void OnDisable()
public void Dispose()
{
CommandExecutorRegistry<ICommand>.Instance.UnRegister(this);
}
public void PlayThemeMusic()
{
_musicPlayer.clip = _themeMusicClip;
_musicPlayer.volume = _musicVolume;
_musicPlayer.loop = true;
_musicPlayer.Play();
}
public void Execute(SettingChangedNotification command)
{
if (command.SettingName == nameof(_gameSettings.MusicVolume))
@@ -113,15 +95,15 @@ namespace Pal3.Audio
private IEnumerator PlaySceneMusicAsync(string cityName, string sceneName)
{
var key = $"{cityName}_{sceneName}";
var musicName = string.Empty;
if (MusicConstants.SceneMusicInfo.ContainsKey(key.ToLower()))
if (MusicConstants.SceneMusicInfo.TryGetValue($"{cityName}_{sceneName}".ToLower(), out var sceneMusic))
{
musicName = MusicConstants.SceneMusicInfo[key.ToLower()];
musicName = sceneMusic;
}
else if (MusicConstants.SceneMusicInfo.ContainsKey(cityName.ToLower()))
else if (MusicConstants.SceneMusicInfo.TryGetValue(cityName.ToLower(), out var sceneCityMusic))
{
musicName = MusicConstants.SceneMusicInfo[cityName.ToLower()];
musicName = sceneCityMusic;
}
if (string.IsNullOrEmpty(musicName) || musicName.Equals(STOP_MUSIC_NAME))
@@ -158,10 +140,6 @@ namespace Pal3.Audio
if (audioSource.clip != null)
{
audioSource.Stop();
if (audioSource.clip != _themeMusicClip)
{
Destroy(audioSource.clip);
}
}
audioSource.clip = audioClip;
@@ -293,14 +271,9 @@ namespace Pal3.Audio
if (audioSourceParentTransform.GetComponent<AudioSource>() is { } audioSource)
{
audioSource.Stop();
if (audioSource.clip != null)
{
Destroy(audioSource.clip);
}
}
Destroy(audioSourceParentTransform.gameObject);
UnityEngine.Object.Destroy(audioSourceParentTransform.gameObject);
}
_playingSfxSourceNames.Clear();
@@ -345,7 +318,7 @@ namespace Pal3.Audio
{
case 0: // start playing sfx indefinitely for the given sfxName
_playingSfxSourceNames.Add(sfxName);
StartCoroutine(AttachSfxToGameObjectAndPlaySfxAsync(_mainCamera.gameObject,
Pal3.Instance.StartCoroutine(AttachSfxToGameObjectAndPlaySfxAsync(_mainCamera.gameObject,
_resourceProvider.GetSfxFilePath(sfxName),
sfxName, // use sfx name as audio source name
loopCount: -1, // loop indefinitely
@@ -365,7 +338,7 @@ namespace Pal3.Audio
_playingSfxSourceNames.Add(sfxName);
var sfxFilePath = _resourceProvider.GetSfxFilePath(sfxName);
CancellationToken cancellationToken = _sceneAudioCts.Token;
StartCoroutine(AttachSfxToGameObjectAndPlaySfxAsync(_mainCamera.gameObject,
Pal3.Instance.StartCoroutine(AttachSfxToGameObjectAndPlaySfxAsync(_mainCamera.gameObject,
sfxFilePath,
sfxName, // use sfx name as audio source name
loopCount,
@@ -386,7 +359,7 @@ namespace Pal3.Audio
var sfxFilePath = _resourceProvider.GetSfxFilePath(request.SfxName);
CancellationToken cancellationToken = _sceneAudioCts.Token;
StartCoroutine(StartWithDelayAsync(request.StartDelayInSeconds,
Pal3.Instance.StartCoroutine(StartWithDelayAsync(request.StartDelayInSeconds,
AttachSfxToGameObjectAndPlaySfxAsync(request.Parent,
sfxFilePath,
request.AudioSourceName,
@@ -416,7 +389,7 @@ namespace Pal3.Audio
if (command.DisposeSource)
{
Destroy(audioSourceParent);
UnityEngine.Object.Destroy(audioSourceParent);
}
}
@@ -442,7 +415,7 @@ namespace Pal3.Audio
_currentMusicClipName = command.MusicName;
var musicFileVirtualPath = FileConstants.GetMusicFileVirtualPath(command.MusicName);
var musicFileCachePath = _resourceProvider.GetMusicFilePathInCacheFolder(musicFileVirtualPath);
StartCoroutine(PlayMusicAsync(command.MusicName,
Pal3.Instance.StartCoroutine(PlayMusicAsync(command.MusicName,
musicFileVirtualPath,
musicFileCachePath,
command.Loop == 0 ? -1 : command.Loop));
@@ -459,7 +432,7 @@ namespace Pal3.Audio
_currentMusicClipName = string.Empty;
ScnSceneInfo sceneInfo = _sceneManager.GetCurrentScene().GetSceneInfo();
StartCoroutine(PlaySceneMusicAsync(sceneInfo.CityName, sceneInfo.SceneName));
Pal3.Instance.StartCoroutine(PlaySceneMusicAsync(sceneInfo.CityName, sceneInfo.SceneName));
}
public void Execute(ScenePreLoadingNotification command)
@@ -473,7 +446,8 @@ namespace Pal3.Audio
{
if (string.IsNullOrEmpty(_currentScriptMusic))
{
StartCoroutine(PlaySceneMusicAsync(command.NewSceneInfo.CityName, command.NewSceneInfo.SceneName));
Pal3.Instance.StartCoroutine(
PlaySceneMusicAsync(command.NewSceneInfo.CityName, command.NewSceneInfo.SceneName));
}
}
+44 -47
View File
@@ -27,7 +27,7 @@ namespace Pal3.Camera
using UnityEngine.InputSystem.OnScreen;
using UnityEngine.UI;
public sealed class CameraManager : MonoBehaviour,
public sealed class CameraManager : IDisposable,
ICommandExecutor<CameraSetTransformCommand>,
ICommandExecutor<CameraSetDefaultTransformCommand>,
ICommandExecutor<CameraShakeEffectCommand>,
@@ -65,8 +65,8 @@ namespace Pal3.Camera
private const float CAMERA_SMOOTH_FOLLOW_TIME = 0.2f;
private const float CAMERA_SMOOTH_FOLLOW_MAX_DISTANCE = 7f;
private Camera _camera;
private Image _curtainImage;
private readonly Camera _camera;
private readonly Image _curtainImage;
private GameObject _lookAtGameObject;
private Vector3 _lastLookAtPoint = Vector3.zero;
@@ -81,14 +81,14 @@ namespace Pal3.Camera
private bool _shouldResetVelocity = false;
private int _currentAppliedDefaultTransformOption = 0;
private PlayerInputActions _inputActions;
private PlayerGamePlayController _gamePlayController;
private SceneManager _sceneManager;
private GameStateManager _gameStateManager;
private readonly PlayerInputActions _inputActions;
private readonly PlayerGamePlayManager _gamePlayManager;
private readonly SceneManager _sceneManager;
private readonly GameStateManager _gameStateManager;
private RectTransform _joyStickRectTransform;
private float _joyStickMovementRange;
private bool _isTouchEnabled;
private readonly RectTransform _joyStickRectTransform;
private readonly float _joyStickMovementRange;
private readonly bool _isTouchEnabled;
private bool _cameraAnimationInProgress;
private CancellationTokenSource _asyncCameraAnimationCts = new ();
@@ -102,8 +102,8 @@ namespace Pal3.Camera
Quaternion cameraRotation,
int transformOption)> _cameraLastKnownState = new ();
public void Init(PlayerInputActions inputActions,
PlayerGamePlayController gamePlayController,
public CameraManager(PlayerInputActions inputActions,
PlayerGamePlayManager gamePlayManager,
SceneManager sceneManager,
GameStateManager gameStateManager,
Camera mainCamera,
@@ -111,7 +111,7 @@ namespace Pal3.Camera
Image curtainImage)
{
_inputActions = Requires.IsNotNull(inputActions, nameof(inputActions));
_gamePlayController = Requires.IsNotNull(gamePlayController, nameof(gamePlayController));
_gamePlayManager = Requires.IsNotNull(gamePlayManager, nameof(gamePlayManager));
_sceneManager = Requires.IsNotNull(sceneManager, nameof(sceneManager));
_gameStateManager = Requires.IsNotNull(gameStateManager, nameof(gameStateManager));
@@ -126,19 +126,16 @@ namespace Pal3.Camera
_joyStickMovementRange = onScreenStick.movementRange;
var joyStickImage = onScreenStick.gameObject.GetComponent<Image>();
_joyStickRectTransform = joyStickImage.rectTransform;
}
private void OnEnable()
{
CommandExecutorRegistry<ICommand>.Instance.Register(this);
}
private void OnDisable()
public void Dispose()
{
CommandExecutorRegistry<ICommand>.Instance.UnRegister(this);
}
private void LateUpdate()
public void LateUpdate(float deltaTime)
{
if (!_cameraFollowPlayer)
{
@@ -152,7 +149,7 @@ namespace Pal3.Camera
{
_lastLookAtPoint = _lookAtGameObject.transform.position;
}
else if (_gamePlayController.TryGetPlayerActorLastKnownPosition(out Vector3 playerActorPosition))
else if (_gamePlayManager.TryGetPlayerActorLastKnownPosition(out Vector3 playerActorPosition))
{
_lastLookAtPoint = playerActorPosition;
}
@@ -191,24 +188,24 @@ namespace Pal3.Camera
return;
}
RotateCameraBasedOnUserInput();
RotateCameraBasedOnUserInput(deltaTime);
}
private void RotateCameraBasedOnUserInput()
private void RotateCameraBasedOnUserInput(float deltaTime)
{
if (_inputActions.Gameplay.RotateCameraClockwise.inProgress)
{
RotateToOrbitPoint(Time.deltaTime * CAMERA_ROTATION_SPEED_KEY_PRESS);
RotateToOrbitPoint(deltaTime * CAMERA_ROTATION_SPEED_KEY_PRESS);
}
else if (_inputActions.Gameplay.RotateCameraCounterClockwise.inProgress)
{
RotateToOrbitPoint(-Time.deltaTime * CAMERA_ROTATION_SPEED_KEY_PRESS);
RotateToOrbitPoint(-deltaTime * CAMERA_ROTATION_SPEED_KEY_PRESS);
}
var mouseScroll = _inputActions.Gameplay.OnScroll.ReadValue<float>();
if (mouseScroll != 0)
{
RotateToOrbitPoint(mouseScroll * Time.deltaTime * CAMERA_ROTATION_SPEED_SCROLL);
RotateToOrbitPoint(mouseScroll * deltaTime * CAMERA_ROTATION_SPEED_SCROLL);
}
if (!_isTouchEnabled) return;
@@ -220,7 +217,7 @@ namespace Pal3.Camera
if (IsTouchPositionOutsideVirtualJoyStickRange(startPosition))
{
RotateToOrbitPoint(touch0Delta * Time.deltaTime * CAMERA_ROTATION_SPEED_DRAG);
RotateToOrbitPoint(touch0Delta * deltaTime * CAMERA_ROTATION_SPEED_DRAG);
}
}
@@ -231,7 +228,7 @@ namespace Pal3.Camera
if (IsTouchPositionOutsideVirtualJoyStickRange(startPosition))
{
RotateToOrbitPoint(touch1Delta * Time.deltaTime * CAMERA_ROTATION_SPEED_DRAG);
RotateToOrbitPoint(touch1Delta * deltaTime * CAMERA_ROTATION_SPEED_DRAG);
}
}
}
@@ -489,7 +486,7 @@ namespace Pal3.Camera
{
if (!_asyncCameraAnimationCts.IsCancellationRequested) _asyncCameraAnimationCts.Cancel();
if (_gamePlayController.TryGetPlayerActorLastKnownPosition(out Vector3 playerActorPosition))
if (_gamePlayManager.TryGetPlayerActorLastKnownPosition(out Vector3 playerActorPosition))
{
_lastLookAtPoint = playerActorPosition;
}
@@ -537,7 +534,7 @@ namespace Pal3.Camera
var waiter = new WaitUntilCanceled();
CommandDispatcher<ICommand>.Instance.Dispatch(new ScriptRunnerAddWaiterRequest(waiter));
StartCoroutine(ShakeAsync(command.Duration,
Pal3.Instance.StartCoroutine(ShakeAsync(command.Duration,
GameBoxInterpreter.ToUnityDistance(command.Amplitude),
() => waiter.CancelWait()));
}
@@ -549,7 +546,7 @@ namespace Pal3.Camera
var waiter = new WaitUntilCanceled();
CommandDispatcher<ICommand>.Instance.Dispatch(new ScriptRunnerAddWaiterRequest(waiter));
Quaternion rotation = GameBoxInterpreter.ToUnityRotation(command.Pitch, command.Yaw, 0f);
StartCoroutine(OrbitAsync(rotation,
Pal3.Instance.StartCoroutine(OrbitAsync(rotation,
command.Duration,
(AnimationCurveType)command.CurveType,
0f,
@@ -569,7 +566,7 @@ namespace Pal3.Camera
var waiter = new WaitUntilCanceled();
CommandDispatcher<ICommand>.Instance.Dispatch(new ScriptRunnerAddWaiterRequest(waiter));
Quaternion rotation = GameBoxInterpreter.ToUnityRotation(command.Pitch, command.Yaw, 0f);
StartCoroutine(RotateAsync(rotation,
Pal3.Instance.StartCoroutine(RotateAsync(rotation,
command.Duration,
(AnimationCurveType)command.CurveType,
() => waiter.CancelWait()));
@@ -579,7 +576,7 @@ namespace Pal3.Camera
{
_asyncCameraAnimationCts = new CancellationTokenSource();
Quaternion rotation = GameBoxInterpreter.ToUnityRotation(command.Pitch, command.Yaw, 0f);
StartCoroutine(RotateAsync(rotation,
Pal3.Instance.StartCoroutine(RotateAsync(rotation,
command.Duration,
(AnimationCurveType)command.CurveType,
onFinished: null,
@@ -594,7 +591,7 @@ namespace Pal3.Camera
_cameraFadeAnimationCts = new CancellationTokenSource();
var waiter = new WaitUntilCanceled();
CommandDispatcher<ICommand>.Instance.Dispatch(new ScriptRunnerAddWaiterRequest(waiter));
StartCoroutine(FadeAsync(true,
Pal3.Instance.StartCoroutine(FadeAsync(true,
FADE_ANIMATION_DURATION,
Color.black,
() => waiter.CancelWait(),
@@ -607,7 +604,7 @@ namespace Pal3.Camera
_cameraFadeAnimationCts = new CancellationTokenSource();
var waiter = new WaitUntilCanceled();
CommandDispatcher<ICommand>.Instance.Dispatch(new ScriptRunnerAddWaiterRequest(waiter));
StartCoroutine(FadeAsync(true,
Pal3.Instance.StartCoroutine(FadeAsync(true,
FADE_ANIMATION_DURATION,
Color.white,
() => waiter.CancelWait(),
@@ -620,7 +617,7 @@ namespace Pal3.Camera
_cameraFadeAnimationCts = new CancellationTokenSource();
var waiter = new WaitUntilCanceled();
CommandDispatcher<ICommand>.Instance.Dispatch(new ScriptRunnerAddWaiterRequest(waiter));
StartCoroutine(FadeAsync(false,
Pal3.Instance.StartCoroutine(FadeAsync(false,
FADE_ANIMATION_DURATION,
Color.black,
() => waiter.CancelWait(),
@@ -633,7 +630,7 @@ namespace Pal3.Camera
_cameraFadeAnimationCts = new CancellationTokenSource();
var waiter = new WaitUntilCanceled();
CommandDispatcher<ICommand>.Instance.Dispatch(new ScriptRunnerAddWaiterRequest(waiter));
StartCoroutine(FadeAsync(false,
Pal3.Instance.StartCoroutine(FadeAsync(false,
FADE_ANIMATION_DURATION,
Color.white,
() => waiter.CancelWait(),
@@ -653,7 +650,7 @@ namespace Pal3.Camera
var waiter = new WaitUntilCanceled();
CommandDispatcher<ICommand>.Instance.Dispatch(new ScriptRunnerAddWaiterRequest(waiter));
var distance = GameBoxInterpreter.ToUnityDistance(command.GameBoxDistance);
StartCoroutine(PushAsync(distance,
Pal3.Instance.StartCoroutine(PushAsync(distance,
command.Duration,
(AnimationCurveType)command.CurveType,
() => waiter.CancelWait()));
@@ -663,7 +660,7 @@ namespace Pal3.Camera
{
_asyncCameraAnimationCts = new CancellationTokenSource();
var distance = GameBoxInterpreter.ToUnityDistance(command.GameBoxDistance);
StartCoroutine(PushAsync(distance,
Pal3.Instance.StartCoroutine(PushAsync(distance,
command.Duration,
(AnimationCurveType)command.CurveType,
onFinished: null,
@@ -688,7 +685,7 @@ namespace Pal3.Camera
command.GameBoxXPosition,
command.GameBoxYPosition,
command.GameBoxZPosition));
StartCoroutine(MoveAsync(position,
Pal3.Instance.StartCoroutine(MoveAsync(position,
command.Duration,
(AnimationCurveType)command.CurveType,
() => waiter.CancelWait()));
@@ -701,7 +698,7 @@ namespace Pal3.Camera
command.GameBoxXPosition,
command.GameBoxYPosition,
command.GameBoxZPosition));
StartCoroutine(MoveAsync(position,
Pal3.Instance.StartCoroutine(MoveAsync(position,
command.Duration,
(AnimationCurveType)command.CurveType,
onFinished: null,
@@ -816,7 +813,7 @@ namespace Pal3.Camera
var waiter = new WaitUntilCanceled();
CommandDispatcher<ICommand>.Instance.Dispatch(new ScriptRunnerAddWaiterRequest(waiter));
Quaternion rotation = GameBoxInterpreter.ToUnityRotation(command.Pitch, command.Yaw, 0f);
StartCoroutine(OrbitAsync(rotation,
Pal3.Instance.StartCoroutine(OrbitAsync(rotation,
command.Duration,
(AnimationCurveType)command.CurveType,
distanceDelta,
@@ -826,7 +823,7 @@ namespace Pal3.Camera
{
_asyncCameraAnimationCts = new CancellationTokenSource();
Quaternion rotation = GameBoxInterpreter.ToUnityRotation(command.Pitch, command.Yaw, 0f);
StartCoroutine(OrbitAsync(rotation,
Pal3.Instance.StartCoroutine(OrbitAsync(rotation,
command.Duration,
(AnimationCurveType)command.CurveType,
distanceDelta,
@@ -848,7 +845,7 @@ namespace Pal3.Camera
var waiter = new WaitUntilCanceled();
CommandDispatcher<ICommand>.Instance.Dispatch(new ScriptRunnerAddWaiterRequest(waiter));
Quaternion rotation = GameBoxInterpreter.ToUnityRotation(command.Pitch, command.Yaw, 0f);
StartCoroutine(OrbitAsync(rotation,
Pal3.Instance.StartCoroutine(OrbitAsync(rotation,
command.Duration,
(AnimationCurveType)command.CurveType,
distanceDelta,
@@ -858,7 +855,7 @@ namespace Pal3.Camera
{
_asyncCameraAnimationCts = new CancellationTokenSource();
Quaternion rotation = GameBoxInterpreter.ToUnityRotation(command.Pitch, command.Yaw, 0f);
StartCoroutine(OrbitAsync(rotation,
Pal3.Instance.StartCoroutine(OrbitAsync(rotation,
command.Duration,
(AnimationCurveType)command.CurveType,
distanceDelta,
@@ -883,7 +880,7 @@ namespace Pal3.Camera
command.GameBoxXPosition,
command.GameBoxYPosition,
command.GameBoxZPosition));
StartCoroutine(MoveAsync(position,
Pal3.Instance.StartCoroutine(MoveAsync(position,
duration,
AnimationCurveType.Sine,
() => waiter.CancelWait()));
@@ -895,7 +892,7 @@ namespace Pal3.Camera
command.GameBoxXPosition,
command.GameBoxYPosition,
command.GameBoxZPosition));
StartCoroutine(MoveAsync(position,
Pal3.Instance.StartCoroutine(MoveAsync(position,
duration,
AnimationCurveType.Sine,
onFinished: null,
@@ -910,10 +907,10 @@ namespace Pal3.Camera
var waiter = new WaitUntilCanceled();
CommandDispatcher<ICommand>.Instance.Dispatch(new ScriptRunnerAddWaiterRequest(waiter));
if (_gamePlayController.TryGetPlayerActorLastKnownPosition(out Vector3 playerActorPosition))
if (_gamePlayManager.TryGetPlayerActorLastKnownPosition(out Vector3 playerActorPosition))
{
Vector3 position = _cameraOffset + playerActorPosition;
StartCoroutine(MoveAsync(position,
Pal3.Instance.StartCoroutine(MoveAsync(position,
command.Duration,
AnimationCurveType.Sine,
() => waiter.CancelWait()));
@@ -11,6 +11,10 @@ namespace Pal3.Command
using System.Reflection;
using UnityEngine;
/// <summary>
/// A generic class that dispatches commands to their registered executors.
/// </summary>
/// <typeparam name="TCommand">The type of command to dispatch.</typeparam>
public class CommandDispatcher<TCommand>
{
public static CommandDispatcher<TCommand> Instance
@@ -11,16 +11,19 @@ namespace Pal3.Command.InternalCommands
public ThreePhaseSwitchStateChangedNotification(
int objectId,
int previousState,
int currentState)
int currentState,
bool isBridgeMovingAlongYAxis)
{
ObjectId = objectId;
PreviousState = previousState;
CurrentState = currentState;
IsBridgeMovingAlongYAxis = isBridgeMovingAlongYAxis;
}
public int ObjectId { get; }
public int PreviousState { get; }
public int CurrentState { get; }
public bool IsBridgeMovingAlongYAxis { get; }
}
#endif
}
@@ -17,23 +17,16 @@ namespace Pal3.Data
using Core.DataLoader;
using Core.DataReader;
using Core.DataReader.Cpk;
using Core.DataReader.Cvd;
using Core.DataReader.Dat;
using Core.DataReader.Data;
using Core.DataReader.Gdb;
using Core.DataReader.Ini;
using Core.DataReader.Lgt;
using Core.DataReader.Mov;
using Core.DataReader.Msh;
using Core.DataReader.Mtl;
using Core.DataReader.Mv3;
using Core.DataReader.Nav;
using Core.DataReader.Pol;
using Core.DataReader.Sce;
using Core.DataReader.Scn;
using Core.FileSystem;
using Core.Services;
using Core.Utils;
using MetaData;
using Renderer;
using Rendering.Material;
using Settings;
using UnityEngine;
using Object = UnityEngine.Object;
@@ -43,12 +36,13 @@ namespace Pal3.Data
/// Also manages the lifecycle of the resource it provides.
/// </summary>
public sealed class GameResourceProvider : IDisposable,
ICommandExecutor<ScenePreLoadingNotification>
ICommandExecutor<ScenePreLoadingNotification>,
ICommandExecutor<SettingChangedNotification>
{
private const string CACHE_FOLDER_NAME = "CacheData";
private const string MV3_ACTOR_CONFIG_HEADER = ";#MV3#";
private const char DirSeparator = CpkConstants.DirectorySeparatorChar;
private const char DIR_SEPARATOR = CpkConstants.DirectorySeparatorChar;
private readonly ICpkFileSystem _fileSystem;
private readonly ITextureLoaderFactory _textureLoaderFactory;
@@ -64,15 +58,13 @@ namespace Pal3.Data
private readonly Dictionary<string, AudioClip> _audioClipCache = new ();
private readonly Dictionary<int, Object> _vfxEffectPrefabCache = new ();
private readonly Dictionary<string, ActorActionConfig> _actorConfigCache = new (); // Cache forever
private readonly Dictionary<Type, Dictionary<string, object>> _gameResourceFileCache = new ();
// Cache player actor movement sfx audio clips
private readonly HashSet<string> _audioClipCacheList = AudioConstants.PlayerActorMovementSfxAudioFileNames;
// No need to deallocate the shadow texture since it is been used almost every where.
private static readonly Texture2D ShadowTexture = Resources.Load<Texture2D>("Textures/shadow");
private readonly int _codepage;
public GameResourceProvider(ICpkFileSystem fileSystem,
ITextureLoaderFactory textureLoaderFactory,
IMaterialFactory unlitMaterialFactory,
@@ -85,6 +77,7 @@ namespace Pal3.Data
_litMaterialFactory = litMaterialFactory; // Lit materials are not required
_gameSettings = Requires.IsNotNull(gameSettings, nameof(gameSettings));
_codepage = _gameSettings.Language == Language.SimplifiedChinese ? 936 : 950;
_gameDatabase = GetGameDatabaseFile(); // Initialize game database file
CommandExecutorRegistry<ICommand>.Instance.Register(this);
@@ -93,23 +86,33 @@ namespace Pal3.Data
private GdbFile GetGameDatabaseFile()
{
var gdbFilePath = FileConstants.GameDatabaseFileVirtualPath;
return GetGameResourceFileReader<GdbFile>().Read(_fileSystem.ReadAllBytes(gdbFilePath));
}
private IFileReader<T> GetGameResourceFileReader<T>()
{
return ServiceLocator.Instance.Get<IFileReader<T>>();
return GetGameResourceFile<GdbFile>(gdbFilePath);
}
public void Dispose()
{
_textureCache?.DisposeAll();
_spriteCache.Clear();
_gameResourceFileCache.Clear();
_actorConfigCache.Clear();
_audioClipCache.Clear();
_vfxEffectPrefabCache.Clear();
CommandExecutorRegistry<ICommand>.Instance.UnRegister(this);
_textureCache?.DisposeAll();
foreach (Sprite sprite in _spriteCache.Values)
{
Object.Destroy(sprite);
}
_spriteCache.Clear();
foreach (AudioClip audioClip in _audioClipCache.Values)
{
Object.Destroy(audioClip);
}
_audioClipCache.Clear();
_vfxEffectPrefabCache.Clear();
_unlitMaterialFactory?.DeallocateMaterialPool();
_litMaterialFactory?.DeallocateMaterialPool();
_gameResourceFileCache.Clear();
}
public void UseTextureCache(TextureCache textureCache)
@@ -141,7 +144,7 @@ namespace Pal3.Data
new TextureProvider(_fileSystem, _textureLoaderFactory, relativeDirectoryPath);
}
public T GetGameResourceFile<T>(string fileVirtualPath, bool useCache = true)
public T GetGameResourceFile<T>(string fileVirtualPath, bool useCache = true, byte[] data = null)
{
fileVirtualPath = fileVirtualPath.ToLower();
@@ -152,7 +155,8 @@ namespace Pal3.Data
return (T)_gameResourceFileCache[typeof(T)][fileVirtualPath];
}
T file = GetGameResourceFileReader<T>().Read(_fileSystem.ReadAllBytes(fileVirtualPath));
T file = ServiceLocator.Instance.Get<IFileReader<T>>().Read(
data ?? _fileSystem.ReadAllBytes(fileVirtualPath), _codepage);
if (useCache)
{
@@ -167,39 +171,24 @@ namespace Pal3.Data
return file;
}
public NavFile GetNavFile(string sceneFileName, string sceneName)
public IDictionary<int, GameItemInfo> GetGameItemInfos()
{
var navFilePath = FileConstants.GetNavFileVirtualPath(sceneFileName, sceneName);
return GetGameResourceFileReader<NavFile>().Read(_fileSystem.ReadAllBytes(navFilePath));
return _gameDatabase.GameItemInfos;
}
public ScnFile GetScnFile(string sceneFileName, string sceneName)
public IDictionary<int, CombatActorInfo> GetCombatActorInfos()
{
var scnFilePath = FileConstants.GetScnFileVirtualPath(sceneFileName, sceneName);
return GetGameResourceFileReader<ScnFile>().Read(_fileSystem.ReadAllBytes(scnFilePath));
return _gameDatabase.CombatActorInfos;
}
public SceFile GetSceneSceFile(string sceneFileName)
public IDictionary<int, SkillInfo> GetSkillInfos()
{
var sceFilePath = FileConstants.GetSceneSceFileVirtualPath(sceneFileName);
return GetGameResourceFileReader<SceFile>().Read(_fileSystem.ReadAllBytes(sceFilePath));
return _gameDatabase.SkillInfos;
}
public SceFile GetSystemSceFile()
public IDictionary<int, ComboSkillInfo> GetComboSkillInfos()
{
var systemSceFilePath = FileConstants.SystemSceFileVirtualPath;
return GetGameResourceFileReader<SceFile>().Read(_fileSystem.ReadAllBytes(systemSceFilePath));
}
public SceFile GetBigMapSceFile()
{
var bigMapSceFilePath = FileConstants.BigMapSceFileVirtualPath;
return GetGameResourceFileReader<SceFile>().Read(_fileSystem.ReadAllBytes(bigMapSceFilePath));
}
public Dictionary<int, GameItem> GetGameItems()
{
return _gameDatabase.GameItems;
return _gameDatabase.ComboSkillInfos;
}
/// <summary>
@@ -275,16 +264,13 @@ namespace Pal3.Data
bool streamAudio,
Action<AudioClip> onLoaded)
{
var fileName = Path.GetFileName(filePath);
var shouldCache = _audioClipCacheList.Contains(fileName);
string cacheKey = filePath.ToLower();
if (shouldCache && _audioClipCache.ContainsKey(fileName))
if (_audioClipCache.ContainsKey(cacheKey) &&
_audioClipCache[cacheKey] != null)
{
if (_audioClipCache[fileName] != null) // check if clip has been destroyed
{
onLoaded?.Invoke(_audioClipCache[fileName]);
yield break;
}
onLoaded?.Invoke(_audioClipCache[cacheKey]);
yield break;
}
yield return AudioClipLoader.LoadAudioClipAsync(filePath,
@@ -292,11 +278,7 @@ namespace Pal3.Data
streamAudio,
audioClip =>
{
if (shouldCache && audioClip != null)
{
_audioClipCache[fileName] = audioClip;
}
_audioClipCache[cacheKey] = audioClip;
onLoaded?.Invoke(audioClip);
});
}
@@ -366,13 +348,13 @@ namespace Pal3.Data
var relativeFilePath = string.Format(FileConstants.SkyBoxTexturePathFormat.First(), skyBoxId);
ITextureResourceProvider textureProvider = CreateTextureResourceProvider(
Utility.GetDirectoryName(relativeFilePath, DirSeparator));
Utility.GetDirectoryName(relativeFilePath, DIR_SEPARATOR));
var textures = new Texture2D[FileConstants.SkyBoxTexturePathFormat.Length];
for (var i = 0; i < FileConstants.SkyBoxTexturePathFormat.Length; i++)
{
var textureNameFormat = Utility.GetFileName(
string.Format(FileConstants.SkyBoxTexturePathFormat[i], skyBoxId), DirSeparator);
string.Format(FileConstants.SkyBoxTexturePathFormat[i], skyBoxId), DIR_SEPARATOR);
Texture2D texture = textureProvider.GetTexture(string.Format(textureNameFormat, i));
// Set wrap mode to clamp to remove "edges" between sides
texture.wrapMode = TextureWrapMode.Clamp;
@@ -458,14 +440,8 @@ namespace Pal3.Data
actorConfigFilePath = actorConfigFilePath.ToLower();
if (_actorConfigCache.TryGetValue(actorConfigFilePath, out ActorActionConfig actorActionConfig))
if (!FileExists(actorConfigFilePath))
{
return actorActionConfig;
}
if (!_fileSystem.FileExists(actorConfigFilePath))
{
_actorConfigCache[actorConfigFilePath] = null;
return null;
}
@@ -474,15 +450,11 @@ namespace Pal3.Data
if (string.Equals(MV3_ACTOR_CONFIG_HEADER, configHeaderStr))
{
Mv3ActionConfig config = GetGameResourceFileReader<Mv3ActionConfig>().Read(configData);
_actorConfigCache[actorConfigFilePath] = config;
return config;
return GetGameResourceFile<Mv3ActionConfig>(actorConfigFilePath, data: configData);
}
else // MOV actor config
{
MovActionConfig config = GetGameResourceFileReader<MovActionConfig>().Read(configData);
_actorConfigCache[actorConfigFilePath] = config;
return config;
return GetGameResourceFile<MovActionConfig>(actorConfigFilePath, data: configData);
}
}
@@ -492,29 +464,29 @@ namespace Pal3.Data
if (!Directory.Exists(videoFolder))
{
throw new Exception($"Video directory does not exists: {videoFolder}.");
throw new DirectoryNotFoundException($"Video directory does not exists: {videoFolder}.");
}
var supportedVideoFormats = UnitySupportedVideoFormats.GetSupportedVideoFormats(Application.platform);
foreach (FileInfo file in new DirectoryInfo(videoFolder).GetFiles($"*.*", SearchOption.AllDirectories))
{
var fileExtension = Path.GetExtension(file.Name);
if (supportedVideoFormats.Contains(fileExtension.ToLower()) &&
Path.GetFileNameWithoutExtension(file.Name).ToLower().Equals(videoName.ToLower()))
var fileExtension = Path.GetExtension(file.Name).ToLower();
if (supportedVideoFormats.Contains(fileExtension) &&
Path.GetFileNameWithoutExtension(file.Name).Equals(videoName, StringComparison.OrdinalIgnoreCase))
{
return file.FullName;
}
}
throw new Exception($"Cannot find video file: {videoName} under path: {videoFolder}. " +
throw new FileNotFoundException($"Cannot find video file: {videoName} under path: {videoFolder}. " +
$"Supported video formats are: {string.Join(" ", supportedVideoFormats)}.");
}
public (Texture2D texture, bool hasAlphaChannel)[] GetEffectTextures(GraphicsEffect effect, string texturePathFormat)
{
ITextureResourceProvider textureProvider = CreateTextureResourceProvider(
Utility.GetDirectoryName(texturePathFormat, DirSeparator));
Utility.GetDirectoryName(texturePathFormat, DIR_SEPARATOR));
if (effect == GraphicsEffect.Fire)
{
@@ -522,7 +494,7 @@ namespace Pal3.Data
var textures = new (Texture2D texture, bool hasAlphaChannel)[numberOfFrames];
for (var i = 0; i < numberOfFrames; i++)
{
var textureNameFormat = Utility.GetFileName(texturePathFormat, DirSeparator);
var textureNameFormat = Utility.GetFileName(texturePathFormat, DIR_SEPARATOR);
Texture2D texture = textureProvider.GetTexture(string.Format(textureNameFormat, i + 1), out var hasAlphaChannel);
textures[i] = (texture, hasAlphaChannel);
}
@@ -633,7 +605,7 @@ namespace Pal3.Data
{
// Dispose non-main actor mv3 files
// All main actor names start with "1"
var mainActorMv3 = $"{FileConstants.GetActorFolderName()}{DirSeparator}1".ToLower();
var mainActorMv3 = $"{FileConstants.GetActorFolderName()}{DIR_SEPARATOR}1".ToLower();
var mv3FilesToDispose = fileCache.Value.Keys
.Where(mv3FilePath => !mv3FilePath.Contains(mainActorMv3))
.ToArray();
@@ -644,7 +616,9 @@ namespace Pal3.Data
}
else if (fileCache.Key == typeof(GdbFile) ||
fileCache.Key == typeof(Mv3ActionConfig) ||
fileCache.Key == typeof(MovActionConfig))
fileCache.Key == typeof(MovActionConfig) ||
fileCache.Key == typeof(EffectDefinitionFile) ||
fileCache.Key == typeof(EffectLinkerFile))
{
// These files are used/cached across scenes
// Do not dispose them since they will be used in next scene block
@@ -658,5 +632,23 @@ namespace Pal3.Data
// clear all vfx prefabs in cache
_vfxEffectPrefabCache.Clear();
}
public void Execute(SettingChangedNotification command)
{
// Need to deallocate and reallocate material pool when switching between lit and unlit materials
if (command.SettingName == nameof(_gameSettings.IsRealtimeLightingAndShadowsEnabled))
{
if (_gameSettings.IsRealtimeLightingAndShadowsEnabled)
{
_unlitMaterialFactory?.DeallocateMaterialPool();
_litMaterialFactory?.AllocateMaterialPool();
}
else
{
_litMaterialFactory?.DeallocateMaterialPool();
_unlitMaterialFactory?.AllocateMaterialPool();
}
}
}
}
}
+63 -52
View File
@@ -34,7 +34,7 @@ namespace Pal3.Dev
using UnityEngine.Rendering;
using UnityEngine.UI;
public sealed class MainMenu : MonoBehaviour,
public sealed class MainMenu : IDisposable,
ICommandExecutor<ToggleMainMenuRequest>,
ICommandExecutor<GameSwitchToMainMenuCommand>,
ICommandExecutor<ScenePostLoadingNotification>,
@@ -42,38 +42,35 @@ namespace Pal3.Dev
{
private const int SAVE_SLOT_COUNT = 5;
private GameSettings _gameSettings;
private AudioManager _audioManager;
private InputManager _inputManager;
private EventSystem _eventSystem;
private PlayerInputActions _playerInputActions;
private ScriptManager _scriptManager;
private TeamManager _teamManager;
private GameStateManager _gameStateManager;
private SceneManager _sceneManager;
private SaveManager _saveManager;
private InformationManager _informationManager;
private MazeSkipper _mazeSkipper;
private readonly GameSettings _gameSettings;
private readonly InputManager _inputManager;
private readonly EventSystem _eventSystem;
private readonly PlayerInputActions _playerInputActions;
private readonly ScriptManager _scriptManager;
private readonly TeamManager _teamManager;
private readonly GameStateManager _gameStateManager;
private readonly SceneManager _sceneManager;
private readonly SaveManager _saveManager;
private readonly InformationManager _informationManager;
private readonly MazeSkipper _mazeSkipper;
private CanvasGroup _mainMenuCanvasGroup;
private GameObject _menuButtonPrefab;
private RectTransform _backgroundTransform;
private RectTransform _contentTransform;
private GridLayoutGroup _contentGridLayoutGroup;
private ScrollRect _contentScrollRect;
private readonly CanvasGroup _mainMenuCanvasGroup;
private readonly GameObject _menuButtonPrefab;
private readonly RectTransform _backgroundTransform;
private readonly RectTransform _contentTransform;
private readonly GridLayoutGroup _contentGridLayoutGroup;
private readonly ScrollRect _contentScrollRect;
private bool _isInInitView = true;
private CancellationTokenSource _initViewCameraOrbitAnimationCts = new ();
private Camera _mainCamera;
private readonly Camera _mainCamera;
private readonly List<string> _deferredExecutionCommands = new();
private readonly List<GameObject> _menuItems = new();
public void Init(GameSettings gameSettings,
AudioManager audioManager,
public MainMenu(GameSettings gameSettings,
InputManager inputManager,
EventSystem eventSystem,
SceneManager sceneManager,
GameStateManager gameStateManager,
ScriptManager scriptManager,
@@ -86,12 +83,11 @@ namespace Pal3.Dev
ScrollRect contentScrollRect,
RectTransform backgroundTransform,
RectTransform contentTransform,
EventSystem eventSystem,
Camera mainCamera)
{
_gameSettings = Requires.IsNotNull(gameSettings, nameof(gameSettings));
_audioManager = Requires.IsNotNull(audioManager, nameof(audioManager));
_inputManager = Requires.IsNotNull(inputManager, nameof(inputManager));
_eventSystem = Requires.IsNotNull(eventSystem, nameof(eventSystem));
_sceneManager = Requires.IsNotNull(sceneManager, nameof(sceneManager));
_gameStateManager = Requires.IsNotNull(gameStateManager, nameof(gameStateManager));
_scriptManager = Requires.IsNotNull(scriptManager, nameof(scriptManager));
@@ -104,6 +100,7 @@ namespace Pal3.Dev
_contentScrollRect = Requires.IsNotNull(contentScrollRect, nameof(contentScrollRect));
_backgroundTransform = Requires.IsNotNull(backgroundTransform, nameof(backgroundTransform));
_contentTransform = Requires.IsNotNull(contentTransform, nameof(contentTransform));
_eventSystem = Requires.IsNotNull(eventSystem, nameof(eventSystem));
_mainCamera = Requires.IsNotNull(mainCamera, nameof(mainCamera));
_contentGridLayoutGroup = Requires.IsNotNull(
@@ -115,21 +112,18 @@ namespace Pal3.Dev
_mainMenuCanvasGroup.interactable = false;
_playerInputActions.Gameplay.ToggleStorySelector.performed += ToggleMainMenuPerformed;
_playerInputActions.Cutscene.ToggleStorySelector.performed += ToggleMainMenuPerformed;
_playerInputActions.Cutscene.ExitCurrentShowingMenu.performed += HideMainMenuPerformed;
}
_playerInputActions.UI.ToggleStorySelector.performed += ToggleMainMenuPerformed;
_playerInputActions.UI.ExitCurrentShowingMenu.performed += HideMainMenuPerformed;
private void OnEnable()
{
CommandExecutorRegistry<ICommand>.Instance.Register(this);
}
private void OnDisable()
public void Dispose()
{
CommandExecutorRegistry<ICommand>.Instance.UnRegister(this);
_playerInputActions.Gameplay.ToggleStorySelector.performed -= ToggleMainMenuPerformed;
_playerInputActions.Cutscene.ToggleStorySelector.performed -= ToggleMainMenuPerformed;
_playerInputActions.Cutscene.ExitCurrentShowingMenu.performed -= HideMainMenuPerformed;
_playerInputActions.UI.ToggleStorySelector.performed -= ToggleMainMenuPerformed;
_playerInputActions.UI.ExitCurrentShowingMenu.performed -= HideMainMenuPerformed;
}
private void ToggleMainMenuPerformed(InputAction.CallbackContext _)
@@ -144,7 +138,7 @@ namespace Pal3.Dev
if (_mainMenuCanvasGroup.interactable)
{
HideMenu();
_gameStateManager.GoToState(GameState.Gameplay);
_gameStateManager.TryGoToState(GameState.Gameplay);
}
}
@@ -155,7 +149,7 @@ namespace Pal3.Dev
if (_mainMenuCanvasGroup.interactable)
{
HideMenu();
_gameStateManager.GoToState(GameState.Gameplay);
_gameStateManager.TryGoToState(GameState.Gameplay);
}
else if (_gameStateManager.GetCurrentState() == GameState.Gameplay)
{
@@ -167,7 +161,6 @@ namespace Pal3.Dev
{
#if PAL3
// 景天房间
_deferredExecutionCommands.Add("ActorActivate 0 0");
_deferredExecutionCommands.Add("SceneActivateObject 14 0");
_deferredExecutionCommands.Add("SceneActivateObject 15 0");
_deferredExecutionCommands.Add("PlayerEnableInput 0");
@@ -175,26 +168,25 @@ namespace Pal3.Dev
_deferredExecutionCommands.Add("CameraSetTransform -33.24 -19.48 688.0 308.31 240.44 480.61");
_deferredExecutionCommands.Add("CameraFadeIn");
CommandDispatcher<ICommand>.Instance.Dispatch(new SceneLoadCommand("q01", "yn09a"));
CommandDispatcher<ICommand>.Instance.Dispatch(new PlayMusicCommand(AudioConstants.ThemeMusicName, -1));
#elif PAL3A
// 南宫煌房间
_deferredExecutionCommands.Add("ActorActivate 0 0");
_deferredExecutionCommands.Add("PlayerEnableInput 0");
_deferredExecutionCommands.Add("CameraFollowPlayer 0");
_deferredExecutionCommands.Add("CameraSetTransform -21.69 -22.48 688.0 182.87 263.07 531.61");
_deferredExecutionCommands.Add("CameraFadeIn");
CommandDispatcher<ICommand>.Instance.Dispatch(new SceneLoadCommand("q02", "qn08y"));
CommandDispatcher<ICommand>.Instance.Dispatch(new PlayMusicCommand(AudioConstants.ThemeMusicName, -1));
#endif
_audioManager.PlayThemeMusic();
if (!_initViewCameraOrbitAnimationCts.IsCancellationRequested)
{
_initViewCameraOrbitAnimationCts.Cancel();
}
_initViewCameraOrbitAnimationCts = new CancellationTokenSource();
StartCoroutine(StartCameraOrbitAnimationAsync(_initViewCameraOrbitAnimationCts.Token));
Pal3.Instance.StartCoroutine(StartCameraOrbitAnimationAsync(_initViewCameraOrbitAnimationCts.Token));
_gameStateManager.GoToState(GameState.Cutscene);
_gameStateManager.TryGoToState(GameState.UI);
}
private IEnumerator StartCameraOrbitAnimationAsync(CancellationToken cancellationToken)
@@ -239,7 +231,7 @@ namespace Pal3.Dev
public void ShowMenu()
{
_gameStateManager.GoToState(GameState.Cutscene);
_gameStateManager.TryGoToState(GameState.UI);
CommandDispatcher<ICommand>.Instance.Dispatch(
new ActorStopActionAndStandCommand(ActorConstants.PlayerActorVirtualID));
SetupMainMenuButtons();
@@ -272,7 +264,7 @@ namespace Pal3.Dev
CreateMenuButton("返回游戏", _ => delegate
{
HideMenu();
_gameStateManager.GoToState(GameState.Gameplay);
_gameStateManager.TryGoToState(GameState.Gameplay);
});
}
@@ -311,13 +303,13 @@ namespace Pal3.Dev
{
_mazeSkipper.PortalToEntrance();
HideMenu();
_gameStateManager.GoToState(GameState.Gameplay);
_gameStateManager.TryGoToState(GameState.Gameplay);
});
CreateMenuButton("迷宫出口或剧情点", _ => delegate
{
_mazeSkipper.PortalToExitOrNextStoryPoint();
HideMenu();
_gameStateManager.GoToState(GameState.Gameplay);
_gameStateManager.TryGoToState(GameState.Gameplay);
});
}
@@ -511,6 +503,24 @@ namespace Pal3.Dev
(_gameSettings.SfxVolume == 0f ? "关闭" : "开启") + ""));
});
#if !UNITY_IOS
const string languageSimplifiedChineseText = "数据包版本:简体中文版";
const string languageTraditionalChineseText = "数据包版本:繁体中文版";
string GetLanguageButtonText() => _gameSettings.Language == Language.SimplifiedChinese ?
languageSimplifiedChineseText : languageTraditionalChineseText;
CreateMenuButton(GetLanguageButtonText(), buttonTextUGUI => delegate
{
_gameSettings.Language = _gameSettings.Language == Language.SimplifiedChinese ?
Language.TraditionalChinese : Language.SimplifiedChinese;
buttonTextUGUI.text = GetLanguageButtonText();
CommandDispatcher<ICommand>.Instance.Dispatch(new UIDisplayNoteCommand("游戏版本已切换为" +
(_gameSettings.Language == Language.SimplifiedChinese ? "简体中文版" : "繁体中文版") +
"\n注意:游戏版本需要与数据文件一致(否则会出现乱码),且重启游戏后才会生效"));
});
#endif
const string debugInfoEnabledText = "调试信息:开启";
const string debugInfoDisabledText = "调试信息:关闭";
string GetDebugInfoButtonText() => _gameSettings.IsDebugInfoEnabled ? debugInfoEnabledText : debugInfoDisabledText;
@@ -714,7 +724,7 @@ namespace Pal3.Dev
private void CreateMenuButton(string text, Func<TextMeshProUGUI, UnityAction> onSelection)
{
GameObject menuButtonGo = Instantiate(_menuButtonPrefab, _contentTransform);
GameObject menuButtonGo = UnityEngine.Object.Instantiate(_menuButtonPrefab, _contentTransform);
var buttonTextUI = menuButtonGo.GetComponentInChildren<TextMeshProUGUI>();
buttonTextUI.text = text;
var button = menuButtonGo.GetComponent<Button>();
@@ -785,7 +795,7 @@ namespace Pal3.Dev
foreach (GameObject item in _menuItems)
{
item.GetComponent<Button>()?.onClick.RemoveAllListeners();
Destroy(item);
UnityEngine.Object.Destroy(item);
}
_menuItems.Clear();
}
@@ -805,7 +815,7 @@ namespace Pal3.Dev
CommandDispatcher<ICommand>.Instance.Dispatch(new TaskOpenCommand(TaskConstants.InitTaskId));
#endif
_gameStateManager.GoToState(GameState.Cutscene);
_gameStateManager.TryGoToState(GameState.Cutscene);
}
private void ExecuteCommands(string commands)
@@ -897,7 +907,8 @@ namespace Pal3.Dev
}
else
{
StartCoroutine(ExecuteDeferredCommandsAfterSceneScriptFinishedAsync(command.SceneScriptId));
Pal3.Instance.StartCoroutine(ExecuteDeferredCommandsAfterSceneScriptFinishedAsync(
command.SceneScriptId));
}
}
@@ -919,13 +930,13 @@ namespace Pal3.Dev
public void Execute(GameStateChangedNotification command)
{
// If menu is still active, go to cutscene state
// If menu is still active, go to UI state
// When turn on/off real time lighting and shadow, the game will reload the scene
// and run scene script again, so we need to check if the menu is still active
// and set the game state to cutscene
// and set the game state to UI
if (_mainMenuCanvasGroup.interactable)
{
_gameStateManager.GoToState(GameState.Cutscene);
_gameStateManager.TryGoToState(GameState.UI);
}
}
}
+17 -17
View File
@@ -7,19 +7,20 @@ namespace Pal3.Effect
{
using System;
using Actor;
using Actor.Controllers;
using Command;
using Command.InternalCommands;
using Command.SceCommands;
using Core.DataReader.Dat;
using Core.GameBox;
using Core.Utils;
using Data;
using MetaData;
using Scene;
using Script.Waiter;
using UnityEngine;
using Object = UnityEngine.Object;
public sealed class EffectManager : MonoBehaviour, IDisposable,
public sealed class EffectManager : IDisposable,
ICommandExecutor<EffectPreLoadCommand>,
ICommandExecutor<EffectAttachToActorCommand>,
ICommandExecutor<EffectSetPositionCommand>,
@@ -27,29 +28,28 @@ namespace Pal3.Effect
ICommandExecutor<SceneLeavingCurrentSceneNotification>,
ICommandExecutor<ResetGameStateCommand>
{
private GameResourceProvider _resourceProvider;
private SceneManager _sceneManager;
private readonly GameResourceProvider _resourceProvider;
private readonly SceneManager _sceneManager;
private ICommand _effectPositionCommand;
public void Init(GameResourceProvider resourceProvider,
private const string EFFECT_LINKER_FILE_NAME = "efflinker.dat";
private EffectLinkerFile _effectLinkerFile;
public EffectManager(GameResourceProvider resourceProvider,
SceneManager sceneManager)
{
_resourceProvider = Requires.IsNotNull(resourceProvider, nameof(resourceProvider));
_sceneManager = Requires.IsNotNull(sceneManager, nameof(sceneManager));
}
private void OnEnable()
{
_effectLinkerFile = _resourceProvider.GetGameResourceFile<EffectLinkerFile>(
FileConstants.CombatDataFolderVirtualPath + EFFECT_LINKER_FILE_NAME);
CommandExecutorRegistry<ICommand>.Instance.Register(this);
}
private void OnDisable()
{
CommandExecutorRegistry<ICommand>.Instance.UnRegister(this);
}
public void Dispose()
{
CommandExecutorRegistry<ICommand>.Instance.UnRegister(this);
_effectPositionCommand = null;
}
@@ -60,7 +60,7 @@ namespace Pal3.Effect
// Even with a waiter, we need to make sure waiter's current execution mode is set
// to synchronous otherwise the effect will be played before the pre-load is finished.
#if PAL3
StartCoroutine(_resourceProvider.PreLoadVfxEffectAsync(command.EffectGroupId));
Pal3.Instance.StartCoroutine(_resourceProvider.PreLoadVfxEffectAsync(command.EffectGroupId));
#endif
}
@@ -110,7 +110,7 @@ namespace Pal3.Effect
if (parent != null)
{
var vfx = (GameObject)Instantiate(vfxPrefab, parent, false);
var vfx = (GameObject)Object.Instantiate(vfxPrefab, parent, false);
vfx.name = "VFX_" + command.EffectGroupId;
vfx.transform.localPosition += localPosition;
}
@@ -164,12 +164,12 @@ namespace Pal3.Effect
public void Execute(SceneLeavingCurrentSceneNotification command)
{
Dispose();
_effectPositionCommand = null;
}
public void Execute(ResetGameStateCommand command)
{
Dispose();
_effectPositionCommand = null;
}
}
}
+4 -2
View File
@@ -13,7 +13,8 @@ namespace Pal3.Effect
using Core.Utils;
using Data;
using MetaData;
using Renderer;
using Rendering.Material;
using Rendering.Renderer;
using UnityEngine;
public class FireEffect : MonoBehaviour, IEffect
@@ -40,7 +41,8 @@ namespace Pal3.Effect
_sceneObjectRenderer = gameObject.AddComponent<PolyModelRenderer>();
_sceneObjectRenderer.Render(polFile,
textureProvider,
materialFactory);
materialFactory,
isStaticObject: false);
}
if (!string.IsNullOrEmpty(info.TexturePathFormat))
@@ -5,32 +5,32 @@
namespace Pal3.Effect.PostProcessing
{
using System;
using Command;
using Command.InternalCommands;
using Command.SceCommands;
using Core.Utils;
using Settings;
using UnityEngine;
using UnityEngine.Rendering.PostProcessing;
public sealed class PostProcessManager : MonoBehaviour,
public sealed class PostProcessManager : IDisposable,
ICommandExecutor<EffectSetScreenEffectCommand>,
ICommandExecutor<ResetGameStateCommand>,
ICommandExecutor<SettingChangedNotification>
{
private PostProcessVolume _postProcessVolume;
private PostProcessLayer _postProcessLayer;
private GameSettings _gameSettings;
private readonly PostProcessVolume _postProcessVolume;
private readonly PostProcessLayer _postProcessLayer;
private readonly GameSettings _gameSettings;
private Bloom _bloom;
private AmbientOcclusion _ambientOcclusion;
private ColorGrading _colorGrading;
private Vignette _vignette;
private Distortion _distortion;
private readonly Bloom _bloom;
private readonly AmbientOcclusion _ambientOcclusion;
private readonly ColorGrading _colorGrading;
private readonly Vignette _vignette;
private readonly Distortion _distortion;
private int _currentAppliedEffectMode = -1;
public void Init(PostProcessVolume volume,
public PostProcessManager(PostProcessVolume volume,
PostProcessLayer postProcessLayer,
GameSettings gameSettings)
{
@@ -57,6 +57,8 @@ namespace Pal3.Effect.PostProcessing
}
TogglePostProcessLayerWhenNeeded();
CommandExecutorRegistry<ICommand>.Instance.Register(this);
}
private void ToggleBloomBasedOnSetting()
@@ -102,12 +104,7 @@ namespace Pal3.Effect.PostProcessing
}
}
private void OnEnable()
{
CommandExecutorRegistry<ICommand>.Instance.Register(this);
}
private void OnDisable()
public void Dispose()
{
CommandExecutorRegistry<ICommand>.Instance.UnRegister(this);
}
@@ -12,7 +12,7 @@ namespace Pal3.GamePlay
using Core.DataReader.Scn;
using MetaData;
public sealed class PlayerManager : IDisposable,
public sealed class PlayerActorManager : IDisposable,
ICommandExecutor<DialogueRenderActorAvatarCommand>,
ICommandExecutor<ActorActivateCommand>,
ICommandExecutor<ActorAddSkillCommand>,
@@ -57,7 +57,7 @@ namespace Pal3.GamePlay
private bool _playerActorControlEnabled = true;
private bool _playerInputEnabled;
public PlayerManager()
public PlayerActorManager()
{
CommandExecutorRegistry<ICommand>.Instance.Register(this);
}
@@ -87,6 +87,24 @@ namespace Pal3.GamePlay
_playerInputEnabled = (command.Enable == 1);
}
public void Execute(ScenePreLoadingNotification command)
{
// Need to set main actor as player actor for non-maze scenes
if (command.NewSceneInfo.SceneType != ScnSceneType.Maze &&
_playerActor != 0)
{
_playerActor = 0;
}
}
public void Execute(ResetGameStateCommand command)
{
_playerActor = 0;
_playerActorControlEnabled = true;
_playerInputEnabled = false;
}
#region Command routing
public void Execute(DialogueRenderActorAvatarCommand command)
{
if (command.ActorId == ActorConstants.PlayerActorVirtualID)
@@ -208,6 +226,19 @@ namespace Pal3.GamePlay
{
if (command.ActorId == ActorConstants.PlayerActorVirtualID)
{
// Fix a bug in PAL3 script
// TODO: Implement a better solution to fix command at dispatching time
#if PAL3
if (command.TileXPosition == 289 &&
command.TileYPosition == 21 &&
command.Mode == 0)
{
CommandDispatcher<ICommand>.Instance.Dispatch(
new ActorPathToCommand((int)_playerActor, 288, 20, command.Mode));
return;
}
#endif
CommandDispatcher<ICommand>.Instance.Dispatch(
new ActorPathToCommand((int)_playerActor, command.TileXPosition, command.TileYPosition, command.Mode));
}
@@ -388,22 +419,6 @@ namespace Pal3.GamePlay
new EffectAttachToActorCommand((int)_playerActor));
}
}
public void Execute(ScenePreLoadingNotification command)
{
// Need to set main actor as player actor for non-maze scenes
if (command.NewSceneInfo.SceneType != ScnSceneType.Maze &&
_playerActor != 0)
{
_playerActor = 0;
}
}
public void Execute(ResetGameStateCommand command)
{
_playerActor = 0;
_playerActorControlEnabled = true;
_playerInputEnabled = false;
}
#endregion
}
}
File diff suppressed because it is too large. Load diff
@@ -0,0 +1,60 @@
// ---------------------------------------------------------------------------------------------
// Copyright (c) 2021-2023, Jiaqi Liu. All rights reserved.
// See LICENSE file in the project root for license information.
// ---------------------------------------------------------------------------------------------
namespace Pal3.GamePlay
{
using System;
using Command;
using Command.InternalCommands;
using Command.SceCommands;
using Core.DataReader.Scn;
using MetaData;
using UnityEngine.InputSystem;
public partial class PlayerGamePlayManager :
ICommandExecutor<SwitchPlayerActorRequest>
{
public void Execute(SwitchPlayerActorRequest command)
{
if (_sceneManager.GetCurrentScene().GetSceneInfo().SceneType == ScnSceneType.Maze)
{
SwitchPlayerActorInCurrentTeam(true);
}
}
private void SwitchToNextPlayerActorPerformed(InputAction.CallbackContext _)
{
SwitchPlayerActorInCurrentTeam(true);
}
private void SwitchToPreviousPlayerActorPerformed(InputAction.CallbackContext _)
{
SwitchPlayerActorInCurrentTeam(false);
}
private void SwitchPlayerActorInCurrentTeam(bool next)
{
if (!_playerActorManager.IsPlayerActorControlEnabled() ||
!_playerActorManager.IsPlayerInputEnabled() ||
_sceneManager.GetCurrentScene().GetSceneInfo().SceneType != ScnSceneType.Maze)
{
return;
}
var actorsInTeam = _teamManager.GetActorsInTeam();
if (actorsInTeam.Count <= 1) return; // Makes no sense to change player actor if there is only one actor in the team
var playerActorIdLength = Enum.GetNames(typeof(PlayerActorId)).Length;
int targetPlayerActorId = _playerActor.Info.Id;
do
{
targetPlayerActorId = (targetPlayerActorId + playerActorIdLength + (next ? +1 : -1)) % playerActorIdLength;
} while (!actorsInTeam.Contains((PlayerActorId) targetPlayerActorId));
CommandDispatcher<ICommand>.Instance.Dispatch(new ActorEnablePlayerControlCommand(targetPlayerActorId));
}
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: a3822202328afc74380116ad2e9a5247
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,147 @@
// ---------------------------------------------------------------------------------------------
// Copyright (c) 2021-2023, Jiaqi Liu. All rights reserved.
// See LICENSE file in the project root for license information.
// ---------------------------------------------------------------------------------------------
namespace Pal3.GamePlay
{
using System;
using System.Collections;
using Command;
using Command.InternalCommands;
using Command.SceCommands;
using Core.GameBox;
using Core.Renderer;
using MetaData;
using Scene;
using Scene.SceneObjects;
using Script.Waiter;
using UnityEngine;
public partial class PlayerGamePlayManager :
ICommandExecutor<ActorPerformClimbActionCommand>
{
public void Execute(ActorPerformClimbActionCommand command)
{
Scene scene = _sceneManager.GetCurrentScene();
SceneObject climbableSceneObject = scene.GetSceneObject(command.ObjectId);
GameObject climbableObject = climbableSceneObject.GetGameObject();
if (climbableObject == null)
{
Debug.LogError($"[{nameof(PlayerGamePlayManager)}] Scene object not found or not activated yet: {command.ObjectId}.");
return;
}
Vector3 climbableObjectPosition = climbableObject.transform.position;
Vector3 climbableObjectFacing = GameBoxInterpreter.ToUnityRotation(
new Vector3(0f, climbableSceneObject.ObjectInfo.GameBoxYRotation, 0f)) * Vector3.forward;
Vector3 lowerPosition = climbableObjectFacing.normalized * 0.5f + climbableObjectPosition;
Vector3 lowerStandingPosition = climbableObjectFacing.normalized * 1.5f + climbableObjectPosition;
Vector3 upperPosition = -climbableObjectFacing.normalized * 0.5f + climbableObjectPosition;
Vector3 upperStandingPosition = -climbableObjectFacing.normalized * 1.5f + climbableObjectPosition;
var currentPlayerLayer = _playerActorMovementController.GetCurrentLayerIndex();
var climbUp = (command.ClimbUp == 1);
var climbableHeight = climbableObject.GetComponentInChildren<StaticMeshRenderer>()
.GetRendererBounds().max.y / 2f; // Half is enough for the animation
Vector3 playerCurrentPosition = _playerActorGameObject.transform.position;
if (command.ClimbUp == 1)
{
lowerPosition.y = playerCurrentPosition.y;
lowerStandingPosition.y = playerCurrentPosition.y;
upperPosition.y = playerCurrentPosition.y + climbableHeight;
upperStandingPosition.y = playerCurrentPosition.y + climbableHeight;
}
else
{
lowerPosition.y = playerCurrentPosition.y - climbableHeight;
lowerStandingPosition.y = playerCurrentPosition.y - climbableHeight;
upperPosition.y = playerCurrentPosition.y;
upperStandingPosition.y = playerCurrentPosition.y;
}
var waiter = new WaitUntilCanceled();
CommandDispatcher<ICommand>.Instance.Dispatch(new ScriptRunnerAddWaiterRequest(waiter));
var climbAnimationOnly = command.ClimbUp != -1;
Pal3.Instance.StartCoroutine(PlayerActorMoveToClimbableObjectAndClimbAsync(climbableObject,
climbUp,
climbAnimationOnly,
climbableHeight,
lowerPosition,
lowerStandingPosition,
upperPosition,
upperStandingPosition,
currentPlayerLayer,
currentPlayerLayer,
() => waiter.CancelWait()));
}
public IEnumerator PlayerActorMoveToClimbableObjectAndClimbAsync(
GameObject climbableObject,
bool climbUp,
bool climbOnly,
float climbableHeight,
Vector3 lowerPosition,
Vector3 lowerStandingPosition,
Vector3 upperPosition,
Vector3 upperStandingPosition,
int lowerLayer,
int upperLayer,
Action onFinished = null)
{
yield return _playerActorMovementController
.MoveDirectlyToAsync(climbUp ? lowerPosition : upperPosition, 0, true);
_playerActorActionController.PerformAction(climbUp ? ActorActionType.Climb : ActorActionType.ClimbDown);
Vector3 newPosition = new Vector3(lowerPosition.x, _playerActorGameObject.transform.position.y, lowerPosition.z);
var objectRotationY = climbableObject.transform.rotation.eulerAngles.y;
Quaternion newRotation = Quaternion.Euler(0f, objectRotationY + 180f, 0f);
_playerActorGameObject.transform.SetPositionAndRotation(newPosition, newRotation);
if (climbUp)
{
var currentHeight = 0f;
while (currentHeight < climbableHeight)
{
var delta = Time.deltaTime * ActorConstants.PlayerActorClimbSpeed;
currentHeight += delta;
_playerActorGameObject.transform.position += new Vector3(0f, delta, 0f);
yield return null;
}
if (!climbOnly)
{
_playerActorMovementController.SetNavLayer(upperLayer);
yield return _playerActorMovementController.MoveDirectlyToAsync(upperStandingPosition, 0, true);
_playerActorGameObject.transform.position = upperStandingPosition;
}
}
else
{
var currentHeight = climbableHeight;
while (currentHeight > 0f)
{
var delta = Time.deltaTime * ActorConstants.PlayerActorClimbSpeed;
currentHeight -= delta;
_playerActorGameObject.transform.position -= new Vector3(0f, delta, 0f);
yield return null;
}
if (!climbOnly)
{
_playerActorMovementController.SetNavLayer(lowerLayer);
yield return _playerActorMovementController.MoveDirectlyToAsync(lowerStandingPosition, 0, true);
_playerActorGameObject.transform.position = lowerStandingPosition;
}
}
onFinished?.Invoke();
}
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 9373576ee1894d44db3c4002224ae072
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,234 @@
// ---------------------------------------------------------------------------------------------
// Copyright (c) 2021-2023, Jiaqi Liu. All rights reserved.
// See LICENSE file in the project root for license information.
// ---------------------------------------------------------------------------------------------
namespace Pal3.GamePlay
{
using System;
using System.Collections;
using Actor;
using Actor.Controllers;
using Command;
using Command.InternalCommands;
using Command.SceCommands;
using Core.DataReader.Scn;
using MetaData;
using Scene;
using Scene.SceneObjects;
using Script;
using Script.Waiter;
using State;
using UnityEngine;
using UnityEngine.InputSystem;
public partial class PlayerGamePlayManager :
ICommandExecutor<PlayerInteractionRequest>,
ICommandExecutor<PlayerInteractWithObjectCommand>
{
public void Execute(PlayerInteractWithObjectCommand command)
{
Scene currentScene = _sceneManager.GetCurrentScene();
if (currentScene.GetAllActivatedSceneObjects().Contains(command.SceneObjectId))
{
Pal3.Instance.StartCoroutine(InteractWithSceneObjectAsync(
currentScene.GetSceneObject(command.SceneObjectId), startedByPlayer: false));
}
else
{
Debug.LogError($"[{nameof(PlayerGamePlayManager)}] Scene object not found" +
$" or not activated yet: {command.SceneObjectId}.");
}
}
public void Execute(PlayerInteractionRequest _)
{
if (IsPlayerActorInsideJumpableArea())
{
Pal3.Instance.StartCoroutine(JumpAsync());
}
else
{
InteractWithFacingInteractable();
}
}
private void InteractionPerformed(InputAction.CallbackContext _)
{
if (!_playerActorManager.IsPlayerActorControlEnabled() ||
!_playerActorManager.IsPlayerInputEnabled())
{
return;
}
if (IsPlayerActorInsideJumpableArea())
{
Pal3.Instance.StartCoroutine(JumpAsync());
}
else
{
InteractWithFacingInteractable();
}
}
/// <summary>
/// Interact with the nearby interactable object by the player actor facing direction.
/// </summary>
private void InteractWithFacingInteractable()
{
Vector3 actorFacingDirection = _playerActorMovementController.transform.forward;
Vector3 actorCenterPosition = _playerActorActionController.GetRendererBounds().center;
var currentLayerIndex = _playerActorMovementController.GetCurrentLayerIndex();
float nearestInteractableFacingAngle = 181f;
IEnumerator interactionRoutine = null;
foreach (var sceneObjectId in
_sceneManager.GetCurrentScene().GetAllActivatedSceneObjects())
{
SceneObject sceneObject = _sceneManager.GetCurrentScene().GetSceneObject(sceneObjectId);
Vector3 closetPointOnObject = sceneObject.GetRendererBounds().ClosestPoint(actorCenterPosition);
float distanceToActor = Vector3.Distance(actorCenterPosition, closetPointOnObject);
Vector3 actorToObjectFacing = closetPointOnObject - actorCenterPosition;
float facingAngle = Vector2.Angle(
new Vector2(actorFacingDirection.x, actorFacingDirection.z),
new Vector2(actorToObjectFacing.x, actorToObjectFacing.z));
if (sceneObject.IsDirectlyInteractable(distanceToActor) &&
facingAngle < nearestInteractableFacingAngle)
{
//Debug.DrawLine(actorCenterPosition, closetPointOnObject, Color.white, 1000);
nearestInteractableFacingAngle = facingAngle;
interactionRoutine = InteractWithSceneObjectAsync(sceneObject, startedByPlayer: true);
}
}
foreach (var actorInfo in
_sceneManager.GetCurrentScene().GetAllActorGameObjects())
{
var actorController = actorInfo.Value.GetComponent<ActorController>();
var actorActionController = actorInfo.Value.GetComponent<ActorActionController>();
var actorMovementController = actorInfo.Value.GetComponent<ActorMovementController>();
if (actorMovementController.GetCurrentLayerIndex() != currentLayerIndex ||
actorInfo.Key == (int)_playerActorManager.GetPlayerActor() ||
!actorController.IsActive) continue;
Vector3 targetActorCenterPosition = actorActionController.GetRendererBounds().center;
var distance = Vector3.Distance(actorCenterPosition,targetActorCenterPosition);
Vector3 actorToActorFacing = targetActorCenterPosition - actorCenterPosition;
float facingAngle = Vector2.Angle(
new Vector2(actorFacingDirection.x, actorFacingDirection.z),
new Vector2(actorToActorFacing.x, actorToActorFacing.z));
if (actorController.IsDirectlyInteractable(distance) &&
facingAngle < nearestInteractableFacingAngle)
{
//Debug.DrawLine(actorCenterPosition, targetActorCenterPosition, Color.white, 1000);
nearestInteractableFacingAngle = facingAngle;
interactionRoutine = InteractWithActorAsync(actorInfo.Key, actorInfo.Value);
}
}
if (interactionRoutine != null)
{
Pal3.Instance.StartCoroutine(interactionRoutine);
}
}
private IEnumerator InteractWithSceneObjectAsync(SceneObject sceneObject, bool startedByPlayer)
{
var correlationId = Guid.NewGuid();
var requiresStateChange = sceneObject.ShouldGoToCutsceneWhenInteractionStarted();
if (requiresStateChange)
{
_gameStateManager.TryGoToState(GameState.Cutscene);
_gameStateManager.AddGamePlayStateLocker(correlationId);
}
yield return sceneObject.InteractAsync(new InteractionContext
{
CorrelationId = correlationId,
InitObjectId = sceneObject.ObjectInfo.Id,
PlayerActorGameObject = _playerActorGameObject,
CurrentScene = _sceneManager.GetCurrentScene(),
StartedByPlayer = startedByPlayer,
});
if (requiresStateChange)
{
_gameStateManager.RemoveGamePlayStateLocker(correlationId);
_gameStateManager.TryGoToState(GameState.Gameplay);
}
}
private IEnumerator InteractWithActorAsync(int actorId, GameObject actorGameObject)
{
CommandDispatcher<ICommand>.Instance.Dispatch(
new GameStateChangeRequest(GameState.Cutscene));
CommandDispatcher<ICommand>.Instance.Dispatch(
new ActorStopActionAndStandCommand(ActorConstants.PlayerActorVirtualID));
Actor targetActor = _sceneManager.GetCurrentScene().GetActor(actorId);
Quaternion rotationBeforeInteraction = actorGameObject.transform.rotation;
var actorController = actorGameObject.GetComponent<ActorController>();
var movementController = actorGameObject.GetComponent<ActorMovementController>();
// Pause current path follow movement of the interacting actor
if (actorController != null &&
movementController != null &&
actorController.GetCurrentBehaviour() == ScnActorBehaviour.PathFollow)
{
movementController.PauseMovement();
}
// Look at the target actor
CommandDispatcher<ICommand>.Instance.Dispatch(
new ActorLookAtActorCommand(_playerActor.Info.Id, targetActor.Info.Id));
bool shouldResetFacingAfterInteraction = false;
// Only let target actor look at player actor when NoTurn is set to false
// and InitBehaviour is not set to Hold
if (targetActor.Info.NoTurn == 0 && targetActor.Info.InitBehaviour != ScnActorBehaviour.Hold)
{
CommandDispatcher<ICommand>.Instance.Dispatch(
new ActorLookAtActorCommand(targetActor.Info.Id, _playerActor.Info.Id));
shouldResetFacingAfterInteraction = true;
}
// Resume animation of the target actor if it is set to hold and loop action is set to 0
if (targetActor.Info.InitBehaviour == ScnActorBehaviour.Hold &&
targetActor.Info.LoopAction == 0)
{
var actionController = actorGameObject.GetComponent<ActorActionController>();
// PerformAction internally checks if the target actor is already performing the action
actionController.PerformAction(actionController.GetCurrentAction(), false, 1);
}
// Run dialogue script
CommandDispatcher<ICommand>.Instance.Dispatch(
new ScriptRunCommand((int)targetActor.Info.ScriptId));
// Wait until the dialogue script is finished
yield return new WaitUntilScriptFinished(PalScriptType.Scene, targetActor.Info.ScriptId);
// Resume current path follow movement of the interacting actor
if (actorController != null &&
movementController != null &&
actorController.GetCurrentBehaviour() == ScnActorBehaviour.PathFollow)
{
movementController.ResumeMovement();
}
// Reset facing rotation of the interacting actor if needed
if (shouldResetFacingAfterInteraction && actorGameObject != null)
{
actorGameObject.transform.rotation = rotationBeforeInteraction;
}
}
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 7d408f988e08d644c8124b5b6b735f83
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,224 @@
// ---------------------------------------------------------------------------------------------
// Copyright (c) 2021-2023, Jiaqi Liu. All rights reserved.
// See LICENSE file in the project root for license information.
// ---------------------------------------------------------------------------------------------
namespace Pal3.GamePlay
{
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using Core.Animation;
using Core.DataReader.Nav;
using Core.GameBox;
using Core.Renderer;
using MetaData;
using Scene;
using State;
using UnityEngine;
public partial class PlayerGamePlayManager
{
private const float MIN_JUMP_DISTANCE = 1.2f;
private const float MAX_JUMP_DISTANCE = 8f;
private const float MAX_JUMP_Y_DIFFERENTIAL = 3.5f;
private const float JUMP_HEIGHT = 6f;
private int _jumpableAreaEnterCount;
private GameObject _jumpIndicatorGameObject;
private AnimatedBillboardRenderer _jumpIndicatorRenderer;
private void JumpToTapPosition()
{
if (!_lastInputTapPosition.HasValue) return;
Ray ray = _camera.ScreenPointToRay(_lastInputTapPosition.Value);
if (!Physics.Raycast(ray, out RaycastHit hit)) return;
if (_sceneManager.GetCurrentScene()
.GetMeshColliders().Any(_ => _.Value == hit.collider))
{
Pal3.Instance.StartCoroutine(JumpAsync(hit.point));
}
}
public void PlayerActorEnteredJumpableArea()
{
if (_jumpIndicatorGameObject == null)
{
var sprites = _resourceProvider.GetJumpIndicatorSprites();
_jumpIndicatorGameObject = new GameObject($"JumpIndicator");
_jumpIndicatorGameObject.transform.SetParent(_playerActorGameObject.transform, false);
_jumpIndicatorGameObject.transform.localScale = new Vector3(3f, 3f, 3f);
_jumpIndicatorGameObject.transform.localPosition = new Vector3(0f,
_playerActorActionController.GetActorHeight() + 1f, 0f);
_jumpIndicatorRenderer = _jumpIndicatorGameObject.AddComponent<AnimatedBillboardRenderer>();
_jumpIndicatorRenderer.Init(sprites, 4);
}
if (_jumpableAreaEnterCount == 0)
{
_jumpIndicatorRenderer.StartAnimation(-1);
}
_jumpableAreaEnterCount++;
}
public void PlayerActorExitedJumpableArea()
{
_jumpableAreaEnterCount--;
if (_jumpableAreaEnterCount == 0 && _jumpIndicatorRenderer != null)
{
_jumpIndicatorRenderer.StopAnimation();
}
}
private bool IsPlayerActorInsideJumpableArea()
{
return _jumpableAreaEnterCount > 0;
}
private void ResetAndDisposeJumpIndicators()
{
_jumpableAreaEnterCount = 0;
if (_jumpIndicatorRenderer != null)
{
_jumpIndicatorRenderer.StopAnimation();
UnityEngine.Object.Destroy(_jumpIndicatorRenderer);
_jumpIndicatorRenderer = null;
}
if (_jumpIndicatorGameObject != null)
{
UnityEngine.Object.Destroy(_jumpIndicatorGameObject);
_jumpIndicatorGameObject = null;
}
}
private IEnumerator JumpAsync(Vector3? jumpTargetPosition = null)
{
_gameStateManager.TryGoToState(GameState.Cutscene);
_playerActorMovementController.CancelMovement();
Vector3 currentPosition = _playerActorMovementController.GetWorldPosition();
Scene currentScene = _sceneManager.GetCurrentScene();
Tilemap tilemap = currentScene.GetTilemap();
bool IsPositionCanJumpTo(Vector3 position, int layerIndex, out float yPosition, out int distanceToObstacle)
{
Vector2Int tilePosition = tilemap.GetTilePosition(position, layerIndex);
if (tilemap.TryGetTile(position, layerIndex, out NavTile tile) &&
tile.IsWalkable())
{
distanceToObstacle = tile.DistanceToNearestObstacle;
yPosition = GameBoxInterpreter.ToUnityYPosition(tile.GameBoxYPosition);
if (Mathf.Abs(yPosition - currentPosition.y) > MAX_JUMP_Y_DIFFERENTIAL) return false;
if (currentScene.IsPositionInsideJumpableArea(layerIndex, tilePosition))
{
return true;
}
#if PAL3
// Special case for PAL3 M15-B1
if (_sceneManager.GetCurrentScene().GetSceneInfo().Is("m15", "b1"))
{
return true;
}
#endif
}
yPosition = 0f;
distanceToObstacle = 0;
return false;
}
Vector3 jumpDirection = _playerActorGameObject.transform.forward;
if (jumpTargetPosition != null)
{
jumpDirection = jumpTargetPosition.Value - _playerActorGameObject.transform.position;
jumpDirection.y = 0f;
jumpDirection.Normalize();
_playerActorGameObject.transform.forward = jumpDirection;
}
var validJumpTargetPositions = new List<(Vector3 position, int layerIndex, int distanceToObstacle)>();
for (float i = MIN_JUMP_DISTANCE; i <= MAX_JUMP_DISTANCE; i += 0.1f)
{
Vector3 targetPosition = currentPosition + jumpDirection * i;
for (var j = 0; j < tilemap.GetLayerCount(); j++)
{
if (IsPositionCanJumpTo(targetPosition, j,
out float yPosition, out int distanceToObstacle))
{
Vector3 position = targetPosition;
position.y = yPosition;
validJumpTargetPositions.Add((position, j, distanceToObstacle));
}
}
}
var currentLayer = _playerActorMovementController.GetCurrentLayerIndex();
var jumpTargetLayer = currentLayer;
if (validJumpTargetPositions.Count > 0)
{
// If there are valid jump target positions in different layers,
// only pick positions in the other layer
if (validJumpTargetPositions.Any(_ => _.layerIndex != currentLayer))
{
validJumpTargetPositions = validJumpTargetPositions.Where(_ => _.layerIndex != currentLayer).ToList();
}
// Pick a position that is farthest from obstacles
int maxDistanceToObstacle = validJumpTargetPositions.Max(_ => _.distanceToObstacle);
var bestPosition = validJumpTargetPositions
.First(_ => _.distanceToObstacle == maxDistanceToObstacle);
jumpTargetPosition = bestPosition.position;
jumpTargetLayer = bestPosition.layerIndex;
}
else
{
jumpTargetPosition = currentPosition;
}
_playerActorActionController.PerformAction(ActorConstants.ActionToNameMap[ActorActionType.Jump],
overwrite: true, loopCount: 1);
yield return new WaitForSeconds(0.7f);
var xzOffset = Vector2.Distance(
new Vector2(jumpTargetPosition.Value.x, jumpTargetPosition.Value.z),
new Vector2(currentPosition.x, currentPosition.z));
var startingYPosition = currentPosition.y;
var yOffset = jumpTargetPosition.Value.y - currentPosition.y;
yield return CoreAnimation.EnumerateValueAsync(0f, 1f, 1.1f, AnimationCurveType.Sine,
value =>
{
Vector3 calculatedPosition = currentPosition + jumpDirection * (xzOffset * value);
calculatedPosition.y = startingYPosition + (0.5f - MathF.Abs(value - 0.5f)) * JUMP_HEIGHT + yOffset * value;
_playerActorGameObject.transform.position = calculatedPosition;
});
yield return new WaitForSeconds(0.7f);
_playerActorMovementController.SetNavLayer(jumpTargetLayer);
PlayerActorTilePositionChanged(jumpTargetLayer,
tilemap.GetTilePosition(jumpTargetPosition.Value, jumpTargetLayer), false);
_gameStateManager.TryGoToState(GameState.Gameplay);
}
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: b9dcc05fc2830c441b0e4e26a21ca33b
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,260 @@
// ---------------------------------------------------------------------------------------------
// Copyright (c) 2021-2023, Jiaqi Liu. All rights reserved.
// See LICENSE file in the project root for license information.
// ---------------------------------------------------------------------------------------------
namespace Pal3.GamePlay
{
using System.Collections.Generic;
using System.Linq;
using Actor.Controllers;
using Command;
using Command.InternalCommands;
using Core.DataReader.Nav;
using Core.Navigation;
using MetaData;
using Scene;
using Scene.SceneObjects.Common;
using UnityEngine;
public partial class PlayerGamePlayManager
{
private const float PLAYER_ACTOR_MOVEMENT_SFX_WALK_VOLUME = 0.6f;
private const float PLAYER_ACTOR_MOVEMENT_SFX_RUN_VOLUME = 1.0f;
private void ReadInputAndMovePlayerIfNeeded()
{
var movement = _inputActions.Gameplay.Movement.ReadValue<Vector2>();
if (movement.magnitude <= 0.01f) return;
MovementMode movementMode = movement.magnitude < 0.7f ? MovementMode.Walk : MovementMode.Run;
ActorActionType movementAction = movementMode == MovementMode.Walk ? ActorActionType.Walk : ActorActionType.Run;
_playerActorMovementController.CancelMovement();
Transform cameraTransform = _camera.transform;
Vector2 normalizedDirection = movement.normalized;
Vector3 inputDirection = cameraTransform.forward * normalizedDirection.y +
cameraTransform.right * normalizedDirection.x;
MovementResult result = PlayerActorMoveTowards(inputDirection, movementMode);
_playerActorActionController.PerformAction(result == MovementResult.Blocked
? ActorActionType.Stand
: movementAction);
}
private void PortalToTapPosition()
{
if (!_lastInputTapPosition.HasValue) return;
Ray ray = _camera.ScreenPointToRay(_lastInputTapPosition.Value);
if (!Physics.Raycast(ray, out RaycastHit hit)) return;
int layerIndex;
bool isPositionOnStandingPlatform;
if (hit.collider.gameObject.GetComponent<StandingPlatformController>() is { } standingPlatformController)
{
layerIndex = standingPlatformController.LayerIndex;
isPositionOnStandingPlatform = true;
}
else
{
var meshColliders = _sceneManager.GetCurrentScene()
.GetMeshColliders();
if (meshColliders.Any(_ => _.Value == hit.collider))
{
layerIndex = meshColliders.First(_ => _.Value == hit.collider).Key;
isPositionOnStandingPlatform = false;
}
else
{
// Raycast hit a collider that is not a mesh collider or a standing platform
return;
}
}
_playerActorMovementController.PortalToPosition(hit.point, layerIndex, isPositionOnStandingPlatform);
}
// Raycast caches to avoid GC
private readonly RaycastHit[] _raycastHits = new RaycastHit[4];
private readonly Dictionary<int, (Vector3 point, bool isPlatform)> _tapPoints = new ();
private void MoveToTapPosition(bool isDoubleTap)
{
if (!_lastInputTapPosition.HasValue) return;
Scene currentScene = _sceneManager.GetCurrentScene();
var meshColliders = currentScene.GetMeshColliders();
Ray ray = _camera.ScreenPointToRay(_lastInputTapPosition.Value);
var hitCount = Physics.RaycastNonAlloc(ray, _raycastHits, 500f);
if (hitCount == 0) return;
Tilemap tilemap = currentScene.GetTilemap();
_tapPoints.Clear();
for (var i = 0; i < hitCount; i++)
{
RaycastHit hit = _raycastHits[i];
if (hit.collider.gameObject.GetComponent<StandingPlatformController>() is { }
standingPlatformController)
{
_tapPoints[standingPlatformController.LayerIndex] = (hit.point, true);
continue;
}
var layerIndex = meshColliders.FirstOrDefault(_ => _.Value == hit.collider).Key;
if (!tilemap.TryGetTile(hit.point, layerIndex, out NavTile _))
{
continue;
}
Vector3 cameraPosition = _camera.transform.position;
var distanceToCamera = Vector3.Distance(cameraPosition, hit.point);
if (_tapPoints.ContainsKey(layerIndex))
{
var existingDistance = Vector3.Distance(cameraPosition, _tapPoints[layerIndex].point);
if (distanceToCamera < existingDistance)
{
_tapPoints[layerIndex] = (hit.point, false);
}
}
else
{
_tapPoints[layerIndex] = (hit.point, false);
}
}
if (_tapPoints.Count > 0)
{
_playerActorMovementController.MoveToTapPoint(_tapPoints, isDoubleTap);
}
}
/// <summary>
/// Adjust some degrees to the inputDirection to prevent player actor
/// from hitting into the wall and gets blocked.
/// This process is purely for improving the gameplay experience.
/// </summary>
/// <param name="inputDirection">User input direction in game space</param>
/// <param name="movementMode">Player actor movement mode</param>
/// <returns>MovementResult</returns>
private MovementResult PlayerActorMoveTowards(Vector3 inputDirection, MovementMode movementMode)
{
Vector3 playerActorPosition = _playerActorGameObject.transform.position;
MovementResult result = _playerActorMovementController.MoveTowards(
playerActorPosition + inputDirection, movementMode);
if (result != MovementResult.Blocked) return result;
if (_playerActorMovementController.IsDuringCollision()) return result;
// Don't adjust direction if player actor is inside jumpable area
if (IsPlayerActorInsideJumpableArea()) return result;
// Try change direction a little bit to see if it works
for (var degrees = 2; degrees <= 80; degrees+= 2)
{
// + degrees
{
Vector3 newDirection = Quaternion.Euler(0f, degrees, 0f) * inputDirection;
result = _playerActorMovementController.MoveTowards(
playerActorPosition + newDirection, movementMode);
if (result != MovementResult.Blocked) return result;
}
// - degrees
{
Vector3 newDirection = Quaternion.Euler(0f, -degrees, 0f) * inputDirection;
result = _playerActorMovementController.MoveTowards(
playerActorPosition + newDirection, movementMode);
if (result != MovementResult.Blocked) return result;
}
}
return result;
}
private string GetMovementSfxName(ActorActionType movementAction)
{
if (movementAction is not (ActorActionType.Walk or ActorActionType.Run)) return string.Empty;
#if PAL3
var sfxPrefix = movementAction == ActorActionType.Walk ?
AudioConstants.MainActorWalkSfxNamePrefix : AudioConstants.MainActorRunSfxNamePrefix;
Tilemap tileMap = _sceneManager.GetCurrentScene().GetTilemap();
if ((_lastKnownPosition.HasValue && _lastKnownLayerIndex.HasValue) &&
tileMap.TryGetTile(_lastKnownPosition.Value, _lastKnownLayerIndex.Value, out NavTile tile))
{
return tile.FloorKind switch
{
NavFloorKind.Grass => sfxPrefix + 'b',
NavFloorKind.Snow => sfxPrefix + 'c',
NavFloorKind.Sand => sfxPrefix + 'd',
_ => sfxPrefix + 'a'
};
}
else
{
return sfxPrefix + 'a';
}
#elif PAL3A
if (movementAction == ActorActionType.Walk)
{
return AudioConstants.MainActorWalkSfxName;
}
else
{
return _playerActor.Info.Id == (byte)PlayerActorId.WangPengXu ?
AudioConstants.WangPengXuFlySfxName : AudioConstants.MainActorRunSfxName;
}
#endif
}
private void UpdatePlayerActorMovementSfx(string playerActorAction)
{
var newMovementSfxAudioFileName = string.Empty;
ActorActionType actionType = ActorActionType.Walk;
if (string.Equals(playerActorAction, ActorConstants.ActionToNameMap[ActorActionType.Walk]))
{
newMovementSfxAudioFileName = GetMovementSfxName(ActorActionType.Walk);
actionType = ActorActionType.Walk;
}
else if (string.Equals(playerActorAction, ActorConstants.ActionToNameMap[ActorActionType.Run]))
{
newMovementSfxAudioFileName = GetMovementSfxName(ActorActionType.Run);
actionType = ActorActionType.Run;
}
if (string.Equals(_currentMovementSfxAudioName, newMovementSfxAudioFileName)) return;
_currentMovementSfxAudioName = newMovementSfxAudioFileName;
if (string.IsNullOrEmpty(_currentMovementSfxAudioName))
{
CommandDispatcher<ICommand>.Instance.Dispatch(
new StopSfxPlayingAtGameObjectRequest(_playerActorGameObject,
AudioConstants.PlayerActorMovementSfxAudioSourceName,
disposeSource: false));
}
else
{
CommandDispatcher<ICommand>.Instance.Dispatch(
new AttachSfxToGameObjectRequest(_playerActorGameObject,
newMovementSfxAudioFileName,
AudioConstants.PlayerActorMovementSfxAudioSourceName,
loopCount: -1,
actionType == ActorActionType.Walk
? PLAYER_ACTOR_MOVEMENT_SFX_WALK_VOLUME
: PLAYER_ACTOR_MOVEMENT_SFX_RUN_VOLUME,
startDelayInSeconds: 0f,
interval: 0f));
}
}
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: b1f00335891b5c64e8664b2686da4f09
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,485 @@
// ---------------------------------------------------------------------------------------------
// Copyright (c) 2021-2023, Jiaqi Liu. All rights reserved.
// See LICENSE file in the project root for license information.
// ---------------------------------------------------------------------------------------------
namespace Pal3.GamePlay
{
using System;
using System.Collections.Generic;
using System.Linq;
using Actor;
using Actor.Controllers;
using Command;
using Command.InternalCommands;
using Command.SceCommands;
using Core.DataReader.Scn;
using Core.Utils;
using Data;
using GameSystem;
using Input;
using MetaData;
using Scene;
using Scene.SceneObjects;
using State;
using UnityEngine;
using UnityEngine.InputSystem;
public partial class PlayerGamePlayManager : IDisposable,
ICommandExecutor<ActorEnablePlayerControlCommand>,
ICommandExecutor<ActorSetTilePositionCommand>,
ICommandExecutor<PlayerEnableInputCommand>,
#if PAL3
ICommandExecutor<LongKuiSwitchModeCommand>,
#endif
ICommandExecutor<SceneLeavingCurrentSceneNotification>,
ICommandExecutor<ScenePostLoadingNotification>,
ICommandExecutor<PlayerActorLookAtSceneObjectCommand>,
ICommandExecutor<ResetGameStateCommand>
{
private readonly GameResourceProvider _resourceProvider;
private readonly GameStateManager _gameStateManager;
private readonly PlayerActorManager _playerActorManager;
private readonly TeamManager _teamManager;
private readonly PlayerInputActions _inputActions;
private readonly SceneManager _sceneManager;
private readonly Camera _camera;
private string _currentMovementSfxAudioName = string.Empty;
private Vector2? _lastInputTapPosition;
private Vector3? _lastKnownPosition;
private Vector2Int? _lastKnownTilePosition;
private int? _lastKnownLayerIndex;
private bool _isTilePositionPendingNotify;
private string _lastKnownPlayerActorAction = string.Empty;
#if PAL3
private int _longKuiLastKnownMode = 0;
#endif
private Actor _playerActor;
private GameObject _playerActorGameObject;
private ActorController _playerActorController;
private ActorActionController _playerActorActionController;
private ActorMovementController _playerActorMovementController;
private const int LAST_KNOWN_SCENE_STATE_LIST_MAX_LENGTH = 2;
private readonly List<(ScnSceneInfo sceneInfo,
int actorNavIndex,
Vector2Int actorTilePosition,
Vector3 actorFacing)> _playerActorLastKnownSceneState = new ();
public PlayerGamePlayManager(GameResourceProvider resourceProvider,
GameStateManager gameStateManager,
PlayerActorManager playerActorManager,
TeamManager teamManager,
PlayerInputActions inputActions,
SceneManager sceneManager,
Camera mainCamera)
{
_resourceProvider = Requires.IsNotNull(resourceProvider, nameof(resourceProvider));
_gameStateManager = Requires.IsNotNull(gameStateManager, nameof(gameStateManager));
_playerActorManager = Requires.IsNotNull(playerActorManager, nameof(playerActorManager));
_teamManager = Requires.IsNotNull(teamManager, nameof(teamManager));
_inputActions = Requires.IsNotNull(inputActions, nameof(inputActions));
_sceneManager = Requires.IsNotNull(sceneManager, nameof(sceneManager));
_camera = Requires.IsNotNull(mainCamera, nameof(mainCamera));
_inputActions.Gameplay.OnTap.performed += OnTapPerformed;
_inputActions.Gameplay.OnMove.performed += OnMovePerformed;
_inputActions.Gameplay.OnDoubleTap.performed += OnDoubleTapPerformed;
_inputActions.Gameplay.PortalTo.performed += PortalToPerformed;
_inputActions.Gameplay.Interact.performed += InteractionPerformed;
_inputActions.Gameplay.Movement.canceled += MovementCanceled;
_inputActions.Gameplay.SwitchToPreviousPlayerActor.performed += SwitchToPreviousPlayerActorPerformed;
_inputActions.Gameplay.SwitchToNextPlayerActor.performed += SwitchToNextPlayerActorPerformed;
CommandExecutorRegistry<ICommand>.Instance.Register(this);
}
public void Dispose()
{
_inputActions.Gameplay.OnTap.performed -= OnTapPerformed;
_inputActions.Gameplay.OnMove.performed -= OnMovePerformed;
_inputActions.Gameplay.OnDoubleTap.performed -= OnDoubleTapPerformed;
_inputActions.Gameplay.PortalTo.performed -= PortalToPerformed;
_inputActions.Gameplay.Interact.performed -= InteractionPerformed;
_inputActions.Gameplay.Movement.canceled -= MovementCanceled;
_inputActions.Gameplay.SwitchToPreviousPlayerActor.performed -= SwitchToPreviousPlayerActorPerformed;
_inputActions.Gameplay.SwitchToNextPlayerActor.performed -= SwitchToNextPlayerActorPerformed;
CommandExecutorRegistry<ICommand>.Instance.UnRegister(this);
}
public void Update(float deltaTime)
{
if (_playerActorGameObject == null) return;
var isPlayerInControl = false;
if (_gameStateManager.GetCurrentState() == GameState.Gameplay &&
_playerActorManager.IsPlayerInputEnabled() &&
_playerActorManager.IsPlayerActorControlEnabled())
{
isPlayerInControl = true;
ReadInputAndMovePlayerIfNeeded();
}
var shouldUpdatePlayerActorMovementSfx = false;
Vector3 position = _playerActorGameObject.transform.position;
var layerIndex = _playerActorMovementController.GetCurrentLayerIndex();
if (!(position == _lastKnownPosition && layerIndex == _lastKnownLayerIndex))
{
_lastKnownPosition = position;
Vector2Int tilePosition = _playerActorMovementController.GetTilePosition();
if (!(tilePosition == _lastKnownTilePosition && layerIndex == _lastKnownLayerIndex))
{
shouldUpdatePlayerActorMovementSfx = true;
_lastKnownTilePosition = tilePosition;
PlayerActorTilePositionChanged(layerIndex, tilePosition, !isPlayerInControl);
}
else if (_isTilePositionPendingNotify)
{
PlayerActorTilePositionChanged(layerIndex, tilePosition, !isPlayerInControl);
_isTilePositionPendingNotify = false;
}
}
_lastKnownLayerIndex = layerIndex;
var currentAction = _playerActorActionController.GetCurrentAction();
if (currentAction != _lastKnownPlayerActorAction)
{
_lastKnownPlayerActorAction = currentAction;
shouldUpdatePlayerActorMovementSfx = true;
}
if (shouldUpdatePlayerActorMovementSfx)
{
UpdatePlayerActorMovementSfx(_lastKnownPlayerActorAction);
}
}
private void PlayerActorTilePositionChanged(int layerIndex, Vector2Int tilePosition, bool movedByScript)
{
CommandDispatcher<ICommand>.Instance.Dispatch(
new PlayerActorTilePositionUpdatedNotification(tilePosition, layerIndex, movedByScript));
}
public bool TryGetPlayerActorLastKnownPosition(out Vector3 position)
{
if (_lastKnownPosition.HasValue)
{
position = _lastKnownPosition.Value;
return true;
}
position = Vector3.zero;
return false;
}
private void MovementCanceled(InputAction.CallbackContext _)
{
_playerActorActionController.PerformAction(ActorActionType.Stand);
}
private void OnTapPerformed(InputAction.CallbackContext _)
{
if (!_playerActorManager.IsPlayerActorControlEnabled() ||
!_playerActorManager.IsPlayerInputEnabled())
{
return;
}
MoveToTapPosition(false);
}
private void OnDoubleTapPerformed(InputAction.CallbackContext _)
{
if (!_playerActorManager.IsPlayerActorControlEnabled() ||
!_playerActorManager.IsPlayerInputEnabled())
{
return;
}
MoveToTapPosition(true);
}
private void PortalToPerformed(InputAction.CallbackContext _)
{
if (!_playerActorManager.IsPlayerActorControlEnabled() ||
!_playerActorManager.IsPlayerInputEnabled())
{
return;
}
if (Keyboard.current.leftCtrlKey.isPressed)
{
PortalToTapPosition();
}
else
{
if (IsPlayerActorInsideJumpableArea())
{
JumpToTapPosition();
}
}
}
private void OnMovePerformed(InputAction.CallbackContext ctx)
{
if (!_playerActorManager.IsPlayerActorControlEnabled() ||
!_playerActorManager.IsPlayerInputEnabled())
{
return;
}
_lastInputTapPosition = ctx.ReadValue<Vector2>();
}
public void Execute(PlayerActorLookAtSceneObjectCommand command)
{
Transform actorTransform = _playerActorGameObject.transform;
SceneObject sceneObject = _sceneManager.GetCurrentScene().GetSceneObject(command.SceneObjectId);
if (sceneObject?.GetGameObject() is { } sceneObjectGameObject)
{
Vector3 objectPosition = sceneObjectGameObject.transform.position;
actorTransform.LookAt(new Vector3(
objectPosition.x,
actorTransform.position.y,
objectPosition.z));
}
}
public void Execute(ActorEnablePlayerControlCommand command)
{
if (command.ActorId == ActorConstants.PlayerActorVirtualID) return;
// Check if actor is player actor.
if (!Enum.IsDefined(typeof(PlayerActorId), command.ActorId))
{
Debug.LogError($"[{nameof(PlayerGamePlayManager)}] Cannot enable player control for actor " +
$"{command.ActorId} since actor is not a player actor.");
return;
}
// Stop & dispose current player actor movement sfx
if (_playerActorGameObject != null)
{
_currentMovementSfxAudioName = string.Empty;
CommandDispatcher<ICommand>.Instance.Dispatch(
new StopSfxPlayingAtGameObjectRequest(_playerActorGameObject,
AudioConstants.PlayerActorMovementSfxAudioSourceName,
disposeSource: true));
}
// Reset & dispose current player actor's jump indicators
int jumpableAreaEnterCount = _jumpableAreaEnterCount;
ResetAndDisposeJumpIndicators();
Vector3? lastActivePlayerActorPosition = null;
Quaternion? lastActivePlayerActorRotation = null;
int? lastActivePlayerActorNavLayerIndex = null;
// Deactivate current player actor
if (_playerActorGameObject != null &&
_playerActor.Info.Id != command.ActorId &&
_playerActorController != null &&
_playerActorController.IsActive)
{
lastActivePlayerActorNavLayerIndex = _playerActorMovementController.GetCurrentLayerIndex();
_playerActorGameObject.transform.GetPositionAndRotation(out Vector3 currentPosition, out Quaternion currentRotation);
lastActivePlayerActorPosition = currentPosition;
lastActivePlayerActorRotation = currentRotation;
CommandDispatcher<ICommand>.Instance.Dispatch(new ActorActivateCommand(_playerActor.Info.Id, 0));
}
// Set target actor as player actor
_playerActor = _sceneManager.GetCurrentScene().GetActor(command.ActorId);
_playerActorGameObject = _sceneManager.GetCurrentScene().GetActorGameObject(command.ActorId);
_playerActorController = _playerActorGameObject.GetComponent<ActorController>();
_playerActorActionController = _playerActorGameObject.GetComponent<ActorActionController>();
_playerActorMovementController = _playerActorGameObject.GetComponent<ActorMovementController>();
#if PAL3
// LongKui should stay blue form when player control is enabled
if (command.ActorId == (int)PlayerActorId.LongKui)
{
CommandDispatcher<ICommand>.Instance.Dispatch(new LongKuiSwitchModeCommand(0));
}
#endif
// Just to make sure the new actor is activated
if (!_playerActorController.IsActive)
{
CommandDispatcher<ICommand>.Instance.Dispatch(new ActorActivateCommand(_playerActor.Info.Id, 1));
// Inherent nav layer index
if (lastActivePlayerActorNavLayerIndex.HasValue)
{
_playerActorMovementController.SetNavLayer(lastActivePlayerActorNavLayerIndex.Value);
}
// Inherent position
if (lastActivePlayerActorPosition.HasValue)
{
_playerActorGameObject.transform.position = lastActivePlayerActorPosition.Value;
}
// Inherent rotation
if (lastActivePlayerActorRotation.HasValue)
{
_playerActorGameObject.transform.rotation = lastActivePlayerActorRotation.Value;
}
}
// Reset states
_lastKnownPosition = null;
_lastKnownTilePosition = null;
_lastKnownPlayerActorAction = string.Empty;
// Inherent jumpable state
if (jumpableAreaEnterCount > 0)
{
PlayerActorEnteredJumpableArea();
// Inherent jumpable area enter count
_jumpableAreaEnterCount = jumpableAreaEnterCount;
}
}
public void Execute(PlayerEnableInputCommand command)
{
if (command.Enable == 0)
{
if (_playerActorMovementController != null)
{
_playerActorMovementController.CancelMovement();
}
if (_playerActorActionController != null &&
!string.IsNullOrEmpty(_playerActorActionController.GetCurrentAction()) &&
!string.Equals(ActorConstants.ActionToNameMap[ActorActionType.Stand],
_playerActorActionController.GetCurrentAction(),
StringComparison.OrdinalIgnoreCase))
{
_playerActorActionController.PerformAction(ActorActionType.Stand);
}
_lastKnownPosition = null;
_lastKnownTilePosition = null;
}
}
public void Execute(ActorSetTilePositionCommand command)
{
if (command.ActorId == ActorConstants.PlayerActorVirtualID ||
(_playerActor != null && _playerActor.Info.Id == command.ActorId))
{
_isTilePositionPendingNotify = true;
}
}
public void Execute(SceneLeavingCurrentSceneNotification command)
{
if (_sceneManager.GetCurrentScene() is not { } currentScene) return;
// Stop current player actor movement sfx
if (_playerActorGameObject != null)
{
_currentMovementSfxAudioName = string.Empty;
CommandDispatcher<ICommand>.Instance.Dispatch(
new StopSfxPlayingAtGameObjectRequest(_playerActorGameObject,
AudioConstants.PlayerActorMovementSfxAudioSourceName,
disposeSource: true));
}
// Remove game play indicators
ResetAndDisposeJumpIndicators();
_playerActorLastKnownSceneState.Add((
currentScene.GetSceneInfo(),
_playerActorMovementController.GetCurrentLayerIndex(),
_playerActorMovementController.GetTilePosition(),
_playerActorGameObject.transform.forward));
if (_playerActorLastKnownSceneState.Count > LAST_KNOWN_SCENE_STATE_LIST_MAX_LENGTH)
{
_playerActorLastKnownSceneState.RemoveAt(0);
}
}
public void Execute(ScenePostLoadingNotification notification)
{
var playerActorId = (int)_playerActorManager.GetPlayerActor();
CommandDispatcher<ICommand>.Instance.Dispatch(new ActorActivateCommand(playerActorId, 1));
if (_playerActorLastKnownSceneState.Count > 0 && _playerActorLastKnownSceneState.Any(_ =>
_.sceneInfo.ModelEquals(notification.NewSceneInfo)))
{
(ScnSceneInfo _, int actorNavIndex, Vector2Int actorTilePosition, Vector3 actorFacing) =
_playerActorLastKnownSceneState.Last(_ => _.sceneInfo.ModelEquals(notification.NewSceneInfo));
CommandDispatcher<ICommand>.Instance.Dispatch(
new ActorSetNavLayerCommand(playerActorId, actorNavIndex));
CommandDispatcher<ICommand>.Instance.Dispatch(
new ActorSetTilePositionCommand(playerActorId, actorTilePosition.x, actorTilePosition.y));
_sceneManager.GetCurrentScene()
.GetActorGameObject(playerActorId).transform.forward = actorFacing;
}
if (_playerActorManager.IsPlayerActorControlEnabled())
{
CommandDispatcher<ICommand>.Instance.Dispatch(new ActorEnablePlayerControlCommand(playerActorId));
}
if (_playerActorManager.IsPlayerInputEnabled())
{
CommandDispatcher<ICommand>.Instance.Dispatch(new PlayerEnableInputCommand(1));
}
#if PAL3
CommandDispatcher<ICommand>.Instance.Dispatch(new LongKuiSwitchModeCommand(_longKuiLastKnownMode));
#endif
_isTilePositionPendingNotify = true;
}
public void Execute(ResetGameStateCommand command)
{
ResetAndDisposeJumpIndicators();
_playerActorLastKnownSceneState.Clear();
_currentMovementSfxAudioName = string.Empty;
_lastInputTapPosition = null;
_lastKnownPosition = null;
_lastKnownTilePosition = null;
_lastKnownLayerIndex = null;
_lastKnownPlayerActorAction = string.Empty;
_isTilePositionPendingNotify = false;
#if PAL3
_longKuiLastKnownMode = 0;
#endif
_playerActor = null;
_playerActorGameObject = null;
_playerActorController = null;
_playerActorActionController = null;
_playerActorMovementController = null;
}
#if PAL3
public void Execute(LongKuiSwitchModeCommand command)
{
_longKuiLastKnownMode = command.Mode;
}
#endif
}
}
+48 -46
View File
@@ -10,29 +10,17 @@ namespace Pal3
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Threading;
using Core.Animation;
using Core.DataReader;
using Core.DataReader.Cpk;
using Core.DataReader.Cvd;
using Core.DataReader.Data;
using Core.DataReader.Gdb;
using Core.DataReader.Ini;
using Core.DataReader.Lgt;
using Core.DataReader.Mov;
using Core.DataReader.Msh;
using Core.DataReader.Mtl;
using Core.DataReader.Mv3;
using Core.DataReader.Nav;
using Core.DataReader.Pol;
using Core.DataReader.Sce;
using Core.DataReader.Scn;
using Core.DataReader.Txt;
using Core.FileSystem;
using Core.Services;
using Data;
using MetaData;
using Renderer;
using Rendering.Material;
using Settings;
using SimpleFileBrowser;
using TMPro;
@@ -50,11 +38,8 @@ namespace Pal3
[SerializeField] private Image backgroundImage;
[SerializeField] private TextMeshProUGUI loadingText;
private const int DEFAULT_CODE_PAGE = 936; // GBK Encoding's code page
// change it to 950 to supports Traditional Chinese (Big5)
// Optional materials that are used in the game but not open sourced
private Material _toonDefaultMaterial;
private Material _toonOpaqueMaterial;
private Material _toonTransparentMaterial;
private IEnumerator Start()
@@ -62,12 +47,12 @@ namespace Pal3
loadingText.text = "正在加载游戏数据...";
yield return null; // Wait for next frame to make sure the text is updated
ResourceRequest toonDefaultMaterialLoadRequest = Resources.LoadAsync<Material>("Materials/ToonDefault");
yield return toonDefaultMaterialLoadRequest;
ResourceRequest toonOpaqueMaterialLoadRequest = Resources.LoadAsync<Material>("Materials/ToonDefault");
yield return toonOpaqueMaterialLoadRequest;
if (toonDefaultMaterialLoadRequest.asset != null)
if (toonOpaqueMaterialLoadRequest.asset != null)
{
_toonDefaultMaterial = toonDefaultMaterialLoadRequest.asset as Material;
_toonOpaqueMaterial = toonOpaqueMaterialLoadRequest.asset as Material;
}
ResourceRequest toonTransparentMaterialLoadRequest = Resources.LoadAsync<Material>("Materials/ToonTransparent");
@@ -85,16 +70,13 @@ namespace Pal3
{
Debug.Log($"[{nameof(GameResourceInitializer)}] Initializing game resources...");
// TODO: let user to choose language? Or auto-detect encoding?
int codepage = DEFAULT_CODE_PAGE;
// Create and init Crc32 hash
Crc32Hash crcHash = new ();
crcHash.Init();
ServiceLocator.Instance.Register<Crc32Hash>(crcHash);
// If toon materials are not present, it's an open source build
bool isOpenSourceVersion = _toonDefaultMaterial == null || _toonTransparentMaterial == null;
bool isOpenSourceVersion = _toonOpaqueMaterial == null || _toonTransparentMaterial == null;
// Init settings store
ITransactionalKeyValueStore settingsStore = new PlayerPrefsStore();
@@ -104,6 +86,9 @@ namespace Pal3
gameSettings.InitOrLoadSettings();
ServiceLocator.Instance.Register<GameSettings>(gameSettings);
// Init codepage
int codepage = gameSettings.Language == Language.SimplifiedChinese ? 936 : 950;
// Init file system
Queue<string> gameDataFolderSearchLocations = new(gameSettings.GetGameDataFolderSearchLocations());
ICpkFileSystem cpkFileSystem = null;
@@ -162,22 +147,26 @@ namespace Pal3
}
}
// Create and register IFileReader<T> instances
ServiceLocator.Instance.Register<IFileReader<CvdFile>>(new CvdFileReader(codepage));
ServiceLocator.Instance.Register<IFileReader<Mv3File>>(new Mv3FileReader(codepage));
ServiceLocator.Instance.Register<IFileReader<MovFile>>(new MovFileReader(codepage));
ServiceLocator.Instance.Register<IFileReader<MshFile>>(new MshFileReader(codepage));
ServiceLocator.Instance.Register<IFileReader<MtlFile>>(new MtlFileReader(codepage));
ServiceLocator.Instance.Register<IFileReader<PolFile>>(new PolFileReader(codepage));
ServiceLocator.Instance.Register<IFileReader<GdbFile>>(new GdbFileReader(codepage));
ServiceLocator.Instance.Register<IFileReader<LgtFile>>(new LgtFileReader());
ServiceLocator.Instance.Register<IFileReader<NavFile>>(new NavFileReader());
ServiceLocator.Instance.Register<IFileReader<MovActionConfig>>(new MovConfigFileReader());
ServiceLocator.Instance.Register<IFileReader<Mv3ActionConfig>>(new Mv3ConfigFileReader());
ServiceLocator.Instance.Register<IFileReader<EffectDefinitionFile>>(new EffectDefinitionFileReader());
ServiceLocator.Instance.Register<IFileReader<SceFile>>(new SceFileReader(codepage));
ServiceLocator.Instance.Register<IFileReader<ScnFile>>(new ScnFileReader(codepage));
ServiceLocator.Instance.Register<IFileReader<TaskDefinitionFile>>(new TaskDefinitionFileReader(codepage));
// Create and register IFileReader<T> instances using reflection
foreach (Assembly assembly in AppDomain.CurrentDomain.GetAssemblies())
{
// Get all types that implement any version of IFileReader<>
var fileReaderTypes = assembly.GetTypes().Where(type =>
type.GetInterfaces().Any(_ =>_.IsGenericType &&_.GetGenericTypeDefinition() == typeof(IFileReader<>)));
foreach (Type readerType in fileReaderTypes)
{
Type fileType = readerType.GetInterfaces()
.First(_ => _.GetGenericTypeDefinition() == typeof(IFileReader<>)).GetGenericArguments()[0];
ServiceLocator.Instance.GetType()
.GetMethod(nameof(ServiceLocator.Instance.Register))!
.MakeGenericMethod(typeof(IFileReader<>).MakeGenericType(fileType))
.Invoke(ServiceLocator.Instance, new[] { Activator.CreateInstance(readerType) });
}
}
loadingText.text = "正在初始化游戏资源...";
yield return null; // Wait for next frame to make sure the text is updated
// Init TextureLoaderFactory
TextureLoaderFactory textureLoaderFactory = new ();
@@ -185,12 +174,22 @@ namespace Pal3
// Init material factories
IMaterialFactory unlitMaterialFactory = new UnlitMaterialFactory();
IMaterialFactory litMaterialFactory = null;
IMaterialFactory litMaterialFactory = null;
// Only create litMaterialFactory when toon materials are present
if (_toonDefaultMaterial != null && _toonTransparentMaterial != null)
if (_toonOpaqueMaterial != null && _toonTransparentMaterial != null)
{
litMaterialFactory = new LitMaterialFactory(_toonDefaultMaterial, _toonTransparentMaterial);
litMaterialFactory = new LitMaterialFactory(_toonOpaqueMaterial, _toonTransparentMaterial);
}
// Pre-allocate material pool, since it is very costly to create new materials at runtime
if (!isOpenSourceVersion && gameSettings.IsRealtimeLightingAndShadowsEnabled && litMaterialFactory != null)
{
litMaterialFactory.AllocateMaterialPool();
}
else
{
unlitMaterialFactory.AllocateMaterialPool();
}
// Init Game resource provider
@@ -203,6 +202,9 @@ namespace Pal3
Debug.Log($"[{nameof(GameResourceInitializer)}] Game resources initialized.");
loadingText.text = "正在启动游戏...";
yield return null; // Wait for next frame to make sure the text is updated
// Instantiate starting component
GameObject startingGameObject = Instantiate(startingComponent, null);
startingGameObject.name = startingComponent.name;
+30 -31
View File
@@ -26,24 +26,24 @@ namespace Pal3.GameSystem
using UnityEngine.InputSystem.DualShock;
using UnityEngine.UI;
public sealed class BigMapManager : MonoBehaviour,
public sealed class BigMapManager : IDisposable,
ICommandExecutor<BigMapEnableRegionCommand>,
ICommandExecutor<ResetGameStateCommand>,
ICommandExecutor<GameSwitchRenderingStateCommand>,
ICommandExecutor<GameSwitchToMainMenuCommand>,
ICommandExecutor<ToggleBigMapRequest>
{
private EventSystem _eventSystem;
private GameStateManager _gameStateManager;
private InputManager _inputManager;
private PlayerInputActions _playerInputActions;
private ScriptManager _scriptManager;
private SceneManager _sceneManager;
private CanvasGroup _bigMapCanvas;
private GridLayoutGroup _bigMapCanvasGridLayoutGroup;
private GameObject _bigMapRegionButtonPrefab;
private RectTransform _bigMapBackgroundTransform;
private CanvasGroup _bigMapBackgroundCanvasGroup;
private readonly EventSystem _eventSystem;
private readonly GameStateManager _gameStateManager;
private readonly InputManager _inputManager;
private readonly PlayerInputActions _playerInputActions;
private readonly ScriptManager _scriptManager;
private readonly SceneManager _sceneManager;
private readonly CanvasGroup _bigMapCanvas;
private readonly GridLayoutGroup _bigMapCanvasGridLayoutGroup;
private readonly GameObject _bigMapRegionButtonPrefab;
private readonly RectTransform _bigMapBackgroundTransform;
private readonly CanvasGroup _bigMapBackgroundCanvasGroup;
private bool _isVisible;
@@ -52,7 +52,7 @@ namespace Pal3.GameSystem
private readonly List<GameObject> _selectionButtons = new();
private readonly Dictionary<int, int> _regionEnablementInfo = new ();
public void Init(EventSystem eventSystem,
public BigMapManager(EventSystem eventSystem,
GameStateManager gameStateManager,
SceneManager sceneManager,
InputManager inputManager,
@@ -82,21 +82,18 @@ namespace Pal3.GameSystem
_isVisible = false;
_playerInputActions.Gameplay.ToggleBigMap.performed += ToggleBigMapOnPerformed;
_playerInputActions.Cutscene.ToggleBigMap.performed += ToggleBigMapOnPerformed;
_playerInputActions.Cutscene.ExitCurrentShowingMenu.performed += HideBigMapOnPerformed;
}
_playerInputActions.UI.ToggleBigMap.performed += ToggleBigMapOnPerformed;
_playerInputActions.UI.ExitCurrentShowingMenu.performed += HideBigMapOnPerformed;
private void OnEnable()
{
CommandExecutorRegistry<ICommand>.Instance.Register(this);
}
private void OnDisable()
public void Dispose()
{
CommandExecutorRegistry<ICommand>.Instance.UnRegister(this);
_playerInputActions.Gameplay.ToggleBigMap.performed -= ToggleBigMapOnPerformed;
_playerInputActions.Cutscene.ToggleBigMap.performed -= ToggleBigMapOnPerformed;
_playerInputActions.Cutscene.ExitCurrentShowingMenu.performed -= HideBigMapOnPerformed;
_playerInputActions.UI.ToggleBigMap.performed -= ToggleBigMapOnPerformed;
_playerInputActions.UI.ExitCurrentShowingMenu.performed -= HideBigMapOnPerformed;
}
private void ToggleBigMapOnPerformed(InputAction.CallbackContext _)
@@ -109,7 +106,7 @@ namespace Pal3.GameSystem
if (_isVisible)
{
Hide();
_gameStateManager.GoToState(GameState.Gameplay);
_gameStateManager.TryGoToState(GameState.Gameplay);
}
}
@@ -130,7 +127,7 @@ namespace Pal3.GameSystem
if (_isVisible)
{
Hide();
_gameStateManager.GoToState(GameState.Gameplay);
_gameStateManager.TryGoToState(GameState.Gameplay);
}
else if (_gameStateManager.GetCurrentState() == GameState.Gameplay)
{
@@ -142,7 +139,7 @@ namespace Pal3.GameSystem
}
}
public void Show()
private void Show()
{
if (_regionEnablementInfo.Count == 0)
{
@@ -150,7 +147,7 @@ namespace Pal3.GameSystem
return;
}
_gameStateManager.GoToState(GameState.Cutscene);
_gameStateManager.TryGoToState(GameState.UI);
// Scene script can execute GameSwitchRenderingStateCommand to toggle BigMap
// After the script finishes, the state will be reset to Gameplay. Thus we need to
// block the state change.
@@ -159,7 +156,8 @@ namespace Pal3.GameSystem
CommandDispatcher<ICommand>.Instance.Dispatch(
new ActorStopActionAndStandCommand(ActorConstants.PlayerActorVirtualID));
GameObject exitButtonObj = Instantiate(_bigMapRegionButtonPrefab, _bigMapCanvas.transform);
GameObject exitButtonObj = UnityEngine.Object.Instantiate(_bigMapRegionButtonPrefab,
_bigMapCanvas.transform);
var exitButtonTextUI = exitButtonObj.GetComponentInChildren<TextMeshProUGUI>();
exitButtonTextUI.text = "关闭";
var exitButton = exitButtonObj.GetComponent<Button>();
@@ -170,7 +168,8 @@ namespace Pal3.GameSystem
for (var i = 0; i < BigMapConstants.BigMapRegions.Length; i++)
{
if (!_regionEnablementInfo.ContainsKey(i) || _regionEnablementInfo[i] != 2) continue;
GameObject selectionButton = Instantiate(_bigMapRegionButtonPrefab, _bigMapCanvas.transform);
GameObject selectionButton = UnityEngine.Object.Instantiate(_bigMapRegionButtonPrefab,
_bigMapCanvas.transform);
var buttonTextUI = selectionButton.GetComponentInChildren<TextMeshProUGUI>();
buttonTextUI.text = BigMapConstants.BigMapRegions[i];
var buttonIndex = i;
@@ -240,10 +239,10 @@ namespace Pal3.GameSystem
_scriptManager.AddScript((uint)(100 + buttonIndex), true);
}
Hide();
_gameStateManager.GoToState(GameState.Gameplay);
_gameStateManager.TryGoToState(GameState.Gameplay);
}
public void Hide()
private void Hide()
{
_bigMapCanvas.alpha = 0f;
_bigMapCanvas.interactable = false;
@@ -253,7 +252,7 @@ namespace Pal3.GameSystem
foreach (GameObject button in _selectionButtons)
{
button.GetComponent<Button>().onClick.RemoveAllListeners();
Destroy(button);
UnityEngine.Object.Destroy(button);
}
_selectionButtons.Clear();
_gameStateManager.RemoveGamePlayStateLocker(_stateLockerGuid);
@@ -271,7 +270,7 @@ namespace Pal3.GameSystem
public void Execute(GameSwitchRenderingStateCommand command)
{
if (command.State == 13)
if ((RenderingState)command.State == RenderingState.BigMap)
{
Show();
}
Loaded 100 of 218 files, more files were not shown because too many files have changed in this diff. Show more