Doraku/DefaultEcs.Analyzer

Update code doesn't work with AEntitySortedSetSystem

Closed this issue · 1 comments

Here's an example repo with the problem. https://github.com/distantcam/SortedEntityExample

DefaultEcs 0.17.2
DefaultEcs.Analyzer 0.17.0

Code

public struct PositionInfo
{
    public int X;
    public int Y;
}

public sealed partial class PositionSystem : AEntitySortedSetSystem<int, PositionInfo>, IComparer<PositionInfo>
{
    public int Compare(PositionInfo x, PositionInfo y)
    {
        return x.X.CompareTo(y.X);
    }

    [Update]
    private void Update(int state, in PositionInfo positionInfo) { }
}

Generated code

public partial class PositionSystem
{
    [CompilerGenerated]
    public PositionSystem(World world)
        : base(world, CreateEntityContainer)
    { }

    [CompilerGenerated]
    private static EntitySortedSet<global::SortedEntityExample.PositionInfo> CreateEntityContainer(object sender, World world)
    {
        var query = world
            .GetEntities()
            .With<global::SortedEntityExample.PositionInfo>();
        return sender is IComparer<global::SortedEntityExample.PositionInfo> comparer ? query.AsSortedSet<global::SortedEntityExample.PositionInfo>(comparer) : query.AsSortedSet<global::SortedEntityExample.PositionInfo>();
    }

    [CompilerGenerated]
    protected override void Update(int state, ReadOnlySpan<Entity> entities)
    {
        Components<global::SortedEntityExample.PositionInfo> components0 = World.GetComponents<global::SortedEntityExample.PositionInfo>();

        foreach (ref readonly Entity entity in entities)
        {
            Update(state, components0[entity]);
        }
    }
}

Error

error CS1503: Argument 1: cannot convert from 'DefaultEcs.World' to 'DefaultEcs.EntitySortedSet<SortedEntityExample.PositionInfo>'
error CS1503: Argument 2: cannot convert from 'method group' to 'bool'

arg indeed the useBuffer parameter is not optional and I forgot it here >_<
https://github.com/Doraku/DefaultEcs.Analyzer/blob/master/source/DefaultEcs.Analyzer/Generators/SystemGenerator.cs#L361

I'll fix it.