jeffcampbellmakesgames / Entitas-Redux

An entity-component framework for Unity with code generation and visual debugging
MIT License
103 stars 13 forks source link

[FEATURE REQUEST] Investigate interface code generated by Event system for improvements #14

Closed jeffcampbellmakesgames closed 4 years ago

jeffcampbellmakesgames commented 4 years ago

Is your feature request related to a problem? Please describe. When documenting usage of the [Event] attribute recently I noticed that the listener interface method could be clearer.

Example Event Component

using System;
using JCMG.EntitasRedux;
using UnityEngine;
using EventType = JCMG.EntitasRedux.EventType;

namespace ExampleContent.VisualDebugging
{
    [Serializable]
    [VisualDebug]
    [Event(EventTarget.Self, EventType.Added)]
    [Event(EventTarget.Self, EventType.Removed)]
    public class Vector3Component : IComponent
    {
        public Vector3 vector3;
    }
}

Example Listener Interfaces Generated

public interface IVector3Listener
{
    // This interface method could be clearer about what is happening
    void OnVector3(VisualDebugEntity entity, UnityEngine.Vector3 vector3);
}

public interface IVector3RemovedListener
{
    // This interface method is clear and doesn't need to change.
    void OnVector3Removed(VisualDebugEntity entity);
}

Describe the solution you'd like I'd like to change the generated interface for the Added event to be something more like OnVector3Added and add a bit of XML documentation on the interface method to reflect that this interface method will be invoked when the component is added, updated, or replaced.

public interface IVector3Listener
{
    /// <summary>
    /// Invoked when the <see cref="ExampleContent.VisualDebugging.Vector3Component"/> on an entity is added, updated,
    /// or replaced. 
    /// </summary>
    /// <param name="entity">The entity on which the component change took place</param>
    void OnVector3Added(VisualDebugEntity entity, UnityEngine.Vector3 vector3);
}
jeffcampbellmakesgames commented 4 years ago

This has been merged to develop.