DayZ 1.27
DayZ Explorer by KGB
 
Загрузка...
Поиск...
Не найдено

◆ ActionCondition()

override bool ActionPlaceOvenIndoor::ActionCondition ( PlayerBase player,
ActionTarget target,
ItemBase item )
inlineprivate

См. определение в файле ActionPlaceOvenIndoor.c строка 17

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 }
bool IsInReach(PlayerBase player, ActionTarget target, float maxDistance=1.0)
Определения ActionBase.c:1158
proto float Normalize()
Normalizes vector. Returns length.
class LOD Object
bool Contains(string sample)
Returns true if sample is substring of string.
Определения EnString.c:286

Перекрестные ссылки Math::Acos(), ActionTarget, string::Contains(), UAMaxDistances::DEFAULT, vector::Distance(), vector::Dot(), ActionBase::IsInReach(), vector::Normalize() и Math::RAD2DEG.