DayZ 1.27
DayZ Explorer by KGB
 
Загрузка...
Поиск...
Не найдено
ActionPlaceOvenIndoor.c
См. документацию.
2{
4 {
5 m_CommandUID = DayZPlayerConstants.CMD_ACTIONMOD_OPENDOORFW;
6 m_StanceMask = DayZPlayerConstants.STANCEMASK_CROUCH | DayZPlayerConstants.STANCEMASK_ERECT;
7 m_SpecialtyWeight = UASoftSkillsWeight.PRECISE_LOW;
8 m_Text = "#place_object";
9 }
10
16
17 override bool ActionCondition( PlayerBase player, ActionTarget target, ItemBase item )
18 {
19 if ( !target ) return false;
20
21 Object target_object = target.GetObject();
22 string action_selection = target_object.GetActionComponentName( target.GetComponentIndex() );
23 BuildingWithFireplace building = BuildingWithFireplace.Cast( target_object );
24
25 if ( target_object && building && action_selection.Contains( OvenIndoor.OVENPOINT_ACTION_SELECTION ) )
26 {
27 if ( !IsInReach(player, target, UAMaxDistances.DEFAULT) ) return false;
28
29 vector fire_point_pos_world, fire_point_rot_world;
30 int fire_point_index = OvenIndoor.GetFirePointIndex( action_selection );
31 if ( OvenIndoor.CanPlaceFireplaceInSelectedSpot( building, fire_point_index, fire_point_pos_world, fire_point_rot_world ) )
32 {
33 float rot_deg = 0.0;
34 if ( building.HasSelection( OvenIndoor.OVENPOINT_PLACE_ROT + fire_point_index.ToString() ) )
35 {
36 vector diff = fire_point_rot_world - fire_point_pos_world;
37 diff[1] = 0.0;
38 diff.Normalize();
39 float dotp = vector.Dot( "0 0 1" , diff );
40 rot_deg = Math.Acos( dotp ) * Math.RAD2DEG;
41 if ( ( diff[0] < 0 ) && ( diff[2] < 0 ) )
42 rot_deg = 360.0 - rot_deg;
43 else if ( ( diff[0] < 0 ) && ( diff[2] > 0 ) )
44 rot_deg = 360.0 - rot_deg;
45
46 //Debug.DrawArrow( fire_point_pos_world, fire_point_pos_world + diff );
47 }
48
49 float fire_point_dist = vector.Distance( fire_point_pos_world, player.GetPosition() );
50 if ( fire_point_dist <= 2 )
51 {
52 player.SetLastFirePoint( fire_point_pos_world );
53 player.SetLastFirePointIndex( fire_point_index );
54 player.SetLastFirePointRot( rot_deg );
55 return true;
56 }
57 }
58 }
59
60 return false;
61 }
62
63 override void OnExecuteServer( ActionData action_data )
64 {
65 FireplaceBase fireplace_in_hands = FireplaceBase.Cast( action_data.m_MainItem );
66
67 //replace fireplace with lambda
68 FireplaceToIndoorOvenLambda lambda = new FireplaceToIndoorOvenLambda( fireplace_in_hands, "OvenIndoor", action_data.m_Player, action_data.m_Player.GetLastFirePoint(), action_data.m_Target.GetObject() );
69 lambda.SetTransferParams( true, true, true );
70 action_data.m_Player.ServerReplaceItemInHandsWithNewElsewhere( lambda );
71 }
72
73 override bool IsLockTargetOnUse()
74 {
75 return false;
76 }
77}
78
79
81{
85
86 void FireplaceToIndoorOvenLambda( EntityAI old_item, string new_item_type, PlayerBase player, vector pos, Object target )
87 {
89 vector mtx[4];
91 mtx[3] = pos;
92 gnd.SetGround( NULL, mtx );
93 OverrideNewLocation( gnd );
94
95 //set fire point index and smoke point position in world
96 m_FirePointIndex = player.GetLastFirePointIndex();
97 m_FireplaceRot = player.GetLastFirePointRot();
98
99 vector smoke_point_pos = target.GetSelectionPositionMS( OvenIndoor.OVENPOINT_SMOKE_POSITION + m_FirePointIndex.ToString() );
100 vector smoke_point_pos_world = target.ModelToWorld( smoke_point_pos );
101 m_SmokePosition = smoke_point_pos_world;
102 }
103
104 override void CopyOldPropertiesToNew (notnull EntityAI old_item, EntityAI new_item)
105 {
106 super.CopyOldPropertiesToNew( old_item, new_item );
107
108 OvenIndoor fireplace_indoor = OvenIndoor.Cast( new_item );
109 if ( fireplace_indoor )
110 {
111 //set fire point index
112 fireplace_indoor.SetFirePointIndex( m_FirePointIndex );
113
114 // rotate fireplace
115 vector fprot = vector.Zero;
116 fprot[0] = m_FireplaceRot;
117 fireplace_indoor.SetOrientation( fprot );
118 Print(fireplace_indoor.GetOrientation());
119
120 // smoke pos (chimney)
121 fireplace_indoor.SetSmokePointPosition( m_SmokePosition );
122
123 //synchronize
124 fireplace_indoor.Synchronize();
125 }
126 }
127};
ActionBase ActionData
Определения ActionBase.c:30
ActionPlaceFireplaceIndoor m_FirePointIndex
vector m_SmokePosition
Определения ActionPlaceFireplaceIndoor.c:86
float m_FireplaceRot
Определения ActionPlaceFireplaceIndoor.c:85
void FireplaceToIndoorOvenLambda(EntityAI old_item, string new_item_type, PlayerBase player, vector pos, Object target)
Определения ActionPlaceOvenIndoor.c:86
class ActionTargets ActionTarget
override void CopyOldPropertiesToNew(notnull EntityAI old_item, EntityAI new_item)
Определения MiscGameplayFunctions.c:124
float m_SpecialtyWeight
Определения ActionBase.c:77
int m_StanceMask
Определения ActionBase.c:62
bool IsInReach(PlayerBase player, ActionTarget target, float maxDistance=1.0)
Определения ActionBase.c:1158
string m_Text
Определения ActionBase.c:58
ref CCIBase m_ConditionItem
Определения ActionBase.c:64
ref CCTBase m_ConditionTarget
Определения ActionBase.c:65
override void OnExecuteServer(ActionData action_data)
Определения ActionPlaceOvenIndoor.c:63
void ActionPlaceOvenIndoor()
Определения ActionPlaceOvenIndoor.c:3
override bool IsLockTargetOnUse()
Определения ActionPlaceOvenIndoor.c:73
override bool ActionCondition(PlayerBase player, ActionTarget target, ItemBase item)
Определения ActionPlaceOvenIndoor.c:17
override void CreateConditionComponents()
Определения ActionPlaceOvenIndoor.c:11
void ActionSingleUseBase()
Определения ActionSingleUseBase.c:31
int m_CommandUID
Определения AnimatedActionBase.c:143
Определения CCINonRuined.c:2
Определения CCTCursor.c:2
Определения Building.c:6
proto native void SetGround(EntityAI e, vector mat[4])
sets current inventory location type to Ground with transformation mat
InventoryLocation.
Определения InventoryLocation.c:29
Определения InventoryItem.c:731
Определения EnMath3D.c:28
Определения EnMath.c:7
Определения ObjectTyped.c:2
Определения PlayerBaseClient.c:2
const float DEFAULT
Определения ActionConstants.c:112
static float Dot(vector v1, vector v2)
Returns Dot product of vector v1 and vector v2.
Определения EnConvert.c:271
static const vector Zero
Определения EnConvert.c:110
proto float Normalize()
Normalizes vector. Returns length.
static proto native float Distance(vector v1, vector v2)
Returns the distance between tips of two 3D vectors.
Определения EnConvert.c:106
DayZPlayerConstants
defined in C++
Определения dayzplayer.c:602
proto void Print(void var)
Prints content of variable to console/log.
static void MatrixIdentity4(out vector mat[4])
Creates identity matrix.
Определения EnMath3D.c:256
static proto float Acos(float c)
Returns angle in radians from cosinus.
static const float RAD2DEG
Определения EnMath.c:16
bool Contains(string sample)
Returns true if sample is substring of string.
Определения EnString.c:286