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

base class for transformation operations (creating one item from another) Подробнее...

+ Граф наследования:ReplaceItemWithNewLambdaBase:

Защищенные члены

bool WantCreateNewEntity ()
 
bool CanExecuteLambda ()
 
bool PrepareLocations ()
 Step A. - prepare inventory locations.
 
void RemoveOldItemFromLocation ()
 Step B. - free location for new item @NOTE this operation does not delete the object, only removes it from inventory location.
 
void UndoRemoveOldItemFromLocation ()
 
void RemoveNetworkObjectInfo ()
 Step C. - remove network part of the object @NOTE this operation does not delete the object, only removes its network part (and deletes it on client)
 
void UndoRemoveNetworkObjectInfo ()
 
EntityAI CreateNewEntity ()
 Step D. - create new entity (LOCAL) with specified type.
 
void CopyOldPropertiesToNew (notnull EntityAI old_item, EntityAI new_item)
 Step E. copy properties from old object to the created one.
 
void DeleteOldEntity ()
 Step F. - deletes physically old item.
 
void CreateNetworkObjectInfo (EntityAI new_item)
 Step G. - create NetworkObjectInfo for new item.
 
void OnSuccess (EntityAI new_item)
 Step H. - notification on finish.
 
void OnAbort ()
 Step Out - notification on abort.
 
void Execute (HumanInventoryWithFSM fsm_to_notify=null)
 
string DumpToString ()
 

Защищенные данные

ref InventoryLocation m_OldLocation
 
ref InventoryLocation m_NewLocation
 
bool m_RemoveFromLocationPassed = false
 

Закрытые члены

void ReplaceItemWithNewLambdaBase (EntityAI old_item, string new_item_type)
 
void OverrideNewLocation (InventoryLocation newLocation)
 
void VerifyItemTypeBySlotType ()
 

Закрытые данные

EntityAI m_OldItem
 
string m_NewItemType
 
bool m_RemoveNetworkObjectInfoPassed = false
 

Подробное описание

base class for transformation operations (creating one item from another)

Конструктор(ы)

◆ ReplaceItemWithNewLambdaBase()

void ReplaceItemWithNewLambdaBase ( EntityAI old_item,
string new_item_type )
inlineprivate
14 {
17 }
Definition EntityAI.c:95
string m_NewItemType
Definition ReplaceItemWithNewLambdaBase.c:7
EntityAI m_OldItem
Definition ReplaceItemWithNewLambdaBase.c:6

Перекрестные ссылки m_NewItemType и m_OldItem.

Методы

◆ CanExecuteLambda()

bool CanExecuteLambda ( )
inlineprotected
32 {
33 if (m_OldItem)
35 //if (WantCreateNewEntity() GameInventory.LocationTestAddEntityType(m_NewItemType, true, true, false, true))
36 return true;
37 return false;
38 }
script counterpart to engine's class Inventory
Definition Inventory.c:79
static proto native bool LocationCanRemoveEntity(notnull InventoryLocation inv_loc)
queries if the entity contained in inv_loc.m_item can be removed from ground/attachment/cargo/hands/....
ref InventoryLocation m_OldLocation
Definition ReplaceItemWithNewLambdaBase.c:8

Перекрестные ссылки GameInventory::LocationCanRemoveEntity(), m_OldItem и m_OldLocation.

Используется в Execute().

◆ CopyOldPropertiesToNew()

CopyOldPropertiesToNew ( notnull EntityAI old_item,
EntityAI new_item )
inlineprotected

Step E. copy properties from old object to the created one.

@NOTE: This is supposed to be overriden in derived classes

186 {
187 if (LogManager.IsInventoryHFSMLogEnable()) hndDebugPrint("[inv] ReplaceItemWithNewLambdaBase Step E) Copying props " + old_item + " --> " + new_item);
188 }
void hndDebugPrint(string s)
Definition HandFSM.c:1
Definition Debug.c:600
static bool IsInventoryHFSMLogEnable()
Definition Debug.c:674

Перекрестные ссылки hndDebugPrint() и LogManager::IsInventoryHFSMLogEnable().

Используется в Execute().

◆ CreateNetworkObjectInfo()

CreateNetworkObjectInfo ( EntityAI new_item)
inlineprotected

Step G. - create NetworkObjectInfo for new item.

@NOTE: new_item can be null if the lambda did not create any item (intentionaly)

205 {
206 if (LogManager.IsInventoryHFSMLogEnable()) hndDebugPrint("[inv] ReplaceItemWithNewLambdaBase Step G) CreateNetworkObjectInfo =" + new_item);
207 if (new_item)
208 GetGame().RemoteObjectTreeCreate(new_item); // G) this forces server to send CreateVehicle Message to client. This is needed for preserving the appearance of network operations on client (so that DeleteObject(old) arrives before CreateVehicle(new)). @NOTE: this does not delete the object on server, only it's network representation.
209 }
proto native CGame GetGame()

Перекрестные ссылки GetGame(), hndDebugPrint() и LogManager::IsInventoryHFSMLogEnable().

Используется в Execute().

◆ CreateNewEntity()

CreateNewEntity ( )
inlineprotected

Step D. - create new entity (LOCAL) with specified type.

@NOTE: if (!m_NewLocation || m_NewItemType.Empty) ==> this function does not create a new entity

124 {
126 {
129
130 switch (m_NewLocation.GetType())
131 {
132 case InventoryLocationType.GROUND:
134 string path = "" + CFG_VEHICLESPATH + " " + m_NewItemType + " inherit_rotation";
135 bool keep_rotation = GetGame().ConfigIsExisting(path) && GetGame().ConfigGetInt(path) > 0;
136 if (keep_rotation)
137 {
138 new_item.SetOrientation(m_OldItem.GetOrientation()); //this one actually works...debug InventoryLocation
139 }
140 break;
141 case InventoryLocationType.ATTACHMENT:
142 // forces rawlocation in C++ to make location Valid
143 m_NewLocation.SetAttachment(m_NewLocation.GetParent(), null, m_NewLocation.GetSlot());
145 break;
146 default:
148 break;
149 }
150
151 if (LogManager.IsInventoryHFSMLogEnable()) hndDebugPrint("[inv] ReplaceItemWithNewLambdaBase Step D) Created new new_item=" + new_item);
152 if (new_item)
153 {
154 return new_item;
155 }
156 else
157 {
158 return null;
159
160 /*InventoryLocation backupLocation = new InventoryLocation;
161 vector mtx[4];
162 Math3D.MatrixIdentity4(mtx);
163 mtx[3] = m_OldItem.GetPosition();
164 backupLocation.SetGround(null, mtx);
165 if (LogManager.IsInventoryHFSMLogEnable()) hndDebugPrint("[inv] ReplaceItemWithNewLambdaBase Step D) plan B - creating=" + m_NewItemType + " at bkp loc=" + backupLocation.DumpToString() + ", but failed");
166 new_item = GameInventory.LocationCreateLocalEntity(backupLocation, m_NewItemType,ECE_OBJECT_SWAP,RF_NONE); // create LOCAL new one on ground
167 if (!new_item)
168 {
169 Error("[inv] ReplaceItemWithNewLambdaBase Step D) plan B - wanted to create=" + m_NewItemType + " at bkp loc=" + backupLocation.DumpToString() + ", but failed");
170 return null;
171 }
172 return new_item;*/
173 }
174 }
175
176 // user did not asked for new entity
177 return null;
178 }
const int RF_NONE
Definition CentralEconomy.c:45
const int ECE_OBJECT_SWAP
Definition CentralEconomy.c:38
const int ECE_LOCAL
Definition CentralEconomy.c:24
const int ECE_PLACE_ON_SURFACE
Definition CentralEconomy.c:37
InventoryLocationType
types of Inventory Location
Definition InventoryLocation.c:4
string path
Definition OptionSelectorMultistate.c:142
Definition Building.c:6
static proto native EntityAI LocationCreateEntity(notnull InventoryLocation inv_loc, string type, int iSetupFlags, int iRotation)
creates new item directly at location
static proto native EntityAI LocationCreateLocalEntity(notnull InventoryLocation inv_loc, string type, int iSetupFlags, int iRotation)
creates new local item directly at location @NOTE: the item is created localy, i.e....
void VerifyItemTypeBySlotType()
Definition ReplaceItemWithNewLambdaBase.c:24
bool WantCreateNewEntity()
Definition ReplaceItemWithNewLambdaBase.c:26
ref InventoryLocation m_NewLocation
Definition ReplaceItemWithNewLambdaBase.c:9
const string CFG_VEHICLESPATH
Definition constants.c:217

Перекрестные ссылки CFG_VEHICLESPATH, ECE_LOCAL, ECE_OBJECT_SWAP, ECE_PLACE_ON_SURFACE, GetGame(), hndDebugPrint(), LogManager::IsInventoryHFSMLogEnable(), GameInventory::LocationCreateEntity(), GameInventory::LocationCreateLocalEntity(), m_NewItemType, m_NewLocation, m_OldItem, path, RF_NONE, VerifyItemTypeBySlotType() и WantCreateNewEntity().

Используется в Execute().

◆ DeleteOldEntity()

DeleteOldEntity ( )
inlineprotected

Step F. - deletes physically old item.

194 {
195 if (LogManager.IsInventoryHFSMLogEnable()) hndDebugPrint("[inv] ReplaceItemWithNewLambdaBase Step F) delete old item=" + m_OldItem);
196 m_OldItem.DeleteSafe();
197 }

Перекрестные ссылки hndDebugPrint(), LogManager::IsInventoryHFSMLogEnable() и m_OldItem.

Используется в Execute().

◆ DumpToString()

string DumpToString ( )
inlineprotected
299 {
300 string s = "{ old=" + m_OldItem + " newType=" + m_NewItemType + "}";
301 return s;
302 }

Перекрестные ссылки m_NewItemType и m_OldItem.

◆ Execute()

void Execute ( HumanInventoryWithFSM fsm_to_notify = null)
inlineprotected
232 {
233 int t = GetGame().GetTime();
234 if (LogManager.IsInventoryHFSMLogEnable()) hndDebugPrint("[syncinv] t=" + t + " lambda.Execute start ");
235
236 // A) init
237 bool prepared = PrepareLocations();
238
239 if (prepared && CanExecuteLambda())
240 {
241 // B) rm old (and delete on client)
244 {
245 Error("[inv] ReplaceItemWithNewLambdaBase Step B) ABORT - failed while rm old item from loc=" + InventoryLocation.DumpToStringNullSafe(m_OldLocation));
246
247 if (fsm_to_notify)
248 fsm_to_notify.ProcessHandAbortEvent(new HandEventHumanCommandActionAborted(fsm_to_notify.GetManOwner()));
249 OnAbort();
250 return;
251 }
252
253 // C) rm NetworkObjectInfo from old item (+ send delete object tree to clients)
255
256 // D) mk new in place of old
259 {
260 //Error("[inv] ReplaceItemWithNewLambdaBase Step D) ABORT - wanted to create=" + m_NewItemType + " at loc=" + m_NewLocation.DumpToString() + ", but failed");
261 Print("Error [inv] ReplaceItemWithNewLambdaBase Step D) ABORT - wanted to create=" + m_NewItemType + " at loc=" + InventoryLocation.DumpToStringNullSafe(m_NewLocation) + ", but failed");
266
267 OnAbort();
268 if (fsm_to_notify)
269 fsm_to_notify.ProcessHandAbortEvent(new HandEventHumanCommandActionAborted(fsm_to_notify.GetManOwner()));
270 return;
271 }
272
273 // E) cpy props
275
276 // F) del old
278
279 // G) mk new NetworkObjectInfo
281
282 // H) notification
284 }
285 else
286 {
287 Print("[syncinv] warning, lambda cannot be executed, skipping!");
288 if (fsm_to_notify)
289 fsm_to_notify.ProcessHandAbortEvent(new HandEventHumanCommandActionAborted(fsm_to_notify.GetManOwner()));
290 OnAbort();
291 return;
292 }
293 int te = GetGame().GetTime();
294 int dt = te - t;
295 if (LogManager.IsInventoryHFSMLogEnable()) hndDebugPrint("[syncinv] te=" + te + " lambda.Execute end, exec time=" + dt);
296 }
InventoryLocation.
Definition InventoryLocation.c:29
static string DumpToStringNullSafe(InventoryLocation loc)
Definition InventoryLocation.c:226
void DeleteOldEntity()
Step F. - deletes physically old item.
Definition ReplaceItemWithNewLambdaBase.c:193
void RemoveNetworkObjectInfo()
Step C. - remove network part of the object @NOTE this operation does not delete the object,...
Definition ReplaceItemWithNewLambdaBase.c:107
void CreateNetworkObjectInfo(EntityAI new_item)
Step G. - create NetworkObjectInfo for new item.
Definition ReplaceItemWithNewLambdaBase.c:204
void OnSuccess(EntityAI new_item)
Step H. - notification on finish.
Definition ReplaceItemWithNewLambdaBase.c:216
void UndoRemoveNetworkObjectInfo()
Definition ReplaceItemWithNewLambdaBase.c:113
bool PrepareLocations()
Step A. - prepare inventory locations.
Definition ReplaceItemWithNewLambdaBase.c:43
EntityAI CreateNewEntity()
Step D. - create new entity (LOCAL) with specified type.
Definition ReplaceItemWithNewLambdaBase.c:123
void CopyOldPropertiesToNew(notnull EntityAI old_item, EntityAI new_item)
Step E. copy properties from old object to the created one.
Definition ReplaceItemWithNewLambdaBase.c:185
bool m_RemoveFromLocationPassed
Definition ReplaceItemWithNewLambdaBase.c:10
bool m_RemoveNetworkObjectInfoPassed
Definition ReplaceItemWithNewLambdaBase.c:11
void UndoRemoveOldItemFromLocation()
Definition ReplaceItemWithNewLambdaBase.c:96
bool CanExecuteLambda()
Definition ReplaceItemWithNewLambdaBase.c:31
void OnAbort()
Step Out - notification on abort.
Definition ReplaceItemWithNewLambdaBase.c:226
void RemoveOldItemFromLocation()
Step B. - free location for new item @NOTE this operation does not delete the object,...
Definition ReplaceItemWithNewLambdaBase.c:86
void Error(string err)
Messagebox with error message.
Definition EnDebug.c:90
proto void Print(void var)
Prints content of variable to console/log.

Перекрестные ссылки CanExecuteLambda(), CopyOldPropertiesToNew(), CreateNetworkObjectInfo(), CreateNewEntity(), DeleteOldEntity(), InventoryLocation::DumpToStringNullSafe(), Error(), GetGame(), hndDebugPrint(), LogManager::IsInventoryHFSMLogEnable(), m_NewItemType, m_NewLocation, m_OldItem, m_OldLocation, m_RemoveFromLocationPassed, m_RemoveNetworkObjectInfoPassed, OnAbort(), OnSuccess(), PrepareLocations(), Print(), RemoveNetworkObjectInfo(), RemoveOldItemFromLocation(), UndoRemoveNetworkObjectInfo(), UndoRemoveOldItemFromLocation() и WantCreateNewEntity().

◆ OnAbort()

OnAbort ( )
inlineprotected

Step Out - notification on abort.

@NOTE: new_item can be null if the lambda did not create any item (intentionaly)

227 {
228 Print("Error [inv] ReplaceItemWithNewLambdaBase OnAbort");
229 }

Перекрестные ссылки Print().

Используется в Execute().

◆ OnSuccess()

OnSuccess ( EntityAI new_item)
inlineprotected

Step H. - notification on finish.

@NOTE: new_item can be null if the lambda did not create any item (intentionaly)

217 {
218 if (LogManager.IsInventoryHFSMLogEnable()) hndDebugPrint("[inv] ReplaceItemWithNewLambdaBase Step H) OnSuccess=" + new_item);
219 }

Перекрестные ссылки hndDebugPrint() и LogManager::IsInventoryHFSMLogEnable().

Используется в Execute().

◆ OverrideNewLocation()

void OverrideNewLocation ( InventoryLocation newLocation)
inlineprivate
20 {
22 }

Перекрестные ссылки m_NewLocation.

◆ PrepareLocations()

PrepareLocations ( )
inlineprotected

Step A. - prepare inventory locations.

44 {
45 if (LogManager.IsInventoryHFSMLogEnable()) hndDebugPrint("[inv] ReplaceItemWithNewLambdaBase Step A) Prepare inventory locations, old_item=" + m_OldItem);
47 if (m_OldItem.GetInventory().GetCurrentInventoryLocation(m_OldLocation)) // A.1) store old location
48 {
49 if (m_NewLocation == null)
50 {
52 m_NewLocation.CopyLocationFrom(m_OldLocation, true); // A.2) prepare new location from old
53
54 //setting proper location type for ground pos
55 if (!m_NewLocation.GetParent())
56 {
57 vector m4[4];
59 m4[3] = m_NewLocation.GetPos();
60 string path = "" + CFG_VEHICLESPATH + " " + m_NewItemType + " inherit_rotation";
61 bool keep_rotation = GetGame().ConfigIsExisting(path) && GetGame().ConfigGetInt(path) > 0;
62
63 if (m_OldLocation.GetType() == InventoryLocationType.GROUND && keep_rotation)
64 {
65 float dir[4];
66 m_OldLocation.GetDir(dir);
67 m_NewLocation.SetGroundEx(null,m_NewLocation.GetPos(),dir);
68 }
69 else
70 {
71 m_NewLocation.SetGround(null,m4);
72 }
73 }
74 }
75 return true;
76 }
77 else
78 Error("[inv] ReplaceItemWithNewLambdaBase Step A.1) failed to get old_item inventory location");
79 return false;
80 }
Definition EnMath3D.c:28
Definition EnConvert.c:106
static void MatrixIdentity4(out vector mat[4])
Creates identity matrix.
Definition EnMath3D.c:256

Перекрестные ссылки CFG_VEHICLESPATH, Error(), GetGame(), hndDebugPrint(), LogManager::IsInventoryHFSMLogEnable(), m_NewItemType, m_NewLocation, m_OldItem, m_OldLocation, Math3D::MatrixIdentity4() и path.

Используется в Execute().

◆ RemoveNetworkObjectInfo()

RemoveNetworkObjectInfo ( )
inlineprotected

Step C. - remove network part of the object @NOTE this operation does not delete the object, only removes its network part (and deletes it on client)

108 {
109 GetGame().RemoteObjectTreeDelete(m_OldItem); // C) this forces server to send DeleteObject Message to client. This is needed for preserving the appearance of network operations on client (so that DeleteObject(old) arrives before CreateVehicle(new)). @NOTE: this does not delete the object on server, only it's network representation.
110 // @NOTE: the item is not deleted right now on server, but rather after copying the properties in Step E)
112 }

Перекрестные ссылки GetGame(), m_OldItem и m_RemoveNetworkObjectInfoPassed.

Используется в Execute().

◆ RemoveOldItemFromLocation()

RemoveOldItemFromLocation ( )
inlineprotected

Step B. - free location for new item @NOTE this operation does not delete the object, only removes it from inventory location.

87 {
88 if (!GameInventory.LocationRemoveEntity(m_OldLocation)) // B) remove entity from old inventory location (making it free for new item)
89 {
90 Error("[inv] ReplaceItemWithNewLambdaBase Step B) failed to remove old_item rom current inventory location");
92 }
93 Print("[inv] ReplaceItemWithNewLambdaBase Step B) remove OK, loc=" + InventoryLocation.DumpToStringNullSafe(m_OldLocation));
95 }
static proto native bool LocationRemoveEntity(notnull InventoryLocation inv_loc)
removes item from inventory location

Перекрестные ссылки InventoryLocation::DumpToStringNullSafe(), Error(), GameInventory::LocationRemoveEntity(), m_OldLocation, m_RemoveFromLocationPassed и Print().

Используется в Execute().

◆ UndoRemoveNetworkObjectInfo()

void UndoRemoveNetworkObjectInfo ( )
inlineprotected
114 {
115 GetGame().RemoteObjectTreeCreate(m_OldItem);
116 }

Перекрестные ссылки GetGame() и m_OldItem.

Используется в Execute().

◆ UndoRemoveOldItemFromLocation()

void UndoRemoveOldItemFromLocation ( )
inlineprotected
97 {
99 Error("[inv] ReplaceItemWithNewLambdaBase Step B) failed to undo remove");
100 Print("[inv] ReplaceItemWithNewLambdaBase Step B) undo remove OK, loc=" + InventoryLocation.DumpToStringNullSafe(m_OldLocation));
101 }
static proto native bool LocationAddEntity(notnull InventoryLocation inv_loc)
adds item to inventory location

Перекрестные ссылки InventoryLocation::DumpToStringNullSafe(), Error(), GameInventory::LocationAddEntity(), m_OldLocation и Print().

Используется в Execute().

◆ VerifyItemTypeBySlotType()

void VerifyItemTypeBySlotType ( )
inlineprivate
24{}

Используется в CreateNewEntity().

◆ WantCreateNewEntity()

bool WantCreateNewEntity ( )
inlineprotected
27 {
28 return m_NewLocation && m_NewItemType != string.Empty;
29 }
static const string Empty
Definition EnString.c:7

Перекрестные ссылки string::Empty, m_NewItemType и m_NewLocation.

Используется в CreateNewEntity() и Execute().

Поля

◆ m_NewItemType

◆ m_NewLocation

◆ m_OldItem

◆ m_OldLocation

◆ m_RemoveFromLocationPassed

bool m_RemoveFromLocationPassed = false
protected

Используется в Execute() и RemoveOldItemFromLocation().

◆ m_RemoveNetworkObjectInfoPassed

bool m_RemoveNetworkObjectInfoPassed = false
private

Используется в Execute() и RemoveNetworkObjectInfo().


Объявления и описания членов класса находятся в файле: