Removed MultiTheftAuto.cs (no longer needed)

Removed Pools (no longer needed)
Removed Utils (no longer needed)
Allowed unsafe blocks
This commit is contained in:
Kernell 2016-01-06 21:04:13 +03:00
parent df922e1236
commit 89ce28931f
6 changed files with 1 additions and 211 deletions

View File

@ -1,21 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace MultiTheftAuto
{
public class MultiTheftAuto
{
#region Constructor
public MultiTheftAuto()
{
Resource.Register<Resource>();
Element.Register<Element>();
}
#endregion
}
}

View File

@ -23,6 +23,7 @@
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
@ -103,7 +104,6 @@
<Compile Include="EventArgs\VehicleStartEnterEventArgs.cs" />
<Compile Include="HeatHazeSettings.cs" />
<Compile Include="Marker.cs" />
<Compile Include="MultiTheftAuto.cs" />
<Compile Include="Native\Account.cs" />
<Compile Include="Native\Blip.cs" />
<Compile Include="Native\ColShape.cs" />
@ -129,15 +129,11 @@
<Compile Include="Player.cs" />
<Compile Include="PlayerACInfo.cs" />
<Compile Include="PlayerModInfo.cs" />
<Compile Include="Pools\IdentifiedPool.cs" />
<Compile Include="Pools\Pool.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Resource.cs" />
<Compile Include="Server.cs" />
<Compile Include="ServerVersion.cs" />
<Compile Include="Team.cs" />
<Compile Include="Utils\Disposable.cs" />
<Compile Include="Utils\IIdentifyable.cs" />
<Compile Include="Vector2.cs" />
<Compile Include="Vector3.cs" />
<Compile Include="Vehicle.cs" />

View File

@ -1,34 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using MultiTheftAuto.Utils;
namespace MultiTheftAuto.Pools
{
public abstract class IdentifiedPool<T> : Pool<T> where T : class, IIdentifyable
{
protected static Type InstanceType;
public static void Register<T2>() where T2 : T
{
InstanceType = typeof( T2 );
}
public static T Find( UInt32 userdata )
{
return All.FirstOrDefault( i => i.userdata == userdata );
}
public static T Create( UInt32 userdata )
{
return (T)Activator.CreateInstance( InstanceType, userdata );
}
public static T FindOrCreate( UInt32 userdata )
{
return Find( userdata ) ?? Create( userdata );
}
}
}

View File

@ -1,59 +0,0 @@
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using MultiTheftAuto.Utils;
namespace MultiTheftAuto.Pools
{
public abstract class Pool<T> : Disposable
{
protected static readonly List<object> Instances = new List<object>();
protected static ReadOnlyCollection<T> ReadOnly = new ReadOnlyCollection<T>( new List<T>() );
protected static object Lock = new object();
protected Pool()
{
lock( Lock )
{
Instances.Add( this );
ReadOnly = Instances.OfType<T>().ToList().AsReadOnly();
}
}
public static ReadOnlyCollection<T> All
{
get
{
lock( Lock )
{
return ReadOnly;
}
}
}
protected override void Dispose( bool disposing )
{
lock( Lock )
{
Instances.Remove( this );
ReadOnly = Instances.OfType<T>().ToList().AsReadOnly();
}
}
public static bool Contains( T item )
{
lock( Lock )
{
return Instances.Contains( item );
}
}
public static ReadOnlyCollection<T2> GetAll<T2>()
{
lock( Lock )
{
return Instances.OfType<T2>().ToList().AsReadOnly();
}
}
}
}

View File

@ -1,70 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace MultiTheftAuto.Utils
{
/// <summary>
/// Defines methods to release allocated resources and to check whether this resource has been disposed.
/// </summary>
public abstract class Disposable : IDisposable
{
/// <summary>
/// Gets whether this resource has been disposed.
/// </summary>
public bool Disposed
{
get;
private set;
}
/// <summary>
/// Performs tasks associated with freeing, releasing, or resetting unmanaged resources.
/// </summary>
public void Dispose()
{
if( Disposed )
{
//We've been desposed already. Abort further disposure.
return;
}
//Dispose all native and managed resources.
Dispose( true );
//Remember we've been disposed.
Disposed = true;
//Suppress finalisation; We already disposed our resources.
GC.SuppressFinalize( this );
}
~Disposable()
{
if( Disposed )
{
//We've been desposed already. Abort further disposure.
return;
}
Dispose( false );
//We don't care to set Disposed value; Resource is being collected by GC anyways.
}
protected void CheckDisposure()
{
if( Disposed )
{
throw new ObjectDisposedException( "Cannot access disposed resource." );
}
}
/// <summary>
/// Performs tasks associated with freeing, releasing, or resetting unmanaged resources.
/// </summary>
/// <param name="disposing">Whether managed resources should be disposed.</param>
protected abstract void Dispose( bool disposing );
}
}

View File

@ -1,22 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace MultiTheftAuto.Utils
{
/// <summary>
/// Contains an Identity property.
/// </summary>
public interface IIdentifyable
{
/// <summary>
/// Gets the Identity of this instance.
/// </summary>
UInt32 userdata
{
get;
}
}
}