container_base.c 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. class Container_Base : ItemBase
  2. {
  3. override bool IsContainer()
  4. {
  5. return true;
  6. }
  7. override bool CanPutInCargo(EntityAI parent)
  8. {
  9. if (!super.CanPutInCargo(parent))
  10. return false;
  11. if (parent && (parent == this || GetType() == parent.GetType() || !parent.GetInventory().AreChildrenAccessible()))
  12. return false;
  13. return true;
  14. }
  15. override bool CanReceiveItemIntoCargo( EntityAI item )
  16. {
  17. if (!super.CanReceiveItemIntoCargo(item))
  18. return false;
  19. //is 'this' somewhere in cargo?
  20. if (!GetInventory().AreChildrenAccessible())
  21. return false;
  22. return true;
  23. }
  24. }
  25. class DeployableContainer_Base : Container_Base
  26. {
  27. protected vector m_HalfExtents; // The Y value contains a heightoffset and not the halfextent !!!
  28. void DeployableContainer_Base()
  29. {
  30. m_HalfExtents = vector.Zero;
  31. ProcessInvulnerabilityCheck(GetInvulnerabilityTypeString());
  32. }
  33. override string GetInvulnerabilityTypeString()
  34. {
  35. return "disableContainerDamage";
  36. }
  37. override void SetActions()
  38. {
  39. super.SetActions();
  40. AddAction(ActionTogglePlaceObject);
  41. AddAction(ActionPlaceObject);
  42. }
  43. override bool CanReceiveAttachment(EntityAI attachment, int slotId)
  44. {
  45. if (GetHealthLevel() == GameConstants.STATE_RUINED)
  46. return false;
  47. return super.CanReceiveAttachment(attachment, slotId);
  48. }
  49. override bool CanLoadAttachment(EntityAI attachment)
  50. {
  51. if (GetHealthLevel() == GameConstants.STATE_RUINED)
  52. return false;
  53. return super.CanLoadAttachment(attachment);
  54. }
  55. override bool CanReceiveItemIntoCargo(EntityAI item)
  56. {
  57. if (GetHealthLevel() == GameConstants.STATE_RUINED)
  58. return false;
  59. return super.CanReceiveItemIntoCargo(item);
  60. }
  61. override bool CanLoadItemIntoCargo(EntityAI item)
  62. {
  63. if (!super.CanLoadItemIntoCargo(item))
  64. return false;
  65. if (GetHealthLevel() == GameConstants.STATE_RUINED)
  66. return false;
  67. return true;
  68. }
  69. override void EEHealthLevelChanged(int oldLevel, int newLevel, string zone)
  70. {
  71. super.EEHealthLevelChanged(oldLevel,newLevel,zone);
  72. if (newLevel == GameConstants.STATE_RUINED && !GetHierarchyParent())
  73. MiscGameplayFunctions.DropAllItemsInInventoryInBounds(this, m_HalfExtents);
  74. }
  75. }