Dayz Explorer  1.24.157551 (v105080)
Dayz Code Explorer by Zeroy
pluginnutritiondumper.c
Go to the documentation of this file.
1 
2 class PluginNutritionDumper extends PluginBase
3 {
4  /*
5  ref TStringArray m_AllPaths = new TStringArray;
6  ref TStringArray m_AllLines = new TStringArray;
7  ref map<string, int> m_ParamPool = new map<string, int>;
8 
9  string config_path;
10  string child_name;
11  int scope;
12  string path;
13  PlayerBase m_Player;
14  override void OnInit()
15  {
16  m_AllPaths.Insert("CfgVehicles");
17  m_AllPaths.Insert("cfgLiquidDefinitions");
18  m_Player = PlayerBase.Cast(GetGame().GetPlayer());
19  }
20 
21  void CheckInit()
22  {
23  m_AllLines.Clear();
24  string line = "Classname(stage),energy,water,toxicity,fullnessIndex,nutritionalIndex";
25  m_AllLines.Insert(line);
26 
27  for(int i = 0; i < m_AllPaths.Count(); i++)
28  {
29  config_path = m_AllPaths.Get(i);
30  int children_count = GetGame().ConfigGetChildrenCount(config_path);
31 
32  for(int x = 0; x < children_count; x++)
33  {
34  GetGame().ConfigGetChildName(config_path, x, child_name);
35  path = config_path + " " + child_name;
36  scope = GetGame().ConfigGetInt( config_path + " " + child_name + " scope" );
37  bool should_check = 1;
38  if( config_path == "CfgVehicles" && scope == 0)
39  {
40  should_check = 0;
41  }
42 
43  if ( should_check )
44  {
45  bool has_nutrition = GetGame().ConfigIsExisting(path + " Nutrition");
46  bool has_stages = GetGame().ConfigIsExisting(path + " Food");
47  if(has_nutrition || has_stages)
48  {
49  EntityAI item = PlayerBase.Cast(GetGame().GetPlayer()).SpawnEntityOnGroundOnCursorDir(child_name,1);
50  Edible_Base edible = Edible_Base.Cast(item);
51  if(edible)
52  {
53  //Print("spawning " + child_name);
54  line = "";
55  NutritionalProfile profile;
56  if(!has_stages)
57  {
58  profile = edible.GetNutritionalProfile();
59  line = BuildLine(child_name, profile);
60  m_AllLines.Insert(line);
61  //Print(line);
62  }
63  else
64  {
65  for(int z = FoodStageType.RAW; z < FoodStageType.COUNT; z++)
66  {
67  if( z != FoodStageType.RAW )
68  edible.ChangeFoodStage(z);
69  profile = edible.GetNutritionalProfile();
70  string itemname = child_name + "(stage " + z.ToString()+")";
71  line = BuildLine(itemname, profile);
72  m_AllLines.Insert(line);
73  }
74  }
75  }
76  }
77  }
78  }
79  }
80 
81  SaveToFile("nutritional_values.csv");
82  }
83 
84 
85  protected void SaveToFile(string filename)
86  {
87  FileHandle file = OpenFile(filename, FileMode.WRITE);
88  if( file!=0 )
89  {
90  for(int i = 0; i < m_AllLines.Count(); i++)
91  {
92  FPrintln(file,m_AllLines.Get(i));
93  Print(m_AllLines.Get(i));
94  }
95 
96  }
97 
98  }
99 
100  string BuildLine(string item_name, NutritionalProfile profile)
101  {
102  string line = item_name+",";
103  line = line + profile.GetEnergy()+",";
104  line = line + profile.GetWaterContent()+",";
105  line = line + profile.GetToxicity()+",";
106  line = line + profile.GetFullnessIndex()+",";
107  line = line + profile.GetNutritionalIndex();
108  return line;
109  }
110  */
111 }
PluginBase
Definition: pluginadminlog.c:1