Dayz Explorer  1.24.157551 (v105080)
Dayz Code Explorer by Zeroy
actiontakefireplacefrombarrel.c
Go to the documentation of this file.
2 {
4  {
5  m_CommandUID = DayZPlayerConstants.CMD_ACTIONMOD_PICKUP_HANDS;
6  m_StanceMask = DayZPlayerConstants.STANCEMASK_CROUCH | DayZPlayerConstants.STANCEMASK_ERECT;
7  m_Text = "#take_fireplace";
8  }
9 
10  override bool ActionCondition( PlayerBase player, ActionTarget target, ItemBase item )
11  {
12  Object target_object = target.GetObject();
13 
14  if ( target_object && target_object.IsFireplace() )
15  {
16  BarrelHoles_ColorBase fireplace_barrel = BarrelHoles_ColorBase.Cast( target_object );
17 
18  //check barrel fireplace state
19  if ( fireplace_barrel && fireplace_barrel.IsOpen() && !fireplace_barrel.HasAshes() && !fireplace_barrel.IsBurning() )
20  {
21  //check cargo and attachments
22  if ( fireplace_barrel.IsCargoEmpty() && fireplace_barrel.GetInventory().AttachmentCount() > 0 )
23  {
24  return true;
25  }
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  BarrelHoles_ColorBase fireplace_barrel = BarrelHoles_ColorBase.Cast( target_object );
36 
37  string newTypeName = "Fireplace";
38  InventoryLocation targetIL = new InventoryLocation;
39  bool found = action_data.m_Player.GetInventory().FindFirstFreeLocationForNewEntity( newTypeName, FindInventoryLocationType.ANY, targetIL );
40  if ( found )
41  {
42  // allow action only if there is place in inventory
43  auto lambda = TakeFireplaceFromBarrelLambda( fireplace_barrel, newTypeName, action_data.m_Player );
44  lambda.OverrideNewLocation( targetIL );
45  action_data.m_Player.ServerReplaceItemWithNew( lambda );
46  }
47  }
48 }
49 
51 {
53 
54  void TakeFireplaceFromBarrelLambda ( EntityAI old_item, string new_item_type, PlayerBase player )
55  {
56  m_Player = player;
57  }
58 
59  override protected void RemoveOldItemFromLocation ()
60  {
61  // intentional no-operation
62  m_RemoveFromLocationPassed = true; // but indicate the operation to be success
63  }
64  override protected void UndoRemoveOldItemFromLocation ()
65  {
66  // undo nothing
67  }
68 
69  override void CopyOldPropertiesToNew( notnull EntityAI old_item, EntityAI new_item )
70  {
71  super.CopyOldPropertiesToNew( old_item, new_item );
72 
73  MiscGameplayFunctions.TransferInventory(old_item, new_item, m_Player);
74  }
75 
76  override protected void DeleteOldEntity ()
77  {
78  // intentional no-operation
79  }
80 
81  override protected void CreateNetworkObjectInfo (EntityAI new_item)
82  {
83  super.CreateNetworkObjectInfo(new_item);
84  GetGame().RemoteObjectTreeCreate(m_OldItem); // re-create network for old item
85  }
86 }
ItemBase
Definition: inventoryitem.c:730
GetGame
proto native CGame GetGame()
CopyOldPropertiesToNew
override void CopyOldPropertiesToNew(notnull EntityAI old_item, EntityAI new_item)
Definition: actiontakefireplacefrombarrel.c:69
TakeFireplaceFromBarrelLambda
void TakeFireplaceFromBarrelLambda(EntityAI old_item, string new_item_type, PlayerBase player)
Definition: actiontakefireplacefrombarrel.c:54
DeleteOldEntity
override protected void DeleteOldEntity()
Definition: actiontakefireplacefrombarrel.c:76
InventoryLocation
InventoryLocation.
Definition: inventorylocation.c:27
ActionInteractBase
Definition: actioninteractbase.c:54
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
UndoRemoveOldItemFromLocation
override protected void UndoRemoveOldItemFromLocation()
Definition: actiontakefireplacefrombarrel.c:64
CreateNetworkObjectInfo
override protected void CreateNetworkObjectInfo(EntityAI new_item)
Definition: actiontakefireplacefrombarrel.c:81
m_Text
protected string m_Text
Definition: actionbase.c:49
ActionTakeFireplaceFromBarrel
Definition: actiontakefireplacefrombarrel.c:1
ReplaceItemWithNewLambdaBase
base class for transformation operations (creating one item from another)
Definition: replaceitemwithnewlambdabase.c:4
m_StanceMask
protected int m_StanceMask
Definition: actionbase.c:53
EntityAI
Definition: building.c:5
RemoveOldItemFromLocation
override protected void RemoveOldItemFromLocation()
Definition: actiontakefireplacefrombarrel.c:59
BarrelHoles_ColorBase
Definition: barrelholes_blue.c:1
m_Player
ActionTakeFireplaceFromBarrel m_Player