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>;
495
497
499 {
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
519 {
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 {
533
534
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 {
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
557 }
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
570 if (
object.
GetType() ==
"Fence" ||
object.
GetType() ==
"Watchttower" ||
object.
GetType() ==
"GardenPlot")
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 {
589 {
590 modelPos = object.GetSelectionPositionMS(components[j]);
591 worldPos = object.ModelToWorld(modelPos);
592
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
609 }
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
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
653 }
654 else
655 {
657 }
658 }
659 else
660 {
662 }
663 }
664 else
665 {
667 }
668
670
673 }
674
675 worldPos = vector.
Zero;
676 isTargetForced = false;
eBleedingSourceType GetType()
override bool HasFixedActionTargetCursorPosition()
bool IsComponentInSelection(array< Selection > selection, string compName)
vector TransformToScreenPos(vector pWorldPos)
transform world pos to screen pos (related to parent widget size)
ref ATCCachedObject m_CachedObject
proto native bool GetSelections(notnull out array< Selection > selections)
bool Contains(string sample)
Returns true if sample is substring of string.