Fix CreateServerEventString
Prevents AmbiguousMatchException Reuses GetComponentString to get the component Fixes wrong Invoke Parameters
This commit is contained in:
@@ -61,26 +61,26 @@ namespace Barotrauma
|
|||||||
{
|
{
|
||||||
public object CreateServerEventString(string component)
|
public object CreateServerEventString(string component)
|
||||||
{
|
{
|
||||||
Type type = Type.GetType("Barotrauma.Items.Components." + component);
|
var comp = GetComponentString(component);
|
||||||
|
|
||||||
if (type == null)
|
if (comp == null)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
MethodInfo method = typeof(Item).GetMethod(nameof(Item.CreateServerEvent));
|
MethodInfo method = typeof(Item).GetMethod(nameof(Item.CreateServerEvent), new Type[]{ Type.MakeGenericMethodParameter(0) });
|
||||||
MethodInfo generic = method.MakeGenericMethod(type);
|
MethodInfo generic = method.MakeGenericMethod(comp.GetType());
|
||||||
return generic.Invoke(this, null);
|
return generic.Invoke(this, new object[]{ comp });
|
||||||
}
|
}
|
||||||
|
|
||||||
public object CreateServerEventString(string component, object[] extraData)
|
public object CreateServerEventString(string component, object[] extraData)
|
||||||
{
|
{
|
||||||
Type type = Type.GetType("Barotrauma.Items.Components." + component);
|
var comp = GetComponentString(component);
|
||||||
|
|
||||||
if (type == null)
|
if (comp == null)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
MethodInfo method = typeof(Item).GetMethod(nameof(Item.CreateServerEvent));
|
MethodInfo method = typeof(Item).GetMethod(nameof(Item.CreateServerEvent), new Type[]{ Type.MakeGenericMethodParameter(0), typeof(object[]) });
|
||||||
MethodInfo generic = method.MakeGenericMethod(type);
|
MethodInfo generic = method.MakeGenericMethod(comp.GetType());
|
||||||
return generic.Invoke(this, new object[]{ extraData });
|
return generic.Invoke(this, new object[]{comp, extraData });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -133,4 +133,4 @@ namespace Barotrauma.Items.Components
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user