public static Bullet Bullet <TAmmoType>(Vec2 position, AmmoTypeModifier modifier, Thing owner = null, float angleDegress = 0, Thing firedFrom = null) where TAmmoType : AmmoType, new() { var ammoType = FastNew.CreateInstance <TAmmoType>(); modifier(ref ammoType.bulletSpeed, ref ammoType.range); return(ammoType.FireBullet(position, owner, angleDegress, firedFrom)); }
public void FN_Struct_PrivateConstructor() { const int expectedNum = int.MaxValue; const string expectedText = "test"; var value = FastNew <TStructPrivateConstructor, int, string> .CreateInstance(expectedNum, expectedText); Assert.Multiple(() => { Assert.AreEqual(expectedNum, value.i); Assert.AreEqual(expectedText, value.text); }); }
public void FN_Class_Parameters() { const int expectedNum = int.MaxValue; const string expectedText = "test"; var value = FastNew <TClassWithParam, int, string> .CreateInstance(expectedNum, expectedText); Assert.Multiple(() => { Assert.NotNull(value); Assert.AreEqual(expectedNum, value.i); Assert.AreEqual(expectedText, value.text); }); }
public Example FastNewT() => FastNew <Example> .CreateInstance();
public void FN_Struct() { var value = FastNew <TStruct> .CreateInstance(); Assert.AreEqual(default(TStruct), value); }
public void FN_Class() { var value = FastNew <TClass> .CreateInstance(); Assert.NotNull(value); }
public void FN_Object() { var value = FastNew <object> .CreateInstance(); Assert.NotNull(value); }
public ExampleValueType FastNewT() => FastNew <ExampleValueType> .CreateInstance();
private static TAmmoType GetAmmoTypeInstance <TAmmoType>() where TAmmoType : AmmoType, new() { return(FastNew.CreateInstance <TAmmoType>()); //return InstanceOf<TAmmoType>.instance; }