A framework for writing game modes for SA-MP in C#. SA-MP is a free Massively Multiplayer Online game mod for the PC version of Rockstar Games Grand Theft Auto: San Andreas.
There are two overloads for AddComponent method, and they are not so convenient to use.
T AddComponent<T>(EntityId entity) where T : Component;
T AddComponent<T>(EntityId entity, params object[] args) where T : Component;
Using params object[] args destroys the whole advantages of having language server intelli-sense. There are no suggestions on what we can pass into the arguments.
Besides, this using reflection to create instance is also a bit slower.
Instead, I'd suggest adding this overload:
T AddComponent<T>(EntityId entity, T value) where T : Component;
The method becomes much more shorter and nicer to use, considering the example below:
public class MyComponent : Component
{
public long Id { get; set; }
public string Name { get; set; }
}
AddComponent(entity, new Component() { Id = 1, Name = "abc" });
There are two overloads for
AddComponent
method, and they are not so convenient to use.Using
params object[] args
destroys the whole advantages of having language server intelli-sense. There are no suggestions on what we can pass into the arguments. Besides, this using reflection to create instance is also a bit slower.Instead, I'd suggest adding this overload:
The method becomes much more shorter and nicer to use, considering the example below: