DayZ 1.28
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 строка 3903

3904 {
3905 array<InventoryItem> optics;
3906
3907 // Find preferred optics, i.e. active on in hands (if any are held) or the ones attached to weapon (if any is held)
3908 ItemOptics preferredOptics;
3909 {
3910 HumanInventory inventory = GetHumanInventory();
3911 EntityAI itemInHands = inventory.GetEntityInHands();
3912
3913 ItemOptics opticsInHands = ItemOptics.Cast(itemInHands);
3914 if (opticsInHands)
3915 {
3916 preferredOptics = opticsInHands;
3917 }
3918 else
3919 {
3920 Weapon_Base weaponInHands = Weapon_Base.Cast(itemInHands);
3921 if (weaponInHands)
3922 {
3923 preferredOptics = weaponInHands.GetAttachedOptics();
3924 }
3925 }
3926 }
3927
3928 // Draw selected optics when the player is viewing through them
3929 if (preferredOptics && preferredOptics.IsInOptics() && preferredOptics.IsUsingOptics2DModel())
3930 {
3931 optics = {}; // only allocate the array when necessary
3932 optics.Insert(preferredOptics);
3933 }
3934
3935 // Draw equipped NVGs; employ better finding!
3936 EntityAI nvAttachment = GetNVEntityAttached();
3937 if (nvAttachment)
3938 {
3939 bool blockedByOptics = preferredOptics && preferredOptics.IsInOptics() && !preferredOptics.IsUsingOptics2DModel();
3940 if (!blockedByOptics && PlayerBase.Cast(this).IsNVGWorking())
3941 {
3942 NVGoggles nvg = NVGoggles.Cast(nvAttachment);
3943 if (nvg)
3944 {
3945 if (!optics)
3946 optics = {};
3947
3948 optics.Insert(nvg);
3949 }
3950 }
3951 }
3952
3953 return optics;
3954 }
class LogManager EntityAI
StarlightOptic ItemOptics
EntityAI GetNVEntityAttached()
Определения DayZPlayerImplement.c:3959
proto native EntityAI GetEntityInHands()
bool IsUsingOptics2DModel()
Returns whether this ItemOptics uses the 2D optics model.
Определения ItemOptics.c:207
proto native bool IsInOptics()
is weapon in optics mode or not

Перекрестные ссылки HumanInventory::GetEntityInHands(), GetNVEntityAttached(), ItemOptics::IsInOptics() и ItemOptics::IsUsingOptics2DModel().