Dayz
Build 1.29.163047, Scripts Rev. 123548
Dayz Code Explorer by Zeroy
Toggle main menu visibility
Loading...
Searching...
No Matches
actiontakefireplacefrombarrel.c
Go to the documentation of this file.
1
2
class
ActionTakeFireplaceFromBarrel
:
ActionInteractBase
3
{
4
void
ActionTakeFireplaceFromBarrel
()
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"
;
39
InventoryLocation
targetIL =
new
InventoryLocation
;
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
51
class
TakeFireplaceFromBarrelLambda
:
ReplaceItemWithNewLambdaBase
52
{
53
PlayerBase
m_Player
;
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
g_Game
.RemoteObjectTreeCreate(m_OldItem);
// re-create network for old item
86
}
87
}
ActionData
ActionBase ActionData
Definition
actionbase.c:30
TakeFireplaceFromBarrelLambda
void TakeFireplaceFromBarrelLambda(EntityAI old_item, string new_item_type, PlayerBase player)
Definition
actiontakefireplacefrombarrel.c:55
ActionTarget
class ActionTargets ActionTarget
m_Player
map m_Player
ActionBase::m_Text
string m_Text
Definition
actionbase.c:64
ActionBase::m_StanceMask
int m_StanceMask
Definition
actionbase.c:68
ActionInteractBase::ActionInteractBase
void ActionInteractBase()
Definition
actioninteractbase.c:43
ActionTakeFireplaceFromBarrel::OnExecuteServer
override void OnExecuteServer(ActionData action_data)
Definition
actiontakefireplacefrombarrel.c:33
ActionTakeFireplaceFromBarrel::ActionTakeFireplaceFromBarrel
void ActionTakeFireplaceFromBarrel()
Definition
actiontakefireplacefrombarrel.c:4
ActionTakeFireplaceFromBarrel::ActionCondition
override bool ActionCondition(PlayerBase player, ActionTarget target, ItemBase item)
Definition
actiontakefireplacefrombarrel.c:11
AnimatedActionBase::m_CommandUID
int m_CommandUID
Definition
animatedactionbase.c:143
BarrelHoles_ColorBase
Definition
barrelholes_blue.c:2
EntityAI
Definition
inventoryitem.c:2
InventoryLocation
InventoryLocation.
Definition
inventorylocation.c:30
ItemBase
Definition
inventoryitem.c:742
Object
Definition
objecttyped.c:2
PlayerBase
Definition
playerbaseclient.c:2
ReplaceItemWithNewLambdaBase
base class for transformation operations (creating one item from another)
Definition
replaceitemwithnewlambdabase.c:5
ReplaceItemWithNewLambdaBase::CreateNetworkObjectInfo
void CreateNetworkObjectInfo(EntityAI new_item)
Definition
replaceitemwithnewlambdabase.c:212
ReplaceItemWithNewLambdaBase::RemoveOldItemFromLocation
void RemoveOldItemFromLocation()
Step B.
Definition
replaceitemwithnewlambdabase.c:86
ReplaceItemWithNewLambdaBase::DeleteOldEntity
void DeleteOldEntity()
Step F.
Definition
replaceitemwithnewlambdabase.c:201
ReplaceItemWithNewLambdaBase::UndoRemoveOldItemFromLocation
void UndoRemoveOldItemFromLocation()
Definition
replaceitemwithnewlambdabase.c:99
ReplaceItemWithNewLambdaBase::CopyOldPropertiesToNew
void CopyOldPropertiesToNew(notnull EntityAI old_item, EntityAI new_item)
Definition
replaceitemwithnewlambdabase.c:193
g_Game
DayZGame g_Game
Definition
dayzgame.c:3942
DayZPlayerConstants
DayZPlayerConstants
defined in C++
Definition
dayzplayer.c:602
FindInventoryLocationType
FindInventoryLocationType
flags for searching locations in inventory
Definition
inventorylocation.c:18
Games
Dayz
scripts
4_world
classes
useractionscomponent
actions
interact
actiontakefireplacefrombarrel.c
Generated by
1.17.0