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

◆ GetOnScreenPosition()

void ActionTargetsCursor::GetOnScreenPosition ( out float x,
out float y )
inlineprotected

kept for backward compatibility

Get memory LOD from p3d

save selection from memory lod

cache current object and the widget world pos

doors/handles

single vertex in selection

multiple vertices in selection

cache current object and the widget world pos

do not store component index for doors/handles

ladders handling

cache current object and the widget world pos

do not store component index for ladders

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

476 {
477 const float DEFAULT_HANDLE_OFFSET = 0.2;
478 const string CE_CENTER_COMP_NAME = "ce_center";
479 const string MEM_LOD_NAME = LOD.NAME_MEMORY;
480
481 int compIdx;
482 float pivotOffset = 0.0;
483 float memOffset = 0.0;
484 string compName;
485
486 bool isTargetForced = false;
487
488 vector worldPos;
489 vector modelPos;
490
491 LOD lod;
492
493 array<Selection> memSelections = new array<Selection>();
494 array<string> components = new array<string>; // for components with multiple selection
495
496 Object object;
497
498 if (m_Target)
499 {
500 object = m_Target.GetObject();
501 compIdx = m_Target.GetComponentIndex();
502
503 if (m_Target.GetCursorHitPos() == vector.Zero)
504 isTargetForced = true;
505 }
506 else
507 {
508 return;
509 }
510
511 if (object)
512 {
513 if (!isTargetForced)
514 {
515 compName = object.GetActionComponentName(compIdx);
516 int namedComponentType = object.GetActionComponentNameList(compIdx, components);
517
518 if (!object.IsInventoryItem() && (object.HasFixedActionTargetCursorPosition() || namedComponentType == 0))
519 {
520 m_FixedOnPosition = true;
521 return;
522 }
523
524 pivotOffset = object.ConfigGetFloat("actionTargetPivotOffsetY");
525 memOffset = object.ConfigGetFloat("actionTargetMemOffsetY");
526
528 lod = object.GetLODByName(MEM_LOD_NAME);
529 if (lod != null)
530 {
532 lod.GetSelections(memSelections);
533
534 // items with CE_Center mem point
535 if (MiscGameplayFunctions.IsComponentInSelection(memSelections, CE_CENTER_COMP_NAME))
536 {
537 for (int i2 = 0; i2 < memSelections.Count(); ++i2)
538 {
539 if (memSelections[i2].GetName() == CE_CENTER_COMP_NAME && memSelections[i2].GetVertexCount() == 1)
540 {
541 m_FixedOnPosition = false;
542 modelPos = object.GetSelectionPositionMS(CE_CENTER_COMP_NAME);
543 worldPos = object.ModelToWorld(modelPos);
544 if (memOffset != 0.0)
545 {
546 worldPos[1] = worldPos[1] + memOffset;
547 }
548 else
549 {
550 worldPos[1] = worldPos[1] + DEFAULT_HANDLE_OFFSET;
551 }
552 }
553 }
554
556 m_CachedObject.Store(object, worldPos, compIdx);
557 }
559 else if (!compName.Contains("ladder") && IsComponentInSelection(memSelections, compName))
560 {
561 for (int i1 = 0; i1 < memSelections.Count(); ++i1)
562 {
564 if (memSelections[i1].GetName() == compName && memSelections[i1].GetVertexCount() == 1)
565 {
566 modelPos = object.GetSelectionPositionMS(compName);
567 worldPos = object.ModelToWorld(modelPos);
568
569 m_FixedOnPosition = false;
570 if (object.GetType() == "Fence" || object.GetType() == "Watchttower" || object.GetType() == "GardenPlot")
571 m_FixedOnPosition = true;
572
573 if (memOffset != 0.0)
574 {
575 worldPos[1] = worldPos[1] + memOffset;
576 }
577 else
578 {
579 worldPos[1] = worldPos[1] + DEFAULT_HANDLE_OFFSET;
580 }
581 }
582
584 if (memSelections[i1].GetName() == compName && memSelections[i1].GetVertexCount() > 1)
585 {
586 for (int j = 0; j < components.Count(); ++j)
587 {
588 if (IsComponentInSelection(memSelections, components[j]))
589 {
590 modelPos = object.GetSelectionPositionMS(components[j]);
591 worldPos = object.ModelToWorld(modelPos);
592
593 m_FixedOnPosition = false;
594 if (memOffset != 0.0)
595 {
596 worldPos[1] = worldPos[1] + memOffset;
597 }
598 else
599 {
600 worldPos[1] = worldPos[1] + DEFAULT_HANDLE_OFFSET;
601 }
602 }
603 }
604 }
605 }
606
608 m_CachedObject.Store(object, worldPos, -1);
609 }
611 else if (compName.Contains("ladder") && IsComponentInSelection(memSelections, compName))
612 {
613 vector ladderHandlePointLS, ladderHandlePointWS;
614 vector closestHandlePos;
615 float lastDistance = 0;
616
617 for (int i3 = 0; i3 < memSelections.Count(); ++i3)
618 {
619 if (memSelections[i3].GetName() == compName && memSelections[i3].GetVertexCount() > 1)
620 {
621 ladderHandlePointLS = memSelections[i3].GetVertexPosition(lod, 0);
622 ladderHandlePointWS = object.ModelToWorld(ladderHandlePointLS);
623 closestHandlePos = ladderHandlePointWS;
624 lastDistance = Math.AbsFloat(vector.DistanceSq(ladderHandlePointWS, m_Player.GetPosition()));
625
626 for (int k = 1; k < memSelections[i3].GetVertexCount(); ++k)
627 {
628 ladderHandlePointLS = memSelections[i3].GetVertexPosition(lod, k);
629 ladderHandlePointWS = object.ModelToWorld(ladderHandlePointLS);
630
631 if (lastDistance > Math.AbsFloat(vector.DistanceSq(ladderHandlePointWS, m_Player.GetPosition())))
632 {
633 lastDistance = Math.AbsFloat(vector.DistanceSq(ladderHandlePointWS, m_Player.GetPosition()));
634 closestHandlePos = ladderHandlePointWS;
635 }
636 }
637
638 m_FixedOnPosition = false;
639 worldPos = closestHandlePos;
640 if (memOffset != 0.0)
641 {
642 worldPos[1] = worldPos[1] + memOffset;
643 }
644 else
645 {
646 worldPos[1] = worldPos[1] + DEFAULT_HANDLE_OFFSET;
647 }
648 }
649 }
650
652 m_CachedObject.Store(object, worldPos, -1);
653 }
654 else
655 {
656 m_FixedOnPosition = true;
657 }
658 }
659 else
660 {
661 m_FixedOnPosition = true;
662 }
663 }
664 else
665 {
666 m_FixedOnPosition = true;
667 }
668
669 vector pos = TransformToScreenPos(worldPos);
670
671 x = pos[0];
672 y = pos[1];
673 }
674
675 worldPos = vector.Zero;
676 isTargetForced = false;
eBleedingSourceType GetType()
override bool HasFixedActionTargetCursorPosition()
Определения DayZAnimal.c:120
Icon x
Icon y
bool IsComponentInSelection(array< Selection > selection, string compName)
Определения ActionTargetsCursor.c:679
PlayerBase m_Player
Определения ActionTargetsCursor.c:60
ActionTarget m_Target
Определения ActionTargetsCursor.c:61
bool m_FixedOnPosition
Определения ActionTargetsCursor.c:81
vector TransformToScreenPos(vector pWorldPos)
transform world pos to screen pos (related to parent widget size)
Определения ActionTargetsCursor.c:457
ref ATCCachedObject m_CachedObject
Определения ActionTargetsCursor.c:62
proto native bool GetSelections(notnull out array< Selection > selections)
static const vector Zero
Определения EnConvert.c:123
class LOD Object
bool Contains(string sample)
Returns true if sample is substring of string.
Определения EnString.c:286
proto native owned string GetName()
Test name getter. Strictly for UI porposes!
Определения SyncedValue.c:119

Перекрестные ссылки Math::AbsFloat(), string::Contains(), vector::DistanceSq(), GetName(), LOD::GetSelections(), GetType(), HasFixedActionTargetCursorPosition(), IsComponentInSelection(), m_CachedObject, m_FixedOnPosition, m_Player, m_Target, LOD::NAME_MEMORY, TransformToScreenPos(), x, y и vector::Zero.

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