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>;
492
494
496 {
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
516 {
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 {
530
531
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 {
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
554 }
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
567 if (
object.
GetType() ==
"Fence" ||
object.
GetType() ==
"Watchttower" ||
object.
GetType() ==
"GardenPlot")
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 {
586 {
587 modelPos = object.GetSelectionPositionMS(components[j]);
588 worldPos = object.ModelToWorld(modelPos);
589
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
606 }
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
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
650 }
651 else
652 {
654 }
655 }
656 else
657 {
659 }
660 }
661 else
662 {
664 }
665
667
670 }
671
672 worldPos = vector.
Zero;
673 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.