DayZ 1.29
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 строка 3886

3887 {
3888 array<InventoryItem> optics;
3889
3890 // Find preferred optics, i.e. active on in hands (if any are held) or the ones attached to weapon (if any is held)
3891 ItemOptics preferredOptics;
3892 {
3893 HumanInventory inventory = GetHumanInventory();
3894 EntityAI itemInHands = inventory.GetEntityInHands();
3895
3896 ItemOptics opticsInHands = ItemOptics.Cast(itemInHands);
3897 if (opticsInHands)
3898 {
3899 preferredOptics = opticsInHands;
3900 }
3901 else
3902 {
3903 Weapon_Base weaponInHands = Weapon_Base.Cast(itemInHands);
3904 if (weaponInHands)
3905 {
3906 preferredOptics = weaponInHands.GetAttachedOptics();
3907 }
3908 }
3909 }
3910
3911 // Draw selected optics when the player is viewing through them
3912 if (preferredOptics && preferredOptics.IsInOptics() && preferredOptics.IsUsingOptics2DModel())
3913 {
3914 optics = {}; // only allocate the array when necessary
3915 optics.Insert(preferredOptics);
3916 }
3917
3918 // Draw equipped NVGs
3919 EntityAI nvAttachment;
3920 CachedEquipmentStorageQuery query = new CachedEquipmentStorageQuery();
3922 query.m_Placement = ECachedEquipmentPlacement.ATTACHMENT;
3923 array<Entity> nvgs = GetCachedEquipment().GetEntitiesByCategory(query);
3924 foreach (Entity nvg : nvgs)
3925 {
3926 nvAttachment = EntityAI.Cast(nvg);
3927 break;
3928 }
3929
3930 if (nvAttachment)
3931 {
3932 bool blockedByOptics = preferredOptics && preferredOptics.IsInOptics() && !preferredOptics.IsUsingOptics2DModel();
3933 if ((!blockedByOptics || preferredOptics.IsUsableWithNV()) && PlayerBase.Cast(this).IsNVGWorking())
3934 {
3935 NVGoggles goggles = NVGoggles.Cast(nvAttachment);
3936 if (goggles)
3937 {
3938 if (!optics)
3939 optics = {};
3940
3941 optics.Insert(goggles);
3942 }
3943 }
3944 }
3945
3946 return optics;
3947 }
class LogManager EntityAI
ECachedEquipmentItemCategory
Определения ECachedEquipmentItemCategory.c:2
ECachedEquipmentPlacement
Определения ECachedEquipmentPlacement.c:2
StarlightOptic ItemOptics
ECachedEquipmentItemCategory m_Category
Определения CachedEquipmentStorageBase.c:4
ECachedEquipmentPlacement m_Placement
Определения CachedEquipmentStorageBase.c:5
override CachedEquipmentStorage GetCachedEquipment()
Определения DayZPlayerImplement.c:460
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_Placement.