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

◆ FindAndTranslateAttachmentSlot()

int ActionAttachToConstruction::FindAndTranslateAttachmentSlot ( PlayerBase player,
ActionTarget target,
ItemBase item )
inlineprotected

where appropriate, returns valid attachment slot ID even without proper selection

См. определение в файле ActionAttachToConstruction.c строка 115

116 {
117 int slotId = InventorySlots.INVALID;
118 int count;
119 Building building;
120 BaseBuildingBase baseBuilding;
121 ConstructionActionData constructionActionData = player.GetConstructionActionData();
122 InventoryLocation loc;
123 bool found;
124 EntityAI targetEntity = EntityAI.Cast(target.GetObject());
125 if (Class.CastTo(baseBuilding, targetEntity)) //BaseBuildingBase entities
126 {
127 if (item.IsExternalLockType()) // External lock handling of base building objects
128 {
129 loc = new InventoryLocation();
130 found = baseBuilding.GetInventory().FindFreeLocationFor(item, FindInventoryLocationType.ATTACHMENT, loc);
131 slotId = loc.GetSlot();
132 if (found && slotId != InventorySlots.INVALID)
133 {
134 return slotId;
135 }
136 }
137 else
138 {
139 string selection = baseBuilding.GetActionComponentName(target.GetComponentIndex());
140 slotId = constructionActionData.GetAttachmentSlotFromSelection(player, baseBuilding, item, selection);
141
142 if (slotId != InventorySlots.INVALID)
143 {
144 if (baseBuilding.CheckSlotVerticalDistance(slotId, player) && baseBuilding.IsPlayerInside(player,""))
145 {
146 return slotId;
147 }
148 }
149 }
150 }
151 else if (Class.CastTo(building, targetEntity) && building.CanUseConstruction()) // Building entities
152 {
153 if (item.IsExternalLockType()) // External lock handling of building objects with doors and lock attachments and internal locks
154 {
155 int doorIndex = building.GetDoorIndex(target.GetComponentIndex());
156 if (doorIndex > -1 && !building.IsDoorLocked(doorIndex) && !building.IsDoorOpen(doorIndex))
157 {
158 AdditionalDoorInfo doorInfo = building.GetDoorInfo(doorIndex);
159 if (!doorInfo || !doorInfo.m_RelatedInventorySlotNames)
160 return InventorySlots.INVALID;
161
162 foreach (string slotName: doorInfo.m_RelatedInventorySlotNames)
163 {
164 EntityAI slotEntity = building.FindAttachmentBySlotName(slotName);
165 if (slotEntity)
166 continue;
167
168 slotId = InventorySlots.GetSlotIdFromString(slotName);
169 GameInventory inventory = building.GetInventory();
170 if (inventory && inventory.CanAddAttachmentEx(item, slotId))
171 break;
172
173 slotId = InventorySlots.INVALID; //invalidate after unsuccessful check
174 }
175
176 if (slotId != InventorySlots.INVALID)
177 {
178 return slotId;
179 }
180 }
181 }
182 else //presumed material, that is only allowed on 'materials slot' selection. Using GUIInventoryAttachmentsProps structure
183 {
184 m_ComponentNames.Clear();
185 building.GetActionComponentNameList(target.GetComponentIndex(), m_ComponentNames, LOD.NAME_VIEW);
186 count = m_ComponentNames.Count();
187 if (count > 0)
188 {
189 foreach (string sel : m_ComponentNames)
190 {
191 slotId = constructionActionData.GetAttachmentSlotFromSelection(player, building, item, sel);
192 if (slotId != InventorySlots.INVALID)
193 return slotId;
194 }
195 }
196 }
197 }
198 else // Everything else
199 {
200 m_ComponentNames.Clear();
201 targetEntity.GetActionComponentNameList(target.GetComponentIndex(), m_ComponentNames, LOD.NAME_VIEW);
202 count = m_ComponentNames.Count();
203 if (count > 0)
204 {
205 foreach (string sel2 : m_ComponentNames)
206 {
207 slotId = constructionActionData.GetAttachmentSlotFromSelection(player, targetEntity, item, sel2);
208 if (slotId != InventorySlots.INVALID)
209 {
210 return slotId;
211 }
212 }
213 }
214 }
215
216 return InventorySlots.INVALID;
217 }
class LogManager EntityAI
void BaseBuildingBase()
Определения BaseBuildingBase.c:1326
PlayerSpawnPreset slotName
FindInventoryLocationType
flags for searching locations in inventory
Определения InventoryLocation.c:18
ref array< string > m_ComponentNames
Определения ActionAttachToConstruction.c:10
ref TStringArray m_RelatedInventorySlotNames
Lock compatibility type, now in door config. Lockpick enabled by default if undefined.
Определения AdditionalDoorsInfo.c:12
override bool IsPlayerInside(PlayerBase player, string selection)
Определения Fence.c:661
override bool CheckSlotVerticalDistance(int slot_id, PlayerBase player)
Определения Watchtower.c:300
AdditionalDoorInfo GetDoorInfo(int doorIdx)
proto native bool IsDoorLocked(int index)
When the door is locked.
proto native bool IsDoorOpen(int index)
When the door is requested to be fully open (animation wanted phase is greater than 0....
proto native int GetDoorIndex(int componentIndex)
Gets the index of the door based on the view geometry component index.
int GetAttachmentSlotFromSelection(PlayerBase player, EntityAI target, ItemBase item_to_attach, string selection)
Определения ConstructionActionData.c:469
proto native bool CanAddAttachmentEx(notnull EntityAI e, int slot)
Check if attachment can be added to slot @NOTE: Note that slot index IS NOT slot ID!...
proto native int GetSlot()
returns slot id if current type is Attachment

Перекрестные ссылки ActionTarget(), GameInventory::CanAddAttachmentEx(), Class::CastTo(), BaseBuildingBase::CheckSlotVerticalDistance(), ConstructionActionData::GetAttachmentSlotFromSelection(), Building::GetDoorIndex(), Building::GetDoorInfo(), InventoryLocation::GetSlot(), InventorySlots::GetSlotIdFromString(), InventorySlots::INVALID, Building::IsDoorLocked(), Building::IsDoorOpen(), BaseBuildingBase::IsPlayerInside(), m_ComponentNames, AdditionalDoorInfo::m_RelatedInventorySlotNames, LOD::NAME_VIEW и slotName.

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