DayZ 1.30
DayZ Explorer by KGB
 
Загрузка...
Поиск...
Не найдено
ActionRepairPart.c
См. документацию.
1
2/*
3TODO:
4No pairing with part and tool similar to 'CanUseToolToBuildPart' exists here, since only one type of part is damage-able at this point.
5This should be handled by adding "repair_action_type" array to basebuilding and tool configs, this would allow for independent pairing of repair action.
6*/
7
8class RepairPartActionReciveData : ActionReciveData
9{
10 int m_ComponentIndexRecived; //DEPRECATED, target is fully synced anyway
11}
12
13class RepairPartActionData : ActionData
14{
15 int m_ComponentIndex; //DEPRECATED, target is fully synced anyway
16}
17
19{
20 override void CreateActionComponent()
21 {
22 float time = SetCallbackDuration(m_ActionData.m_MainItem);
23 m_ActionData.m_ActionComponent = new CAContinuousRepeat( time );
24 }
25
27 {
28 /*switch( item.Type() )
29 {
30 case WoodAxe:
31 return UATimeSpent.BASEBUILDING_REPAIR_SLOW;
32 default:
33 return UATimeSpent.BASEBUILDING_REPAIR_FAST;
34 }*/
36 }
37};
38
40{
42 {
44 m_CommandUID = DayZPlayerConstants.CMD_ACTIONFB_ASSEMBLE;
45 m_FullBody = true;
46 m_StanceMask = DayZPlayerConstants.STANCEMASK_ERECT;
47
48 m_SpecialtyWeight = UASoftSkillsWeight.ROUGH_HIGH;
49 m_LockTargetOnUse = false;
50 m_Text = "#repair";
51 }
52
54 {
57 }
58
59 override void OnActionInfoUpdate( PlayerBase player, ActionTarget target, ItemBase item )
60 {
61 ConstructionActionData construction_action_data = player.GetConstructionActionData();
62 m_Text = "#repair " + construction_action_data.GetTargetPart().GetName();
63 }
64
65 override string GetText()
66 {
67 PlayerBase player = PlayerBase.Cast( g_Game.GetPlayer() );
68 if ( player )
69 {
70 ConstructionActionData construction_action_data = player.GetConstructionActionData();
71 ConstructionPart constrution_part = construction_action_data.GetTargetPart();
72
73 if ( constrution_part )
74 {
75 return "#repair" + " " + constrution_part.GetName();
76 }
77 }
78
79 return "";
80 }
81
82 override bool ActionCondition( PlayerBase player, ActionTarget target, ItemBase item )
83 {
84 //Action not allowed if player has broken legs
85 if (player.GetBrokenLegs() == eBrokenLegs.BROKEN_LEGS)
86 return false;
87
88 return RepairCondition( player, target, item, true );
89 }
90
91 override bool ActionConditionContinue( ActionData action_data )
92 {
93 return RepairCondition( action_data.m_Player, action_data.m_Target, action_data.m_MainItem , false );
94 }
95
96 override void OnFinishProgressServer( ActionData action_data )
97 {
98 EntityAI ent = EntityAI.Cast(action_data.m_Target.GetObject());
99 ConstructionBase construction = ConstructionBase.Cast(ent.GetConstructionBasic());
100 array<string> compNames = new array<string>();
101 ent.GetActionComponentNameList(action_data.m_Target.GetComponentIndex(), compNames);
102 string partName;
103 foreach (string testName : compNames)
104 {
105 if (construction.IsPartConstructed(testName))
106 {
107 partName = testName;
108 break;
109 }
110 }
111
112 if (partName == "")
113 {
114 ErrorEx("Invalid part name on component idx: " + action_data.m_Target.GetComponentIndex());
115 return;
116 }
117
118 string zoneName;
119 PluginRepairing moduleRrepairing = PluginRepairing.Cast(GetPlugin(PluginRepairing));
120 DamageSystem.GetDamageZoneFromComponentName(ent, partName, zoneName);
121 moduleRrepairing.Repair(action_data.m_Player, action_data.m_MainItem, ent,m_SpecialtyWeight, zoneName);
122
123 //consume materials
124 construction.TakeMaterialsServer(partName, true);
125
126 //add damage to tool
127 action_data.m_MainItem.DecreaseHealth(UADamageApplied.REPAIR, false);
128 }
129
130 protected override void SetBuildingAnimation( ItemBase item )
131 {
132 switch( item.Type() )
133 {
134 case Pickaxe:
135 case Shovel:
136 case FarmingHoe:
137 case FieldShovel:
138 m_CommandUID = DayZPlayerConstants.CMD_ACTIONFB_DIG;
139 break;
140 case Pliers:
141 m_CommandUID = DayZPlayerConstants.CMD_ACTIONFB_INTERACT;
142 break;
143 default:
144 m_CommandUID = DayZPlayerConstants.CMD_ACTIONFB_ASSEMBLE;
145 break;
146 }
147 }
148
150 {
151 RepairPartActionData action_data = new RepairPartActionData();
152 return action_data;
153 }
154
155 override void WriteToContext(ParamsWriteContext ctx, ActionData action_data)
156 {
157 super.WriteToContext(ctx, action_data);
158 RepairPartActionData repair_action_data;
159
160 if( HasTarget() && Class.CastTo(repair_action_data,action_data) )
161 {
162 repair_action_data.m_ComponentIndex = action_data.m_Target.GetComponentIndex();
163 ctx.Write(repair_action_data.m_ComponentIndex);
164 }
165 }
166
167 override bool ReadFromContext(ParamsReadContext ctx, out ActionReciveData action_recive_data )
168 {
169 if(!action_recive_data)
170 {
171 action_recive_data = new RepairPartActionReciveData();
172 }
173 RepairPartActionReciveData recive_data_repair = RepairPartActionReciveData.Cast(action_recive_data);
174
175 super.ReadFromContext(ctx, action_recive_data);
176
177 if( HasTarget() )
178 {
179 int component_index;
180 if ( !ctx.Read(component_index) )
181 return false;
182
183 recive_data_repair.m_ComponentIndexRecived = component_index;
184 }
185 return true;
186 }
187
188 override void HandleReciveData(ActionReciveData action_recive_data, ActionData action_data)
189 {
190 super.HandleReciveData(action_recive_data, action_data);
191
192 RepairPartActionReciveData recive_data_repair = RepairPartActionReciveData.Cast(action_recive_data);
193 RepairPartActionData.Cast(action_data).m_ComponentIndex = recive_data_repair.m_ComponentIndexRecived;
194 }
195
196 protected bool RepairCondition( PlayerBase player, ActionTarget target, ItemBase item, bool camera_check )
197 {
198 string zone_name;
199 EntityAI ent = EntityAI.Cast(target.GetObject());
200
201 if (ent && ent.CanUseConstruction())
202 {
203 ConstructionBase construction = ConstructionBase.Cast(ent.GetConstructionBasic());
204 array<string> compNames = new array<string>();
205 ent.GetActionComponentNameList(target.GetComponentIndex(), compNames);
206 foreach (string partName : compNames)
207 {
208 if (construction.IsPartConstructed(partName))
209 return construction.CanRepairPart(partName, item, player, camera_check);
210 }
211 }
212
213 return false;
214 }
215
216 override string GetAdminLogMessage(ActionData action_data)
217 {
218 return " repaired " + action_data.m_Target.GetObject().GetDisplayName() + " with " + action_data.m_MainItem.GetDisplayName();
219 }
220}
bool m_FullBody
Определения ActionBase.c:60
string m_Text
Определения ActionBase.c:57
bool HasTarget()
Определения ActionBase.c:259
bool m_LockTargetOnUse
Определения ActionBase.c:59
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
void ActionTarget(Object object, Object parent, int componentIndex, vector cursorHitPos, float utility, string surfaceName="")
Определения ActionTargets.c:125
void ConstructionBase(EntityAI parent)
Определения ConstructionBase.c:58
DayZGame g_Game
Определения DayZGame.c:4074
eBrokenLegs
Определения EBrokenLegs.c:2
int m_ComponentIndex
Определения ImpactEffects.c:14
PluginBase GetPlugin(typename plugin_type)
Определения PluginManager.c:326
ActionData m_ActionData
Определения AnimatedActionBase.c:3
PlayerBase m_Player
Определения ActionBase.c:40
ref ActionTarget m_Target
Определения ActionBase.c:39
ItemBase m_MainItem
Определения ActionBase.c:35
Определения ActionBase.c:22
void ActionDismantlePart()
Определения ActionDismantlePart.c:25
override void SetBuildingAnimation(ItemBase item)
Определения ActionRepairPart.c:130
override string GetText()
Определения ActionRepairPart.c:65
override void OnActionInfoUpdate(PlayerBase player, ActionTarget target, ItemBase item)
Определения ActionRepairPart.c:59
override bool ReadFromContext(ParamsReadContext ctx, out ActionReciveData action_recive_data)
Определения ActionRepairPart.c:167
override string GetAdminLogMessage(ActionData action_data)
Определения ActionRepairPart.c:216
override bool ActionCondition(PlayerBase player, ActionTarget target, ItemBase item)
Определения ActionRepairPart.c:82
override void WriteToContext(ParamsWriteContext ctx, ActionData action_data)
Определения ActionRepairPart.c:155
void ActionRepairPart()
Определения ActionRepairPart.c:41
override void HandleReciveData(ActionReciveData action_recive_data, ActionData action_data)
Определения ActionRepairPart.c:188
override void OnFinishProgressServer(ActionData action_data)
Определения ActionRepairPart.c:96
override ActionData CreateActionData()
Определения ActionRepairPart.c:149
override bool ActionConditionContinue(ActionData action_data)
Определения ActionRepairPart.c:91
bool RepairCondition(PlayerBase player, ActionTarget target, ItemBase item, bool camera_check)
Определения ActionRepairPart.c:196
override void CreateConditionComponents()
Определения ActionRepairPart.c:53
float SetCallbackDuration(ItemBase item)
Определения ActionRepairPart.c:26
override void CreateActionComponent()
Определения ActionRepairPart.c:20
int m_CommandUID
Определения AnimatedActionBase.c:147
Определения CCINonRuined.c:2
Определения CCTCursor.c:2
Super root of all classes in Enforce script.
Определения EnScript.c:11
ConstructionPart GetTargetPart()
Определения ConstructionActionData.c:126
string GetName()
Определения ConstructionPart.c:193
Instanced construction part data classes for dynamic data, statics now stored on EntityType level in ...
Определения ConstructionPart.c:4
Определения FarmingHoe.c:2
Определения PlayerBaseClient.c:2
int m_ComponentIndexRecived
Определения ActionRepairPart.c:10
proto bool Write(void value_out)
proto bool Read(void value_in)
const float REPAIR
Определения ActionConstants.c:153
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
enum ShapeType ErrorEx
static proto bool CastTo(out Class to, Class from)
Try to safely down-cast base class to child class.