rag.c 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. class Rag extends ItemBase
  2. {
  3. override bool CanSwapEntities(EntityAI otherItem, InventoryLocation otherDestination, InventoryLocation destination)
  4. {
  5. if (!super.CanSwapEntities(otherItem, otherDestination, destination))
  6. {
  7. return false;
  8. }
  9. if (Torch.Cast(GetHierarchyParent()) && otherItem.IsInherited(Rag))
  10. {
  11. return false;
  12. }
  13. return true;
  14. }
  15. override bool CanPutAsAttachment(EntityAI parent)
  16. {
  17. if (!super.CanPutAsAttachment(parent))
  18. {
  19. return false;
  20. }
  21. if (GetQuantity() > 1 && PlayerBase.Cast(parent))
  22. {
  23. return false;
  24. }
  25. return true;
  26. }
  27. override bool CanBeSplit()
  28. {
  29. Torch torchParent = Torch.Cast(GetHierarchyParent());
  30. if (torchParent && torchParent.GetCompEM() && torchParent.GetCompEM().IsWorking())
  31. return false;
  32. return super.CanBeSplit();
  33. }
  34. //================================================================
  35. // IGNITION ACTION
  36. //================================================================
  37. override bool HasFlammableMaterial()
  38. {
  39. return true;
  40. }
  41. override bool CanBeIgnitedBy(EntityAI igniter = null)
  42. {
  43. return GetHierarchyParent() == null;
  44. }
  45. override bool CanIgniteItem(EntityAI ignite_target = null)
  46. {
  47. return false;
  48. }
  49. override bool CanBeCombined(EntityAI other_item, bool reservation_check = true, bool stack_max_limit = false)
  50. {
  51. if (!super.CanBeCombined(other_item, reservation_check, stack_max_limit))
  52. {
  53. return false;
  54. }
  55. return Torch.Cast(other_item.GetHierarchyParent()) == null;//when the other rag is attached to the torch, disallow this action
  56. }
  57. override void OnIgnitedThis(EntityAI fire_source)
  58. {
  59. Fireplace.IgniteEntityAsFireplace(this, fire_source);
  60. }
  61. override bool IsThisIgnitionSuccessful(EntityAI item_source = null)
  62. {
  63. return Fireplace.CanIgniteEntityAsFireplace(this);
  64. }
  65. override bool CanAssignToQuickbar()
  66. {
  67. return (!GetInventory().IsAttachment());
  68. }
  69. override bool CanBeDisinfected()
  70. {
  71. return true;
  72. }
  73. override void SetActions()
  74. {
  75. super.SetActions();
  76. AddAction(ActionBandageTarget);
  77. AddAction(ActionBandageSelf);
  78. AddAction(ActionGagTarget);
  79. AddAction(ActionGagSelf);
  80. AddAction(ActionCreateIndoorFireplace);
  81. AddAction(ActionCreateIndoorOven);
  82. AddAction(ActionAttach);
  83. AddAction(ActionDetach);
  84. AddAction(ActionRefuelTorch);
  85. AddAction(ActionCraftImprovisedHandsCover);
  86. AddAction(ActionCraftImprovisedHeadCover);
  87. AddAction(ActionCraftImprovisedFeetCover);
  88. AddAction(ActionCraftImprovisedFaceCover);
  89. AddAction(ActionCraftImprovisedTorsoCover);
  90. AddAction(ActionCraftImprovisedLegsCover);
  91. AddAction(ActionCraftImprovisedEyePatch);
  92. AddAction(ActionCraftArmband);
  93. }
  94. override float GetBandagingEffectivity()
  95. {
  96. return 0.5;
  97. }
  98. override float GetInfectionChance(int system = 0, Param param = null)
  99. {
  100. if (m_Cleanness == 1)
  101. return 0;
  102. return 0.15;
  103. }
  104. override void OnCombine(ItemBase other_item)
  105. {
  106. super.OnCombine(other_item);
  107. if (m_Cleanness == 1 && other_item.m_Cleanness == 0)
  108. SetCleanness(0);
  109. }
  110. }