DayZ 1.27
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 строка 471

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