58 public static string fName =
"ComponentClothing";
62 public Dictionary<ClothingSlot, List<int>>
m_clothes = [];
105 int leastInsulatedSlot = 0;
109 leastInsulatedSlot = i;
119 IEnumerable<int> enumerable = clothes as List<int> ?? clothes.ToList();
120 if (!
m_clothes[slot].SequenceEqual(enumerable)) {
131 foreach (
int item
in clothe.Value) {
138 m_componentBody.Density += num2;
144 loader.SetClothes(
this, slot, enumerable);
150 [Obsolete(
"Use ApplyArmorProtection(Attackment attackment) instead.")]
155 bool Applied =
false;
156 float attackPowerAfterProtection = attackment.
AttackPower;
162 "ApplyArmorProtection",
164#pragma warning disable CS0618
165 attackment.AttackPower = modLoader.ApplyArmorProtection(
this, attackment.
AttackPower, Applied, out
bool flag2);
166#pragma warning restore CS0618
178 List<int> listBeforeProtection =
new(
GetClothes(slot));
180 "ApplyProtectionBeforeClothes",
183 loader.ApplyProtectionBeforeClothes(
this, attackment, ref attackPowerAfterProtection);
189 "DecideArmorProtectionSequence",
191 loader.DecideArmorProtectionSequence(
this, attackment, num, listBeforeProtection);
195 List<int> listAfterProtection =
new(listBeforeProtection);
197 for (
int i = 0; i < listBeforeProtection.Count; i++) {
198 int value = listBeforeProtection[i];
201 if (clothingData ==
null) {
207 listBeforeProtection,
211 ref attackPowerAfterProtection
214 catch (Exception e) {
215 Log.
Error($
"ClothingData of clothing{clothingData.DisplayName} applies armor protection error: {e}");
220 while (num4 < listAfterProtection.Count) {
222 if (!block.
CanWear(listAfterProtection[num4])) {
223 listAfterProtection.RemoveAt(num4);
229 listAfterProtection.Sort((a, b) => {
232 return (clothingDataA?.Layer ?? 0) - (clothingDataB?.
Layer ?? 0);
236 "ApplyProtectionAfterClothes",
238 loader.ApplyProtectionAfterClothes(
this, attackment, listAfterProtection, ref attackPowerAfterProtection);
245 return MathF.Max(attackPowerAfterProtection, 0f);
284 valuesDictionary.SetValue(
"Clothes", valuesDictionary2);
314 clothingData?.
Update?.Invoke(clothe,
this);
321 clothingData?.
Update?.Invoke(clothe,
this);
335 if (clothingData ==
null) {
339 if (clothingData !=
null
366 bool setClothesNeeded =
false;
373 if (clothingData2 ==
null) {
378 setClothesNeeded =
true;
392 if (setClothesNeeded) {
415 bool notToProcessVanilla =
false;
418 "ClothingSlotProcessCapacity",
420 loader.ClothingSlotProcessCapacity(
this, slotIndex, value, ref notToProcessVanilla, out
int capacity);
421 maxCapacity = Math.Max(capacity, maxCapacity);
425 if (!notToProcessVanilla
426 && maxCapacity < 1) {
438 public virtual void AddSlotItems(
int slotIndex,
int value,
int count) { }
440 public virtual void ProcessSlotItems(
int slotIndex,
int value,
int count,
int processCount, out
int processedValue, out
int processedCount) {
443 bool skippedByMods =
false;
445 "ClothingProcessSlotItems",
447 modLoader.ClothingProcessSlotItems(
457#pragma warning disable CS0618
458 modLoader.ClothingProcessSlotItems(
466 out
bool glitchedLoaderResult
468 bool oldLoaderResult = modLoader.ClothingProcessSlotItems(
475#pragma warning restore CS0618
476 skippedByMods |= oldLoaderResult;
477 skippedByMods |= skipVanilla;
478 skippedByMods |= glitchedLoaderResult;
482 processedCount = pCount;
483 processedValue = pValue;
487 if (processCount != 1) {
497 && processedCount > 0
498 && processedValue != value) {
499 processedValue = value;
500 processedCount = processCount;
504 processedValue = value;
505 processedCount = processCount;
510 if (clothingData ==
null) {
513 clothingData.
Mount?.Invoke(value,
this);
522 if (list.Count > 0) {
523 int value = list[^1];
526 clothingData?.
Dismount?.Invoke(value,
this);
527 list.RemoveAt(list.Count - 1);
557 if (clothingData ==
null) {
561 if (list.Count == 0) {
564 int value2 = list[list.Count - 1];
567 if (clothingData2 ==
null) {
570 return clothingData.Layer > clothingData2.
Layer;
625 if (clothingData ==
null) {
640 texturedBatch2D.QueueQuad(
660 if (clothingData2 ==
null) {
675 texturedBatch2D.QueueQuad(
689 Display.RenderTarget = renderTarget;
690 Display.ScissorRectangle = scissorRectangle;
static readonly BlendState NonPremultiplied
static readonly DepthStencilState None
static void Clear(Vector4? color, float? depth=null, int? stencil=null)
static Rectangle ScissorRectangle
static RenderTarget2D RenderTarget
static SamplerState PointClamp
void QueueQuad(Vector2 corner1, Vector2 corner2, float depth, Vector2 texCoord1, Vector2 texCoord2, Color color)
static void Error(object message)
The spell "Attackment" is wrong, But it is not recommended to change it because many mods rely on thi...
virtual ClothingData GetClothingData(int value)
virtual bool CanWear(int value)
virtual bool Eat(ComponentVitalStats vitalStats, int value)
virtual float GetNutritionalValue(int value)
static Texture2D LoadTexture(string name)
virtual void OnClotheSet(ComponentClothing componentClothing)
在ComponentClothing执行SetClothes()时触发,用于调整ComponentClothing中的一些参数
Action< int, ComponentClothing > Update
ComponentClothing更新时触发。
virtual void UpdateGraduallyDamagedOverTime(ComponentClothing componentClothing, int indexInClothesList, float dt)
在ComponentClothing中每帧都会调用的UpdateGraduallyDamagedOverTime(),主要用于控制衣物随时间逐渐损坏
virtual Color GetColor(ComponentClothing componentClothing, int value)
获取衣物穿着在身上时的颜色附加
virtual void ApplyArmorProtection(ComponentClothing componentClothing, List< int > clothesBeforeProtection, List< int > clothesAfterProtection, int sequence, Attackment attackment, ref float attackPowerAfterProtection)
计算单件护甲的防御
Action< int, ComponentClothing > Mount
装备
Action< int, ComponentClothing > Dismount
卸载
static Dictionary< string, ClothingSlot > ClothingSlots
调用自定义部位(比如手臂)的ClothingSlot,可以用ClothingSlot.ClothingSlots["Arms"]
static ClothingSlot Torso
float CalculateInsulationFromSlots()
virtual void Display_DeviceReset()
ComponentGui m_componentGui
virtual void Update(float dt)
double? m_lastTotalElapsedGameTime
SubsystemTerrain m_subsystemTerrain
SubsystemPickables m_subsystemPickables
static ClothingSlot[] m_innerSlotsOrder
SubsystemParticles m_subsystemParticles
ComponentBody m_componentBody
float m_densityModifierApplied
float SteedMovementSpeedFactor
static List< ClothingSlot > m_innerSlotsOrderList
static List< ClothingSlot > m_outerSlotsOrderList
static ClothingSlot[] m_outerSlotsOrder
PrimitivesRenderer2D m_primitivesRenderer
ComponentPlayer m_componentPlayer
static bool DrawClothedTexture
ComponentVitalStats m_componentVitalStats
ComponentHumanModel m_componentHumanModel
bool EnableDressLimit
穿戴衣服限制
bool m_clothedTexturesValid
SubsystemGameInfo m_subsystemGameInfo
virtual void SetClothes(ClothingSlot slot, IEnumerable< int > clothes)
virtual int GetSlotCapacity(int slotIndex, int value)
virtual void DropAllItems(Vector3 position)
List< int > m_clothesList
virtual void ProcessSlotItems(int slotIndex, int value, int count, int processCount, out int processedValue, out int processedCount)
virtual void AddSlotItems(int slotIndex, int value, int count)
override void Load(ValuesDictionary valuesDictionary, IdToEntityMap idToEntityMap)
Dictionary< ClothingSlot, List< int > > m_clothes
RenderTarget2D m_outerClothedTexture
override void Save(ValuesDictionary valuesDictionary, EntityToIdMap entityToIdMap)
static bool ShowClothedTexture
virtual int GetSlotValue(int slotIndex)
ComponentOuterClothingModel m_componentOuterClothingModel
ComponentLocomotion m_componentLocomotion
Texture2D OuterClothedTexture
RenderTarget2D m_innerClothedTexture
ClothingSlot LeastInsulatedSlot
Dictionary< ClothingSlot, float > InsulationBySlots
virtual void UpdateRenderTargets()
virtual int GetSlotCount(int slotIndex)
virtual int GetSlotProcessCapacity(int slotIndex, int value)
virtual bool CanWearClothing(int value)
float ApplyArmorProtection(float attackPower)
virtual ReadOnlyList< int > GetClothes(ClothingSlot slot)
SubsystemAudio m_subsystemAudio
float ApplyArmorProtection(Attackment attackment)
virtual int RemoveSlotItems(int slotIndex, int count)
实际移除的数量
SubsystemTime m_subsystemTime
Project IInventory. Project
Texture2D InnerClothedTexture
static object Get(Type type, string name)
static bool IsContent(object content)
static string Get(string className, int key)
获取在当前语言类名键对应的字符串
virtual Pickable AddPickable(Pickable pickable)
static int ExtractContents(int value)
ValuesDictionary ValuesDictionary
static void HookAction(string HookName, Func< ModLoader, bool > action)
执行Hook
static Dictionary< string, ModHook > ModHooks
static readonly Vector2 Zero
static readonly Vector2 One
static Vector3 Normalize(Vector3 v)
static readonly Vector3 Zero
static readonly Vector3 UnitY