leaf3woods / taiwu-mods Goto Github PK
View Code? Open in Web Editor NEWmods of the scroll of taiwu
License: MIT License
mods of the scroll of taiwu
License: MIT License
这是一个GameData.Domains.Character.Character 下 GenerateRandomBasicFeatures的前置补丁
[HarmonyPrefix]
[HarmonyPatch(declaringType: typeof(GameData.Domains.Character.Character), methodName: "GenerateRandomBasicFeatures")]
public static bool PrefixOfGenerateRandomBasicFeatures(bool isProtagonist, Dictionary<short, short> featureGroup2Id)
featureGroup2Id 应该会以引用传递进我的补丁,在打印的log中看到 featureGroup2Id 已成功加入了自定义特征池子中的随机特征
AdaptableLog.Info("feature add Succeed! detail:" + string.Join(",", featureGroup2Id.Values));
return false;
可最终已加入 featureGroup2Id 中的特征并未生效,效果是角色的所有基础特征全部丢失
prefix部分完整代码
[HarmonyPrefix]
[HarmonyPatch(declaringType: typeof(GameData.Domains.Character.Character), methodName: "GenerateRandomBasicFeatures")]
public static bool PrefixOfGenerateRandomBasicFeatures(bool isProtagonist, Dictionary<short, short> featureGroup2Id)
{
if (!isProtagonist) return true;
try
{
AdaptableLog.Info($"current features's featId are {string.Join(",", featureGroup2Id.Values)}");
var featureInstance = CharacterFeature.Instance;
_config.AllAvailableFeatures = featureInstance.Select<CharacterFeatureItem, Feature>(x =>
{
return new Feature
{
Id = x.TemplateId,
GroupId = x.MutexGroupId,
Name = x.Name,
};
});
var customFeatPool = _config.AllAvailableFeatures
.Where(x => _config.CustomFeatures.Any(y => x.Id == y.Id))
?? throw new Exception("can't find available feature in custom feature pool!");
var lockedFeatDic = customFeatPool
.Where(x => x.IsLocked && !featureGroup2Id.Any(y => y.Key == x.Id))
.ToDictionary(x => x.Id, x => x.GroupId)
.Take(_config.FeaturesCount);
featureGroup2Id = featureGroup2Id.Concat(lockedFeatDic).ToDictionary(x => x.Key, x => x.Value);
AdaptableLog.Info($"get all({_config.AllAvailableFeatures.Count()})-custom({customFeatPool.Count()}) feats succeed");
if (!_config.IsOriginPoolGen)
{
PatchConfig.SaveAsJson<IEnumerable<Feature>>(_config.AllAvailableFeatures, "available_features.json");
//一个组必定都是基础属性
PatchConfig.SaveAsJson<IEnumerable<Feature>>(_config.AllAvailableFeatures
.Where(x => featureInstance[x.Id].Basic)
, "available_basic_features.json");
PatchConfig.SaveAsJson<IEnumerable<Feature>>(_config.AllAvailableFeatures
.Where(x => featureInstance[x.Id].CandidateGroupId == 0)
, "available_basic_positive_features.json");
AdaptableLog.Info("generate origin pool succeed");
}
//减去消耗的基础属性数
var customFeatureCount = _config.FeaturesCount - featureGroup2Id.Count(x => featureInstance[x.Value].Basic);
var remainsCustomFeatPool = customFeatPool
.Where(x => !featureGroup2Id.Any(y => y.Key == x.Id))
.ToDictionary(x => x.Id, x => x.GroupId);
AdaptableLog.Info($"remain custom features/pool count is {customFeatureCount}/{remainsCustomFeatPool.Count}");
while (customFeatureCount > 0)
{
var radomFeature = GetRandomFeatureFromCustomPool(remainsCustomFeatPool);
featureGroup2Id.Add(radomFeature.Item1, radomFeature.Item2);
customFeatureCount--;
}
_config.IsOriginPoolGen = true;
_config.SaveConfig();
AdaptableLog.Info("feature add Succeed! detail:" + string.Join(",", featureGroup2Id.Values));
return false;
}
catch(Exception ex)
{
AdaptableLog.Warning($"patching feature failed: " + ex.Message);
return true;
}
}
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.