32 public static string fName =
"ComponentFactors";
34 public virtual float GetOtherFactorResult(
string factorName,
bool recalculate =
false,
bool throwIfNotFound =
false) {
39 if (!recalculate && throwIfNotFound) {
40 throw new KeyNotFoundException($
"Required factor result with name {factorName} is not found.");
42 bool factorsGotten =
OtherFactors.TryGetValue(factorName, out List<Factor> factors);
44 if (throwIfNotFound) {
45 throw new KeyNotFoundException($
"Required factor key with name {factorName} is not found.");
54 [Obsolete(
"模组调整StrengthFactor的具体数值,需要通过m_strengthFactors里面增删改里面的Factor")]
60 [Obsolete(
"模组调整ResilienceFactor的具体数值,需要通过m_resilienceFactors里面增删改里面的Factor")]
66 [Obsolete(
"模组调整SpeedFactor的具体数值,需要通过m_speedFactors里面增删改里面的Factor")]
72 [Obsolete(
"模组调整HungerFactor的具体数值,需要通过m_hungerFactors里面增删改里面的Factor")]
95 foreach (var factor
in factors) {
96 if (
float.IsNaN(factor.Value) ||
float.IsInfinity(factor.Value)) {
99 switch (factor.FactorAdditionType) {
110 if (
float.IsNaN(ans) ||
float.IsInfinity(ans)) {
117 foreach ((
string key, List<Factor> factors) in
OtherFactors) {
144 #region Obsolete CalculateFactor
146 [Obsolete(
"Get m_strengthFactors and StrengthFactor instead.")]
148 if (factors is List<Factor> factorsList) {
154 [Obsolete(
"Get m_resilienceFactors and ResilienceFactor instead.")]
156 if (factors is List<Factor> factorsList) {
162 [Obsolete(
"Get m_speedFactors and SpeedFactor instead.")]
164 if (factors is List<Factor> factorsList) {
170 [Obsolete(
"Get m_hungerFactors and HungerFactor instead.")]
172 if (factors is List<Factor> factorsList) {
188#pragma warning disable CS0618
193#pragma warning restore CS0618
203#pragma warning disable CS0618
204 Loader.OnFactorsUpdate(
this, dt);
205#pragma warning restore CS0618
override void Load(ValuesDictionary valuesDictionary, IdToEntityMap idToEntityMap)
AttackSpeed: 生物攻速 DigSpeed: 挖掘速度 ChaseRange: 非玩家生物的仇恨距离
static float CalculateFactorsResult(ICollection< Factor > factors)
virtual void CalculateOtherFactorsResult()
List< Factor > m_speedFactors
virtual void GenerateResilienceFactors()
SubsystemAudio m_subsystemAudio
virtual float GetOtherFactorResult(string factorName, bool recalculate=false, bool throwIfNotFound=false)
Dictionary< string, List< Factor > > OtherFactors
模组如果有自定义的Factors,可以使用这个OtherFactors。例如使用OtherFactors["AttackRate"]来定义攻击频率。
virtual void GenerateSpeedFactors()
SubsystemGameInfo m_subsystemGameInfo
List< Factor > m_resilienceFactors
List< Factor > m_strengthFactors
这四个Factors是可以调整的影响因素
virtual float CalculateSpeedFactor(ICollection< Factor > factors)
virtual float CalculateStrengthFactor(ICollection< Factor > factors)
virtual void GenerateStrengthFactors()
SubsystemTime m_subsystemTime
virtual void Update(float dt)
对等级系统的更新进行了调整。 第一步是计算上一帧Factors的最终结果,并进行赋值。此时已经经过了所有模组的修改。 第二步是GenerateFactors对四个属性进行生成,此时四个m_xxxFact...
virtual float CalculateHungerFactor(ICollection< Factor > factors)
List< Factor > m_hungerFactors
Dictionary< string, float > OtherFactorsResults
virtual void GenerateHungerFactors()
virtual float CalculateResilienceFactor(ICollection< Factor > factors)
virtual void GenerateOtherFactors()
ValuesDictionary ValuesDictionary
static void HookAction(string HookName, Func< ModLoader, bool > action)
执行Hook