Skip to content

Commit

Permalink
太吾修改器 1.0.10.5
Browse files Browse the repository at this point in the history
1. 修复修改属性时有时会弹出错误的人物菜单并且无法关闭的问题
2. 修复使用“奇遇直达终点”时会反复进入战斗的问题
3. 支持游戏V0.2.5.10
  • Loading branch information
ciwei100000 committed Sep 5, 2019
1 parent 9b87202 commit c4e6b4e
Show file tree
Hide file tree
Showing 10 changed files with 1,262 additions and 194 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@
using System.Runtime.CompilerServices;

using UnityEngine;
using UnityModManagerNet;

namespace TaiwuEditor
{
class ActorPropertyHelper : Helper
/// <summary>
/// 角色属性修改工具类
/// </summary>
class ActorPropertyHelper : HelperBase
{
private const string errorString = "无人物数据";
/// <summary>属性ID名称</summary>
Expand Down Expand Up @@ -61,18 +63,29 @@ class ActorPropertyHelper : Helper
{614, "乐器"},
{706, "无属性内力"}
};
private static ActorPropertyHelper instance;
/// <summary>修改框数值缓存</summary>
private readonly Dictionary<int, string> fieldValuesCache;
/// <summary>当前编辑的角色在游戏中的数据</summary>
private Dictionary<int, string> currentActorDate;
/// <summary>修改框标签宽度</summary>
public float fieldHelperLblWidth = 90f;
public static float fieldHelperLblWidth = 90f;
/// <summary>修改框宽度</summary>
public float fieldHelperTextWidth = 120f;
public static float fieldHelperTextWidth = 120f;
/// <summary>修改框修改按钮宽度</summary>
public float fieldHelperBtnWidth = 80f;
public static float fieldHelperBtnWidth = 80f;

public ActorPropertyHelper(UnityModManager.ModEntry.ModLogger logger) : base(logger)
public static ActorPropertyHelper Instance
{
get
{
if (instance == null)
instance = new ActorPropertyHelper();
return instance;
}
}

protected ActorPropertyHelper()
{
fieldValuesCache = new Dictionary<int, string>(fieldNames.Count);
}
Expand Down Expand Up @@ -215,8 +228,7 @@ public bool GetLastActorData(int index, out string text)
private void UpdateAllFields(int actorId)
{
var dateFile = DateFile.instance;
var actorMenu = ActorMenu.instance;
if (dateFile == null || dateFile.actorsDate == null || actorMenu == null
if (dateFile == null || dateFile.actorsDate == null
|| !dateFile.actorsDate.TryGetValue(actorId, out currentActorDate))
{
if (fieldValuesCache.Count > 0)
Expand All @@ -231,7 +243,7 @@ private void UpdateAllFields(int actorId)
currentActorId = actorId;
foreach (var field in fieldNames)
{
FetchFieldValueHelper(dateFile, actorMenu, currentActorDate, field.Key);
FetchFieldValueHelper(dateFile, currentActorDate, field.Key);
}
}
}
Expand All @@ -255,7 +267,7 @@ private void UpdateField(int resid)
}
else
{
FetchFieldValueHelper(dateFile, actorMenu, currentActorDate, resid);
FetchFieldValueHelper(dateFile, currentActorDate, resid);
}
}

Expand All @@ -267,15 +279,15 @@ private void UpdateField(int resid)
/// <param name="actorDate">不能为null</param>
/// <param name="resid"></param>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
private void FetchFieldValueHelper(DateFile dateFileInstance, ActorMenu actorMenuInstance, Dictionary<int, string> actorDate, int resid)
private void FetchFieldValueHelper(DateFile dateFileInstance, Dictionary<int, string> actorDate, int resid)
{
switch (resid)
{
case -1:
fieldValuesCache[resid] = dateFileInstance.gongFaExperienceP.ToString();
break;
case 12: // 获取健康数据
fieldValuesCache[resid] = actorMenuInstance.Health(currentActorId).ToString();
fieldValuesCache[resid] = dateFileInstance.Health(currentActorId).ToString();
break;
default:
if (!actorDate.TryGetValue(resid, out string text))
Expand Down
Loading

0 comments on commit c4e6b4e

Please sign in to comment.