2023-12-09 13:20:02 -05:00
|
|
|
class_name MapEntry
|
|
|
|
|
|
|
|
var src_start := 0
|
|
|
|
var dst_start := 0
|
|
|
|
var range := 0
|
2023-12-09 14:31:28 -05:00
|
|
|
|
|
|
|
func _to_string():
|
2023-12-09 16:57:10 -05:00
|
|
|
return str(self.src_start) + " -> " + str(self.dst_start) + " (" + str(self.range) + ")"
|
2023-12-09 14:31:28 -05:00
|
|
|
|
|
|
|
func apply(input):
|
|
|
|
# Big ints are sus, be safe
|
|
|
|
var d_start = input - src_start
|
|
|
|
|
|
|
|
if d_start < 0 or d_start >= self.range:
|
|
|
|
return null
|
|
|
|
|
|
|
|
return dst_start + d_start
|
2023-12-09 16:57:10 -05:00
|
|
|
|
|
|
|
func apply_rev(input):
|
|
|
|
# Big ints are sus, be safe
|
|
|
|
var d_start = input - dst_start
|
|
|
|
|
|
|
|
if d_start < 0 or d_start >= self.range:
|
|
|
|
return null
|
|
|
|
|
|
|
|
return src_start + d_start
|