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

Question about room logic #50

Open
GamesAndBacon opened this issue May 11, 2024 · 2 comments
Open

Question about room logic #50

GamesAndBacon opened this issue May 11, 2024 · 2 comments
Labels
answered This question has been answered question This is not an issue, just a question about the plugin

Comments

@GamesAndBacon
Copy link

hello there,
im wondering about how i could encapsulate room logic.

for example, i have a room and i want it to be a wave attack type room.
i have spawner actors placed around and i want the room to know about them and be able to use them.
i looked at custom data but i dont think this is what i want.

i currently have another actor my "room manager" that i place in the level blueprint for the room and that does the job.
But im wondering would i be better off expanding the room class? perhaps even removing the custom data aproach and just letting the room class have more of a role in managing all logic in that room.

not sure what you would recommend.

@GamesAndBacon GamesAndBacon added the bug Something isn't working label May 11, 2024
@BenPyton
Copy link
Owner

Hi @GamesAndBacon
You're right, RoomCustomData is meant to carry per room instance data.
You can have some functions in it if you want to manipulate those data, but you should not have logic inside that have direct impact in the world. Instead, I think the better approach is to make your logic in your room level blueprints.

What I would first try do in your case, would be to create an actor component with the standard logic inside.
However, since you can't add components to the level blueprint actor in editor, you should add it at runtime (meaning you can't set per instance variables like in a common actor blueprint class.)

So in short, I would go that way:

  • Create a Room Custom Data filled with specific per room instance data during the dungeon initialization phase.
  • Create an Actor Component containing the logic using the Room Custom Data variables.
  • In the level blueprint, add the component in the begin play and pass it the Room Custom Data.

If you have a C++ project, you can create a subclass of the Room Level class (the level blueprint specific to the plugin).
Inside you can add your component or your logic directly, and then reparent the level blueprints to your own sub-class.
In that case you can also add editable variables in the editor (like I've done with the Room Data asset to display boundaries of the room in editor).

@BenPyton BenPyton added answered This question has been answered question This is not an issue, just a question about the plugin and removed bug Something isn't working labels Jun 2, 2024
@GamesAndBacon
Copy link
Author

just as a follow up to this i wanted to let you know which direction i went with.

i created a RoomLogicComponent class in C++, and when the RoomLevel is just about to finish initilizing at the bottom of begin play, i add the component and pass in the room and room data.

i added a helper function for adding a component, and exposed to to BP. so you could add more at runtime if you wanted. maaaybe your map has modifiers and you want them to add features to certain rooms. something along the lines of Path of Exile random enocunters.

i also added a helper function to GetAllActorsInLevel, inside the level instance. just something i found handy so i could check for spawn points, or if all my team members were inside the room at the same time ect.
im debating making that purely data orientated though. maybe a struct of GameplayTags and vectors. and just implying what a certain location COULD be, then the logic component could read them and place actors accordingly.

i also exposed the roomlevel returning the dungeongenerator. i use my dungeon generator as a singlular source for where i keep my pooled actors and things. so begin able to easily reach that was handy.

in the end i went with using logic driver pro lol. but now in my roomlogiccomponent thats where i spawn my state machine and plugin all the required data.
https://imgur.com/totRpI9

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
answered This question has been answered question This is not an issue, just a question about the plugin
Projects
None yet
Development

No branches or pull requests

2 participants