DayZ 1.30
DayZ Explorer by KGB
 
Загрузка...
Поиск...
Не найдено
ActionRepairTent.c
См. документацию.
1class RepairTentActionReciveData : ActionReciveData
2{
4}
5
6class RepairTentActionData : ActionData
7{
9}
10
18
20{
21 typename m_LastValidType; //legacy stuff
23 int m_LastValidComponentIndex = -1; //legacy stuff
24
26 {
28 m_SpecialtyWeight = UASoftSkillsWeight.PRECISE_LOW;
29
30 m_CommandUID = DayZPlayerConstants.CMD_ACTIONFB_INTERACT;
31 m_FullBody = true;
32 m_StanceMask = DayZPlayerConstants.STANCEMASK_ERECT | DayZPlayerConstants.STANCEMASK_CROUCH;
33 m_Text = "#repair";
34 }
35
41
42 override bool IsUsingProxies()
43 {
44 return true;
45 }
46
47 override bool HasTarget()
48 {
49 return true;
50 }
51
52 override bool ActionCondition( PlayerBase player, ActionTarget target, ItemBase item )
53 {
54 Object targetObject = target.GetObject();
55 Object targetParent = target.GetParent();
56 if ( !targetParent || !targetParent.IsInherited(TentBase) )
57 return false;
58
59 if ( player && targetObject && targetParent )
60 {
61 array<string> selections = new array<string>;
62 PluginRepairing module_repairing;
63 Class.CastTo(module_repairing, GetPlugin(PluginRepairing));
64 targetObject.GetActionComponentNameList(target.GetComponentIndex(), selections, "view");
65 TentBase tent = TentBase.Cast( targetParent );
66
67 string damageZone = "";
68
69 for (int s = 0; s < selections.Count(); s++)
70 {
71 if ( DamageSystem.GetDamageZoneFromComponentName(tent, selections[s], damageZone) ) //NOTE: relevant fire geometry and view geometry selection names MUST match in order to get a valid damage zone
72 {
73 break;
74 }
75 }
76
77 if ( damageZone != "" )
78 {
79 if (module_repairing.CanRepair(item,tent,damageZone))
80 {
81 m_CurrentDamageZone = damageZone;
82 return true;
83 }
84 }
85 }
86 return false;
87 }
88
89 override void OnFinishProgressServer( ActionData action_data )
90 {
91 Object targetObject = action_data.m_Target.GetObject();
92 Object targetParent = action_data.m_Target.GetParent();
93
94 string damageZone = RepairTentActionData.Cast(action_data).m_DamageZone;
95 if (!g_Game.IsMultiplayer())
96 damageZone = m_CurrentDamageZone;
97
98 if ( targetParent && targetParent.IsInherited(TentBase) && damageZone != "" )
99 {
100 TentBase tent = TentBase.Cast( targetParent );
101 PluginRepairing module_repairing;
102 Class.CastTo(module_repairing, GetPlugin(PluginRepairing));
103
104 RepairDamageTransfer(action_data.m_Player,action_data.m_MainItem,tent,m_SpecialtyWeight,damageZone);
105 module_repairing.Repair(action_data.m_Player,action_data.m_MainItem,tent,m_SpecialtyWeight,damageZone);
106 }
107 }
108
110 {
111 RepairTentActionData action_data = new RepairTentActionData;
112 return action_data;
113 }
114
115 override void WriteToContext(ParamsWriteContext ctx, ActionData action_data)
116 {
117 super.WriteToContext(ctx, action_data);
118 RepairTentActionData repair_action_data;
119
120 if( HasTarget() && Class.CastTo(repair_action_data,action_data) )
121 {
122 repair_action_data.m_DamageZone = m_CurrentDamageZone;
123 ctx.Write(repair_action_data.m_DamageZone);
124 }
125 }
126
127 override bool ReadFromContext(ParamsReadContext ctx, out ActionReciveData action_recive_data )
128 {
129 if(!action_recive_data)
130 {
131 action_recive_data = new RepairTentActionReciveData;
132 }
133 super.ReadFromContext(ctx, action_recive_data);
134 RepairTentActionReciveData recive_data_repair = RepairTentActionReciveData.Cast(action_recive_data);
135
136 if( HasTarget() )
137 {
138 string zone;
139 if ( !ctx.Read(zone) )
140 return false;
141
142 recive_data_repair.m_DamageZoneRecived = zone;
143 }
144 return true;
145 }
146
147 override void HandleReciveData(ActionReciveData action_recive_data, ActionData action_data)
148 {
149 super.HandleReciveData(action_recive_data, action_data);
150
151 RepairTentActionReciveData recive_data_repair = RepairTentActionReciveData.Cast(action_recive_data);
152 RepairTentActionData.Cast(action_data).m_DamageZone = recive_data_repair.m_DamageZoneRecived;
153 }
154
155 void RepairDamageTransfer(PlayerBase player, ItemBase repair_kit, ItemBase item, float specialty_weight, string damage_zone = "") //hack; mirrors current config setup, replace with either native DamageSystem methods, or script-side DamageSystem systemic solution
156 {
157 float transfer_to_global_coef = 0;
158 array<string> transfer_zones = new array<string>;
159 string path = "" + CFG_VEHICLESPATH + " " + item.GetType() + " DamageSystem DamageZones " + damage_zone;
160 PluginRepairing module_repairing;
161 Class.CastTo(module_repairing, GetPlugin(PluginRepairing));
162
163 g_Game.ConfigGetTextArray("" + path + " transferToZonesNames", transfer_zones);
164
165 for (int i = 0; i < transfer_zones.Count(); i++)
166 {
167 transfer_to_global_coef += g_Game.ConfigGetFloat("" + path + " Health transferToGlobalCoef");
168 if (transfer_zones.Get(i) == damage_zone)
169 continue;
170
171 module_repairing.Repair(player,repair_kit,item,specialty_weight,transfer_zones.Get(i),false);
172 }
173
174 //finally, repairs global
175 if (transfer_to_global_coef > 0)
176 {
177 module_repairing.Repair(player,repair_kit,item,specialty_weight,"",false);
178 }
179 }
180};
bool m_FullBody
Определения ActionBase.c:60
string m_Text
Определения ActionBase.c:57
ref CCIBase m_ConditionItem
Определения ActionBase.c:63
float m_SpecialtyWeight
Определения ActionBase.c:77
ref CCTBase m_ConditionTarget
Определения ActionBase.c:64
int m_StanceMask
Определения ActionBase.c:61
RepairTentActionReciveData m_DamageZone
void ActionTarget(Object object, Object parent, int componentIndex, vector cursorHitPos, float utility, string surfaceName="")
Определения ActionTargets.c:125
DayZGame g_Game
Определения DayZGame.c:4074
string path
Определения OptionSelectorMultistate.c:142
PluginBase GetPlugin(typename plugin_type)
Определения PluginManager.c:326
ActionData m_ActionData
Определения AnimatedActionBase.c:3
void ActionContinuousBase()
Определения ActionContinuousBase.c:124
PlayerBase m_Player
Определения ActionBase.c:40
ref ActionTarget m_Target
Определения ActionBase.c:39
ItemBase m_MainItem
Определения ActionBase.c:35
Определения ActionBase.c:22
override void OnFinishProgressServer(ActionData action_data)
Определения ActionRepairTent.c:89
override void WriteToContext(ParamsWriteContext ctx, ActionData action_data)
Определения ActionRepairTent.c:115
override ActionData CreateActionData()
Определения ActionRepairTent.c:109
override void CreateConditionComponents()
Определения ActionRepairTent.c:36
void RepairDamageTransfer(PlayerBase player, ItemBase repair_kit, ItemBase item, float specialty_weight, string damage_zone="")
Определения ActionRepairTent.c:155
override bool ReadFromContext(ParamsReadContext ctx, out ActionReciveData action_recive_data)
Определения ActionRepairTent.c:127
string m_CurrentDamageZone
Определения ActionRepairTent.c:22
int m_LastValidComponentIndex
Определения ActionRepairTent.c:23
override bool HasTarget()
Определения ActionRepairTent.c:47
void ActionRepairTent()
Определения ActionRepairTent.c:25
m_LastValidType
Определения ActionRepairTent.c:21
override bool IsUsingProxies()
Определения ActionRepairTent.c:42
override void HandleReciveData(ActionReciveData action_recive_data, ActionData action_data)
Определения ActionRepairTent.c:147
override bool ActionCondition(PlayerBase player, ActionTarget target, ItemBase item)
Определения ActionRepairTent.c:52
override void CreateActionComponent()
Определения ActionRepairTent.c:13
int m_CommandUID
Определения AnimatedActionBase.c:147
Определения CCINonRuined.c:2
Определения CCTCursorParent.c:2
Super root of all classes in Enforce script.
Определения EnScript.c:11
Определения ObjectTyped.c:2
Определения PlayerBaseClient.c:2
string m_DamageZoneRecived
Определения ActionRepairTent.c:3
proto bool Write(void value_out)
proto bool Read(void value_in)
Определения CarTent.c:2
const float SMALL
Определения ActionConstants.c:113
const float BASEBUILDING_REPAIR_FAST
Определения ActionConstants.c:67
Определения ActionConstants.c:28
Result for an object found in CGame.IsBoxCollidingGeometryProxy.
DayZPlayerConstants
defined in C++
Определения dayzplayer.c:602
Serializer ParamsReadContext
Определения gameplay.c:15
Serializer ParamsWriteContext
Определения gameplay.c:16
static proto bool CastTo(out Class to, Class from)
Try to safely down-cast base class to child class.
const string CFG_VEHICLESPATH
Определения 3_Game/DayZ/constants.c:228