Comments (5)
@jhoukem Since using getDeclaredFields() won't find inherited members but getFields() will, 117 was just reverted (117 breaks existing code that inherited fields, and existing code couldn't have used private fields before and so still can't). I'd like to be able to have this handle the Kotlin case mentioned above and the current inheritance use case, but it doesn't seem straightforward. I'm not sure why you actually would need private fields in your behavior tree Tasks, except for Kotlin's quirks which 117 wouldn't be able to handle (since it would need to handle setters).
So there's your reason, getFields() allows inheriting fields as long as they are public, and getDeclaredFields() does not allow inheriting fields.
from gdx-ai.
As of Mar 2022, the unexpected behavior described in this issue still appears for LeafTasks in Kotlin when annotated as documented for Java.
What seems to have worked for me was adding @JvmField annotation before the @TaskAttribute annotation in the LeafTask class as so:
@JvmField
@TaskAttribute
var doing : String? = null
Also important appears to be how one creates the tree. I was unable to get attribute data into the LeafTask class from the btree using the following tree parsing approach (from GdxDemo3d):
// Create behavior tree through the library
BehaviorTreeLibraryManager btlm = BehaviorTreeLibraryManager.getInstance();
this.tree = btlm.createBehaviorTree("btrees/dog.btree", this);
However, the following tree parsing approach (inspired by Benoit Dumas's Alchemist project) populates the LeafTask attribute as I would expect:
var tree : BehaviorTree<KoboldCharacter>
init {
val reader = FileReader("android/assets/btree/kobold.btree")
val parser = BehaviorTreeParser<KoboldCharacter>(BehaviorTreeParser.DEBUG_HIGH)
tree = parser.parse(reader, this)
}
Hope this helps.
Thank you,
Ian
from gdx-ai.
This also becomes a problem when using Kotlin instead of Java. It would be awesome, if the Annotation could be extended to be allowed on Setter Methods so it's also possible to do some post-processing.
from gdx-ai.
I created a PR for this issue.
from gdx-ai.
@tommyettinger Should we close this issue since 117 has been merged?
from gdx-ai.
Related Issues (20)
- Example for Guards in the Wiki.
- @TaskAttribute for enums does not work HOT 1
- Release 1.8.2? HOT 7
- Behavior Trees: Freeze in BehaviorTree#step() in certain conditions HOT 3
- There's a TODO with a link to a page that no longer exists. HOT 2
- Is there something wrong here in Parallel?
- How to correctly pool behavior trees (and tasks)?
- index 81 out of bounds for length 81 HOT 2
- When will gdx-ai released a new version HOT 1
- POOL field in MessageDispatcher should not be static? HOT 1
- TaskAttributes do not appear to populate Tasks for included subtrees
- Broken images in wiki
- Broken Javadocs Links in Wiki
- When I use kryo to serialize btree on android, i got a exception that GuardEvaluator can bot be accessible
- The Fighting Kitten Tutorial is not available
- Running the tests HOT 1
- Are there any plans to release a new version
- Behavior trees Parallel components clearing Sequences
- d
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from gdx-ai.