luminlumin 1 Share Posted November 2, 2017 When making task based scripts, is it more efficient to have a class for everything? For example, would it be more efficient to create a GoToBank task and then a Bank task to handle the actual banking, or is it the same thing as handling walking and banking in 1 class? Sorry if this is a stupid question, what I really want to know is if there is a performance hit (even if it's unnoticeable to the human eye) when you have more tasks, or is it better to separate it all since it's task based anyways.. Edit: To reiterate, right now, I could do addNode(new MineTask(), new BankTask()); where MineTask and BankTask also handle walking to and from places. I can also do new GoToMine(), new Mine(), new GoToBank(), new Bank()); Which is the more acceptable way? Link to comment Share on other sites More sharing options...
RetroBot 35 Share Posted November 2, 2017 I would just do something like if (atbank) { bank} else { walktobank } Link to comment Share on other sites More sharing options...
luminlumin 1 Author Share Posted November 2, 2017 I would just do something like if (atbank) { bank } else { walktobank } Thanks, I just decided to separate them all into different nodes, it makes it easier to understand at least for me. Link to comment Share on other sites More sharing options...
Nuclear Nezz 2040 Share Posted November 2, 2017 For actual efficiency, I'm honestly unsure how much of a hit it would make. I'm pretty sure there are ways to increase performance (see: https://en.wikipedia.org/wiki/Software_design_pattern ) But for the most part it's for readability and general ease of updating/adding features I think. Link to comment Share on other sites More sharing options...
luminlumin 1 Author Share Posted November 2, 2017 For actual efficiency, I'm honestly unsure how much of a hit it would make. I'm pretty sure there are ways to increase performance (see: https://en.wikipedia.org/wiki/Software_design_pattern ) But for the most part it's for readability and general ease of updating/adding features I think. Here's the thing though, see this part: public int priority() { return 1; } I'm not sure if every class needs its own priority, but the tutorial I followed had that, and so I have a priority for all of my tasks, however, I can see it becoming an issue if you're working on a huge script, not 5 or 6 classes but maybe 80 or 90 different tasks (just for example). So, why is priority even needed if we are calling new nodes anyways to be executed in our main class? Link to comment Share on other sites More sharing options...
swift 22 Share Posted November 2, 2017 Here's the thing though, see this part: public int priority() { return 1; } I'm not sure if every class needs its own priority, but the tutorial I followed had that, and so I have a priority for all of my tasks, however, I can see it becoming an issue if you're working on a huge script, not 5 or 6 classes but maybe 80 or 90 different tasks (just for example). So, why is priority even needed if we are calling new nodes anyways to be executed in our main class? Each node class will nee its own priority, and I think you can use it if 2 nodes accept using the same method but you want one to run before the other I'm not certain though. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.