mouthrag.c 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. class MouthRag extends Mask_Base
  2. {
  3. bool m_IncomingLambdaChange;
  4. void MouthRag()
  5. {
  6. m_IncomingLambdaChange = false;
  7. }
  8. override bool CanDetachAttachment(EntityAI parent)
  9. {
  10. return m_IncomingLambdaChange;
  11. }
  12. override bool IsObstructingVoice()
  13. {
  14. return true;
  15. }
  16. override int GetVoiceEffect()
  17. {
  18. return VoiceEffectObstruction;
  19. }
  20. override void EEItemLocationChanged(notnull InventoryLocation oldLoc, notnull InventoryLocation newLoc)
  21. {
  22. super.EEItemLocationChanged(oldLoc,newLoc);
  23. if (GetGame().IsDedicatedServer())
  24. {
  25. PlayerBase playerOld;
  26. PlayerBase playerNew;
  27. if (oldLoc.GetParent())
  28. Class.CastTo(playerOld,oldLoc.GetParent().GetHierarchyRootPlayer());
  29. if (newLoc.GetParent())
  30. Class.CastTo(playerNew,newLoc.GetParent().GetHierarchyRootPlayer());
  31. if (newLoc.GetType() == InventoryLocationType.GROUND)
  32. {
  33. ItemBase newItem;
  34. if (Class.CastTo(newItem,GetGame().CreateObjectEx("Rag",newLoc.GetPos(),ECE_PLACE_ON_SURFACE,RF_DEFAULT)))
  35. {
  36. MiscGameplayFunctions.TransferItemProperties(this,newItem);
  37. newItem.SetQuantity(1);
  38. DeleteSafe();
  39. }
  40. }
  41. }
  42. }
  43. override void OnWasAttached(EntityAI parent, int slot_id)
  44. {
  45. super.OnWasAttached(parent, slot_id);
  46. if (parent.IsPlayer())
  47. {
  48. PlayerBase.Cast(parent).CheckForGag(); //gag removal action does check, since 'OnWasDetached' is not called on item destruction.
  49. }
  50. }
  51. void SetIncomingLambaBool(bool state)
  52. {
  53. m_IncomingLambdaChange = state;
  54. }
  55. bool GetIncomingLambdaBool()
  56. {
  57. return m_IncomingLambdaChange;
  58. }
  59. };