Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Suggestion: Nested advanced condition #175

Open
secretmeister2 opened this issue Nov 29, 2024 · 1 comment
Open

Suggestion: Nested advanced condition #175

secretmeister2 opened this issue Nov 29, 2024 · 1 comment

Comments

@secretmeister2
Copy link

secretmeister2 commented Nov 29, 2024

While trying to use this I realized that something that would be very useful would be to be able to have nested AdvancedModifierConditions, so I wrote my own.

class_name NestedCondition
extends AdvancedModifierCondition
## This condition is only if all the nested conditions are true. 
## (If inverted, instead returns true if all nested conditions are false)
@export var conditions: Array[AdvancedModifierCondition]
var noise:FastNoiseLite
func is_condition_met(grid: GaeaGrid, cell) -> bool:
	for condition in conditions:
		# Sets child noise seeds to selfs noise seed
		if condition.get("noise") != null and condition.get("noise") is FastNoiseLite:
			condition.noise.seed = noise.seed
		# Checks if the condition is met
		if not condition.is_condition_met(grid, cell):
			return (mode!=Mode.NORMAL)
	# If none of them return false, return true (or opposite if inverted)
	return (mode==Mode.NORMAL)

This allows for much more advanced and customized generation. I don't quite know how to properly do the noise offsetting, that is the part that I feel could be vastly improved.

@BenjaTK
Copy link
Owner

BenjaTK commented Nov 29, 2024

Hey! If you can make a PR for it I'd appreciate it, but rn I'm working on a new version of Gaea so I'm not adding stuff anymore.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants