Giter Club home page Giter Club logo

Comments (5)

tommyettinger avatar tommyettinger commented on June 14, 2024 1

@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.

exertionriver avatar exertionriver commented on June 14, 2024 1

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.

deveth0 avatar deveth0 commented on June 14, 2024

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.

jhoukem avatar jhoukem commented on June 14, 2024

I created a PR for this issue.

from gdx-ai.

jhoukem avatar jhoukem commented on June 14, 2024

@tommyettinger Should we close this issue since 117 has been merged?

from gdx-ai.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.