delverengine icon indicating copy to clipboard operation
delverengine copied to clipboard

Entity Tag System

Open joshuaskelly opened this issue 5 years ago • 9 comments

Summary

This feature introduces a tag system for entities that can be used to make decisions.

Goals

  1. Simple straight forward API for working with tags.
  2. Simple JSON serialization types.
  3. Existing systems (status effects, item condition, etc) should participate in to tag system to allow decision marking.

Use Cases

  1. A breakable that only breaks when hit with a weapon with a specific tag. A boulder is only broken by a mattock. The mattock would be a weapon with the tag rock-breaker.
  2. Triggers only fire when the encroaching entity has a specific tag. A special door only opens if the player is poisoned.
  3. Monster only takes damage from certain tags. A ghost might only be hurt with magical tagged weapons.

Proposed JSON

{
  "id": "MyEntity",
  "tags": "poisoned,broken,unique"
}

Proposed Data Structure

public interface TagCollection {
    void add(String value);
    void add(TagCollection values);
    
    void remove(String value);
    void remove(TagCollection values);
    
    void toggle(String value);
    void toggle(TagCollection values);
    
    void contains(String value);
    void containsAny(TagCollection values);
    void containsAll(TagCollection values);
}

joshuaskelly avatar Oct 12 '20 17:10 joshuaskelly

I could imagine that passing a TagCollection to those methods would not be easy?! How about just passing an array of strings instead, e.g. tags.remove(["foo", "bar"]).

PythooonUser avatar Oct 12 '20 17:10 PythooonUser

Why would that be difficult? It would look like:

Trigger t;
Player p;
p.tags.remove(t.tags);

Mock example of a trigger that removes a set of tags

joshuaskelly avatar Oct 12 '20 17:10 joshuaskelly

@PythooonUser I agree with @joshuaskelly as initialisation would be done mainly in the data files. How about a generic collection which also adds method overloads for Array<E> and E[] though?

public interface TagCollection<E> { 
    void add(E value);
    void add(Array<E> value);
    void add(E[] value);
}

evrimoztamur avatar Oct 12 '20 17:10 evrimoztamur

I'd also like to present a pretty easy view in the editor. Which typically is a comma separate list of strings.

joshuaskelly avatar Oct 12 '20 17:10 joshuaskelly

That mock example makes sense. I thought of a non-cached use-case where you would just test for some tags, and not creating a collection first etc.

PythooonUser avatar Oct 12 '20 17:10 PythooonUser

@evrimoztamur I don't know what being generic gets us?

joshuaskelly avatar Oct 12 '20 17:10 joshuaskelly

@joshuaskelly because Java has generics and generics are cool 😎

evrimoztamur avatar Oct 12 '20 17:10 evrimoztamur

I think it would over complicate the editor experience.

joshuaskelly avatar Oct 12 '20 17:10 joshuaskelly

Completely forgot about the editor, you're right!

Is there a way to add an 'editor representation'? As in, have the internal data structure be an array but be represented as string array (or other complex form) in the editor. Not too involved with editor param pane code.

evrimoztamur avatar Oct 12 '20 17:10 evrimoztamur