-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[KK,KKS] Make ext data properly propagate in story mode
- Loading branch information
1 parent
afafe58
commit dc09eed
Showing
5 changed files
with
198 additions
and
70 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 44 additions & 5 deletions
49
src/Shared.Core/Chara/TestCharaCustomFunctionController.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,68 @@ | ||
#if AI || HS2 | ||
using System; | ||
using System.Collections.Generic; | ||
using ExtensibleSaveFormat; | ||
#if AI || HS2 | ||
using AIChara; | ||
#endif | ||
|
||
namespace KKAPI.Chara | ||
{ | ||
internal sealed class TestCharaCustomFunctionController : CharaCustomFunctionController | ||
{ | ||
public string id; | ||
public static int No; | ||
protected override void OnCardBeingSaved(GameMode currentGameMode) | ||
{ | ||
KoikatuAPI.Logger.LogWarning("CharaController - OnCardBeingSaved - currentGameMode:" + currentGameMode); | ||
SetParameterExtData(new PluginData() { data = new Dictionary<string, object> { { "id", id } } }); | ||
SetBodyExtData(new PluginData() { data = new Dictionary<string, object> { { "id", id } } }); | ||
SetFaceExtData(new PluginData() { data = new Dictionary<string, object> { { "id", id } } }); | ||
SetExtendedData(new PluginData() { data = new Dictionary<string, object> { { "id", id } } }); | ||
// todo test if ext data gets carried over when saving inside talk scene and h | ||
Console.WriteLine($"Save ID to ext data - {id} | Chara - {ChaControl.name}"); | ||
|
||
KoikatuAPI.Logger.LogWarning($"event:OnCardBeingSaved chara:{ChaControl.name} currentGameMode:{currentGameMode}"); | ||
} | ||
|
||
protected override void OnReload(GameMode currentGameMode, bool maintainState) | ||
{ | ||
KoikatuAPI.Logger.LogWarning($"CharaController - OnReload - currentGameMode:{currentGameMode}; maintainState:{maintainState}"); | ||
var a = GetExtendedData(); | ||
var b = GetBodyExtData(); | ||
var c = GetParameterExtData(); | ||
var d = GetFaceExtData(); | ||
KoikatuAPI.Assert((a == null && b == null && c == null && d == null) || (a != null && b != null && c != null && d != null), "ext data not lining up"); | ||
if (a != null) | ||
{ | ||
KoikatuAPI.Assert(b != null, "b != null"); | ||
KoikatuAPI.Assert(c != null, "c != null"); | ||
KoikatuAPI.Assert(d != null, "d != null"); | ||
var newId = a.data["id"] as string; | ||
KoikatuAPI.Assert(newId == b?.data["id"] as string, "a.data[\"id\"] == b.data[\"id\"]"); | ||
KoikatuAPI.Assert(newId == c?.data["id"] as string, "a.data[\"id\"] == c.data[\"id\"]"); | ||
KoikatuAPI.Assert(newId == d?.data["id"] as string, "a.data[\"id\"] == d.data[\"id\"]"); | ||
Console.WriteLine($"ID get from ext data - {newId} | Old ID - {id} | Chara - {ChaControl.name}"); | ||
id = newId; | ||
} | ||
if (id == null) | ||
{ | ||
id = $"{No++} - {SceneApi.GetLoadSceneName()} - {SceneApi.GetAddSceneName()}"; | ||
Console.WriteLine($"New ID assigned - {id} | Chara - {ChaControl.name} | {ChaFileControl.parameter.fullname}"); | ||
SetParameterExtData(new PluginData() { data = new Dictionary<string, object> { { "id", id } } }); | ||
SetBodyExtData(new PluginData() { data = new Dictionary<string, object> { { "id", id } } }); | ||
SetFaceExtData(new PluginData() { data = new Dictionary<string, object> { { "id", id } } }); | ||
SetExtendedData(new PluginData() { data = new Dictionary<string, object> { { "id", id } } }); | ||
} | ||
|
||
KoikatuAPI.Logger.LogWarning($"event:OnReload chara:{ChaControl.name} currentGameMode:{currentGameMode} maintainState:{maintainState}"); | ||
} | ||
|
||
protected override void OnCoordinateBeingLoaded(ChaFileCoordinate coordinate, bool maintainState) | ||
{ | ||
KoikatuAPI.Logger.LogWarning($"CharaController - OnCoordinateBeingLoaded - coordinate:{coordinate?.coordinateFileName}; maintainState:{maintainState}"); | ||
KoikatuAPI.Logger.LogWarning($"event:OnCoordinateBeingLoaded chara:{ChaControl.name} coordinate:{coordinate?.coordinateFileName}; maintainState:{maintainState}"); | ||
} | ||
|
||
protected override void OnCoordinateBeingSaved(ChaFileCoordinate coordinate) | ||
{ | ||
KoikatuAPI.Logger.LogWarning($"CharaController - OnCoordinateBeingSaved - coordinate:{coordinate?.coordinateFileName}"); | ||
KoikatuAPI.Logger.LogWarning($"event:OnCoordinateBeingSaved chara:{ChaControl.name} coordinate:{coordinate?.coordinateFileName}"); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.