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

Lightzone Switch component #88

Merged
merged 7 commits into from
Feb 28, 2024

Conversation

kk1201
Copy link
Contributor

@kk1201 kk1201 commented Feb 28, 2024

I noticed that the lightzone script didn't have any functionality to respond to light switch events. I added a LightzoneSwitchComponent.gd script to solve this. Parenting it to a LightzoneComponent and connecting the switched signal from a Cogito_Switch.gd node to the _on_switched function, this should should make the parent lightzone automatically follow the switch's state by enabling and disabling the Area3D::monitoring property.

Reason
Small change, follows composition, I think it makes sense for it to be included in the template since it's a big feature of a lot of immersive sims, allows for new gameplay and level design options :)

No side effects
Will only affect lightzones, and not connecting the signal or setting the switchable flag to false will make the lightzone behave as previously. CogitoSwitch.gd::is_on initial state is respected. I added a LightzoneSwitchComponent to the LightzoneComponent prefab and added a LightzoneComponent child to the CeilingLamp prefab as an example but feel free to make me restore them to their previous state.

Downsides
Uses get_parent(), which violates pure composition. However the use-case is incredibly obvious based on the name and documentation, and it shouldn't pollute anything else, so I feel like using it in this limited scope makes sense.


switchable-lightzone-example.mp4

Copy link
Owner

@Phazorknight Phazorknight left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is awesome.
I have neglected looking into Lightzone's working on other stuff.
Having the Lightzones respond to switch state makes perfect sense and your implementation is great.
Approved!

@Phazorknight Phazorknight merged commit 84ae70d into Phazorknight:main Feb 28, 2024
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

Successfully merging this pull request may close these issues.

2 participants