When reversing Unity dll, the decompiler (i.e. dnSpy) sometimes would create a class with 2 constructors, which are mostly identical apart from some specific field set / not set.
Here is an example:
public TurretShootOrder(IGalaxyTarget target, string sectionName, GalaxyWeaponDefinition galaxyWeaponDefinition, float startShootTime, Vector3 startRandomDispersion, float startImpactTime, float endShootTime, Vector3 endRandomDispersion, float endImpactTime, int shootCount, float missProportion, int flags = 0, int salvoId = 0, int salvoTotalShootCount = 0, int inSalvoFirstShootIndex = 0)
{
this.target = target;
this.sectionName = sectionName;
AND:
public TurretShootOrder(IGalaxyTarget target, IGalaxyModuleSection targetSection, GalaxyWeaponDefinition galaxyWeaponDefinition, float startShootTime, Vector3 startRandomDispersion, float startImpactTime, float endShootTime, Vector3 endRandomDispersion, float endImpactTime, int shootCount, float missProportion, int flags = 0, int salvoId = 0, int salvoTotalShootCount = 0, int inSalvoFirstShootIndex = 0)
{
this.target = target;
this.sectionName = string.Empty;
As you can see the second implementation doesn't set the sectionName on initialization. Otherwise these constructors are identical.
So, how do I combine these 2 constructors together?
null
is in the second parameter: it could either beIGalaxyModuleSection
orstring
. C# is not my forte, but in C++, I would resolve this by putting a cast on thenull
parameter, like(IGalaxyModuleSection*)nullptr
. I don't know if the same trick would work in C#.