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

◆ OnDrawOptics2D()

override array< InventoryItem > DayZPlayer::OnDrawOptics2D ( )
inlineprotected

Called when 2D optics are about to be drawn.

Возвращает
Collection of optics to be drawn. Draws the provided optics when of ItemOptics type. Draws optic of current muzzle when of Weapon_Base type.

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

4031 {
4032 array<InventoryItem> optics;
4033
4034 // Find preferred optics, i.e. active on in hands (if any are held) or the ones attached to weapon (if any is held)
4035 ItemOptics preferredOptics;
4036 {
4037 HumanInventory inventory = GetHumanInventory();
4038 EntityAI itemInHands = inventory.GetEntityInHands();
4039
4040 ItemOptics opticsInHands = ItemOptics.Cast(itemInHands);
4041 if (opticsInHands)
4042 {
4043 preferredOptics = opticsInHands;
4044 }
4045 else
4046 {
4047 Weapon_Base weaponInHands = Weapon_Base.Cast(itemInHands);
4048 if (weaponInHands)
4049 {
4050 preferredOptics = weaponInHands.GetAttachedOptics();
4051 }
4052 }
4053 }
4054
4055 // Draw selected optics when the player is viewing through them
4056 if (preferredOptics && preferredOptics.IsInOptics() && preferredOptics.IsUsingOptics2DModel())
4057 {
4058 optics = {}; // only allocate the array when necessary
4059 optics.Insert(preferredOptics);
4060 }
4061
4062 // Draw equipped NVGs
4063 CachedEquipmentStorageQuery query = new CachedEquipmentStorageQuery();
4064
4066 query.m_Placement = ECachedEquipmentPlacement.ATTACHMENT;
4067 query.m_ParentPlacement = {InventorySlots.HEADGEAR, InventorySlots.EYEWEAR};
4068
4069 array<Entity> nvgs = GetCachedEquipment().GetEntitiesByCategory(query);
4070
4071 EntityAI nvAttachment;
4072 foreach (Entity nvg : nvgs)
4073 {
4074 nvAttachment = EntityAI.Cast(nvg);
4075 break;
4076 }
4077
4078 if (nvAttachment)
4079 {
4080 bool blockedByOptics = preferredOptics && preferredOptics.IsInOptics() && !preferredOptics.IsUsingOptics2DModel();
4081 if ((!blockedByOptics || preferredOptics.IsUsableWithNV()) && PlayerBase.Cast(this).IsNVGWorking())
4082 {
4083 NVGoggles goggles = NVGoggles.Cast(nvAttachment);
4084 if (goggles)
4085 {
4086 if (!optics)
4087 optics = {};
4088
4089 optics.Insert(goggles);
4090 }
4091 }
4092 }
4093
4094 return optics;
4095 }
class LogManager EntityAI
ECachedEquipmentItemCategory
Определения ECachedEquipmentItemCategory.c:2
ECachedEquipmentPlacement
Определения ECachedEquipmentPlacement.c:2
StarlightOptic ItemOptics
array< Entity > GetEntitiesByCategory(CachedEquipmentStorageQuery query)
List of entities matching the CachedEquipmentStorageQuery query.
Определения CachedEquipmentStorageBase.c:69
ECachedEquipmentItemCategory m_Category
Определения CachedEquipmentStorageBase.c:5
ref TIntArray m_ParentPlacement
Определения CachedEquipmentStorageBase.c:4
ECachedEquipmentPlacement m_Placement
Определения CachedEquipmentStorageBase.c:6
override CachedEquipmentStorage GetCachedEquipment()
Определения DayZPlayerImplement.c:463
proto native EntityAI GetEntityInHands()
bool IsUsingOptics2DModel()
Returns whether this ItemOptics uses the 2D optics model.
Определения ItemOptics.c:207
bool IsUsableWithNV()
Определения ItemOptics.c:218
proto native bool IsInOptics()
is weapon in optics mode or not

Перекрестные ссылки GetCachedEquipment(), HumanInventory::GetEntityInHands(), ItemOptics::IsInOptics(), ItemOptics::IsUsableWithNV(), ItemOptics::IsUsingOptics2DModel(), CachedEquipmentStorageQuery::m_Category, CachedEquipmentStorageQuery::m_ParentPlacement и CachedEquipmentStorageQuery::m_Placement.