Dayz Explorer  1.24.157551 (v105080)
Dayz Code Explorer by Zeroy
actiontakeovenindoor.c
Go to the documentation of this file.
2 {
3  string m_NewItemTypeName = "Fireplace";
4 
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 
12  override bool ActionCondition( PlayerBase player, ActionTarget target, ItemBase item )
13  {
14  Object target_object = target.GetObject();
15 
16  //empty hands --interact action base condition
17  if ( target_object && target_object.IsFireplace() )
18  {
19  OvenIndoor fireplace_indoor = OvenIndoor.Cast( target_object );
20 
21  if ( fireplace_indoor && !fireplace_indoor.HasAshes() && !fireplace_indoor.IsBurning() && fireplace_indoor.IsCargoEmpty() && !fireplace_indoor.DirectCookingSlotsInUse() )
22  {
23  InventoryLocation targetIL = new InventoryLocation;
24  bool found = player.GetInventory().FindFirstFreeLocationForNewEntity( m_NewItemTypeName, FindInventoryLocationType.ANY, targetIL );
25  return found;
26  }
27  }
28 
29  return false;
30  }
31 
32  override void OnExecuteServer( ActionData action_data )
33  {
34  Object target_object = action_data.m_Target.GetObject();
35  OvenIndoor fireplace_indoor = OvenIndoor.Cast( target_object );
36 
37  TakeOvenFromIndoorLambda lambda( fireplace_indoor, m_NewItemTypeName, action_data.m_Player );
38  InventoryLocation targetIL = new InventoryLocation;
39  bool found = action_data.m_Player.GetInventory().FindFirstFreeLocationForNewEntity( m_NewItemTypeName, FindInventoryLocationType.ANY, targetIL );
40  if ( found )
41  {
42  // allow action only if there is place in inventory
43  lambda.OverrideNewLocation( targetIL );
44  action_data.m_Player.ServerReplaceItemWithNew( lambda );
45  }
46  }
47 }
48 
50 {
52 
53  void TakeOvenFromIndoorLambda ( EntityAI old_item, string new_item_type, PlayerBase player )
54  {
55  m_Player = player;
56  }
57 
58  override void CopyOldPropertiesToNew( notnull EntityAI old_item, EntityAI new_item )
59  {
60  super.CopyOldPropertiesToNew( old_item, new_item );
61 
62  MiscGameplayFunctions.TransferInventory(old_item, new_item, m_Player);
63  }
64 }
ItemBase
Definition: inventoryitem.c:730
m_Player
ActionTakeOvenIndoor m_Player
TakeOvenFromIndoorLambda
void TakeOvenFromIndoorLambda(EntityAI old_item, string new_item_type, PlayerBase player)
Definition: actiontakeovenindoor.c:53
InventoryLocation
InventoryLocation.
Definition: inventorylocation.c:27
ActionInteractBase
Definition: actioninteractbase.c:54
ActionTakeOvenIndoor
Definition: actiontakeovenindoor.c:1
PlayerBase
Definition: playerbaseclient.c:1
ActionTarget
class ActionTargets ActionTarget
ActionData
Definition: actionbase.c:20
DayZPlayerConstants
DayZPlayerConstants
defined in C++
Definition: dayzplayer.c:601
Object
Definition: objecttyped.c:1
FindInventoryLocationType
FindInventoryLocationType
flags for searching locations in inventory
Definition: inventorylocation.c:15
m_Text
protected string m_Text
Definition: actionbase.c:49
ReplaceItemWithNewLambdaBase
base class for transformation operations (creating one item from another)
Definition: replaceitemwithnewlambdabase.c:4
CopyOldPropertiesToNew
override void CopyOldPropertiesToNew(notnull EntityAI old_item, EntityAI new_item)
Definition: actiontakeovenindoor.c:58
m_StanceMask
protected int m_StanceMask
Definition: actionbase.c:53
EntityAI
Definition: building.c:5