MaFi-Games / Captain-of-industry-modding

Official modding resource for video game Captain of Industry.
https://www.captain-of-industry.com
MIT License
41 stars 40 forks source link

False/Positive Check from Github or indeed a Bug? #5

Open Chaoschaot232 opened 2 years ago

Chaoschaot232 commented 2 years ago

Hey MaFi Games Team,

I am interested in modding or maybe helping out with your game so I looked into your example code and found a red marked line: https://github.com/MaFi-Games/Captain-of-industry-modding/blob/main/src/ExampleMod/ExampleMachineData.cs#L39

Now my questen here is, if this code is valid syntax or if Github is right in marking it red and as an error 🤔 Looking at the lines above I wouold assoume that Github wants it like that:

// Example of a new furnace recipe.
        registrator.RecipeProtoBuilder
            .Start(name: "Example smelting",
                recipeId: ExampleModIds.Recipes.ExampleSmelting,
                machineId: ExampleModIds.Machines.ExampleFurnace)
            .AddInput(8, ExampleModIds.Products.ExampleLooseProduct)
            .AddInput(2, Ids.Products.Coal)
            .SetDuration(20, Seconds())
            .AddOutput(8, ExampleModIds.Products.ExampleMoltenProduct)
            .AddOutput(24, Ids.Products.Exhaust, outputAtStart: true)
            .BuildAndAdd();

But what is correct and what not? Sometime it is correct and working incl. compiling the code but it could also be wrong and this confuses me a little bit. Would be nice to get feedback on this :)

Cheer and keep up the good work 👋 🥂

NotoriousPyro commented 2 years ago

This is provided by Mafi.DurationExtensions.Seconds() which is an extension of int. You can see the definitions if you look at the binaries Mafi.Base and Mafi.Core in a .NET inspector. Can be written as

Mafi.DurationExtensions.Seconds(60);
60.Seconds();

The SetDuration takes Duration as parameter, not two different parameters (20 and Seconds() - which by the way makes no sense that Seconds would be a lone function parameter, maybe if it was Seconds(20) but not 20, Seconds())