Untitled

 avatar
unknown
php
2 years ago
1.0 kB
5
Indexable
	//Checks if the straight line between the callers' position and the specified position can be walked up to.
	Bool IsPosReachable (Vector3 TargetPos)
	{
		Vector3 OldPos = Pos;
		Bool Interp = bDontInterpolate;
		Vector2 Path = Level.Vec2Diff( Pos.XY, TargetPos.XY );
		Double Distance = Path.Length();
		Double Spacing = Distance/Radius;
		If (Distance <= 1) Return False;
		Path /= Distance;
		
		bDontInterpolate = True; //No movement interpolation during the test.
		For (Int I = 0; I < Distance; I += Speed)
		{
			If (Level.Vec3Diff (Pos, OldPos).Length() >= Distance) Break; //Check successful.
			If (TryMove (Level.Vec2Offset(Pos.XY, Path*I), 0)){spawn ("candlestick",pos);} //Run as many as it takes between you and your destination.
			//If one of them fails, then return false.
			Else
			{a_log ("i can't head here");
				bDontInterpolate = Interp;
				SetOrigin (OldPos,False);
				Return False;
			}
		}a_log ("valid path");
		bDontInterpolate = Interp;
		SetOrigin (OldPos,False);
		Return True; //No TryMove call returned false.
	}
Editor is loading...