Dayz Explorer 1.28.160049
Loading...
Searching...
No Matches
actiontakefireplacefrombarrel.c
Go to the documentation of this file.
1
3{
5 {
6 m_CommandUID = DayZPlayerConstants.CMD_ACTIONMOD_PICKUP_HANDS;
7 m_StanceMask = DayZPlayerConstants.STANCEMASK_CROUCH | DayZPlayerConstants.STANCEMASK_ERECT;
8 m_Text = "#take_fireplace";
9 }
10
11 override bool ActionCondition( PlayerBase player, ActionTarget target, ItemBase item )
12 {
13 Object target_object = target.GetObject();
14
15 if ( target_object && target_object.IsFireplace() )
16 {
17 BarrelHoles_ColorBase fireplace_barrel = BarrelHoles_ColorBase.Cast( target_object );
18
19 //check barrel fireplace state
20 if ( fireplace_barrel && fireplace_barrel.IsOpen() && !fireplace_barrel.HasAshes() && !fireplace_barrel.IsBurning() )
21 {
22 //check cargo and attachments
23 if ( fireplace_barrel.IsCargoEmpty() && fireplace_barrel.GetInventory().AttachmentCount() > 0 )
24 {
25 return true;
26 }
27 }
28 }
29
30 return false;
31 }
32
33 override void OnExecuteServer( ActionData action_data )
34 {
35 Object target_object = action_data.m_Target.GetObject();
36 BarrelHoles_ColorBase fireplace_barrel = BarrelHoles_ColorBase.Cast( target_object );
37
38 string newTypeName = "Fireplace";
40 bool found = action_data.m_Player.GetInventory().FindFirstFreeLocationForNewEntity( newTypeName, FindInventoryLocationType.ANY, targetIL );
41 if ( found )
42 {
43 // allow action only if there is place in inventory
44 auto lambda = TakeFireplaceFromBarrelLambda( fireplace_barrel, newTypeName, action_data.m_Player );
45 lambda.OverrideNewLocation( targetIL );
46 action_data.m_Player.ServerReplaceItemWithNew( lambda );
47 }
48 }
49}
50
52{
54
55 void TakeFireplaceFromBarrelLambda ( EntityAI old_item, string new_item_type, PlayerBase player )
56 {
57 m_Player = player;
58 }
59
60 override protected void RemoveOldItemFromLocation ()
61 {
62 // intentional no-operation
63 m_RemoveFromLocationPassed = true; // but indicate the operation to be success
64 }
65 override protected void UndoRemoveOldItemFromLocation ()
66 {
67 // undo nothing
68 }
69
70 override void CopyOldPropertiesToNew( notnull EntityAI old_item, EntityAI new_item )
71 {
72 super.CopyOldPropertiesToNew( old_item, new_item );
73
74 MiscGameplayFunctions.TransferInventory(old_item, new_item, m_Player);
75 }
76
77 override protected void DeleteOldEntity ()
78 {
79 // intentional no-operation
80 }
81
82 override protected void CreateNetworkObjectInfo (EntityAI new_item)
83 {
84 super.CreateNetworkObjectInfo(new_item);
85 GetGame().RemoteObjectTreeCreate(m_OldItem); // re-create network for old item
86 }
87}
void TakeFireplaceFromBarrelLambda(EntityAI old_item, string new_item_type, PlayerBase player)
int m_StanceMask
Definition actionbase.c:62
string m_Text
Definition actionbase.c:58
InventoryLocation.
base class for transformation operations (creating one item from another)
void DeleteOldEntity()
Step F. - deletes physically old item.
void CreateNetworkObjectInfo(EntityAI new_item)
Step G. - create NetworkObjectInfo for new item.
void RemoveOldItemFromLocation()
Step B. - free location for new item @NOTE this operation does not delete the object,...
void CopyOldPropertiesToNew(notnull EntityAI old_item, EntityAI new_item)
Step E. copy properties from old object to the created one.
DayZPlayerConstants
defined in C++
Definition dayzplayer.c:602
proto native CGame GetGame()
DayZPlayer m_Player
Definition hand_events.c:42
FindInventoryLocationType
flags for searching locations in inventory