clothing_base.c 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194
  1. // I know the filename is stupid, but it's what the other files in this structure use..
  2. // And I can't really make it "class Clothing_Base extends Clothing"
  3. // since that will conflict with config and other parts of script and break mods :c
  4. class Clothing extends Clothing_Base
  5. {
  6. override bool IsClothing()
  7. {
  8. return true;
  9. }
  10. override bool CanHaveWetness()
  11. {
  12. return true;
  13. }
  14. //! Used for 'glasses' (and other colored layers triggered by attach/detach in the InventorySlots.EYEWEAR)
  15. int GetGlassesEffectID()
  16. {
  17. return -1;
  18. }
  19. //----------------------------------------------------------------
  20. // GameplayWidgetEffects
  21. array<int> GetEffectWidgetTypes()
  22. {
  23. return null;
  24. }
  25. // Conditions
  26. override bool CanPutInCargo( EntityAI parent )
  27. {
  28. if ( !super.CanPutInCargo( parent ) )
  29. return false;
  30. return !parent || CanPutInCargoClothingConditions( parent );
  31. }
  32. bool CanPutInCargoClothingConditions( EntityAI parent )
  33. {
  34. bool is_hidden_stash_exception = false;
  35. if ( parent.IsInherited( UndergroundStash ) )
  36. is_hidden_stash_exception = true;
  37. if ( GetNumberOfItems() == 0 || !parent || parent.IsMan() || is_hidden_stash_exception )
  38. {
  39. EntityAI cargoParent = parent.GetHierarchyParent();
  40. ClothingBase parentClothing = ClothingBase.Cast(parent);
  41. if (cargoParent)
  42. return !(parent.IsClothing() && cargoParent.IsClothing()) || ( parentClothing && parentClothing.SmershException(cargoParent) );
  43. return true;
  44. }
  45. return false;
  46. }
  47. override bool CanReceiveItemIntoCargo( EntityAI item )
  48. {
  49. if (!super.CanReceiveItemIntoCargo(item))
  50. return false;
  51. return CanReceiveItemIntoCargoClothingConditions( item );
  52. }
  53. bool CanReceiveItemIntoCargoClothingConditions( EntityAI item )
  54. {
  55. EntityAI hierarchyParent = GetHierarchyParent();
  56. return !hierarchyParent || hierarchyParent.IsMan() || SmershException(hierarchyParent);
  57. }
  58. //Kind of a hack but I don't have enough time left to do larger scale reworks, sorry
  59. bool SmershException(EntityAI hierarchyParent)
  60. {
  61. EntityAI hp = hierarchyParent.GetHierarchyParent();
  62. if (hp)
  63. {
  64. if (!hp.IsMan())
  65. return false;
  66. }
  67. return IsInherited(SmershBag) && hierarchyParent.IsInherited(SmershVest);
  68. }
  69. override bool CanLoadItemIntoCargo(EntityAI item)
  70. {
  71. if (!super.CanLoadItemIntoCargo(item))
  72. return false;
  73. return CanLoadItemIntoCargoClothingConditions(item);
  74. }
  75. bool CanLoadItemIntoCargoClothingConditions(EntityAI item)
  76. {
  77. EntityAI parent = GetHierarchyParent();
  78. if ( parent && parent.IsInherited( UndergroundStash ) )
  79. return true;
  80. return !parent || parent.IsMan() || SmershException(parent);
  81. }
  82. //Method used to specify if a piece of eyeware can be worn under a gas mask
  83. //! deprecated
  84. bool CanWearUnderMask(EntityAI parent)
  85. {
  86. return true;
  87. }
  88. // -------------------------------------------------------------------------
  89. override void EEHealthLevelChanged(int oldLevel, int newLevel, string zone)
  90. {
  91. super.EEHealthLevelChanged(oldLevel, newLevel, zone);
  92. if ( !GetGame().IsDedicatedServer() )
  93. {
  94. PlayerBase player_owner = PlayerBase.Cast(GetHierarchyParent());
  95. if( player_owner )
  96. {
  97. if( player_owner.m_CorpseState != 0 )
  98. {
  99. GetGame().GetCallQueue( CALL_CATEGORY_GUI ).CallLater( player_owner.UpdateCorpseState, 0, false);
  100. }
  101. }
  102. }
  103. }
  104. override void SwitchItemSelectionTextureEx(EItemManipulationContext context, Param par = null)
  105. {
  106. super.SwitchItemSelectionTextureEx(context, par);
  107. Param1<PlayerBase> data = Param1<PlayerBase>.Cast(par);
  108. if (!data)
  109. {
  110. return;
  111. }
  112. PlayerBase player = data.param1;
  113. int personality = GetHiddenSelectionIndex("personality");
  114. if (personality >= 0)
  115. {
  116. string tone_mat = player.m_EmptyGloves.GetHiddenSelectionsMaterials().Get(0);
  117. string tone_texture;
  118. if (player.m_CorpseState > PlayerConstants.CORPSE_STATE_FRESH)
  119. {
  120. tone_texture = player.m_DecayedTexture;
  121. }
  122. else
  123. {
  124. tone_texture = player.m_EmptyGloves.GetHiddenSelectionsTextures().Get(0);
  125. }
  126. SetObjectMaterial( personality, tone_mat );
  127. SetObjectTexture( personality, tone_texture );
  128. }
  129. }
  130. };
  131. //////////////////////
  132. //intermediate types//
  133. //////////////////////
  134. class Belt_Base : Clothing {};
  135. class Backpack_Base : Clothing {};
  136. class Glasses_Base : Clothing
  137. {
  138. override protected void InitGlobalExclusionValues()
  139. {
  140. super.InitGlobalExclusionValues();
  141. AddSingleExclusionValueGlobal(EAttExclusions.EXCLUSION_GLASSES_REGULAR_0);
  142. }
  143. };
  144. class Gloves_Base : Clothing {};
  145. class HeadGear_Base : Clothing {};
  146. class Mask_Base : Clothing
  147. {
  148. override protected set<int> GetAttachmentExclusionInitSlotValue(int slotId)
  149. {
  150. set<int> ret = super.GetAttachmentExclusionInitSlotValue(slotId);
  151. if (slotId == InventorySlots.MASK)
  152. {
  153. ret.Insert(EAttExclusions.SHAVING_MASK_ATT_0);
  154. }
  155. return ret;
  156. }
  157. };
  158. class Pants_Base : Clothing {};
  159. class Shoes_Base : Clothing {};
  160. class Top_Base : Clothing {};
  161. class Vest_Base : Clothing {};
  162. typedef Clothing ClothingBase;