nail.c 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. class Nails extends Inventory_Base
  2. {
  3. override bool CanPutAsAttachment( EntityAI parent )
  4. {
  5. if(!super.CanPutAsAttachment(parent)) {return false;}
  6. const int SLOTS_ARRAY = 8;
  7. bool is_barrel = false;
  8. bool is_opened_barrel = false;
  9. bool slot_test = true;
  10. string slot_names[SLOTS_ARRAY] = { "BerryR", "BerryB", "Plant", "OakBark", "BirchBark", "Lime", "Disinfectant", "Guts" };
  11. // is barrel
  12. if ( parent.IsKindOf("Barrel_ColorBase") )
  13. {
  14. is_barrel = true;
  15. }
  16. // is opened barrel
  17. if ( is_barrel && parent.GetAnimationPhase("Lid") == 1 )
  18. {
  19. is_opened_barrel = true;
  20. }
  21. // all of the barrel slots are empty
  22. for ( int i = 0; i < SLOTS_ARRAY ; i++ )
  23. {
  24. if ( parent.FindAttachmentBySlotName(slot_names[i]) != NULL )
  25. {
  26. slot_test = false;
  27. break;
  28. }
  29. }
  30. if ( ( is_opened_barrel && slot_test ) || !is_barrel )
  31. {
  32. return true;
  33. }
  34. return false;
  35. }
  36. override bool CanDetachAttachment( EntityAI parent )
  37. {
  38. bool is_barrel = false;
  39. bool is_opened_barrel = false;
  40. // is barrel
  41. if ( parent.IsKindOf("Barrel_ColorBase") )
  42. {
  43. is_barrel = true;
  44. }
  45. // is opened barrel
  46. if ( is_barrel && parent.GetAnimationPhase("Lid") == 1 )
  47. {
  48. is_opened_barrel = true;
  49. }
  50. if ( is_opened_barrel || !is_barrel )
  51. {
  52. return true;
  53. }
  54. return false;
  55. }
  56. }