26 lines
526 B
GDScript
26 lines
526 B
GDScript
class_name MapEntry
|
|
|
|
var src_start := 0
|
|
var dst_start := 0
|
|
var range := 0
|
|
|
|
func _to_string():
|
|
return str(self.src_start) + " -> " + str(self.dst_start) + " (" + str(self.range) + ")"
|
|
|
|
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
|
|
|
|
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
|