burlapsackcover.c 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. class BurlapSackCover extends HeadGear_Base
  2. {
  3. PlayerBase m_Player;
  4. void ~BurlapSackCover()
  5. {
  6. if (m_Player)
  7. {
  8. OnRemovedFromHead(m_Player);
  9. }
  10. }
  11. override void EEItemLocationChanged(notnull InventoryLocation oldLoc, notnull InventoryLocation newLoc)
  12. {
  13. super.EEItemLocationChanged(oldLoc,newLoc);
  14. if (GetGame().IsDedicatedServer() && newLoc.GetType() == InventoryLocationType.GROUND)
  15. {
  16. EntityAI newItem = EntityAI.Cast(GetGame().CreateObjectEx("BurlapSack",newLoc.GetPos(),ECE_PLACE_ON_SURFACE,RF_DEFAULT));
  17. MiscGameplayFunctions.TransferItemProperties(this,newItem);
  18. DeleteSafe();
  19. }
  20. }
  21. override void OnWasAttached(EntityAI parent, int slot_id)
  22. {
  23. super.OnWasAttached(parent, slot_id);
  24. Class.CastTo(m_Player, parent.GetHierarchyRootPlayer());
  25. if ((!GetGame().IsDedicatedServer()) && m_Player && m_Player.IsControlledPlayer() && slot_id == InventorySlots.HEADGEAR)
  26. {
  27. PPERequesterBank.GetRequester(PPERequester_BurlapSackEffects).Start();
  28. m_Player.SetInventorySoftLock(true);
  29. m_Player.SetMasterAttenuation("BurlapSackAttenuation");
  30. if (GetGame().GetUIManager().IsMenuOpen(MENU_INVENTORY))
  31. {
  32. GetGame().GetMission().HideInventory();
  33. }
  34. }
  35. SetInvisibleRecursive(true,m_Player,{InventorySlots.MASK,InventorySlots.EYEWEAR});
  36. }
  37. override bool CanPutInCargo( EntityAI parent )
  38. {
  39. if (!super.CanPutInCargo(parent))
  40. return false;
  41. if (parent && parent != this)
  42. return true;
  43. return false;
  44. }
  45. override bool CanDetachAttachment( EntityAI parent )
  46. {
  47. return false;
  48. }
  49. void OnRemovedFromHead(PlayerBase player)
  50. {
  51. if (player.IsControlledPlayer())
  52. {
  53. PPERequesterBank.GetRequester(PPERequester_BurlapSackEffects).Stop();
  54. player.SetInventorySoftLock(false);
  55. player.SetMasterAttenuation("");
  56. }
  57. SetInvisibleRecursive(false,player,{InventorySlots.MASK,InventorySlots.EYEWEAR});
  58. }
  59. override protected set<int> GetAttachmentExclusionInitSlotValue(int slotId)
  60. {
  61. set<int> ret = super.GetAttachmentExclusionInitSlotValue(slotId);
  62. if (slotId == InventorySlots.HEADGEAR)
  63. {
  64. ret.Insert(EAttExclusions.SHAVING_HEADGEAR_ATT_0);
  65. }
  66. return ret;
  67. }
  68. }