1using System.Globalization;
36 public new static string fName =
"ComponentLevel";
54 for (
int i = 0; i < count; i++) {
55 float num = 0.012f / MathF.Pow(1.08f, MathF.Floor(
m_componentPlayer.PlayerData.Level - 1f));
59 delegate { m_componentPlayer.ComponentGui.DisplaySmallMessage(LanguageControl.Get(fName, 1), Color.White, true, false); }
63 delegate { m_subsystemAudio.PlaySound(
"Audio/ExperienceCollected", 1f, -0.2f, 0f, 0f); }
67 delegate { m_subsystemAudio.PlaySound(
"Audio/ExperienceCollected", 1f, -0.03333333f, 0f, 0f); }
71 delegate { m_subsystemAudio.PlaySound(
"Audio/ExperienceCollected", 1f, 142f / (339f * (float)Math.PI), 0f, 0f); }
75 delegate { m_subsystemAudio.PlaySound(
"Audio/ExperienceCollected", 1f, 23f / 60f, 0f, 0f); }
79 delegate { m_subsystemAudio.PlaySound(
"Audio/ExperienceCollected", 1f, -0.03333333f, 0f, 0f); }
83 delegate { m_subsystemAudio.PlaySound(
"Audio/ExperienceCollected", 1f, 23f / 60f, 0f, 0f); }
86 m_componentPlayer.PlayerData.Level += num;
94 base.GenerateStrengthFactors();
103 float num3 = 1f + 0.05f * MathF.Floor(Math.Clamp(level, 1f, 21f) - 1f);
108 Description =
string.Format(
LanguageControl.
Get(
fName, 2), MathF.Floor(level).ToString(CultureInfo.InvariantCulture))
119 Value = m_componentPlayer.ComponentSickness.IsSick ? 0.75f : 1f,
126 Value = !m_componentPlayer.ComponentSickness.IsPuking ? 1 : 0,
133 Value = m_componentPlayer.ComponentFlu.HasFlu ? 0.75f : 1f,
140 Value = !m_componentPlayer.ComponentFlu.IsCoughing ? 1 : 0,
144 float num15 = m_subsystemGameInfo.WorldSettings.GameMode ==
GameMode.Harmless ? 1.25f : 1f;
158 base.GenerateResilienceFactors();
161 Name =
"PlayerClass",
167 float num3 = 1f + 0.05f * MathF.Floor(Math.Clamp(level, 1f, 21f) - 1f);
172 Description =
string.Format(
LanguageControl.
Get(
fName, 2), MathF.Floor(level).ToString(CultureInfo.InvariantCulture))
178 Value = m_componentPlayer.ComponentSickness.IsSick ? 0.75f : 1f,
185 Value = m_componentPlayer.ComponentFlu.HasFlu ? 0.75f : 1f,
197 num9 =
float.PositiveInfinity;
212 base.GenerateSpeedFactors();
215 Name =
"PlayerClass",
221 float num3 = 1f + 0.02f * MathF.Floor(Math.Clamp(level, 1f, 21f) - 1f);
226 Description =
string.Format(
LanguageControl.
Get(
fName, 2), MathF.Floor(level).ToString(CultureInfo.InvariantCulture))
230 foreach (
int clothe
in m_componentPlayer.ComponentClothing.GetClothes(clothingSlot)) {
242 Value = m_componentPlayer.ComponentSickness.IsSick ? 0.75f : 1f,
249 Value = !m_componentPlayer.ComponentSickness.IsPuking ? 1 : 0,
256 Value = m_componentPlayer.ComponentFlu.HasFlu ? 0.75f : 1f,
263 Value = !m_componentPlayer.ComponentFlu.IsCoughing ? 1 : 0,
273 base.GenerateHungerFactors();
276 Name =
"PlayerClass",
282 float num3 = 1f - 0.01f * MathF.Floor(Math.Clamp(level, 1f, 21f) - 1f);
287 Description =
string.Format(
LanguageControl.
Get(
fName, 2), MathF.Floor(level).ToString(CultureInfo.InvariantCulture))
332 if (num2 >= precipitationShaftInfo.
YLimit
360 m_componentPlayer.ComponentGui.LevelLabelWidget.Text =
string.Format(
362 MathF.Floor(
m_componentPlayer.PlayerData.Level).ToString(CultureInfo.InvariantCulture)
366 m_componentPlayer.PlayerStats.HighestLevel =
MathUtils.
Max(
375#pragma warning disable CS0618
376 modLoader.OnLevelUpdate(
this);
377#pragma warning restore CS0618
384 base.Load(valuesDictionary, idToEntityMap);
398 if (clothingData !=
null
402 Name = $
"Clothing {clothingValue}", Value = clothingData.
MovementSpeedFactor, Description = clothingData.DisplayName
408 [Obsolete(
"Use GenerateClothingSpeedFactors.")]
409 public static void AddClothingFactor(
int clothingValue, ref
float clothingFactor, ICollection<Factor> factors) {
412 if (clothingData !=
null
static float Saturate(float x)
static int Max(int x1, int x2)
static float Lerp(float x1, float x2, float f)
static void QueueTimeDelayedExecution(double time, Action action)
static double FrameStartTime
virtual ClothingData GetClothingData(int value)
float MovementSpeedFactor
static Dictionary< string, ClothingSlot > ClothingSlots
调用自定义部位(比如手臂)的ClothingSlot,可以用ClothingSlot.ClothingSlots["Arms"]
List< Factor > m_speedFactors
SubsystemAudio m_subsystemAudio
Dictionary< string, List< Factor > > OtherFactors
模组如果有自定义的Factors,可以使用这个OtherFactors。例如使用OtherFactors["AttackRate"]来定义攻击频率。
SubsystemGameInfo m_subsystemGameInfo
List< Factor > m_resilienceFactors
List< Factor > m_strengthFactors
这四个Factors是可以调整的影响因素
SubsystemTime m_subsystemTime
List< Factor > m_hungerFactors
这里的Factor类型从struct改为class,是由于模组在修改Factor的时候,通常是需要修改引用的值。 如果是struct则只能复制并修改值,不能修改引用。
string Name
该Factor的索引名称,模组使用Name来在m_xxxFactors列表中查找对应的Factor
string Description
在玩家信息面板上显示影响因素的名称,如“未患流感”
FactorAdditionType FactorAdditionType
该影响因子是乘算还是加算
override void GenerateHungerFactors()
生成玩家所有关于饥饿的因素
const float FemaleStrengthFactor
float? m_lastLevelTextValue
static void AddClothingFactor(int clothingValue, ref float clothingFactor, ICollection< Factor > factors)
string m_cachedGameModeString
void GenerateWetnessFactors()
生成玩家所有关于潮湿度的因素
void GenerateClothingSpeedFactors(int clothingValue)
const float FemaleResilienceFactor
virtual void AddExperience(int count, bool playSound)
ComponentVitalStats m_componentVitalStats
const float FemaleSpeedFactor
ComponentPlayer m_componentPlayer
override void Update(float dt)
对等级系统的更新进行了调整。 第一步是计算上一帧Factors的最终结果,并进行赋值。此时已经经过了所有模组的修改。 第二步是GenerateFactors对四个属性进行生成,此时四个m_xxxFact...
const float FemaleHungerFactor
string m_cachedPlayerClassName
override void Load(ValuesDictionary valuesDictionary, IdToEntityMap idToEntityMap)
AttackSpeed: 生物攻速 DigSpeed: 挖掘速度 ChaseRange: 非玩家生物的仇恨距离
override void GenerateStrengthFactors()
生成玩家的所有关于力量的因素
override void GenerateSpeedFactors()
生成玩家所有关于速度的因素
override void GenerateResilienceFactors()
生成玩家所有关于防御的因素
static string Get(string className, int key)
获取在当前语言类名键对应的字符串
static int ExtractContents(int value)
static int ToCell(float x)
ValuesDictionary ValuesDictionary
static void HookAction(string HookName, Func< ModLoader, bool > action)
执行Hook