actiontakeovenindoor.c 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. //!DEPRECATED
  2. class ActionTakeOvenIndoor: ActionInteractBase
  3. {
  4. string m_NewItemTypeName = "Fireplace";
  5. void ActionTakeOvenIndoor()
  6. {
  7. m_CommandUID = DayZPlayerConstants.CMD_ACTIONMOD_PICKUP_HANDS;
  8. m_StanceMask = DayZPlayerConstants.STANCEMASK_CROUCH | DayZPlayerConstants.STANCEMASK_ERECT;
  9. m_Text = "#take_fireplace";
  10. }
  11. override bool ActionCondition( PlayerBase player, ActionTarget target, ItemBase item )
  12. {
  13. Object target_object = target.GetObject();
  14. //empty hands --interact action base condition
  15. if ( target_object && target_object.IsFireplace() )
  16. {
  17. OvenIndoor fireplace_indoor = OvenIndoor.Cast( target_object );
  18. if ( fireplace_indoor && !fireplace_indoor.HasAshes() && !fireplace_indoor.IsBurning() && fireplace_indoor.IsCargoEmpty() && !fireplace_indoor.DirectCookingSlotsInUse() )
  19. {
  20. InventoryLocation targetIL = new InventoryLocation;
  21. bool found = player.GetInventory().FindFirstFreeLocationForNewEntity( m_NewItemTypeName, FindInventoryLocationType.ANY, targetIL );
  22. return found;
  23. }
  24. }
  25. return false;
  26. }
  27. override void OnExecuteServer( ActionData action_data )
  28. {
  29. Object target_object = action_data.m_Target.GetObject();
  30. OvenIndoor fireplace_indoor = OvenIndoor.Cast( target_object );
  31. TakeOvenFromIndoorLambda lambda( fireplace_indoor, m_NewItemTypeName, action_data.m_Player );
  32. InventoryLocation targetIL = new InventoryLocation;
  33. bool found = action_data.m_Player.GetInventory().FindFirstFreeLocationForNewEntity( m_NewItemTypeName, FindInventoryLocationType.ANY, targetIL );
  34. if ( found )
  35. {
  36. // allow action only if there is place in inventory
  37. lambda.OverrideNewLocation( targetIL );
  38. action_data.m_Player.ServerReplaceItemWithNew( lambda );
  39. }
  40. }
  41. }
  42. class TakeOvenFromIndoorLambda : ReplaceItemWithNewLambdaBase
  43. {
  44. PlayerBase m_Player;
  45. void TakeOvenFromIndoorLambda ( EntityAI old_item, string new_item_type, PlayerBase player )
  46. {
  47. m_Player = player;
  48. }
  49. override void CopyOldPropertiesToNew( notnull EntityAI old_item, EntityAI new_item )
  50. {
  51. super.CopyOldPropertiesToNew( old_item, new_item );
  52. MiscGameplayFunctions.TransferInventory(old_item, new_item, m_Player);
  53. }
  54. }