Skip to content

Commit f61521a

Browse files
Update entity-factories.md
1 parent ee643c8 commit f61521a

File tree

1 file changed

+24
-1
lines changed

1 file changed

+24
-1
lines changed

docs/articles/entity-factories.md

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,4 +54,27 @@ public class SampleResource : Resource {
5454

5555
This also works when you extend ```AsyncResource``` ect.
5656

57-
It works exactly the same for vehicles.
57+
## Vehicle class
58+
59+
It works the same for vehicles, but with a small difference, because you can create vehicles via the constructor by defining the vehicle model, position and rotation.
60+
61+
Thats why you most likely will add a second constructor to the vehicle that looks like this.
62+
63+
```csharp
64+
public class MyVehicle : Vehicle
65+
{
66+
public int MyData { get; set; }
67+
68+
// This constructor is used for creation via constructor
69+
public MyVehicle(uint model, Position position, Rotation rotation) : base(model, position, rotation)
70+
{
71+
MyData = 7;
72+
}
73+
74+
// This constructor is used for creation via entity factory
75+
public MyVehicle(IntPtr nativePointer, ushort id) : base(nativePointer, id)
76+
{
77+
MyData = 6;
78+
}
79+
}
80+
```

0 commit comments

Comments
 (0)