Computor 178 Share Posted September 13, 2015 ^exactly... too much code packed into a single statement Link to comment Share on other sites More sharing options...
Mad Moxxi 6 Author Share Posted September 13, 2015 looks prety clunky fam ^exactly... too much code packed into a single statement Of course the buildTask method can get overcrowded, but that's looking at only the implementation I whipped up in a matter of minutes. It's designed to be used wherever you see fit. It can be implemented pretty much anywhere in your existing framework with a few lines. Link to comment Share on other sites More sharing options...
Computor 178 Share Posted September 13, 2015 Of course the buildTask method can get overcrowded, but that's looking at only the implementation I whipped up in a matter of minutes. It's designed to be used wherever you see fit. It can be implemented pretty much anywhere in your existing framework with a few lines. Node frameworks really seems to eliminate the need for this, and also looks a little better imo. I don't like the look of 4 lines for a single statement. Link to comment Share on other sites More sharing options...
Mad Moxxi 6 Author Share Posted September 13, 2015 Node frameworks really seems to eliminate the need for this, and also looks a little better imo. I don't like the look of 4 lines for a single statement. You can use it within your node framework. Instead of doing NPC npc = getContext().getNPCs().closest((npc) -> npc.getName().equals("Flesh crawler")); if (npc != null) npc.interact("Attack"); you could do getContext().getTaskExecutor().execute(new InteractEntityTask(getContext(), (npc) -> npc.getName().equals("Flesh crawler"), "Attack")); which also handles walking, camera movement and will attempt to WebWalk, if no matching local Entity is found. Edit: You can also use them as nodes. Here is an example of what a banking node would look like. public class BankingTask extends ChainableTask { private final String axeName; private boolean hasAxe; public BankingTask(Context context, String axeName) { super(context); this.axeName = axeName; } @Override public boolean execute() { // Standard processing method return getContext().getTaskExecutor().execute( hasAxe ? new DepositAllExceptTask(getContext(), false, axeName) : new WithdrawTask(getContext(), axeName, 1)); } @Override public void prepare() { // This executes if canExecute returns false } @Override public boolean canExecute() { // Can it execute? hasAxe = getContext().getInventory().contains(axeName) || getContext().getEquipment().contains(axeName); return getContext().getInventory().isFull() || !hasAxe; } } Link to comment Share on other sites More sharing options...
QuakedM8 58 Share Posted September 14, 2015 o.O nice man Link to comment Share on other sites More sharing options...
Explicit 213 Share Posted September 14, 2015 Personally I really like the idea behind this. It's much easier to use a simple lambda then create an entire class for an "eat" action. @Everyone complaining about large projects getting messy, just create a container class to hold methods which return their respective lambdas or even group them within multiple classes. You can still receive all the benefits of this with the organization of the typical task framework. Link to comment Share on other sites More sharing options...
sini 32 Share Posted September 16, 2015 ripped my framework ggggggg Nah just kidding looks really good. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.