<commit_before>Strict

Import flxextern
Import flxpoint
Import flxg

Import flixel.system.flxcolor

Import flixel.plugin.debugpathdisplay


Class FlxPath

	Global ClassObject:FlxClass = new FlxObjectClass()

	Field nodes:Stack<FlxPoint>
	
	Field debugColor:Int
	
	Field debugScrollFactor:FlxPoint
	
	Field ignoreDrawDebug:Bool
	
Private
	Field _point:FlxPoint
	
	Field _debugNodeColor:FlxColor
	
Public
	Method New(nodes:Stack<FlxPoint> = Null)
		If (nodes = Null) Then
			Self.nodes = New Stack<FlxPoint>()
		Else
			Self.nodes = nodes	
		End if
		
		_point = New FlxPoint()
		debugScrollFactor = New FlxPoint(1.0, 1.0)
		debugColor = FlxG.WHITE
		ignoreDrawDebug = False
		
		Local debugPathDisplay:DebugPathDisplay = Manager()
		If (debugPathDisplay <> Null) debugPathDisplay.Add(Self)			
	End Method

	Method Destroy:Void()
		Local debugPathDisplay:DebugPathDisplay = Manager()
		If (debugPathDisplay <> Null) debugPathDisplay.Remove(Self)
		
		debugScrollFactor = Null
		_point = Null
		nodes = Null
		_debugNodeColor = Null
	End Method
	
	Method Add:Void(x:Float, y:Float)
		nodes.Push(New FlxPoint(x, y))
	End Method
	
	Method AddAt:Void(x:Float, y:Float, index:Int)
		If (index > nodes.Length()) index = nodes.Length()
		nodes.Insert(index, New FlxPoint(x, y))	
	End Method
	
	Method AddPoint:Void(node:FlxPoint, asReference:Bool = False)
		If (asReference) Then
			nodes.Push(node)
		Else
			nodes.Push(New FlxPoint(node.x, node.y))
		End If
	End Method
	
	Method AddPointAt:Void(node:FlxPoint, index:Int, asReference:Bool = False)
		If (index > nodes.Length()) index = nodes.Length()
		
		If (asReference) Then
			nodes.Insert(i, node)
		Else
			nodes.Insert(i, New FlxPoint(node.x, node.y))	
		End If
	End Method
	
	Method Remove:FlxPoint(node:FlxPoint)		
		Local i:Int = 0
		Local l:Int = nodes.Length()
		Local point:FlxPoint
		
		While (i < l)
			point = nodes.Get(i)
			If (point = node) Exit
			i += 1	
		Wend
		
		nodes.Remove(i)
		Return point
	End Method
	
	Method RemoveAt:FlxPoint(index:Int)
		If (nodes.Length() <= 0) Return Null
		If (index >= nodes.Length()) index = nodes.Length() - 1
		
		Local point:FlxPoint = nodes.Get(i)
		nodes.Remove(i)
		Return point
	End Method
	
	Method Head:FlxPoint()
		If (nodes.Length() > 0) Return nodes.Get(0)
		Return Null
	End Method
	
	Method Tail:FlxPoint()
		If (nodes.Length() > 0) Return nodes.Top()
		Return Null	
	End Method
	
	Method DrawDebug:Void(camera:FlxCamera = Null)
		If (nodes.Length() <= 0) Return
		If (camera = Null) camera = FlxG.Camera
	
		Local node:FlxPoint
		Local nextNode:FlxPoint
		Local i:Int = 0
		Local l:Int = nodes.Length()
		
		Local fromX:Float
		Local fromY:Float		
		
		While(i < l)
			node = nodes.Get(i)
			
			_point.x = node.x - Int(camera.scroll.x * debugScrollFactor.x)
			_point.y = node.y - Int(camera.scroll.y * debugScrollFactor.y)
			
			If (_point.x > 0) Then
				_point.x = Int(_point.x + 0.0000001)
			Else
				_point.x = Int(_point.x - 0.0000001)			
			End If
			
			If (_point.y > 0) Then
				_point.y = Int(_point.y + 0.0000001)
			Else
				_point.y = Int(_point.y - 0.0000001)			
			End If
			
			Local nodeSize:Int = 2
			If (i = 0 Or i = l - 1) nodeSize *= 2
			
			If (_debugNodeColor = Null) _debugNodeColor = New FlxColor()
			_debugNodeColor.SetARGB(FlxG.WHITE)
			
			If (l > 1) Then
				If (i = 0) Then
					_debugNodeColor.SetARGB(FlxG.GREEN)
					
				ElseIf (i = l -1) Then
					_debugNodeColor.SetARGB(FlxG.RED)
				End If
			End If
			
			SetAlpha(.5)		
			
			If (FlxG._LastDrawingColor <> _debugNodeColor.argb) Then
				SetColor(_debugNodeColor.r, _debugNodeColor.g, _debugNodeColor.b)
				FlxG._LastDrawingColor = _debugNodeColor.argb
			End If
			
			DrawRect(_point.x - nodeSize * 0.5, _point.y - nodeSize * 0.5, nodeSize, nodeSize)
			
			Local linealpha:Float = .3
			
			If (i < l - 1) Then
				nextNode = nodes.Get(i + 1)
			Else
				nextNode = nodes.Get(0)
				linealpha = .15
			End If
			
			_debugNodeColor.SetARGB(debugColor)
			
			SetAlpha(linealpha)
			
			If (FlxG._LastDrawingColor <> _debugNodeColor.argb) Then
				SetColor(_debugNodeColor.r, _debugNodeColor.g, _debugNodeColor.b)
				FlxG._LastDrawingColor = _debugNodeColor.argb
			End If
			
			fromX = _point.x
			fromY = _point.y		
			
			_point.x = nextNode.x - Int(camera.scroll.x * debugScrollFactor.x)
			_point.y = nextNode.y - Int(camera.scroll.y * debugScrollFactor.y)<commit_msg>Fixed debug draw for FlxPath<commit_after>Strict

Import flxextern
Import flxpoint
Import flxg

Import flixel.system.flxcolor

Import flixel.plugin.debugpathdisplay


Class FlxPath

	Global ClassObject:FlxClass = new FlxObjectClass()

	Field nodes:Stack<FlxPoint>
	
	Field debugColor:Int
	
	Field debugScrollFactor:FlxPoint
	
	Field ignoreDrawDebug:Bool
	
Private
	Field _point:FlxPoint
	
	Field _debugNodeColor:FlxColor
	
Public
	Method New(nodes:Stack<FlxPoint> = Null)
		If (nodes = Null) Then
			Self.nodes = New Stack<FlxPoint>()
		Else
			Self.nodes = nodes	
		End if
		
		_point = New FlxPoint()
		debugScrollFactor = New FlxPoint(1.0, 1.0)
		debugColor = FlxG.WHITE
		ignoreDrawDebug = False
		
		Local debugPathDisplay:DebugPathDisplay = Manager()
		If (debugPathDisplay <> Null) debugPathDisplay.Add(Self)			
	End Method

	Method Destroy:Void()
		Local debugPathDisplay:DebugPathDisplay = Manager()
		If (debugPathDisplay <> Null) debugPathDisplay.Remove(Self)
		
		debugScrollFactor = Null
		_point = Null
		nodes = Null
		_debugNodeColor = Null
	End Method
	
	Method Add:Void(x:Float, y:Float)
		nodes.Push(New FlxPoint(x, y))
	End Method
	
	Method AddAt:Void(x:Float, y:Float, index:Int)
		If (index > nodes.Length()) index = nodes.Length()
		nodes.Insert(index, New FlxPoint(x, y))	
	End Method
	
	Method AddPoint:Void(node:FlxPoint, asReference:Bool = False)
		If (asReference) Then
			nodes.Push(node)
		Else
			nodes.Push(New FlxPoint(node.x, node.y))
		End If
	End Method
	
	Method AddPointAt:Void(node:FlxPoint, index:Int, asReference:Bool = False)
		If (index > nodes.Length()) index = nodes.Length()
		
		If (asReference) Then
			nodes.Insert(i, node)
		Else
			nodes.Insert(i, New FlxPoint(node.x, node.y))	
		End If
	End Method
	
	Method Remove:FlxPoint(node:FlxPoint)		
		Local i:Int = 0
		Local l:Int = nodes.Length()
		Local point:FlxPoint
		
		While (i < l)
			point = nodes.Get(i)
			If (point = node) Exit
			i += 1	
		Wend
		
		nodes.Remove(i)
		Return point
	End Method
	
	Method RemoveAt:FlxPoint(index:Int)
		If (nodes.Length() <= 0) Return Null
		If (index >= nodes.Length()) index = nodes.Length() - 1
		
		Local point:FlxPoint = nodes.Get(i)
		nodes.Remove(i)
		Return point
	End Method
	
	Method Head:FlxPoint()
		If (nodes.Length() > 0) Return nodes.Get(0)
		Return Null
	End Method
	
	Method Tail:FlxPoint()
		If (nodes.Length() > 0) Return nodes.Top()
		Return Null	
	End Method
	
	Method DrawDebug:Void(camera:FlxCamera = Null)
		If (nodes.Length() <= 0) Return
		If (camera = Null) camera = FlxG.Camera
	
		Local node:FlxPoint
		Local nextNode:FlxPoint
		Local i:Int = 0
		Local l:Int = nodes.Length()
		
		Local fromX:Float
		Local fromY:Float		
		
		While(i < l)
			node = nodes.Get(i)
			
			_point.x = node.x - Int(camera.scroll.x * debugScrollFactor.x)
			_point.y = node.y - Int(camera.scroll.y * debugScrollFactor.y)
			
			If (_point.x > 0) Then
				_point.x = Int(_point.x + 0.0000001)
			Else
				_point.x = Int(_point.x - 0.0000001)			
			End If
			
			If (_point.y > 0) Then
				_point.y = Int(_point.y + 0.0000001)
			Else
				_point.y = Int(_point.y - 0.0000001)			
			End If
			
			Local nodeSize:Int = 2
			If (i = 0 Or i = l - 1) nodeSize *= 2
			
			If (_debugNodeColor = Null) _debugNodeColor = New FlxColor()
			_debugNodeColor.SetARGB(FlxG.WHITE)
			
			If (l > 1) Then
				If (i = 0) Then
					_debugNodeColor.SetARGB(FlxG.GREEN)
					
				ElseIf (i = l -1) Then
					_debugNodeColor.SetARGB(FlxG.RED)
				End If
			End If
			
			SetAlpha(.5)		
			
			If (FlxG._LastDrawingColor <> _debugNodeColor.argb) Then
				SetColor(_debugNodeColor.r, _debugNodeColor.g, _debugNodeColor.b)
				FlxG._LastDrawingColor = _debugNodeColor.argb
			End If
			
			DrawRect(_point.x - nodeSize * 0.5, _point.y - nodeSize * 0.5, nodeSize, nodeSize)
			
			If (i = l - 1) Exit
			
			Local linealpha:Float = .3
			
			If (i < l - 1) Then
				nextNode = nodes.Get(i + 1)
			Else
				nextNode = nodes.Get(0)
				linealpha = .15
			End If
			
			_debugNodeColor.SetARGB(debugColor)
			
			SetAlpha(linealpha)
			
			If (FlxG._LastDrawingColor <> _debugNodeColor.argb) Then
				SetColor(_debugNodeColor.r, _debugNodeColor.g, _debugNodeColor.b)
				FlxG._LastDrawingColor = _debugNodeColor.argb
			End If
			
			fromX = _point.x
			fromY = _point.y		
			
			_point.x = nextNode.x - Int(camera.scroll.x * debugScrollFactor.x)
			_point.y = nextNode.y - Int(camera.scroll.y * debugScrollFactor.y)
{'fraction_non_alphanumeric': 0.10768533212423487, 'fraction_numerical': 0.014849240535026072, 'mean_word_length': 3.096100278551532, 'pattern_counts': {'":': 0, '<': 27, '<?xml version=': 0, '>': 33, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6292616', 'n_tokens_mistral': 3928, 'n_tokens_neox': 3203, 'n_words': 774}