39 lines
927 B
GDScript
39 lines
927 B
GDScript
class_name AltInstance
|
|
|
|
var alt: Alt
|
|
var index: int = -1
|
|
var random: Random
|
|
|
|
func _init(behavior: AltBehavior.AltBehavior, outputs: Array[Output], random2: Random) -> void:
|
|
self.alt = Alt.new(behavior, outputs)
|
|
self.random = random2
|
|
|
|
func next() -> Output:
|
|
if true:
|
|
var _g: AltBehavior.AltBehavior = self.alt.behavior
|
|
match (((_g as Variant) as int)):
|
|
0:
|
|
var tempRight
|
|
var v: float = min(self.alt.outputs.size() - 1, self.index + 1)
|
|
tempRight = int(floor(v))
|
|
self.index = tempRight
|
|
1:
|
|
if (self.index >= -1):
|
|
self.index = self.index + 1
|
|
if (self.index >= self.alt.outputs.size()):
|
|
self.index = -2
|
|
2:
|
|
self.index = (self.index + 1) % self.alt.outputs.size()
|
|
3:
|
|
self.index = self.random._int(0, self.alt.outputs.size() - 1, null)
|
|
|
|
var tempResult
|
|
|
|
if (self.index < 0):
|
|
tempResult = Output.new()
|
|
else:
|
|
tempResult = self.alt.outputs[self.index]
|
|
|
|
return tempResult
|
|
|