Dayz Explorer  1.24.157551 (v105080)
Dayz Code Explorer by Zeroy
actioncreategreenhousegardenplot.c
Go to the documentation of this file.
2 {
3  override void CreateActionComponent()
4  {
5  m_ActionData.m_ActionComponent = new CAContinuousTime(UATimeSpent.DIG_GARDEN);
6  }
7 };
8 
10 {
11  GardenPlot m_GardenPlot;
12  private const float CAMERA_PITCH_THRESHOLD = -30;
13 
15  {
16  m_CallbackClass = ActionCreateGreenhouseGardenPlotCB;
17  m_FullBody = true;
18  m_CommandUID = DayZPlayerConstants.CMD_ACTIONFB_DIGMANIPULATE;
19  m_StanceMask = DayZPlayerConstants.STANCEMASK_ERECT;
21  m_Text = "#make_garden_plot";
22  }
23 
24  override void CreateConditionComponents()
25  {
28  }
29 
30  override bool ActionCondition( PlayerBase player, ActionTarget target, ItemBase item )
31  {
32  if ( !target )
33  return false;
34 
35  if ( player.IsPlacingLocal() )
36  return false;
37 
38  Object target_object = target.GetObject();
39 
40  Land_Misc_Greenhouse greenHouse = Land_Misc_Greenhouse.Cast( target_object );
41  Land_Misc_Polytunnel polytunnel = Land_Misc_Polytunnel.Cast( target_object) ;
42 
43  if ( target_object && ( greenHouse || polytunnel ) )
44  {
45  string action_selection = target_object.GetActionComponentName( target.GetComponentIndex() );
46  //Update selections in model, name the desired part Soil to improve action condition check
47  if ( action_selection != "soil" )
48  return false;
49 
50  //check if there is any gardenplot objects in the current building
51  ref array<Object> nearest_objects = new array<Object>;
52  ref array<CargoBase> proxy_cargos = new array<CargoBase>;
53  vector pos = target_object.GetPosition();
54  pos[1] = pos[1] - 1; //Lower by one meter for check if plot already present
55  GetGame().GetObjectsAtPosition3D( pos, 2, nearest_objects, proxy_cargos );
56 
57  for ( int i = 0; i < nearest_objects.Count(); ++i )
58  {
59  Object object = nearest_objects.Get( i );
60 
61  if ( object.IsInherited( GardenPlot ) )
62  {
63  return false;
64  }
65  }
66 
67  return true;
68  }
69 
70  return false;
71  }
72 
73  override void OnFinishProgressServer( ActionData action_data )
74  {
75  PlaceObjectActionData poActionData;
76  poActionData = PlaceObjectActionData.Cast(action_data);
77  EntityAI entity_for_placing = action_data.m_MainItem;
78  Object targetObject = action_data.m_Target.GetObject();
79 
80  vector position = targetObject.GetPosition();
81 
82  //Depending on where we dig the required height offset is not the same
83  Land_Misc_Greenhouse greenHouse = Land_Misc_Greenhouse.Cast( targetObject );
84  Land_Misc_Polytunnel polytunnel = Land_Misc_Polytunnel.Cast( targetObject) ;
85 
86  if ( polytunnel )
87  position[1] = position[1] - 1.15; //Lower Y position by roughly 1 meter to compensate for spawning location offset
88  else
89  position[1] = position[1] - 1.05;
90 
91  vector orientation = targetObject.GetOrientation();
92 
93  if ( GetGame().IsMultiplayer() )
94  {
95  Land_Misc_Polytunnel tunnel = Land_Misc_Polytunnel.Cast(action_data.m_Target.GetObject());
96  if (tunnel)
97  {
98  m_GardenPlot = GardenPlot.Cast( GetGame().CreateObjectEx( "GardenPlotPolytunnel", position, ECE_KEEPHEIGHT ) );
99  }
100  else
101  {
102  m_GardenPlot = GardenPlot.Cast( GetGame().CreateObjectEx( "GardenPlotGreenhouse", position, ECE_KEEPHEIGHT ) );
103  }
104 
105  m_GardenPlot.SetOrientation( orientation );
106  }
107  }
108 }
ItemBase
Definition: inventoryitem.c:730
GetGame
proto native CGame GetGame()
ActionCreateGreenhouseGardenPlotCB
Definition: actioncreategreenhousegardenplot.c:1
ActionCreateGreenhouseGardenPlot
Definition: actioncreategreenhousegardenplot.c:9
CAContinuousTime
Definition: cacontinuoustime.c:1
ECE_KEEPHEIGHT
const int ECE_KEEPHEIGHT
Definition: centraleconomy.c:27
UASoftSkillsWeight
Definition: actionconstants.c:118
m_FullBody
protected bool m_FullBody
Definition: actionbase.c:52
PlayerBase
Definition: playerbaseclient.c:1
vector
Definition: enconvert.c:105
Land_Misc_Greenhouse
void Land_Misc_Greenhouse()
Definition: land_misc_greenhouse.c:2
ActionTarget
class ActionTargets ActionTarget
ActionData
Definition: actionbase.c:20
PlaceObjectActionData
Definition: actiondeploybase.c:1
DayZPlayerConstants
DayZPlayerConstants
defined in C++
Definition: dayzplayer.c:601
Object
Definition: objecttyped.c:1
CCTCursor
Definition: cctcursor.c:1
UATimeSpent
Definition: actionconstants.c:26
ActionContinuousBaseCB
Definition: actioncontinuousbase.c:1
array< Object >
m_Text
protected string m_Text
Definition: actionbase.c:49
m_ConditionItem
ref CCIBase m_ConditionItem
Definition: actionbase.c:55
ActionContinuousBase
Definition: actioncontinuousbase.c:132
CCINonRuined
Definition: ccinonruined.c:1
Land_Misc_Polytunnel
class Land_Misc_Greenhouse extends BuildingSuper Land_Misc_Polytunnel()
Definition: land_misc_greenhouse.c:11
m_ConditionTarget
ref CCTBase m_ConditionTarget
Definition: actionbase.c:56
m_SpecialtyWeight
protected float m_SpecialtyWeight
Definition: actionbase.c:68
m_StanceMask
protected int m_StanceMask
Definition: actionbase.c:53
EntityAI
Definition: building.c:5