diff --git a/sources/Gameplay/BaseClasses/Frontend/World/TracingIterator.uc b/sources/Gameplay/BaseClasses/Frontend/World/TracingIterator.uc index 0a9f30c..90b0626 100644 --- a/sources/Gameplay/BaseClasses/Frontend/World/TracingIterator.uc +++ b/sources/Gameplay/BaseClasses/Frontend/World/TracingIterator.uc @@ -20,6 +20,20 @@ class TracingIterator extends Iter abstract; +/** + * Returns position from which tracing is started. + * + * @return Position from which stracing has started. + */ +public function Vector GetTracingStart(); + +/** + * Returns position at which tracing has ended. + * + * @return Position at which tracing has ended. + */ +public function Vector GetTracingEnd(); + /** * Returns only `EPlaceable` interfaces for traced entities. * @@ -79,6 +93,14 @@ public function EPawn GetPawn(); */ public function TracingIterator LeaveOnlyPawns(); +/** + * Makes caller iterator skip any entities that are not visible in the game + * world. + * + * @return Reference to caller `TracingIterator` to allow for method chaining. + */ +public function TracingIterator LeaveOnlyVisible(); + defaultproperties { } \ No newline at end of file diff --git a/sources/Gameplay/KF1Frontend/KF1_Frontend.uc b/sources/Gameplay/KF1Frontend/KF1_Frontend.uc index 99c8022..8d43e54 100644 --- a/sources/Gameplay/KF1Frontend/KF1_Frontend.uc +++ b/sources/Gameplay/KF1Frontend/KF1_Frontend.uc @@ -34,6 +34,7 @@ public function EItemTemplateInfo GetItemTemplateInfo(BaseText templateName) defaultproperties { templatesClass = class'KF1_TemplatesComponent' + worldClass = class'KF1_WorldComponent' tradingClass = class'KF1_TradingComponent' healthClass = class'KF1_HealthComponent' } \ No newline at end of file diff --git a/sources/Gameplay/KF1Frontend/World/KF1_TracingIterator.uc b/sources/Gameplay/KF1Frontend/World/KF1_TracingIterator.uc index e504d5a..030b674 100644 --- a/sources/Gameplay/KF1Frontend/World/KF1_TracingIterator.uc +++ b/sources/Gameplay/KF1Frontend/World/KF1_TracingIterator.uc @@ -35,6 +35,7 @@ var private bool traced; // Iterator filters var private bool onlyPawns; +var private bool onlyVisible; protected function Finalizer() { @@ -57,10 +58,21 @@ public final function Initialize(Vector start, Vector end) initialized = true; } +public function Vector GetTracingStart() +{ + return startPosition; +} + +public function Vector GetTracingEnd() +{ + return endPosition; +} + // Does actual tracing, but only once per iterator's lifecycle. // Assumes `initialized` is `true`. private final function TryTracing() { + local bool isVisible; local Pawn nextPawn; local Actor nextActor; local class targetClass; @@ -87,6 +99,14 @@ private final function TryTracing() endPosition, startPosition) { + if (onlyVisible) + { + isVisible = (!nextActor.bHidden || nextActor.bWorldGeometry); + isVisible = isVisible && (nextActor.drawType != DT_None); + if (!isVisible) { + continue; + } + } hitLocations[hitLocations.length] = nextHitLocation; hitNormals[hitNormals.length] = nextHitNormal; nextPawn = Pawn(nextActor); @@ -173,6 +193,7 @@ public function EPawn GetPawn() public function bool HasFinished() { + TryTracing(); return (currentIndex >= tracedActors.length); } @@ -190,6 +211,14 @@ public function TracingIterator LeaveOnlyPawns() return self; } +public function TracingIterator LeaveOnlyVisible() +{ + if (initialized && !traced) { + onlyVisible = true; + } + return self; +} + defaultproperties { } \ No newline at end of file diff --git a/sources/Gameplay/KF1Frontend/World/KF1_WorldComponent.uc b/sources/Gameplay/KF1Frontend/World/KF1_WorldComponent.uc index 059b676..a70cd36 100644 --- a/sources/Gameplay/KF1Frontend/World/KF1_WorldComponent.uc +++ b/sources/Gameplay/KF1Frontend/World/KF1_WorldComponent.uc @@ -17,8 +17,7 @@ * You should have received a copy of the GNU General Public License * along with Acedia. If not, see . */ -class KF1_WorldComponent extends AWorldComponent - abstract; +class KF1_WorldComponent extends AWorldComponent; var private const float tracingDistance; @@ -63,7 +62,7 @@ public function TracingIterator TracePlayerSight(EPlayer player) if (controller != none) { controller.PlayerCalcView(dummy, start, direction); - return Trace(start, direction); + return Trace(start, controller.rotation); } return none; } @@ -80,7 +79,7 @@ public function TracingIterator TraceSight(EPawn pawn) if (nativePawn == none) return none; start = nativePawn.location + nativePawn.EyePosition(); - end = start + tracingDistance * Vector(nativePawn.rotation); + end = start + tracingDistance * Vector(nativePawn.controller.rotation); return TraceBetween(start, end); }