diff --git a/MultiTheftAuto/Account.cs b/MultiTheftAuto/Account.cs index 705a5d7..427ebe9 100644 --- a/MultiTheftAuto/Account.cs +++ b/MultiTheftAuto/Account.cs @@ -7,10 +7,8 @@ namespace MultiTheftAuto { public class Account : Element { - public Account( UInt32 userdata ) - : base( userdata ) + public Account() { - } } } diff --git a/MultiTheftAuto/Ban.cs b/MultiTheftAuto/Ban.cs index ec5e259..832c5b9 100644 --- a/MultiTheftAuto/Ban.cs +++ b/MultiTheftAuto/Ban.cs @@ -8,8 +8,7 @@ namespace MultiTheftAuto { public class Ban : Element { - public Ban( UInt32 userdata ) - : base( userdata ) + internal Ban() { } } diff --git a/MultiTheftAuto/Blip.cs b/MultiTheftAuto/Blip.cs index c4dfda6..d676492 100644 --- a/MultiTheftAuto/Blip.cs +++ b/MultiTheftAuto/Blip.cs @@ -1,4 +1,5 @@ using System; +using System.Runtime.CompilerServices; using System.Collections.Generic; using System.Linq; using System.Text; @@ -79,81 +80,53 @@ namespace MultiTheftAuto { #region Constructors - public Blip( Vector3 position, BlipIcon icon = BlipIcon.None, int size = 2, Color color = null, int ordering = 0, float visibleDistance = 99999.0f, Element visibleTo = null ) - : base( Native.Blip.Create( position, (int)icon, size, color, ordering, visibleDistance, visibleTo != null ? visibleTo.userdata : 0 ) ) + [MethodImpl( MethodImplOptions.InternalCall )] + public extern Blip( Vector3 position, BlipIcon icon = BlipIcon.None, int size = 2, Color color = null, int ordering = 0, float visibleDistance = 99999.0f, Element visibleTo = null ); + + [MethodImpl( MethodImplOptions.InternalCall )] + public extern Blip( Element element, BlipIcon icon = BlipIcon.None, int size = 2, Color color = null, int ordering = 0, float visibleDistance = 99999.0f, Element visibleTo = null ); + + internal Blip() { - - } - - public Blip( Element element, BlipIcon icon = BlipIcon.None, int size = 2, Color color = null, int ordering = 0, float visibleDistance = 99999.0f, Element visibleTo = null ) - : base( Native.Blip.CreateAttachedTo( element.userdata, (int)icon, size, color, ordering, visibleDistance, visibleTo != null ? visibleTo.userdata : 0 ) ) - { - - } - - public Blip( UInt32 userdata ) - : base( userdata ) - { - } #endregion #region Get functions - public int GetIcon() - { - return Native.Blip.GetIcon( this.userdata ); - } + [MethodImpl( MethodImplOptions.InternalCall )] + public extern int GetIcon(); - public int GetSize() - { - return Native.Blip.GetSize( this.userdata ); - } + [MethodImpl( MethodImplOptions.InternalCall )] + public extern int GetSize(); - public Color GetColor() - { - return Native.Blip.GetColor( this.userdata ); - } + [MethodImpl( MethodImplOptions.InternalCall )] + public extern Color GetColor(); - public int GetOrdering() - { - return Native.Blip.GetOrdering( this.userdata ); - } + [MethodImpl( MethodImplOptions.InternalCall )] + public extern int GetOrdering(); - public float GetVisibleDistance() - { - return Native.Blip.GetVisibleDistance( this.userdata ); - } + [MethodImpl( MethodImplOptions.InternalCall )] + public extern float GetVisibleDistance(); #endregion #region Set functions - public bool SetIcon( int icon ) - { - return Native.Blip.SetIcon( this.userdata, icon ); - } + [MethodImpl( MethodImplOptions.InternalCall )] + public extern bool SetIcon( int icon ); - public bool SetSize( int size ) - { - return Native.Blip.SetSize( this.userdata, size ); - } + [MethodImpl( MethodImplOptions.InternalCall )] + public extern bool SetSize( int size ); - public bool SetColor( Color color ) - { - return Native.Blip.SetColor( this.userdata, color ); - } + [MethodImpl( MethodImplOptions.InternalCall )] + public extern bool SetColor( Color color ); - public bool SetOrdering( int ordering ) - { - return Native.Blip.SetOrdering( this.userdata, ordering ); - } + [MethodImpl( MethodImplOptions.InternalCall )] + public extern bool SetOrdering( int ordering ); - public bool SetVisibleDistance( float distance ) - { - return Native.Blip.SetVisibleDistance( this.userdata, distance ); - } + [MethodImpl( MethodImplOptions.InternalCall )] + public extern bool SetVisibleDistance( float distance ); #endregion } diff --git a/MultiTheftAuto/ColShape.cs b/MultiTheftAuto/ColShape.cs index 39048b4..9560fe2 100644 --- a/MultiTheftAuto/ColShape.cs +++ b/MultiTheftAuto/ColShape.cs @@ -1,4 +1,5 @@ using System; +using System.Runtime.CompilerServices; using System.Collections.Generic; using System.Linq; using System.Text; @@ -8,64 +9,44 @@ namespace MultiTheftAuto { public class ColShape : Element { - public ColShape( UInt32 userdata ) - : base( userdata ) + public ColShape() { - } } public class ColCircle : ColShape { - public ColCircle( float x, float y, float radius ) - : base( Native.ColShape.CreateCircle( x, y, radius ) ) - { - - } + [MethodImpl( MethodImplOptions.InternalCall )] + public extern ColCircle( Vector2 position, float radius ); } public class ColCuboid : ColShape { - public ColCuboid( float x, float y, float z, float width, float depth, float height ) - : base( Native.ColShape.CreateCuboid( x, y, z, width, depth, height ) ) - { - - } + [MethodImpl( MethodImplOptions.InternalCall )] + public extern ColCuboid( Vector3 position, Vector3 size ); } public class ColSphere : ColShape { - public ColSphere( float x, float y, float z, float fadius ) - : base( Native.ColShape.CreateSphere( x, y, z, fadius ) ) - { - - } + [MethodImpl( MethodImplOptions.InternalCall )] + public extern ColSphere( Vector3 position, float fadius ); } public class ColRectangle : ColShape { - public ColRectangle( float x, float y, float width, float height ) - : base( Native.ColShape.CreateRectangle( x, y, width, height ) ) - { - - } + [MethodImpl( MethodImplOptions.InternalCall )] + public extern ColRectangle( Vector2 position, Vector2 size ); } public class ColPolygon : ColShape { - public ColPolygon( float x, float y, float x1, float y1, float x2, float y2, float x3, float y3, params float[] args ) - : base( Native.ColShape.CreatePolygon( x, y, x1, y1, x2, y2, x3, y3, args ) ) - { - - } + [MethodImpl( MethodImplOptions.InternalCall )] + public extern ColPolygon( Vector2 pos1, Vector2 pos2, Vector2 pos3, Vector2 pos4, params Vector2[] args ); } public class ColTube : ColShape { - public ColTube( float x, float y, float z, float radius, float height ) - : base( Native.ColShape.CreateTube( x, y, z, radius, height ) ) - { - - } + [MethodImpl( MethodImplOptions.InternalCall )] + public extern ColTube( Vector3 position, float radius, float height ); } } diff --git a/MultiTheftAuto/Console.cs b/MultiTheftAuto/Console.cs index fff1b5f..b77b8cf 100644 --- a/MultiTheftAuto/Console.cs +++ b/MultiTheftAuto/Console.cs @@ -1,4 +1,5 @@ using System; +using System.Runtime.CompilerServices; using System.Collections.Generic; using System.Linq; using System.Text; @@ -8,15 +9,12 @@ namespace MultiTheftAuto { public class Console : Player { - public Console( uint userdata ) : - base( userdata ) + private Console() { } - public static bool Output( string text, Element element = null ) - { - return Native.Server.OutputConsole( text, element == null ? Element.Root.userdata : element.userdata ); - } + [MethodImpl( MethodImplOptions.InternalCall )] + public static extern bool Output( string text, Element element = null ); public static int Read() { @@ -38,14 +36,20 @@ namespace MultiTheftAuto return System.Console.ReadLine(); } - public static bool Write( string message, params string[] args ) + [MethodImpl( MethodImplOptions.InternalCall )] + private static extern void Write( string message ); + + [MethodImpl( MethodImplOptions.InternalCall )] + private static extern void WriteLine( string message ); + + public static void Write( string message, params object[] args ) { - return Native.Server.OutputServerLog( string.Format( message, args ) ); + Write( String.Format( message, args ) ); } - public static bool WriteLine( string message, params string[] args ) + public static void WriteLine( string message, params object[] args ) { - return Native.Server.OutputServerLog( string.Format( message, args ) ); + WriteLine( String.Format( message, args ) ); } } } diff --git a/MultiTheftAuto/Element.cs b/MultiTheftAuto/Element.cs index 4dac956..5472cc0 100644 --- a/MultiTheftAuto/Element.cs +++ b/MultiTheftAuto/Element.cs @@ -1,33 +1,20 @@ using System; +using System.Runtime.CompilerServices; using System.Collections.Generic; using System.Linq; using MultiTheftAuto.EventArgs; -using MultiTheftAuto.Pools; -using MultiTheftAuto.Utils; namespace MultiTheftAuto { - public class Element : IdentifiedPool, IIdentifyable + public class Element { - #region Properties - - public UInt32 userdata - { - get; - private set; - } - - #endregion - #region Static properties public static Element Root { get { - UInt32 userdata = Native.Element.GetRootElement(); - - return userdata != 0 ? Element.FindOrCreate( userdata ) : null; + return Element.GetRootElement(); } } @@ -35,16 +22,16 @@ namespace MultiTheftAuto #region Constructors - public Element( UInt32 userdata ) - { - this.userdata = userdata; + [MethodImpl( MethodImplOptions.InternalCall )] + public extern Element( string type, string ID ); - FindOrCreate( userdata ); + internal Element() + { } - public Element( string type, string ID ) - : this( Native.Element.Create( type, ID ) ) + ~Element() { + Debug.Info( "~Element() [0x" + this + "]" ); } #endregion @@ -53,282 +40,172 @@ namespace MultiTheftAuto #region Set - public bool Destroy() - { - bool result = Native.Element.Destroy( this.userdata ); + [MethodImpl( MethodImplOptions.InternalCall )] + public extern bool Destroy(); - if( result ) - { - this.userdata = 0; + [MethodImpl( MethodImplOptions.InternalCall )] + public extern Element Clone( Vector3 position = null, bool cloneChildren = false ); - this.Dispose(); - } + [MethodImpl( MethodImplOptions.InternalCall )] + public extern bool ClearElementVisibleTo(); - return result; - } + [MethodImpl( MethodImplOptions.InternalCall )] + public extern bool SetID( string id ); - public Element Clone( Vector3 position = null, bool cloneChildren = false ) - { - return Element.FindOrCreate( Native.Element.Clone( this.userdata, position, cloneChildren ) ); - } + [MethodImpl( MethodImplOptions.InternalCall )] + public extern bool SetData( string key, string value, bool sync = true ); - public bool ClearElementVisibleTo() - { - return Native.Element.ClearElementVisibleTo( this.userdata ); - } + [MethodImpl( MethodImplOptions.InternalCall )] + public extern bool RemoveData( string key ); - public bool SetID( string id ) - { - return Native.Element.SetID( this.userdata, id ); - } + [MethodImpl( MethodImplOptions.InternalCall )] + public extern bool SetParent( Element parent ); - public bool SetData( string key, string value, bool sync = true ) - { - return Native.Element.SetData( this.userdata, key, value, sync ); - } + [MethodImpl( MethodImplOptions.InternalCall )] + public extern bool SetPosition( Vector3 position, bool warp = true ); - public bool RemoveData( string key ) - { - return Native.Element.RemoveData( this.userdata, key ); - } + [MethodImpl( MethodImplOptions.InternalCall )] + public extern bool SetRotation( Vector3 rotation, string order = "default", bool pedRotation = false ); - public bool SetParent( UInt32 parent ) - { - return Native.Element.SetParent( this.userdata, parent ); - } + [MethodImpl( MethodImplOptions.InternalCall )] + public extern bool SetVelocity( Vector3 velocity ); - public bool SetPosition( Vector3 position, bool warp = true ) - { - return Native.Element.SetPosition( this.userdata, position, warp ); - } + [MethodImpl( MethodImplOptions.InternalCall )] + public extern bool SetVisibleTo( Element target, bool visible ); - public bool SetRotation( Vector3 rotation, string order = "default", bool pedRotation = false ) - { - return Native.Element.SetRotation( this.userdata, rotation, order, pedRotation ); - } + [MethodImpl( MethodImplOptions.InternalCall )] + public extern bool SetInterior( int interior, Vector3 position = null ); - public bool SetVelocity( Vector3 velocity ) - { - return Native.Element.SetVelocity( this.userdata, velocity ); - } + [MethodImpl( MethodImplOptions.InternalCall )] + public extern bool SetDimension( int dimension ); - public bool SetVisibleTo( Element target, bool visible ) - { - return Native.Element.SetVisibleTo( this.userdata, target.GetUserData(), visible ); - } + [MethodImpl( MethodImplOptions.InternalCall )] + public extern bool Attach( Element target, Vector3 offsetPosition = null, Vector3 offsetRotation = null ); - public bool SetInterior( int interior, Vector3 position = null ) - { - return Native.Element.SetInterior( this.userdata, interior, position ); - } + [MethodImpl( MethodImplOptions.InternalCall )] + public extern bool Detach( Element target ); - public bool SetDimension( int dimension ) - { - return Native.Element.SetDimension( this.userdata, dimension ); - } + [MethodImpl( MethodImplOptions.InternalCall )] + public extern bool SetAlpha( int alpha ); - public bool Attach( Element target, Vector3 offsetPosition = null, Vector3 offsetRotation = null ) - { - return Native.Element.Attach( this.userdata, target.GetUserData(), offsetPosition, offsetRotation ); - } + [MethodImpl( MethodImplOptions.InternalCall )] + public extern bool SetDoubleSided( bool doublesided ); - public bool Detach( Element target ) - { - return Native.Element.Detach( this.userdata, target.GetUserData() ); - } + [MethodImpl( MethodImplOptions.InternalCall )] + public extern bool SetHealth( float health ); - public bool SetAlpha( int alpha ) - { - return Native.Element.SetAlpha( this.userdata, alpha ); - } + [MethodImpl( MethodImplOptions.InternalCall )] + public extern bool SetModel( int model ); - public bool SetDoubleSided( bool doublesided ) - { - return Native.Element.SetDoubleSided( this.userdata, doublesided ); - } + [MethodImpl( MethodImplOptions.InternalCall )] + public extern bool SetAttachedOffsets( Vector3 offsetPosition = null, Vector3 offsetRotation = null ); - public bool SetHealth( float health ) - { - return Native.Element.SetHealth( this.userdata, health ); - } + [MethodImpl( MethodImplOptions.InternalCall )] + public extern bool SetSyncer( Player player ); - public bool SetModel( int model ) - { - return Native.Element.SetModel( this.userdata, model ); - } + [MethodImpl( MethodImplOptions.InternalCall )] + public extern bool SetCollisionsEnabled( bool enabled ); - public bool SetAttachedOffsets( Vector3 offsetPosition = null, Vector3 offsetRotation = null ) - { - return Native.Element.SetAttachedOffsets( this.userdata, offsetPosition, offsetRotation ); - } + [MethodImpl( MethodImplOptions.InternalCall )] + public extern bool SetFrozen( bool frozen ); - public bool SetSyncer( Player player ) - { - return Native.Element.SetSyncer( this.userdata, player.GetUserData() ); - } - - public bool SetCollisionsEnabled( bool enabled ) - { - return Native.Element.SetCollisionsEnabled( this.userdata, enabled ); - } - - public bool SetFrozen( bool frozen ) - { - return Native.Element.SetFrozen( this.userdata, frozen ); - } - - public bool SetLowLODElement( Element element ) - { - return Native.Element.SetLowLODElement( this.userdata, element.GetUserData() ); - } + [MethodImpl( MethodImplOptions.InternalCall )] + public extern bool SetLowLODElement( Element element ); #endregion #region Get - public string GetID() - { - return Native.Element.GetID( this.userdata ); - } + [MethodImpl( MethodImplOptions.InternalCall )] + public extern uint GetUserData(); - public string GetData( string key, bool inherit = true ) - { - return Native.Element.GetData( this.userdata, key, inherit ); - } + [MethodImpl( MethodImplOptions.InternalCall )] + public extern string GetID(); - public string GetElementType() - { - return Native.Element.GetType( this.userdata ); - } + [MethodImpl( MethodImplOptions.InternalCall )] + public extern object GetData( string key, bool inherit = true ); - public Object GetChild( UInt32 parent, int index ) - { - return Element.FindOrCreate( Native.Element.GetChild( this.userdata, index ) ); - } + [MethodImpl( MethodImplOptions.InternalCall )] + public extern string GetElementType(); - public int GetChildrenCount() - { - return Native.Element.GetChildrenCount( this.userdata ); - } + [MethodImpl( MethodImplOptions.InternalCall )] + public extern object GetChild( int index ); - public Object GetParent() - { - return Element.FindOrCreate( Native.Element.GetParent( this.userdata ) ); - } + [MethodImpl( MethodImplOptions.InternalCall )] + public extern int GetChildrenCount(); - public Vector3 GetPosition() - { - return Native.Element.GetPosition( this.userdata ); - } + [MethodImpl( MethodImplOptions.InternalCall )] + public extern object GetParent(); - public Vector3 GetRotation( string order = "default" ) - { - return Native.Element.GetRotation( this.userdata, order ); - } + [MethodImpl( MethodImplOptions.InternalCall )] + public extern Vector3 GetPosition(); - public Vector3 GetVelocity() - { - return Native.Element.GetVelocity( this.userdata ); - } + [MethodImpl( MethodImplOptions.InternalCall )] + public extern Vector3 GetRotation( string order = "default" ); - public int GetInterior() - { - return Native.Element.GetInterior( this.userdata ); - } + [MethodImpl( MethodImplOptions.InternalCall )] + public extern Vector3 GetVelocity(); - public int GetDimension() - { - return Native.Element.GetDimension( this.userdata ); - } + [MethodImpl( MethodImplOptions.InternalCall )] + public extern int GetInterior(); - public string GetZoneName() - { - return Native.Element.GetZoneName( this.userdata ); - } + [MethodImpl( MethodImplOptions.InternalCall )] + public extern int GetDimension(); - public Object GetAttachedTo() - { - return Element.FindOrCreate( Native.Element.GetAttachedTo( this.userdata ) ); - } + [MethodImpl( MethodImplOptions.InternalCall )] + public extern string GetZoneName(); - public Object GetColShape() - { - return Element.FindOrCreate( Native.Element.GetColShape( this.userdata ) ); - } + [MethodImpl( MethodImplOptions.InternalCall )] + public extern Element GetAttachedTo(); - public int GetAlpha() - { - return Native.Element.GetAlpha( this.userdata ); - } + [MethodImpl( MethodImplOptions.InternalCall )] + public extern Element GetColShape(); - public float GetHealth() - { - return Native.Element.GetHealth( this.userdata ); - } + [MethodImpl( MethodImplOptions.InternalCall )] + public extern int GetAlpha(); - public int GetModel() - { - return Native.Element.GetModel( this.userdata ); - } + [MethodImpl( MethodImplOptions.InternalCall )] + public extern float GetHealth(); - public Player GetSyncer() - { - return Element.FindOrCreate( Native.Element.GetSyncer( this.userdata ) ) as Player; - } + [MethodImpl( MethodImplOptions.InternalCall )] + public extern int GetModel(); - public bool GetCollisionsEnabled() - { - return Native.Element.GetCollisionsEnabled( this.userdata ); - } + [MethodImpl( MethodImplOptions.InternalCall )] + public extern Player GetSyncer(); - public Object GetLowLODElement() - { - return Element.FindOrCreate( Native.Element.GetLowLODElement( this.userdata ) ); - } + [MethodImpl( MethodImplOptions.InternalCall )] + public extern bool GetCollisionsEnabled(); + + [MethodImpl( MethodImplOptions.InternalCall )] + public extern Element GetLowLODElement(); #endregion #region Is - public bool IsValid() - { - return Native.Element.IsElement( this.userdata ); - } + [MethodImpl( MethodImplOptions.InternalCall )] + public extern bool IsValid(); - public bool IsWithinColShape( ColShape colshape ) - { - return Native.Element.IsWithinColShape( this.userdata, colshape.GetUserData() ); - } + [MethodImpl( MethodImplOptions.InternalCall )] + public extern bool IsWithinColShape( ColShape colshape ); - public bool IsWithinMarker( Marker marker ) - { - return Native.Element.IsWithinMarker( this.userdata, marker.GetUserData() ); - } + [MethodImpl( MethodImplOptions.InternalCall )] + public extern bool IsWithinMarker( Marker marker ); - public bool IsAttached() - { - return Native.Element.IsAttached( this.userdata ); - } + [MethodImpl( MethodImplOptions.InternalCall )] + public extern bool IsAttached(); - public bool IsDoubleSided() - { - return Native.Element.IsDoubleSided( this.userdata ); - } + [MethodImpl( MethodImplOptions.InternalCall )] + public extern bool IsDoubleSided(); - public bool IsInWater() - { - return Native.Element.IsInWater( this.userdata ); - } + [MethodImpl( MethodImplOptions.InternalCall )] + public extern bool IsInWater(); - public bool IsFrozen() - { - return Native.Element.IsFrozen( this.userdata ); - } + [MethodImpl( MethodImplOptions.InternalCall )] + public extern bool IsFrozen(); - public bool IsElementLowLOD() - { - return Native.Element.IsElementLowLOD( this.userdata ); - } + [MethodImpl( MethodImplOptions.InternalCall )] + public extern bool IsElementLowLOD(); #endregion @@ -337,37 +214,30 @@ namespace MultiTheftAuto return (int)this.GetHashCode(); } - public uint GetUserData() - { - return this.userdata; - } - public override string ToString() { - return string.Format( "[{0}: 0x{1}]", this.GetType().Name, this.userdata.ToString( "X8" ) ); + return string.Format( "[{0}: 0x{1}]", this.GetType().Name, this.GetUserData().ToString( "X8" ) ); } #endregion #region Static methods + [MethodImpl( MethodImplOptions.InternalCall )] + public static extern Element GetRootElement(); + + [MethodImpl( MethodImplOptions.InternalCall )] + public static extern Element[] GetByType( string elementType ); + + [MethodImpl( MethodImplOptions.InternalCall )] + public static extern Element GetByID( string elementID, int index = 0 ); + + [MethodImpl( MethodImplOptions.InternalCall )] + public static extern Element GetByIndex( string type, int index ); + public static IEnumerable GetByType( string elementType ) where T : class { - return Native.Element.GetByType( elementType ).Select( i => Element.FindOrCreate( i ) as T ); - } - - public static Object GetByID( string elementID, int index = 0 ) - { - UInt32 userdata = Native.Element.GetByID( elementID, index ); - - return userdata != 0 ? Element.FindOrCreate( userdata ) : null; - } - - public static Object GetByIndex( string type, int index ) - { - UInt32 userdata = Native.Element.GetByIndex( type, index ); - - return userdata != 0 ? Element.FindOrCreate( userdata ) : null; + return GetByType( elementType ).Select( i => i as T ); } #endregion diff --git a/MultiTheftAuto/Marker.cs b/MultiTheftAuto/Marker.cs index edc3003..ca1e41c 100644 --- a/MultiTheftAuto/Marker.cs +++ b/MultiTheftAuto/Marker.cs @@ -9,8 +9,7 @@ namespace MultiTheftAuto { #region Constructors - public Marker( UInt32 userdata ) - : base( userdata ) + public Marker() { } diff --git a/MultiTheftAuto/Ped.cs b/MultiTheftAuto/Ped.cs index 4d0a10a..63b16be 100644 --- a/MultiTheftAuto/Ped.cs +++ b/MultiTheftAuto/Ped.cs @@ -1,4 +1,5 @@ using System; +using System.Runtime.CompilerServices; using System.Collections.Generic; using System.Linq; using System.Text; @@ -25,16 +26,11 @@ namespace MultiTheftAuto #region Constructors - public Ped( UInt32 userdata ) - : base( userdata ) - { + [MethodImpl( MethodImplOptions.InternalCall )] + public extern Ped( int modelid, Vector3 position, float rot = 0.0f, bool synced = true ); - } - - public Ped( int modelid, Vector3 position, float rot = 0.0f, bool synced = true ) - : base( Native.Ped.Create( modelid, position, rot, synced ) ) + internal Ped() { - } #endregion @@ -43,213 +39,133 @@ namespace MultiTheftAuto #region Set - public bool SetArmor( int armor ) - { - return Native.Ped.SetArmor( this.GetUserData(), armor ); - } + [MethodImpl( MethodImplOptions.InternalCall )] + public extern bool SetArmor( int armor ); - public bool Kill( Ped killer = null, int weapon = 255, int bodyPart = 255, bool stealth = false ) - { - return Native.Ped.Kill( this.GetUserData(), killer != null ? killer.GetUserData() : 0, weapon, bodyPart, stealth ); - } + [MethodImpl( MethodImplOptions.InternalCall )] + public extern bool Kill( Ped killer = null, int weapon = 255, int bodyPart = 255, bool stealth = false ); - public bool SetStat( int stat, float value ) - { - return Native.Ped.SetStat( this.GetUserData(), stat, value ); - } + [MethodImpl( MethodImplOptions.InternalCall )] + public extern bool SetStat( int stat, float value ); - public bool AddClothes( string clothesTexture, string clothesModel, int clothesType ) - { - return Native.Ped.AddClothes( this.GetUserData(), clothesTexture, clothesModel, clothesType ); - } + [MethodImpl( MethodImplOptions.InternalCall )] + public extern bool AddClothes( string clothesTexture, string clothesModel, int clothesType ); - public bool RemoveClothes( int clothesType, string clothesTexture, string clothesModel ) - { - return Native.Ped.RemoveClothes( this.GetUserData(), clothesType, clothesTexture, clothesModel ); - } + [MethodImpl( MethodImplOptions.InternalCall )] + public extern bool RemoveClothes( int clothesType, string clothesTexture, string clothesModel ); - public bool GiveJetPack() - { - return Native.Ped.GiveJetPack( this.GetUserData() ); - } + [MethodImpl( MethodImplOptions.InternalCall )] + public extern bool GiveJetPack(); - public bool RemoveJetPack() - { - return Native.Ped.RemoveJetPack( this.GetUserData() ); - } + [MethodImpl( MethodImplOptions.InternalCall )] + public extern bool RemoveJetPack(); - public bool SetFightingStyle( int style ) - { - return Native.Ped.SetFightingStyle( this.GetUserData(), style ); - } + [MethodImpl( MethodImplOptions.InternalCall )] + public extern bool SetFightingStyle( int style ); - public bool SetPedMoveAnim( int style ) - { - return Native.Ped.SetPedMoveAnim( this.GetUserData(), style ); - } + [MethodImpl( MethodImplOptions.InternalCall )] + public extern bool SetPedMoveAnim( int style ); - public bool SetGravity( float gravity ) - { - return Native.Ped.SetGravity( this.GetUserData(), gravity ); - } + [MethodImpl( MethodImplOptions.InternalCall )] + public extern bool SetGravity( float gravity ); - public bool SetChoking( bool choking ) - { - return Native.Ped.SetChoking( this.GetUserData(), choking ); - } + [MethodImpl( MethodImplOptions.InternalCall )] + public extern bool SetChoking( bool choking ); - public bool WarpIntoVehicle( Vehicle vehicle, int seat = 0 ) - { - return Native.Ped.WarpIntoVehicle( this.GetUserData(), vehicle.GetUserData(), seat ); - } + [MethodImpl( MethodImplOptions.InternalCall )] + public extern bool WarpIntoVehicle( Vehicle vehicle, int seat = 0 ); - public bool RemoveFromVehicle() - { - return Native.Ped.RemoveFromVehicle( this.GetUserData() ); - } + [MethodImpl( MethodImplOptions.InternalCall )] + public extern bool RemoveFromVehicle(); - public bool SetDoingGangDriveby( bool state ) - { - return Native.Ped.SetDoingGangDriveby( this.GetUserData(), state ); - } + [MethodImpl( MethodImplOptions.InternalCall )] + public extern bool SetDoingGangDriveby( bool state ); - public bool SetAnimation( string block = null, string anim = null, int time = -1, bool loop = true, bool updatePosition = true, bool interruptable = true, bool freezeLastFrame = true ) - { - return Native.Ped.SetAnimation( this.GetUserData(), block, anim, time, loop, updatePosition, interruptable, freezeLastFrame ); - } + [MethodImpl( MethodImplOptions.InternalCall )] + public extern bool SetAnimation( string block = null, string anim = null, int time = -1, bool loop = true, bool updatePosition = true, bool interruptable = true, bool freezeLastFrame = true ); - public bool SetAnimationProgress( string anim, float progress ) - { - return Native.Ped.SetAnimationProgress( this.GetUserData(), anim, progress ); - } + [MethodImpl( MethodImplOptions.InternalCall )] + public extern bool SetAnimationProgress( string anim, float progress ); - public bool SetWeaponSlot( int weaponSlot ) - { - return Native.Ped.SetWeaponSlot( this.GetUserData(), weaponSlot ); - } + [MethodImpl( MethodImplOptions.InternalCall )] + public extern bool SetWeaponSlot( int weaponSlot ); - public bool SetOnFire( bool isOnFire ) - { - return Native.Ped.SetOnFire( this.GetUserData(), isOnFire ); - } + [MethodImpl( MethodImplOptions.InternalCall )] + public extern bool SetOnFire( bool isOnFire ); - public bool SetHeadless( bool headless ) - { - return Native.Ped.SetHeadless( this.GetUserData(), headless ); - } + [MethodImpl( MethodImplOptions.InternalCall )] + public extern bool SetHeadless( bool headless ); - public bool ReloadWeapon() - { - return Native.Ped.ReloadWeapon( this.GetUserData() ); - } + [MethodImpl( MethodImplOptions.InternalCall )] + public extern bool ReloadWeapon(); #endregion #region Get - - public float GetArmor() - { - return Native.Ped.GetArmor( this.GetUserData() ); - } - public float GetStat( int stat ) - { - return Native.Ped.GetStat( this.GetUserData(), stat ); - } + [MethodImpl( MethodImplOptions.InternalCall )] + public extern float GetArmor(); - public Object GetTarget() - { - return Element.FindOrCreate( Native.Ped.GetTarget( this.GetUserData() ) ); - } + [MethodImpl( MethodImplOptions.InternalCall )] + public extern float GetStat( int stat ); - public int GetWeapon( int slot = 0 ) - { - return Native.Ped.GetWeapon( this.GetUserData(), slot ); - } + [MethodImpl( MethodImplOptions.InternalCall )] + public extern Element GetTarget(); - public int GetFightingStyle() - { - return Native.Ped.GetFightingStyle( this.GetUserData() ); - } + [MethodImpl( MethodImplOptions.InternalCall )] + public extern int GetWeapon( int slot = 0 ); - public int GetPedMoveAnim() - { - return Native.Ped.GetPedMoveAnim( this.GetUserData() ); - } + [MethodImpl( MethodImplOptions.InternalCall )] + public extern int GetFightingStyle(); - public float GetGravity() - { - return Native.Ped.GetGravity( this.GetUserData() ); - } + [MethodImpl( MethodImplOptions.InternalCall )] + public extern int GetPedMoveAnim(); - public Object GetContactElement() - { - return Element.FindOrCreate( Native.Ped.GetContactElement( this.GetUserData() ) ); - } + [MethodImpl( MethodImplOptions.InternalCall )] + public extern float GetGravity(); - public int GetWeaponSlot() - { - return Native.Ped.GetWeaponSlot( this.GetUserData() ); - } + [MethodImpl( MethodImplOptions.InternalCall )] + public extern Element GetContactElement(); - public Vehicle GetVehicle() - { - return Element.FindOrCreate( Native.Ped.GetOccupiedVehicle( this.GetUserData() ) ) as Vehicle; - } + [MethodImpl( MethodImplOptions.InternalCall )] + public extern int GetWeaponSlot(); - public int GetVehicleSeat() - { - return Native.Ped.GetOccupiedVehicleSeat( this.GetUserData() ); - } + [MethodImpl( MethodImplOptions.InternalCall )] + public extern Vehicle GetVehicle(); + + [MethodImpl( MethodImplOptions.InternalCall )] + public extern int GetVehicleSeat(); #endregion #region Is - public bool IsChoking() - { - return Native.Ped.IsChoking( this.GetUserData() ); - } + [MethodImpl( MethodImplOptions.InternalCall )] + public extern bool IsChoking(); - public bool IsDead() - { - return Native.Ped.IsDead( this.GetUserData() ); - } + [MethodImpl( MethodImplOptions.InternalCall )] + public extern bool IsDead(); - public bool IsDucked() - { - return Native.Ped.IsDucked( this.GetUserData() ); - } + [MethodImpl( MethodImplOptions.InternalCall )] + public extern bool IsDucked(); - public bool IsHaveJetPack() - { - return Native.Ped.DoesHaveJetPack( this.GetUserData() ); - } + [MethodImpl( MethodImplOptions.InternalCall )] + public extern bool IsHaveJetPack(); - public bool IsOnGround() - { - return Native.Ped.IsOnGround( this.GetUserData() ); - } + [MethodImpl( MethodImplOptions.InternalCall )] + public extern bool IsOnGround(); - public bool IsDoingGangDriveby() - { - return Native.Ped.IsDoingGangDriveby( this.GetUserData() ); - } + [MethodImpl( MethodImplOptions.InternalCall )] + public extern bool IsDoingGangDriveby(); - public bool IsOnFire() - { - return Native.Ped.IsOnFire( this.GetUserData() ); - } + [MethodImpl( MethodImplOptions.InternalCall )] + public extern bool IsOnFire(); - public bool IsHeadless() - { - return Native.Ped.IsHeadless( this.GetUserData() ); - } + [MethodImpl( MethodImplOptions.InternalCall )] + public extern bool IsHeadless(); - public bool IsInVehicle() - { - return Native.Ped.IsInVehicle( this.GetUserData() ); - } + [MethodImpl( MethodImplOptions.InternalCall )] + public extern bool IsInVehicle(); #endregion diff --git a/MultiTheftAuto/Pickup.cs b/MultiTheftAuto/Pickup.cs index 1566b24..3c3749b 100644 --- a/MultiTheftAuto/Pickup.cs +++ b/MultiTheftAuto/Pickup.cs @@ -8,8 +8,7 @@ namespace MultiTheftAuto { public class Pickup : Element { - public Pickup( UInt32 userdata ) - : base( userdata ) + public Pickup() { } } diff --git a/MultiTheftAuto/Player.cs b/MultiTheftAuto/Player.cs index 8349453..57e6f18 100644 --- a/MultiTheftAuto/Player.cs +++ b/MultiTheftAuto/Player.cs @@ -1,4 +1,5 @@ using System; +using System.Runtime.CompilerServices; using System.Collections.Generic; using System.Linq; using System.Text; @@ -7,283 +8,173 @@ namespace MultiTheftAuto { public class Player : Ped { - #region Constructors - - public Player( UInt32 userdata ) - : base( userdata ) - { - - } - - #endregion - #region Methods #region Set - public bool SetMoney( int money ) - { - return Native.Player.SetMoney( this.GetUserData(), money ); - } + [MethodImpl( MethodImplOptions.InternalCall )] + public extern bool SetMoney( int money ); - public bool GiveMoney( int money ) - { - return Native.Player.GiveMoney( this.GetUserData(), money ); - } + [MethodImpl( MethodImplOptions.InternalCall )] + public extern bool GiveMoney( int money ); - public bool TakeMoney( int money ) - { - return Native.Player.TakeMoney( this.GetUserData(), money ); - } + [MethodImpl( MethodImplOptions.InternalCall )] + public extern bool TakeMoney( int money ); - public bool Spawn( Vector3 position, int rotation = 0, int skinID = 0, int interior = 0, int dimension = 0, Team team = null ) - { - return Native.Player.Spawn( this.GetUserData(), position, rotation, skinID, interior, dimension, team != null ? team.GetUserData() : 0 ); - } + [MethodImpl( MethodImplOptions.InternalCall )] + public extern bool Spawn( Vector3 position, int rotation = 0, int skinID = 0, int interior = 0, int dimension = 0, Team team = null ); - public bool ShowHudComponent( string component, bool show ) - { - return Native.Player.ShowHudComponent( this.GetUserData(), component, show ); - } + [MethodImpl( MethodImplOptions.InternalCall )] + public extern bool ShowHudComponent( string component, bool show ); - public bool SetWantedLevel( int level ) - { - return Native.Player.SetWantedLevel( this.GetUserData(), level ); - } + [MethodImpl( MethodImplOptions.InternalCall )] + public extern bool SetWantedLevel( int level ); - public bool ForceMap( bool forcedOn ) - { - return Native.Player.ForceMap( this.GetUserData(), forcedOn ); - } + [MethodImpl( MethodImplOptions.InternalCall )] + public extern bool ForceMap( bool forcedOn ); - public bool SetNametagText( string text ) - { - return Native.Player.SetNametagText( this.GetUserData(), text ); - } + [MethodImpl( MethodImplOptions.InternalCall )] + public extern bool SetNametagText( string text ); - public bool SetNametagColor( Color color ) - { - return Native.Player.SetNametagColor( this.GetUserData(), color ); - } + [MethodImpl( MethodImplOptions.InternalCall )] + public extern bool SetNametagColor( Color color ); - public bool SetNametagShowing( bool showed ) - { - return Native.Player.SetNametagShowing( this.GetUserData(), showed ); - } + [MethodImpl( MethodImplOptions.InternalCall )] + public extern bool SetNametagShowing( bool showed ); - public bool SetMuted( bool muted ) - { - return Native.Player.SetMuted( this.GetUserData(), muted ); - } + [MethodImpl( MethodImplOptions.InternalCall )] + public extern bool SetMuted( bool muted ); - public bool SetBlurLevel( int level ) - { - return Native.Player.SetBlurLevel( this.GetUserData(), level ); - } + [MethodImpl( MethodImplOptions.InternalCall )] + public extern bool SetBlurLevel( int level ); - public bool Redirect( string serverIP, int serverPort, string serverPassword = null ) - { - return Native.Player.Redirect( this.GetUserData(), serverIP, serverPort, serverPassword ); - } + [MethodImpl( MethodImplOptions.InternalCall )] + public extern bool Redirect( string serverIP, int serverPort, string serverPassword = null ); - public bool SetName( string name ) - { - return Native.Player.SetName( this.GetUserData(), name ); - } + [MethodImpl( MethodImplOptions.InternalCall )] + public extern bool SetName( string name ); - public bool DetonateSatchels() - { - return Native.Player.DetonateSatchels( this.GetUserData() ); - } + [MethodImpl( MethodImplOptions.InternalCall )] + public extern bool DetonateSatchels(); - public bool TakeScreenShot( int width, int height, string tag = "", int quality = 30, int maxBandwith = 5000 ) - { - return Native.Player.TakeScreenShot( this.GetUserData(), width, height, tag, quality, maxBandwith ); - } + [MethodImpl( MethodImplOptions.InternalCall )] + public extern bool TakeScreenShot( int width, int height, string tag = "", int quality = 30, int maxBandwith = 5000 ); - public bool SetTeam( Team team ) - { - return Native.Player.SetTeam( this.GetUserData(), team.GetUserData() ); - } + [MethodImpl( MethodImplOptions.InternalCall )] + public extern bool SetTeam( Team team ); - public bool SetCameraMatrix( CameraMatrix pCameraMatrix ) - { - return Native.Player.SetCameraMatrix( this.userdata, pCameraMatrix ); - } + [MethodImpl( MethodImplOptions.InternalCall )] + public extern bool SetCameraMatrix( CameraMatrix pCameraMatrix ); - public bool SetCameraTarget( Element pTarget ) - { - return Native.Player.SetCameraTarget( this.userdata, pTarget.userdata ); - } + [MethodImpl( MethodImplOptions.InternalCall )] + public extern bool SetCameraTarget( Element pTarget ); - public bool SetCameraInterior( UInt16 ucInterior ) - { - return Native.Player.SetCameraInterior( this.userdata, ucInterior ); - } + [MethodImpl( MethodImplOptions.InternalCall )] + public extern bool SetCameraInterior( UInt16 ucInterior ); - public bool FadeCamera( bool bFadeIn, float fFadeTime, Color pColor ) - { - return Native.Player.FadeCamera( this.userdata, bFadeIn, fFadeTime, pColor ); - } + [MethodImpl( MethodImplOptions.InternalCall )] + public extern bool FadeCamera( bool bFadeIn, float fFadeTime, Color pColor ); #endregion #region Get - public int GetAmmoInClip( int weaponSlot = 0 ) - { - return Native.Player.GetAmmoInClip( this.GetUserData(), weaponSlot ); - } + [MethodImpl( MethodImplOptions.InternalCall )] + public extern int GetAmmoInClip( int weaponSlot = 0 ); - public int GetTotalAmmo( int weaponSlot = 0 ) - { - return Native.Player.GetTotalAmmo( this.GetUserData(), weaponSlot ); - } + [MethodImpl( MethodImplOptions.InternalCall )] + public extern int GetTotalAmmo( int weaponSlot = 0 ); - public bool SetWeaponAmmo( int weapon, int totalAmmo, int ammoInClip ) - { - return Native.Player.SetWeaponAmmo( this.GetUserData(), weapon, totalAmmo, ammoInClip ); - } + [MethodImpl( MethodImplOptions.InternalCall )] + public extern bool SetWeaponAmmo( int weapon, int totalAmmo, int ammoInClip ); - public Player GetFromName( string name ) - { - return Element.FindOrCreate( Native.Player.GetFromName( name ) ) as Player; - } + [MethodImpl( MethodImplOptions.InternalCall )] + public extern Player GetFromName( string name ); - public int GetMoney() - { - return Native.Player.GetMoney( this.GetUserData() ); - } + [MethodImpl( MethodImplOptions.InternalCall )] + public extern int GetMoney(); - public int GetPing() - { - return Native.Player.GetPing( this.GetUserData() ); - } + [MethodImpl( MethodImplOptions.InternalCall )] + public extern int GetPing(); - public Player GetRandom() - { - return Element.FindOrCreate( Native.Player.GetRandom() ) as Player; - } + [MethodImpl( MethodImplOptions.InternalCall )] + public extern Player GetRandom(); - public Team GetTeam() - { - return Element.FindOrCreate( Native.Player.GetTeam( this.GetUserData() ) ) as Team; - } + [MethodImpl( MethodImplOptions.InternalCall )] + public extern Team GetTeam(); - public int GetWantedLevel() - { - return Native.Player.GetWantedLevel( this.GetUserData() ); - } + [MethodImpl( MethodImplOptions.InternalCall )] + public extern int GetWantedLevel(); - public int GetIdleTime() - { - return Native.Player.GetIdleTime( this.GetUserData() ); - } + [MethodImpl( MethodImplOptions.InternalCall )] + public extern int GetIdleTime(); - public string GetNametagText() - { - return Native.Player.GetNametagText( this.GetUserData() ); - } + [MethodImpl( MethodImplOptions.InternalCall )] + public extern string GetNametagText(); - public Color GetNametagColor() - { - return Native.Player.GetNametagColor( this.GetUserData() ); - } + [MethodImpl( MethodImplOptions.InternalCall )] + public extern Color GetNametagColor(); - public string GetSerial() - { - return Native.Player.GetSerial( this.GetUserData() ); - } + [MethodImpl( MethodImplOptions.InternalCall )] + public extern string GetSerial(); - public string GetUserName() - { - return Native.Player.GetUserName( this.GetUserData() ); - } + [MethodImpl( MethodImplOptions.InternalCall )] + public extern string GetUserName(); - public int GetBlurLevel() - { - return Native.Player.GetBlurLevel( this.GetUserData() ); - } + [MethodImpl( MethodImplOptions.InternalCall )] + public extern int GetBlurLevel(); - public string GetName() - { - return Native.Player.GetName( this.GetUserData() ); - } + [MethodImpl( MethodImplOptions.InternalCall )] + public extern string GetName(); - public string GetIP() - { - return Native.Player.GetIP( this.GetUserData() ); - } + [MethodImpl( MethodImplOptions.InternalCall )] + public extern string GetIP(); - public Account GetAccount() - { - return Element.FindOrCreate( Native.Player.GetAccount( this.GetUserData() ) ) as Account; - } + [MethodImpl( MethodImplOptions.InternalCall )] + public extern Account GetAccount(); - public string GetVersion() - { - return Native.Player.GetVersion( this.GetUserData() ); - } + [MethodImpl( MethodImplOptions.InternalCall )] + public extern string GetVersion(); - public Object GetACInfo() - { - return Native.Player.GetACInfo( this.GetUserData() ); - } + [MethodImpl( MethodImplOptions.InternalCall )] + public extern PlayerACInfo GetACInfo(); - public CameraMatrix GetCameraMatrix() - { - return Native.Player.GetCameraMatrix( this.userdata ); - } + [MethodImpl( MethodImplOptions.InternalCall )] + public extern CameraMatrix GetCameraMatrix(); - public UInt32 GetCameraTarget() - { - return Native.Player.GetCameraTarget( this.userdata ); - } + [MethodImpl( MethodImplOptions.InternalCall )] + public extern Element GetCameraTarget(); - public UInt16 GetCameraInterior() - { - return Native.Player.GetCameraInterior( this.userdata ); - } + [MethodImpl( MethodImplOptions.InternalCall )] + public extern UInt16 GetCameraInterior(); #endregion #region Is - public bool IsMuted() - { - return Native.Player.IsMuted( this.GetUserData() ); - } + [MethodImpl( MethodImplOptions.InternalCall )] + public extern bool IsMuted(); - public bool IsMapForced() - { - return Native.Player.IsMapForced( this.GetUserData() ); - } + [MethodImpl( MethodImplOptions.InternalCall )] + public extern bool IsMapForced(); - public bool IsNametagShowing() - { - return Native.Player.IsNametagShowing( this.GetUserData() ); - } + [MethodImpl( MethodImplOptions.InternalCall )] + public extern bool IsNametagShowing(); #endregion #endregion #region Static - - public static Array GetAlivePlayers() - { - return Native.Player.GetAlivePlayers(); - } - public static Array GetDeadPlayers() - { - return Native.Player.GetDeadPlayers(); - } + [MethodImpl( MethodImplOptions.InternalCall )] + public extern static Player[] GetAlivePlayers(); - public static int GetCount() - { - return Native.Player.GetCount(); - } + [MethodImpl( MethodImplOptions.InternalCall )] + public extern static Player[] GetDeadPlayers(); + + [MethodImpl( MethodImplOptions.InternalCall )] + public extern static int GetCount(); #endregion } diff --git a/MultiTheftAuto/Resource.cs b/MultiTheftAuto/Resource.cs index 07c982b..1c6c716 100644 --- a/MultiTheftAuto/Resource.cs +++ b/MultiTheftAuto/Resource.cs @@ -1,4 +1,5 @@ using System; +using System.Runtime.CompilerServices; using System.Collections.Generic; using System.Linq; using System.Text; @@ -8,25 +9,15 @@ using MultiTheftAuto.Utils; namespace MultiTheftAuto { - public class Resource : IdentifiedPool, IIdentifyable + public class Resource { - #region Properties - - public UInt32 userdata - { - get; - private set; - } - - #endregion - #region Static properties public static Element Root { get { - return Element.FindOrCreate( Native.Resource.GetRootElement() ); + return Resource.GetCurrent().GetRoot(); } } @@ -34,174 +25,98 @@ namespace MultiTheftAuto #region Constuctors - public Resource( string resourceName, string organizationalDir ) - : this( Native.Resource.Create( resourceName, organizationalDir ) ) - { - } + [MethodImpl( MethodImplOptions.InternalCall )] + public extern Resource( string resourceName, string organizationalDir ); - public Resource( UInt32 userdata ) + private Resource() { - this.userdata = userdata; } #endregion #region Methods - public Resource Copy( string newResourceName, string organizationalDir ) - { - return new Resource( Native.Resource.Copy( this.userdata, newResourceName, organizationalDir ) ); - } + [MethodImpl( MethodImplOptions.InternalCall )] + public extern Resource Copy( string newResourceName, string organizationalDir ); - public Element GetRoot() - { - return Element.FindOrCreate( Native.Resource.GetRootElement( this.userdata ) ); - } + [MethodImpl( MethodImplOptions.InternalCall )] + public extern Element GetRoot(); - public Element GetMapRootElement( UInt32 resource, string map ) - { - return Element.FindOrCreate( Native.Resource.GetMapRootElement( this.userdata, map ) ); - } + [MethodImpl( MethodImplOptions.InternalCall )] + public extern Element GetMapRootElement( UInt32 resource, string map ); - public Element GetDynamicElementRoot() - { - return Element.FindOrCreate( Native.Resource.GetDynamicElementRoot( this.userdata ) ); - } + [MethodImpl( MethodImplOptions.InternalCall )] + public extern Element GetDynamicElementRoot(); - public bool RemoveFile( string filename ) - { - return Native.Resource.RemoveFile( this.userdata, filename ); - } + [MethodImpl( MethodImplOptions.InternalCall )] + public extern bool RemoveFile( string filename ); - public string GetInfo( string attribute ) - { - return Native.Resource.GetInfo( this.userdata, attribute ); - } + [MethodImpl( MethodImplOptions.InternalCall )] + public extern string GetInfo( string attribute ); - public uint GetLastStartTime() - { - return Native.Resource.GetLastStartTime( this.userdata ); - } + [MethodImpl( MethodImplOptions.InternalCall )] + public extern uint GetLastStartTime(); - public string GetLoadFailureReason() - { - return Native.Resource.GetLoadFailureReason( this.userdata ); - } + [MethodImpl( MethodImplOptions.InternalCall )] + public extern string GetLoadFailureReason(); - public uint GetLoadTime() - { - return Native.Resource.GetLoadTime( this.userdata ); - } + [MethodImpl( MethodImplOptions.InternalCall )] + public extern uint GetLoadTime(); - public string GetName() - { - return Native.Resource.GetName( this.userdata ); - } + [MethodImpl( MethodImplOptions.InternalCall )] + public extern string GetName(); - public string GetState() - { - return Native.Resource.GetState( this.userdata ); - } + [MethodImpl( MethodImplOptions.InternalCall )] + public extern string GetState(); - public bool SetDefaultSetting( string settingName, string settingValue ) - { - return Native.Resource.SetDefaultSetting( this.userdata, settingName, settingValue ); - } + [MethodImpl( MethodImplOptions.InternalCall )] + public extern bool SetDefaultSetting( string settingName, string settingValue ); - public bool RemoveDefaultSetting( string settingName ) - { - return Native.Resource.RemoveDefaultSetting( this.userdata, settingName ); - } + [MethodImpl( MethodImplOptions.InternalCall )] + public extern bool RemoveDefaultSetting( string settingName ); - public bool Start( bool persistent = false, bool startIncludedResources = true, bool loadServerConfigs = true, bool loadMaps = true, bool loadServerScripts = true, bool loadHTML = true, bool loadClientConfigs = true, bool loadClientScripts = true, bool loadFiles = true ) - { - return Native.Resource.Start( this.userdata, persistent, startIncludedResources, loadServerConfigs, loadMaps, loadServerScripts, loadHTML, loadClientConfigs, loadClientScripts, loadFiles ); - } + [MethodImpl( MethodImplOptions.InternalCall )] + public extern bool Start( bool persistent = false, bool startIncludedResources = true, bool loadServerConfigs = true, bool loadMaps = true, bool loadServerScripts = true, bool loadHTML = true, bool loadClientConfigs = true, bool loadClientScripts = true, bool loadFiles = true ); - public bool Restart() - { - return Native.Resource.Restart( this.userdata ); - } + [MethodImpl( MethodImplOptions.InternalCall )] + public extern bool Restart(); - public bool Stop() - { - return Native.Resource.Stop( this.userdata ); - } + [MethodImpl( MethodImplOptions.InternalCall )] + public extern bool Stop(); - public bool SetInfo( string attribute, string value ) - { - return Native.Resource.SetInfo( this.userdata, attribute, value ); - } + [MethodImpl( MethodImplOptions.InternalCall )] + public extern bool SetInfo( string attribute, string value ); - public bool Rename( string newResourceName, string organizationalPath ) - { - return Native.Resource.Rename( this.GetName(), newResourceName, organizationalPath ); - } + [MethodImpl( MethodImplOptions.InternalCall )] + public extern bool Rename( string newResourceName, string organizationalPath ); - public bool Delete() - { - return Native.Resource.Delete( this.GetName() ); - } + [MethodImpl( MethodImplOptions.InternalCall )] + public extern bool Delete(); - public bool UpdateACLRequest( string rightName, bool bAccess, string byWho ) - { - return Native.Resource.UpdateACLRequest( this.userdata, rightName, bAccess, byWho ); - } + [MethodImpl( MethodImplOptions.InternalCall )] + public extern bool UpdateACLRequest( string rightName, bool bAccess, string byWho ); #endregion #region Static methods - public static bool Rename( string resourceName, string newResourceName, string organizationalPath ) - { - return Native.Resource.Rename( resourceName, newResourceName, organizationalPath ); - } + [MethodImpl( MethodImplOptions.InternalCall )] + public extern static bool Rename( string resourceName, string newResourceName, string organizationalPath ); - public static bool Delete( string resourceName ) - { - return Native.Resource.Delete( resourceName ); - } + [MethodImpl( MethodImplOptions.InternalCall )] + public extern static bool Delete( string resourceName ); - public static bool Refresh( bool refreshAll = false ) - { - return Native.Resource.Refresh( refreshAll ); - } + [MethodImpl( MethodImplOptions.InternalCall )] + public extern static bool Refresh( bool refreshAll = false ); - public static Resource GetCurrent() - { - return Resource.FindOrCreate( Native.Resource.GetCurrent() ); - } + [MethodImpl( MethodImplOptions.InternalCall )] + public extern static Resource GetCurrent(); - public static Resource[] GetAll() - { - UInt32[] userdataArray = Native.Resource.GetResources(); + [MethodImpl( MethodImplOptions.InternalCall )] + public extern static Resource[] GetAll(); - Resource[] resources = new Resource[ userdataArray.Length ]; - - for( uint i = 0; i < userdataArray.Length; i++ ) - { - resources.SetValue( Resource.FindOrCreate( userdataArray[ i ] ), i ); - } - - return resources; - } - - public static Element GetRootElement( Element resource = null ) - { - return Element.FindOrCreate( Native.Resource.GetRootElement( resource.userdata ) ); - } - - public static Resource GetFromName( string resourceName ) - { - UInt32 userdata = Native.Resource.GetFromName( resourceName ); - - if( userdata != 0 ) - { - return Resource.FindOrCreate( userdata ); - } - - return null; - } + [MethodImpl( MethodImplOptions.InternalCall )] + public extern static Resource GetFromName( string resourceName ); #endregion } diff --git a/MultiTheftAuto/Server.cs b/MultiTheftAuto/Server.cs index 3cc9f2b..e4bab0c 100644 --- a/MultiTheftAuto/Server.cs +++ b/MultiTheftAuto/Server.cs @@ -7,24 +7,16 @@ namespace MultiTheftAuto public static class Server { - public static bool OutputChatBox( string text, Element element, Color color, bool colorCoded ) - { - return Native.Server.OutputChatBox( text, element.userdata, color, colorCoded ); - } + [MethodImpl( MethodImplOptions.InternalCall )] + public extern static bool OutputChatBox( string text, Element element, Color color, bool colorCoded ); - public static bool AddCommandHandler( string name, CommandHandler handler, bool restricted = false, bool caseSensitive = true ) - { - return Native.Server.AddCommandHandler( name, handler, restricted, caseSensitive ); - } + [MethodImpl( MethodImplOptions.InternalCall )] + public extern static bool AddCommandHandler( string name, CommandHandler handler, bool restricted = false, bool caseSensitive = true ); - public static bool ExecuteCommandHandler( string name, Player player, string args ) - { - return Native.Server.ExecuteCommandHandler( name, player.userdata, args ); - } + [MethodImpl( MethodImplOptions.InternalCall )] + public extern static bool ExecuteCommandHandler( string name, Player player, string args ); - public static bool RemoveCommandHandler( string name, CommandHandler handler ) - { - return Native.Server.RemoveCommandHandler( name, handler ); - } + [MethodImpl( MethodImplOptions.InternalCall )] + public extern static bool RemoveCommandHandler( string name, CommandHandler handler = null ); } } diff --git a/MultiTheftAuto/Team.cs b/MultiTheftAuto/Team.cs index be4d7a2..6f7fff2 100644 --- a/MultiTheftAuto/Team.cs +++ b/MultiTheftAuto/Team.cs @@ -1,4 +1,5 @@ using System; +using System.Runtime.CompilerServices; using System.Collections.Generic; using System.Linq; using System.Text; @@ -9,79 +10,47 @@ namespace MultiTheftAuto { #region Construcotrs - public Team( string name, Color color = null ) - : base( Native.Team.Create( name, color ) ) - { - - } + [MethodImpl( MethodImplOptions.InternalCall )] + public extern Team( string name, Color color = null ); - public Team( UInt32 userdata ) - : base( userdata ) + private Team() { - } #endregion #region Methods - public string GetName() - { - return Native.Team.GetName( this.userdata ); - } + [MethodImpl( MethodImplOptions.InternalCall )] + public extern string GetName(); - public Color GetColor() - { - return Native.Team.GetColor( this.userdata ); - } + [MethodImpl( MethodImplOptions.InternalCall )] + public extern Color GetColor(); - public bool GetFriendlyFire() - { - return Native.Team.GetFriendlyFire( this.userdata ); - } + [MethodImpl( MethodImplOptions.InternalCall )] + public extern bool GetFriendlyFire(); - public Player[] GetPlayers() - { - UInt32[] userdataArray = Native.Team.GetPlayers( this.userdata ); + [MethodImpl( MethodImplOptions.InternalCall )] + public extern Player[] GetPlayers(); - Player[] players = new Player[ userdataArray.Length ]; + [MethodImpl( MethodImplOptions.InternalCall )] + public extern int CountPlayers(); - for( uint i = 0; i < userdataArray.Length; i++ ) - { - players.SetValue( Element.FindOrCreate( userdataArray[ i ] ) as Player, i ); - } + [MethodImpl( MethodImplOptions.InternalCall )] + public extern bool SetName( string name ); - return players; - } + [MethodImpl( MethodImplOptions.InternalCall )] + public extern bool SetColor( Color color ); - public int CountPlayers() - { - return Native.Team.CountPlayers( this.userdata ); - } - - public bool SetName( string name ) - { - return Native.Team.SetName( this.userdata, name ); - } - - public bool SetColor( Color color ) - { - return Native.Team.SetColor( this.userdata, color ); - } - - public bool SetFriendlyFire( bool enabled ) - { - return Native.Team.SetFriendlyFire( this.userdata, enabled ); - } + [MethodImpl( MethodImplOptions.InternalCall )] + public extern bool SetFriendlyFire( bool enabled ); #endregion #region Static methods - public static Team GetFromName( string name ) - { - return Element.FindOrCreate( Native.Team.GetFromName( name ) ) as Team; - } + [MethodImpl( MethodImplOptions.InternalCall )] + public extern static Team GetFromName( string name ); #endregion } diff --git a/MultiTheftAuto/Vehicle.cs b/MultiTheftAuto/Vehicle.cs index 1737743..cb6a40f 100644 --- a/MultiTheftAuto/Vehicle.cs +++ b/MultiTheftAuto/Vehicle.cs @@ -1,4 +1,5 @@ using System; +using System.Runtime.CompilerServices; using System.Collections.Generic; using System.Linq; using System.Text; @@ -230,7 +231,7 @@ namespace MultiTheftAuto { get { - return Native.Vehicle.GetType( this.GetUserData() ); + return this.GetVehicleType(); } } @@ -238,36 +239,34 @@ namespace MultiTheftAuto #region Constructors - public Vehicle( VehicleModel model, Vector3 position, Vector3 rotation, string numberplate = null, bool direction = false, int variant1 = 255, int variant2 = 255 ) - : base( Native.Vehicle.Create( (int)model, position, rotation, numberplate, direction, variant1, variant2 ) ) + [MethodImpl( MethodImplOptions.InternalCall )] + public extern Vehicle( VehicleModel model, Vector3 position, Vector3 rotation, string numberplate = null, bool direction = false, int variant1 = 255, int variant2 = 255 ); + + internal Vehicle() { - + } - public Vehicle( UInt32 userdata ) - : base( userdata ) + ~Vehicle() { - + Debug.Info( "~Vehicle() [" + this.GetName() + "]" ); } #endregion #region Static Methods - public static string GetNameFromModel( int modelID ) - { - return Native.Vehicle.GetNameFromModel( modelID ); - } + [MethodImpl( MethodImplOptions.InternalCall )] + public extern static string GetNameFromModel( int modelID ); - public static string GetUpgradeSlotName( int upgradeOrSlot ) - { - return Native.Vehicle.GetUpgradeSlotName( upgradeOrSlot ); - } + [MethodImpl( MethodImplOptions.InternalCall )] + public extern static string GetUpgradeSlotName( int upgradeOrSlot ); - public static IEnumerable GetOfType( VehicleModel model ) - { - return Native.Vehicle.GetOfType( (int)model ).Select( i => Element.FindOrCreate( i ) as Vehicle ); - } + [MethodImpl( MethodImplOptions.InternalCall )] + public extern static Vehicle[] GetOfType( VehicleModel model ); + + [MethodImpl( MethodImplOptions.InternalCall )] + public extern static int GetModelFromName( string name ); #endregion @@ -275,429 +274,256 @@ namespace MultiTheftAuto #region Set - public bool Fix() - { - return Native.Vehicle.Fix( this.GetUserData() ); - } + [MethodImpl( MethodImplOptions.InternalCall )] + public extern bool Fix(); - public bool Blow( bool blow = true ) - { - return Native.Vehicle.Blow( this.GetUserData(), blow ); - } + [MethodImpl( MethodImplOptions.InternalCall )] + public extern bool Blow( bool blow = true ); - public bool SetTurnVelocity( Vector3 velocity ) - { - return Native.Vehicle.SetTurnVelocity( this.GetUserData(), velocity ); - } + [MethodImpl( MethodImplOptions.InternalCall )] + public extern bool SetTurnVelocity( Vector3 velocity ); - public bool SetColor( Color color1, Color color2 = null, Color color3 = null, Color color4 = null ) - { - return Native.Vehicle.SetColor( this.GetUserData(), color1, color2, color3, color4 ); - } + [MethodImpl( MethodImplOptions.InternalCall )] + public extern bool SetColor( Color color1, Color color2 = null, Color color3 = null, Color color4 = null ); - public bool SetLandingGearDown( bool state ) - { - return Native.Vehicle.SetLandingGearDown( this.GetUserData(), state ); - } + [MethodImpl( MethodImplOptions.InternalCall )] + public extern bool SetLandingGearDown( bool state ); - public bool SetLocked( bool locked ) - { - return Native.Vehicle.SetLocked( this.GetUserData(), locked ); - } + [MethodImpl( MethodImplOptions.InternalCall )] + public extern bool SetLocked( bool locked ); - public bool SetDoorsUndamageable( bool state ) - { - return Native.Vehicle.SetDoorsUndamageable( this.GetUserData(), state ); - } + [MethodImpl( MethodImplOptions.InternalCall )] + public extern bool SetDoorsUndamageable( bool state ); - public bool SetSirensOn( bool state ) - { - return Native.Vehicle.SetSirensOn( this.GetUserData(), state ); - } + [MethodImpl( MethodImplOptions.InternalCall )] + public extern bool SetSirensOn( bool state ); - public bool SetTaxiLightOn( bool state ) - { - return Native.Vehicle.SetTaxiLightOn( this.GetUserData(), state ); - } + [MethodImpl( MethodImplOptions.InternalCall )] + public extern bool SetTaxiLightOn( bool state ); - public bool AddUpgrade( int upgrade ) - { - return Native.Vehicle.AddUpgrade( this.GetUserData(), upgrade ); - } + [MethodImpl( MethodImplOptions.InternalCall )] + public extern bool AddUpgrade( int upgrade ); - public bool RemoveUpgrade( int upgrade ) - { - return Native.Vehicle.RemoveUpgrade( this.GetUserData(), upgrade ); - } + [MethodImpl( MethodImplOptions.InternalCall )] + public extern bool RemoveUpgrade( int upgrade ); - public bool SetDoorState( int door, int state ) - { - return Native.Vehicle.SetDoorState( this.GetUserData(), door, state ); - } + [MethodImpl( MethodImplOptions.InternalCall )] + public extern bool SetDoorState( int door, int state ); - public bool SetWheelStates( int frontLeft, int rearLeft, int frontRight, int rearRight ) - { - return Native.Vehicle.SetWheelStates( this.GetUserData(), frontLeft, rearLeft, frontRight, rearRight ); - } + [MethodImpl( MethodImplOptions.InternalCall )] + public extern bool SetWheelStates( int frontLeft, int rearLeft, int frontRight, int rearRight ); - public bool SetLightState( int light, int state ) - { - return Native.Vehicle.SetLightState( this.GetUserData(), light, state ); - } + [MethodImpl( MethodImplOptions.InternalCall )] + public extern bool SetLightState( int light, int state ); - public bool SetPanelState( int panelID, int state ) - { - return Native.Vehicle.SetPanelState( this.GetUserData(), panelID, state ); - } + [MethodImpl( MethodImplOptions.InternalCall )] + public extern bool SetPanelState( int panelID, int state ); - public bool SetIdleRespawnDelay( int timeDelay ) - { - return Native.Vehicle.SetIdleRespawnDelay( this.GetUserData(), timeDelay ); - } + [MethodImpl( MethodImplOptions.InternalCall )] + public extern bool SetIdleRespawnDelay( int timeDelay ); - public bool SetRespawnDelay( int timeDelay ) - { - return Native.Vehicle.SetRespawnDelay( this.GetUserData(), timeDelay ); - } + [MethodImpl( MethodImplOptions.InternalCall )] + public extern bool SetRespawnDelay( int timeDelay ); - public bool SetRespawnPosition( Vector3 position, Vector3 rotation ) - { - return Native.Vehicle.SetRespawnPosition( this.GetUserData(), position, rotation ); - } + [MethodImpl( MethodImplOptions.InternalCall )] + public extern bool SetRespawnPosition( Vector3 position, Vector3 rotation ); - public bool ToggleRespawn( bool respawn ) - { - return Native.Vehicle.ToggleRespawn( this.GetUserData(), respawn ); - } + [MethodImpl( MethodImplOptions.InternalCall )] + public extern bool ToggleRespawn( bool respawn ); - public bool ResetExplosionTime() - { - return Native.Vehicle.ResetExplosionTime( this.GetUserData() ); - } + [MethodImpl( MethodImplOptions.InternalCall )] + public extern bool ResetExplosionTime(); - public bool ResetIdleTime() - { - return Native.Vehicle.ResetIdleTime( this.GetUserData() ); - } + [MethodImpl( MethodImplOptions.InternalCall )] + public extern bool ResetIdleTime(); - public bool Spawn( Vector3 position, Vector3 rotation ) - { - return Native.Vehicle.Spawn( this.GetUserData(), position, rotation ); - } + [MethodImpl( MethodImplOptions.InternalCall )] + public extern bool Spawn( Vector3 position, Vector3 rotation ); - public bool Respawn() - { - return Native.Vehicle.Respawn( this.GetUserData() ); - } + [MethodImpl( MethodImplOptions.InternalCall )] + public extern bool Respawn(); - public bool SetOverrideLights( int state ) - { - return Native.Vehicle.SetOverrideLights( this.GetUserData(), state ); - } + [MethodImpl( MethodImplOptions.InternalCall )] + public extern bool SetOverrideLights( int state ); - public bool AttachTrailerToVehicle( Element trailer ) - { - return Native.Vehicle.AttachTrailerToVehicle( this.GetUserData(), trailer.GetUserData() ); - } + [MethodImpl( MethodImplOptions.InternalCall )] + public extern bool AttachTrailerToVehicle( Element trailer ); - public bool DetachTrailerFromVehicle( Element trailer = null ) - { - if( trailer == null ) - return Native.Vehicle.DetachTrailerFromVehicle( this.GetUserData() ); + [MethodImpl( MethodImplOptions.InternalCall )] + public extern bool DetachTrailerFromVehicle( Element trailer = null ); - return Native.Vehicle.DetachTrailerFromVehicle( this.GetUserData(), trailer.GetUserData() ); - } + [MethodImpl( MethodImplOptions.InternalCall )] + public extern bool SetEngineState( bool state ); - public bool SetEngineState( bool state ) - { - return Native.Vehicle.SetEngineState( this.GetUserData(), state ); - } + [MethodImpl( MethodImplOptions.InternalCall )] + public extern bool SetDamageProof( bool state ); - public bool SetDamageProof( bool state ) - { - return Native.Vehicle.SetDamageProof( this.GetUserData(), state ); - } + [MethodImpl( MethodImplOptions.InternalCall )] + public extern bool SetPaintjob( int value ); - public bool SetPaintjob( int value ) - { - return Native.Vehicle.SetPaintjob( this.GetUserData(), value ); - } + [MethodImpl( MethodImplOptions.InternalCall )] + public extern bool SetFuelTankExplodable( bool state ); - public bool SetFuelTankExplodable( bool state ) - { - return Native.Vehicle.SetFuelTankExplodable( this.GetUserData(), state ); - } + [MethodImpl( MethodImplOptions.InternalCall )] + public extern bool SetTrainDerailed( bool state ); - public bool SetTrainDerailed( bool state ) - { - return Native.Vehicle.SetTrainDerailed( this.GetUserData(), state ); - } + [MethodImpl( MethodImplOptions.InternalCall )] + public extern bool SetTrainDerailable( bool state ); - public bool SetTrainDerailable( bool state ) - { - return Native.Vehicle.SetTrainDerailable( this.GetUserData(), state ); - } + [MethodImpl( MethodImplOptions.InternalCall )] + public extern bool SetTrainDirection( bool state ); - public bool SetTrainDirection( bool state ) - { - return Native.Vehicle.SetTrainDirection( this.GetUserData(), state ); - } + [MethodImpl( MethodImplOptions.InternalCall )] + public extern bool SetTrainSpeed( float speed ); - public bool SetTrainSpeed( float speed ) - { - return Native.Vehicle.SetTrainSpeed( this.GetUserData(), speed ); - } + [MethodImpl( MethodImplOptions.InternalCall )] + public extern bool SetHeadLightColor( Color color ); - public bool SetHeadLightColor( Color color ) - { - return Native.Vehicle.SetHeadLightColor( this.GetUserData(), color ); - } + [MethodImpl( MethodImplOptions.InternalCall )] + public extern bool SetTurretPosition( float x, float y ); - public bool SetTurretPosition( float x, float y ) - { - return Native.Vehicle.SetTurretPosition( this.GetUserData(), x, y ); - } + [MethodImpl( MethodImplOptions.InternalCall )] + public extern bool SetDoorOpenRatio( int door, float ratio, int time = 0 ); - public bool SetDoorOpenRatio( int door, float ratio, int time = 0 ) - { - return Native.Vehicle.SetDoorOpenRatio( this.GetUserData(), door, ratio, time ); - } + [MethodImpl( MethodImplOptions.InternalCall )] + public extern bool SetVariant( int variant1 = 255, int variant2 = 255 ); - public bool SetVariant( int variant1 = 255, int variant2 = 255 ) - { - return Native.Vehicle.SetVariant( this.GetUserData(), variant1, variant2 ); - } + [MethodImpl( MethodImplOptions.InternalCall )] + public extern bool AddSirens( int sirenCount, int sirenType, bool flag360 = false, bool checkLos = true, bool useRandomiser = true, bool silent = false ); - public bool AddSirens( int sirenCount, int sirenType, bool flag360 = false, bool checkLos = true, bool useRandomiser = true, bool silent = false ) - { - return Native.Vehicle.AddSirens( this.GetUserData(), sirenCount, sirenType, flag360, checkLos, useRandomiser, silent ); - } + [MethodImpl( MethodImplOptions.InternalCall )] + public extern bool RemoveSirens(); - public bool RemoveSirens() - { - return Native.Vehicle.RemoveSirens( this.GetUserData() ); - } + [MethodImpl( MethodImplOptions.InternalCall )] + public extern bool SetSirens( int sirenPoint, Vector3 position, Color color = null, float minAlpha = 0.0f ); - public bool SetSirens( int sirenPoint, Vector3 position, Color color = null, float minAlpha = 0.0f ) - { - if( color == null ) - return Native.Vehicle.SetSirens( this.GetUserData(), sirenPoint, position, color, minAlpha ); - - return Native.Vehicle.SetSirens( this.GetUserData(), sirenPoint, position, color, minAlpha ); - } - - public bool SetPlateText( string text ) - { - return Native.Vehicle.SetPlateText( this.GetUserData(), text ); - } + [MethodImpl( MethodImplOptions.InternalCall )] + public extern bool SetPlateText( string text ); #endregion #region Get - public Array GetSirens() - { - return Native.Vehicle.GetSirens( this.userdata ); - } + [MethodImpl( MethodImplOptions.InternalCall )] + public extern Array GetSirens(); - public Object GetSirenParams() - { - return Native.Vehicle.GetSirenParams( this.userdata ); - } + [MethodImpl( MethodImplOptions.InternalCall )] + public extern object GetSirenParams(); - public string GetVehicleType() - { - return Native.Vehicle.GetType( this.userdata ); - } - - public char[] GetVariant() - { - return Native.Vehicle.GetVariant( this.userdata ); - } + [MethodImpl( MethodImplOptions.InternalCall )] + public extern string GetVehicleType(); - public VehicleColor GetColor() - { - return Native.Vehicle.GetColor( this.userdata ); - } + [MethodImpl( MethodImplOptions.InternalCall )] + public extern char[] GetVariant(); - public static int GetModelFromName( string name ) - { - return Native.Vehicle.GetModelFromName( name ); - } + [MethodImpl( MethodImplOptions.InternalCall )] + public extern VehicleColor GetColor(); - public bool GetLandingGearDown() - { - return Native.Vehicle.GetLandingGearDown( this.userdata ); - } + [MethodImpl( MethodImplOptions.InternalCall )] + public extern bool GetLandingGearDown(); - public int GetMaxPassengers() - { - return Native.Vehicle.GetMaxPassengers( this.userdata ); - } + [MethodImpl( MethodImplOptions.InternalCall )] + public extern int GetMaxPassengers(); - public string GetName() - { - return Native.Vehicle.GetName( this.userdata ); - } + [MethodImpl( MethodImplOptions.InternalCall )] + public extern string GetName(); - public Ped GetOccupant( int seat = 0 ) - { - return Element.FindOrCreate( Native.Vehicle.GetOccupant( this.userdata, seat ) ) as Ped; - } + [MethodImpl( MethodImplOptions.InternalCall )] + public extern Ped GetOccupant( int seat = 0 ); - public IEnumerable GetOccupants() - { - return Native.Vehicle.GetOccupants( this.userdata ).Select( i => Element.FindOrCreate( i ) as Ped ); - } + [MethodImpl( MethodImplOptions.InternalCall )] + public extern Ped[] GetOccupants(); - public Ped GetController() - { - return Element.FindOrCreate( Native.Vehicle.GetController( this.userdata ) ) as Ped; - } + [MethodImpl( MethodImplOptions.InternalCall )] + public extern Ped GetController(); - public bool GetSirensOn() - { - return Native.Vehicle.GetSirensOn( this.userdata ); - } + [MethodImpl( MethodImplOptions.InternalCall )] + public extern bool GetSirensOn(); - public Vector3 GetTurnVelocity() - { - return Native.Vehicle.GetTurnVelocity( this.userdata ); - } + [MethodImpl( MethodImplOptions.InternalCall )] + public extern Vector3 GetTurnVelocity(); - public Vector3 GetTurretPosition() - { - return Native.Vehicle.GetTurretPosition( this.userdata ); - } + [MethodImpl( MethodImplOptions.InternalCall )] + public extern Vector3 GetTurretPosition(); - public int GetUpgradeOnSlot( int slot ) - { - return Native.Vehicle.GetUpgradeOnSlot( this.userdata, slot ); - } + [MethodImpl( MethodImplOptions.InternalCall )] + public extern int GetUpgradeOnSlot( int slot ); - public UInt32[] GetUpgrades() - { - return Native.Vehicle.GetUpgrades( this.userdata ); - } + [MethodImpl( MethodImplOptions.InternalCall )] + public extern UInt32[] GetUpgrades(); - public UInt32[] GetCompatibleUpgrades( int slot = 0 ) - { - return Native.Vehicle.GetCompatibleUpgrades( this.userdata, slot ); - } + [MethodImpl( MethodImplOptions.InternalCall )] + public extern UInt32[] GetCompatibleUpgrades( int slot = 0 ); - public int GetDoorState( int door ) - { - return Native.Vehicle.GetDoorState( this.userdata, door ); - } + [MethodImpl( MethodImplOptions.InternalCall )] + public extern int GetDoorState( int door ); - public VehicleWheelsState GetWheelStates() - { - return Native.Vehicle.GetWheelStates( this.userdata ); - } + [MethodImpl( MethodImplOptions.InternalCall )] + public extern VehicleWheelsState GetWheelStates(); - public int GetLightState( int light ) - { - return Native.Vehicle.GetLightState( this.userdata, light ); - } + [MethodImpl( MethodImplOptions.InternalCall )] + public extern int GetLightState( int light ); - public int GetPanelState( int panel ) - { - return Native.Vehicle.GetPanelState( this.userdata, panel ); - } + [MethodImpl( MethodImplOptions.InternalCall )] + public extern int GetPanelState( int panel ); - public int GetOverrideLights() - { - return Native.Vehicle.GetOverrideLights( this.userdata ); - } + [MethodImpl( MethodImplOptions.InternalCall )] + public extern int GetOverrideLights(); - public Vehicle GetTowedByVehicle() - { - return Element.FindOrCreate( Native.Vehicle.GetTowedByVehicle( this.userdata ) ) as Vehicle; - } + [MethodImpl( MethodImplOptions.InternalCall )] + public extern Vehicle GetTowedByVehicle(); - public Vehicle GetTowingVehicle() - { - return Element.FindOrCreate( Native.Vehicle.GetTowingVehicle( this.userdata ) ) as Vehicle; - } + [MethodImpl( MethodImplOptions.InternalCall )] + public extern Vehicle GetTowingVehicle(); - public int GetPaintjob() - { - return Native.Vehicle.GetPaintjob( this.userdata ); - } + [MethodImpl( MethodImplOptions.InternalCall )] + public extern int GetPaintjob(); - public string GetPlateText() - { - return Native.Vehicle.GetPlateText( this.userdata ); - } + [MethodImpl( MethodImplOptions.InternalCall )] + public extern string GetPlateText(); - public bool GetEngineState() - { - return Native.Vehicle.GetEngineState( this.userdata ); - } + [MethodImpl( MethodImplOptions.InternalCall )] + public extern bool GetEngineState(); - public bool GetTrainDirection() - { - return Native.Vehicle.GetTrainDirection( this.userdata ); - } + [MethodImpl( MethodImplOptions.InternalCall )] + public extern bool GetTrainDirection(); - public float GetTrainSpeed() - { - return Native.Vehicle.GetTrainSpeed( this.userdata ); - } + [MethodImpl( MethodImplOptions.InternalCall )] + public extern float GetTrainSpeed(); - public Color GetHeadLightColor() - { - return Native.Vehicle.GetHeadLightColor( this.userdata ); - } + [MethodImpl( MethodImplOptions.InternalCall )] + public extern Color GetHeadLightColor(); - public float GetVehicleDoorOpenRatio( int door ) - { - return Native.Vehicle.GetVehicleDoorOpenRatio( this.userdata, door ); - } + [MethodImpl( MethodImplOptions.InternalCall )] + public extern float GetVehicleDoorOpenRatio( int door ); #endregion #region Is - public bool IsTaxiLightOn() - { - return Native.Vehicle.IsTaxiLightOn( this.GetUserData() ); - } + [MethodImpl( MethodImplOptions.InternalCall )] + public extern bool IsTaxiLightOn(); - public bool IsTrainDerailed() - { - return Native.Vehicle.IsTrainDerailed( this.userdata ); - } + [MethodImpl( MethodImplOptions.InternalCall )] + public extern bool IsTrainDerailed(); - public bool IsTrainDerailable() - { - return Native.Vehicle.IsTrainDerailable( this.userdata ); - } + [MethodImpl( MethodImplOptions.InternalCall )] + public extern bool IsTrainDerailable(); - public bool IsDamageProof() - { - return Native.Vehicle.IsDamageProof( this.userdata ); - } + [MethodImpl( MethodImplOptions.InternalCall )] + public extern bool IsDamageProof(); - public bool IsFuelTankExplodable() - { - return Native.Vehicle.IsFuelTankExplodable( this.userdata ); - } + [MethodImpl( MethodImplOptions.InternalCall )] + public extern bool IsFuelTankExplodable(); - public bool IsOnGround() - { - return Native.Vehicle.IsOnGround( this.userdata ); - } + [MethodImpl( MethodImplOptions.InternalCall )] + public extern bool IsOnGround(); - public bool IsBlown() - { - return Native.Vehicle.IsBlown( this.userdata ); - } + [MethodImpl( MethodImplOptions.InternalCall )] + public extern bool IsBlown(); - public bool IsLocked() - { - return Native.Vehicle.IsLocked( this.userdata ); - } + [MethodImpl( MethodImplOptions.InternalCall )] + public extern bool IsLocked(); #endregion