83 lines
3.1 KiB
C#
83 lines
3.1 KiB
C#
// File: ModExtensions/OothecaIncubatorExtension.cs
|
||
using RimWorld;
|
||
using Verse;
|
||
|
||
namespace ArachnaeSwarm
|
||
{
|
||
public class OothecaIncubatorExtension : DefModExtension
|
||
{
|
||
// 营养液检测半径(单位:格)
|
||
public float nutrientSolutionRadius = 5f;
|
||
|
||
// 其他卵距离检测半径(单位:格)
|
||
public float nearbyOothecaRadius = 5f;
|
||
|
||
// 是否检查同房间内的其他卵(默认:是)
|
||
public bool checkSameRoomForOotheca = true;
|
||
|
||
// 营养液加成比例(每个营养液增加多少百分比的速度)
|
||
public float nutrientSolutionBonusPerTile = 0.01f; // 默认每个+1%
|
||
|
||
// 附近其他卵的惩罚比例(每个减少多少百分比的质量)
|
||
public float nearbyOothecaPenaltyPerUnit = 0.10f; // 默认每个-10%
|
||
|
||
// 幼虫搜索半径(单位:格)
|
||
public float larvaSearchRadius = 999f; // 默认在整个地图搜索
|
||
|
||
// 是否需要在孵化间内才能正常工作(默认:否)
|
||
public bool requiresIncubatorRoom = false;
|
||
|
||
// 不在孵化间内的速度惩罚(百分比)
|
||
public float speedPenaltyOutsideIncubator = 0.8f; // 默认80%
|
||
|
||
// 质量因子房间检查(默认:是)
|
||
public bool useRoomQualityFactor = true;
|
||
|
||
// 建筑血量影响质量(默认:是)
|
||
public bool healthAffectsQuality = true;
|
||
|
||
// 获取营养液检测半径的整数形式(用于循环)
|
||
public int NutrientSolutionRadiusInt => (int)nutrientSolutionRadius;
|
||
|
||
// 获取其他卵距离检测半径的整数形式
|
||
public int NearbyOothecaRadiusInt => (int)nearbyOothecaRadius;
|
||
|
||
// 是否启用营养液不足时的伤害
|
||
public bool nutrientDeficiencyDamageEnabled = false;
|
||
|
||
// 每次检查间隔造成的伤害量
|
||
public float nutrientDeficiencyDamageAmount = 1f;
|
||
|
||
// 伤害类型
|
||
public DamageDef nutrientDamageType = DamageDefOf.Burn;
|
||
|
||
// 是否显示伤害消息
|
||
public bool showDamageMessages = true;
|
||
|
||
// 伤害消息显示几率(避免刷屏)
|
||
public float damageMessageChance = 0.1f;
|
||
|
||
// 是否在营养液不足时停止孵化(如果设置为true,则缺少营养液时停止孵化进度)
|
||
public bool stopIncubationWhenNutrientDeficient = false;
|
||
|
||
|
||
public static OothecaIncubatorExtension Get(Thing thing)
|
||
{
|
||
if (thing?.def?.GetModExtension<OothecaIncubatorExtension>() is OothecaIncubatorExtension ext)
|
||
return ext;
|
||
return null;
|
||
}
|
||
|
||
// 验证配置是否有效
|
||
public bool IsValid()
|
||
{
|
||
return nutrientSolutionRadius >= 0f &&
|
||
nearbyOothecaRadius >= 0f &&
|
||
nutrientSolutionBonusPerTile >= 0f &&
|
||
nearbyOothecaPenaltyPerUnit >= 0f;
|
||
}
|
||
// 默认实例
|
||
public static readonly OothecaIncubatorExtension Default = new OothecaIncubatorExtension();
|
||
}
|
||
}
|