using System;
using System.Collections;
using System.Runtime.InteropServices;
using System.Runtime.InteropServices.ComTypes;
using System.Threading;

namespace Decal.Interop.Filters;

internal sealed class IWorldEvents_EventProvider : IWorldEvents_Event, IDisposable
{
	private IConnectionPointContainer m_ConnectionPointContainer;

	private ArrayList m_aEventSinkHelpers;

	private IConnectionPoint m_ConnectionPoint;

	private void Init()
	{
		IConnectionPoint ppCP = null;
		Guid riid = new Guid(new byte[16]
		{
			241, 153, 95, 23, 55, 185, 197, 71, 132, 110,
			202, 203, 185, 134, 175, 217
		});
		m_ConnectionPointContainer.FindConnectionPoint(ref riid, out ppCP);
		m_ConnectionPoint = ppCP;
		m_aEventSinkHelpers = new ArrayList();
	}

	event IWorldEvents_CreateObjectEventHandler IWorldEvents_Event.CreateObject
	{
		add
		{

			bool lockTaken = default(bool);
			try
			{
				Monitor.Enter(this, ref lockTaken);
				if (m_ConnectionPoint == null)
				{
					Init();
				}
				IWorldEvents_SinkHelper worldEvents_SinkHelper = new IWorldEvents_SinkHelper();
				int pdwCookie = 0;
				m_ConnectionPoint.Advise(worldEvents_SinkHelper, out pdwCookie);
				worldEvents_SinkHelper.m_dwCookie = pdwCookie;
				worldEvents_SinkHelper.m_CreateObjectDelegate = value;
				m_aEventSinkHelpers.Add(worldEvents_SinkHelper);
			}
			finally
			{
				if (lockTaken)
				{
					Monitor.Exit(this);
				}
			}
	
		}
		remove
		{

			bool lockTaken = default(bool);
			try
			{
				Monitor.Enter(this, ref lockTaken);
				if (m_aEventSinkHelpers == null)
				{
					return;
				}
				int count = m_aEventSinkHelpers.Count;
				int num = 0;
				if (0 >= count)
				{
					return;
				}
				do
				{
					IWorldEvents_SinkHelper worldEvents_SinkHelper = (IWorldEvents_SinkHelper)m_aEventSinkHelpers[num];
					if (worldEvents_SinkHelper.m_CreateObjectDelegate != null && ((worldEvents_SinkHelper.m_CreateObjectDelegate.Equals(value) ? 1u : 0u) & 0xFFu) != 0)
					{
						m_aEventSinkHelpers.RemoveAt(num);
						m_ConnectionPoint.Unadvise(worldEvents_SinkHelper.m_dwCookie);
						if (count <= 1)
						{
							Marshal.ReleaseComObject(m_ConnectionPoint);
							m_ConnectionPoint = null;
							m_aEventSinkHelpers = null;
						}
						break;
					}
					num++;
				}
				while (num < count);
			}
			finally
			{
				if (lockTaken)
				{
					Monitor.Exit(this);
				}
			}
	
		}
	}

	event IWorldEvents_ReleaseObjectEventHandler IWorldEvents_Event.ReleaseObject
	{
		add
		{

			bool lockTaken = default(bool);
			try
			{
				Monitor.Enter(this, ref lockTaken);
				if (m_ConnectionPoint == null)
				{
					Init();
				}
				IWorldEvents_SinkHelper worldEvents_SinkHelper = new IWorldEvents_SinkHelper();
				int pdwCookie = 0;
				m_ConnectionPoint.Advise(worldEvents_SinkHelper, out pdwCookie);
				worldEvents_SinkHelper.m_dwCookie = pdwCookie;
				worldEvents_SinkHelper.m_ReleaseObjectDelegate = value;
				m_aEventSinkHelpers.Add(worldEvents_SinkHelper);
			}
			finally
			{
				if (lockTaken)
				{
					Monitor.Exit(this);
				}
			}
	
		}
		remove
		{

			bool lockTaken = default(bool);
			try
			{
				Monitor.Enter(this, ref lockTaken);
				if (m_aEventSinkHelpers == null)
				{
					return;
				}
				int count = m_aEventSinkHelpers.Count;
				int num = 0;
				if (0 >= count)
				{
					return;
				}
				do
				{
					IWorldEvents_SinkHelper worldEvents_SinkHelper = (IWorldEvents_SinkHelper)m_aEventSinkHelpers[num];
					if (worldEvents_SinkHelper.m_ReleaseObjectDelegate != null && ((worldEvents_SinkHelper.m_ReleaseObjectDelegate.Equals(value) ? 1u : 0u) & 0xFFu) != 0)
					{
						m_aEventSinkHelpers.RemoveAt(num);
						m_ConnectionPoint.Unadvise(worldEvents_SinkHelper.m_dwCookie);
						if (count <= 1)
						{
							Marshal.ReleaseComObject(m_ConnectionPoint);
							m_ConnectionPoint = null;
							m_aEventSinkHelpers = null;
						}
						break;
					}
					num++;
				}
				while (num < count);
			}
			finally
			{
				if (lockTaken)
				{
					Monitor.Exit(this);
				}
			}
	
		}
	}

	event IWorldEvents_ChangeObjectEventHandler IWorldEvents_Event.ChangeObject
	{
		add
		{

			bool lockTaken = default(bool);
			try
			{
				Monitor.Enter(this, ref lockTaken);
				if (m_ConnectionPoint == null)
				{
					Init();
				}
				IWorldEvents_SinkHelper worldEvents_SinkHelper = new IWorldEvents_SinkHelper();
				int pdwCookie = 0;
				m_ConnectionPoint.Advise(worldEvents_SinkHelper, out pdwCookie);
				worldEvents_SinkHelper.m_dwCookie = pdwCookie;
				worldEvents_SinkHelper.m_ChangeObjectDelegate = value;
				m_aEventSinkHelpers.Add(worldEvents_SinkHelper);
			}
			finally
			{
				if (lockTaken)
				{
					Monitor.Exit(this);
				}
			}
	
		}
		remove
		{

			bool lockTaken = default(bool);
			try
			{
				Monitor.Enter(this, ref lockTaken);
				if (m_aEventSinkHelpers == null)
				{
					return;
				}
				int count = m_aEventSinkHelpers.Count;
				int num = 0;
				if (0 >= count)
				{
					return;
				}
				do
				{
					IWorldEvents_SinkHelper worldEvents_SinkHelper = (IWorldEvents_SinkHelper)m_aEventSinkHelpers[num];
					if (worldEvents_SinkHelper.m_ChangeObjectDelegate != null && ((worldEvents_SinkHelper.m_ChangeObjectDelegate.Equals(value) ? 1u : 0u) & 0xFFu) != 0)
					{
						m_aEventSinkHelpers.RemoveAt(num);
						m_ConnectionPoint.Unadvise(worldEvents_SinkHelper.m_dwCookie);
						if (count <= 1)
						{
							Marshal.ReleaseComObject(m_ConnectionPoint);
							m_ConnectionPoint = null;
							m_aEventSinkHelpers = null;
						}
						break;
					}
					num++;
				}
				while (num < count);
			}
			finally
			{
				if (lockTaken)
				{
					Monitor.Exit(this);
				}
			}
	
		}
	}

	event IWorldEvents_MoveObjectEventHandler IWorldEvents_Event.MoveObject
	{
		add
		{

			bool lockTaken = default(bool);
			try
			{
				Monitor.Enter(this, ref lockTaken);
				if (m_ConnectionPoint == null)
				{
					Init();
				}
				IWorldEvents_SinkHelper worldEvents_SinkHelper = new IWorldEvents_SinkHelper();
				int pdwCookie = 0;
				m_ConnectionPoint.Advise(worldEvents_SinkHelper, out pdwCookie);
				worldEvents_SinkHelper.m_dwCookie = pdwCookie;
				worldEvents_SinkHelper.m_MoveObjectDelegate = value;
				m_aEventSinkHelpers.Add(worldEvents_SinkHelper);
			}
			finally
			{
				if (lockTaken)
				{
					Monitor.Exit(this);
				}
			}
	
		}
		remove
		{

			bool lockTaken = default(bool);
			try
			{
				Monitor.Enter(this, ref lockTaken);
				if (m_aEventSinkHelpers == null)
				{
					return;
				}
				int count = m_aEventSinkHelpers.Count;
				int num = 0;
				if (0 >= count)
				{
					return;
				}
				do
				{
					IWorldEvents_SinkHelper worldEvents_SinkHelper = (IWorldEvents_SinkHelper)m_aEventSinkHelpers[num];
					if (worldEvents_SinkHelper.m_MoveObjectDelegate != null && ((worldEvents_SinkHelper.m_MoveObjectDelegate.Equals(value) ? 1u : 0u) & 0xFFu) != 0)
					{
						m_aEventSinkHelpers.RemoveAt(num);
						m_ConnectionPoint.Unadvise(worldEvents_SinkHelper.m_dwCookie);
						if (count <= 1)
						{
							Marshal.ReleaseComObject(m_ConnectionPoint);
							m_ConnectionPoint = null;
							m_aEventSinkHelpers = null;
						}
						break;
					}
					num++;
				}
				while (num < count);
			}
			finally
			{
				if (lockTaken)
				{
					Monitor.Exit(this);
				}
			}
	
		}
	}

	event IWorldEvents_ReleaseDoneEventHandler IWorldEvents_Event.ReleaseDone
	{
		add
		{

			bool lockTaken = default(bool);
			try
			{
				Monitor.Enter(this, ref lockTaken);
				if (m_ConnectionPoint == null)
				{
					Init();
				}
				IWorldEvents_SinkHelper worldEvents_SinkHelper = new IWorldEvents_SinkHelper();
				int pdwCookie = 0;
				m_ConnectionPoint.Advise(worldEvents_SinkHelper, out pdwCookie);
				worldEvents_SinkHelper.m_dwCookie = pdwCookie;
				worldEvents_SinkHelper.m_ReleaseDoneDelegate = value;
				m_aEventSinkHelpers.Add(worldEvents_SinkHelper);
			}
			finally
			{
				if (lockTaken)
				{
					Monitor.Exit(this);
				}
			}
	
		}
		remove
		{

			bool lockTaken = default(bool);
			try
			{
				Monitor.Enter(this, ref lockTaken);
				if (m_aEventSinkHelpers == null)
				{
					return;
				}
				int count = m_aEventSinkHelpers.Count;
				int num = 0;
				if (0 >= count)
				{
					return;
				}
				do
				{
					IWorldEvents_SinkHelper worldEvents_SinkHelper = (IWorldEvents_SinkHelper)m_aEventSinkHelpers[num];
					if (worldEvents_SinkHelper.m_ReleaseDoneDelegate != null && ((worldEvents_SinkHelper.m_ReleaseDoneDelegate.Equals(value) ? 1u : 0u) & 0xFFu) != 0)
					{
						m_aEventSinkHelpers.RemoveAt(num);
						m_ConnectionPoint.Unadvise(worldEvents_SinkHelper.m_dwCookie);
						if (count <= 1)
						{
							Marshal.ReleaseComObject(m_ConnectionPoint);
							m_ConnectionPoint = null;
							m_aEventSinkHelpers = null;
						}
						break;
					}
					num++;
				}
				while (num < count);
			}
			finally
			{
				if (lockTaken)
				{
					Monitor.Exit(this);
				}
			}
	
		}
	}

	event IWorldEvents_EnterTradeEventHandler IWorldEvents_Event.EnterTrade
	{
		add
		{

			bool lockTaken = default(bool);
			try
			{
				Monitor.Enter(this, ref lockTaken);
				if (m_ConnectionPoint == null)
				{
					Init();
				}
				IWorldEvents_SinkHelper worldEvents_SinkHelper = new IWorldEvents_SinkHelper();
				int pdwCookie = 0;
				m_ConnectionPoint.Advise(worldEvents_SinkHelper, out pdwCookie);
				worldEvents_SinkHelper.m_dwCookie = pdwCookie;
				worldEvents_SinkHelper.m_EnterTradeDelegate = value;
				m_aEventSinkHelpers.Add(worldEvents_SinkHelper);
			}
			finally
			{
				if (lockTaken)
				{
					Monitor.Exit(this);
				}
			}
	
		}
		remove
		{

			bool lockTaken = default(bool);
			try
			{
				Monitor.Enter(this, ref lockTaken);
				if (m_aEventSinkHelpers == null)
				{
					return;
				}
				int count = m_aEventSinkHelpers.Count;
				int num = 0;
				if (0 >= count)
				{
					return;
				}
				do
				{
					IWorldEvents_SinkHelper worldEvents_SinkHelper = (IWorldEvents_SinkHelper)m_aEventSinkHelpers[num];
					if (worldEvents_SinkHelper.m_EnterTradeDelegate != null && ((worldEvents_SinkHelper.m_EnterTradeDelegate.Equals(value) ? 1u : 0u) & 0xFFu) != 0)
					{
						m_aEventSinkHelpers.RemoveAt(num);
						m_ConnectionPoint.Unadvise(worldEvents_SinkHelper.m_dwCookie);
						if (count <= 1)
						{
							Marshal.ReleaseComObject(m_ConnectionPoint);
							m_ConnectionPoint = null;
							m_aEventSinkHelpers = null;
						}
						break;
					}
					num++;
				}
				while (num < count);
			}
			finally
			{
				if (lockTaken)
				{
					Monitor.Exit(this);
				}
			}
	
		}
	}

	event IWorldEvents_EndTradeEventHandler IWorldEvents_Event.EndTrade
	{
		add
		{

			bool lockTaken = default(bool);
			try
			{
				Monitor.Enter(this, ref lockTaken);
				if (m_ConnectionPoint == null)
				{
					Init();
				}
				IWorldEvents_SinkHelper worldEvents_SinkHelper = new IWorldEvents_SinkHelper();
				int pdwCookie = 0;
				m_ConnectionPoint.Advise(worldEvents_SinkHelper, out pdwCookie);
				worldEvents_SinkHelper.m_dwCookie = pdwCookie;
				worldEvents_SinkHelper.m_EndTradeDelegate = value;
				m_aEventSinkHelpers.Add(worldEvents_SinkHelper);
			}
			finally
			{
				if (lockTaken)
				{
					Monitor.Exit(this);
				}
			}
	
		}
		remove
		{

			bool lockTaken = default(bool);
			try
			{
				Monitor.Enter(this, ref lockTaken);
				if (m_aEventSinkHelpers == null)
				{
					return;
				}
				int count = m_aEventSinkHelpers.Count;
				int num = 0;
				if (0 >= count)
				{
					return;
				}
				do
				{
					IWorldEvents_SinkHelper worldEvents_SinkHelper = (IWorldEvents_SinkHelper)m_aEventSinkHelpers[num];
					if (worldEvents_SinkHelper.m_EndTradeDelegate != null && ((worldEvents_SinkHelper.m_EndTradeDelegate.Equals(value) ? 1u : 0u) & 0xFFu) != 0)
					{
						m_aEventSinkHelpers.RemoveAt(num);
						m_ConnectionPoint.Unadvise(worldEvents_SinkHelper.m_dwCookie);
						if (count <= 1)
						{
							Marshal.ReleaseComObject(m_ConnectionPoint);
							m_ConnectionPoint = null;
							m_aEventSinkHelpers = null;
						}
						break;
					}
					num++;
				}
				while (num < count);
			}
			finally
			{
				if (lockTaken)
				{
					Monitor.Exit(this);
				}
			}
	
		}
	}

	event IWorldEvents_AddTradeItemEventHandler IWorldEvents_Event.AddTradeItem
	{
		add
		{

			bool lockTaken = default(bool);
			try
			{
				Monitor.Enter(this, ref lockTaken);
				if (m_ConnectionPoint == null)
				{
					Init();
				}
				IWorldEvents_SinkHelper worldEvents_SinkHelper = new IWorldEvents_SinkHelper();
				int pdwCookie = 0;
				m_ConnectionPoint.Advise(worldEvents_SinkHelper, out pdwCookie);
				worldEvents_SinkHelper.m_dwCookie = pdwCookie;
				worldEvents_SinkHelper.m_AddTradeItemDelegate = value;
				m_aEventSinkHelpers.Add(worldEvents_SinkHelper);
			}
			finally
			{
				if (lockTaken)
				{
					Monitor.Exit(this);
				}
			}
	
		}
		remove
		{

			bool lockTaken = default(bool);
			try
			{
				Monitor.Enter(this, ref lockTaken);
				if (m_aEventSinkHelpers == null)
				{
					return;
				}
				int count = m_aEventSinkHelpers.Count;
				int num = 0;
				if (0 >= count)
				{
					return;
				}
				do
				{
					IWorldEvents_SinkHelper worldEvents_SinkHelper = (IWorldEvents_SinkHelper)m_aEventSinkHelpers[num];
					if (worldEvents_SinkHelper.m_AddTradeItemDelegate != null && ((worldEvents_SinkHelper.m_AddTradeItemDelegate.Equals(value) ? 1u : 0u) & 0xFFu) != 0)
					{
						m_aEventSinkHelpers.RemoveAt(num);
						m_ConnectionPoint.Unadvise(worldEvents_SinkHelper.m_dwCookie);
						if (count <= 1)
						{
							Marshal.ReleaseComObject(m_ConnectionPoint);
							m_ConnectionPoint = null;
							m_aEventSinkHelpers = null;
						}
						break;
					}
					num++;
				}
				while (num < count);
			}
			finally
			{
				if (lockTaken)
				{
					Monitor.Exit(this);
				}
			}
	
		}
	}

	event IWorldEvents_AcceptTradeEventHandler IWorldEvents_Event.AcceptTrade
	{
		add
		{

			bool lockTaken = default(bool);
			try
			{
				Monitor.Enter(this, ref lockTaken);
				if (m_ConnectionPoint == null)
				{
					Init();
				}
				IWorldEvents_SinkHelper worldEvents_SinkHelper = new IWorldEvents_SinkHelper();
				int pdwCookie = 0;
				m_ConnectionPoint.Advise(worldEvents_SinkHelper, out pdwCookie);
				worldEvents_SinkHelper.m_dwCookie = pdwCookie;
				worldEvents_SinkHelper.m_AcceptTradeDelegate = value;
				m_aEventSinkHelpers.Add(worldEvents_SinkHelper);
			}
			finally
			{
				if (lockTaken)
				{
					Monitor.Exit(this);
				}
			}
	
		}
		remove
		{

			bool lockTaken = default(bool);
			try
			{
				Monitor.Enter(this, ref lockTaken);
				if (m_aEventSinkHelpers == null)
				{
					return;
				}
				int count = m_aEventSinkHelpers.Count;
				int num = 0;
				if (0 >= count)
				{
					return;
				}
				do
				{
					IWorldEvents_SinkHelper worldEvents_SinkHelper = (IWorldEvents_SinkHelper)m_aEventSinkHelpers[num];
					if (worldEvents_SinkHelper.m_AcceptTradeDelegate != null && ((worldEvents_SinkHelper.m_AcceptTradeDelegate.Equals(value) ? 1u : 0u) & 0xFFu) != 0)
					{
						m_aEventSinkHelpers.RemoveAt(num);
						m_ConnectionPoint.Unadvise(worldEvents_SinkHelper.m_dwCookie);
						if (count <= 1)
						{
							Marshal.ReleaseComObject(m_ConnectionPoint);
							m_ConnectionPoint = null;
							m_aEventSinkHelpers = null;
						}
						break;
					}
					num++;
				}
				while (num < count);
			}
			finally
			{
				if (lockTaken)
				{
					Monitor.Exit(this);
				}
			}
	
		}
	}

	event IWorldEvents_DeclineTradeEventHandler IWorldEvents_Event.DeclineTrade
	{
		add
		{

			bool lockTaken = default(bool);
			try
			{
				Monitor.Enter(this, ref lockTaken);
				if (m_ConnectionPoint == null)
				{
					Init();
				}
				IWorldEvents_SinkHelper worldEvents_SinkHelper = new IWorldEvents_SinkHelper();
				int pdwCookie = 0;
				m_ConnectionPoint.Advise(worldEvents_SinkHelper, out pdwCookie);
				worldEvents_SinkHelper.m_dwCookie = pdwCookie;
				worldEvents_SinkHelper.m_DeclineTradeDelegate = value;
				m_aEventSinkHelpers.Add(worldEvents_SinkHelper);
			}
			finally
			{
				if (lockTaken)
				{
					Monitor.Exit(this);
				}
			}
	
		}
		remove
		{

			bool lockTaken = default(bool);
			try
			{
				Monitor.Enter(this, ref lockTaken);
				if (m_aEventSinkHelpers == null)
				{
					return;
				}
				int count = m_aEventSinkHelpers.Count;
				int num = 0;
				if (0 >= count)
				{
					return;
				}
				do
				{
					IWorldEvents_SinkHelper worldEvents_SinkHelper = (IWorldEvents_SinkHelper)m_aEventSinkHelpers[num];
					if (worldEvents_SinkHelper.m_DeclineTradeDelegate != null && ((worldEvents_SinkHelper.m_DeclineTradeDelegate.Equals(value) ? 1u : 0u) & 0xFFu) != 0)
					{
						m_aEventSinkHelpers.RemoveAt(num);
						m_ConnectionPoint.Unadvise(worldEvents_SinkHelper.m_dwCookie);
						if (count <= 1)
						{
							Marshal.ReleaseComObject(m_ConnectionPoint);
							m_ConnectionPoint = null;
							m_aEventSinkHelpers = null;
						}
						break;
					}
					num++;
				}
				while (num < count);
			}
			finally
			{
				if (lockTaken)
				{
					Monitor.Exit(this);
				}
			}
	
		}
	}

	event IWorldEvents_ResetTradeEventHandler IWorldEvents_Event.ResetTrade
	{
		add
		{

			bool lockTaken = default(bool);
			try
			{
				Monitor.Enter(this, ref lockTaken);
				if (m_ConnectionPoint == null)
				{
					Init();
				}
				IWorldEvents_SinkHelper worldEvents_SinkHelper = new IWorldEvents_SinkHelper();
				int pdwCookie = 0;
				m_ConnectionPoint.Advise(worldEvents_SinkHelper, out pdwCookie);
				worldEvents_SinkHelper.m_dwCookie = pdwCookie;
				worldEvents_SinkHelper.m_ResetTradeDelegate = value;
				m_aEventSinkHelpers.Add(worldEvents_SinkHelper);
			}
			finally
			{
				if (lockTaken)
				{
					Monitor.Exit(this);
				}
			}
	
		}
		remove
		{

			bool lockTaken = default(bool);
			try
			{
				Monitor.Enter(this, ref lockTaken);
				if (m_aEventSinkHelpers == null)
				{
					return;
				}
				int count = m_aEventSinkHelpers.Count;
				int num = 0;
				if (0 >= count)
				{
					return;
				}
				do
				{
					IWorldEvents_SinkHelper worldEvents_SinkHelper = (IWorldEvents_SinkHelper)m_aEventSinkHelpers[num];
					if (worldEvents_SinkHelper.m_ResetTradeDelegate != null && ((worldEvents_SinkHelper.m_ResetTradeDelegate.Equals(value) ? 1u : 0u) & 0xFFu) != 0)
					{
						m_aEventSinkHelpers.RemoveAt(num);
						m_ConnectionPoint.Unadvise(worldEvents_SinkHelper.m_dwCookie);
						if (count <= 1)
						{
							Marshal.ReleaseComObject(m_ConnectionPoint);
							m_ConnectionPoint = null;
							m_aEventSinkHelpers = null;
						}
						break;
					}
					num++;
				}
				while (num < count);
			}
			finally
			{
				if (lockTaken)
				{
					Monitor.Exit(this);
				}
			}
	
		}
	}

	event IWorldEvents_FailToAddTradeItemEventHandler IWorldEvents_Event.FailToAddTradeItem
	{
		add
		{

			bool lockTaken = default(bool);
			try
			{
				Monitor.Enter(this, ref lockTaken);
				if (m_ConnectionPoint == null)
				{
					Init();
				}
				IWorldEvents_SinkHelper worldEvents_SinkHelper = new IWorldEvents_SinkHelper();
				int pdwCookie = 0;
				m_ConnectionPoint.Advise(worldEvents_SinkHelper, out pdwCookie);
				worldEvents_SinkHelper.m_dwCookie = pdwCookie;
				worldEvents_SinkHelper.m_FailToAddTradeItemDelegate = value;
				m_aEventSinkHelpers.Add(worldEvents_SinkHelper);
			}
			finally
			{
				if (lockTaken)
				{
					Monitor.Exit(this);
				}
			}
	
		}
		remove
		{

			bool lockTaken = default(bool);
			try
			{
				Monitor.Enter(this, ref lockTaken);
				if (m_aEventSinkHelpers == null)
				{
					return;
				}
				int count = m_aEventSinkHelpers.Count;
				int num = 0;
				if (0 >= count)
				{
					return;
				}
				do
				{
					IWorldEvents_SinkHelper worldEvents_SinkHelper = (IWorldEvents_SinkHelper)m_aEventSinkHelpers[num];
					if (worldEvents_SinkHelper.m_FailToAddTradeItemDelegate != null && ((worldEvents_SinkHelper.m_FailToAddTradeItemDelegate.Equals(value) ? 1u : 0u) & 0xFFu) != 0)
					{
						m_aEventSinkHelpers.RemoveAt(num);
						m_ConnectionPoint.Unadvise(worldEvents_SinkHelper.m_dwCookie);
						if (count <= 1)
						{
							Marshal.ReleaseComObject(m_ConnectionPoint);
							m_ConnectionPoint = null;
							m_aEventSinkHelpers = null;
						}
						break;
					}
					num++;
				}
				while (num < count);
			}
			finally
			{
				if (lockTaken)
				{
					Monitor.Exit(this);
				}
			}
	
		}
	}

	event IWorldEvents_FailToCompleteTradeEventHandler IWorldEvents_Event.FailToCompleteTrade
	{
		add
		{

			bool lockTaken = default(bool);
			try
			{
				Monitor.Enter(this, ref lockTaken);
				if (m_ConnectionPoint == null)
				{
					Init();
				}
				IWorldEvents_SinkHelper worldEvents_SinkHelper = new IWorldEvents_SinkHelper();
				int pdwCookie = 0;
				m_ConnectionPoint.Advise(worldEvents_SinkHelper, out pdwCookie);
				worldEvents_SinkHelper.m_dwCookie = pdwCookie;
				worldEvents_SinkHelper.m_FailToCompleteTradeDelegate = value;
				m_aEventSinkHelpers.Add(worldEvents_SinkHelper);
			}
			finally
			{
				if (lockTaken)
				{
					Monitor.Exit(this);
				}
			}
	
		}
		remove
		{

			bool lockTaken = default(bool);
			try
			{
				Monitor.Enter(this, ref lockTaken);
				if (m_aEventSinkHelpers == null)
				{
					return;
				}
				int count = m_aEventSinkHelpers.Count;
				int num = 0;
				if (0 >= count)
				{
					return;
				}
				do
				{
					IWorldEvents_SinkHelper worldEvents_SinkHelper = (IWorldEvents_SinkHelper)m_aEventSinkHelpers[num];
					if (worldEvents_SinkHelper.m_FailToCompleteTradeDelegate != null && ((worldEvents_SinkHelper.m_FailToCompleteTradeDelegate.Equals(value) ? 1u : 0u) & 0xFFu) != 0)
					{
						m_aEventSinkHelpers.RemoveAt(num);
						m_ConnectionPoint.Unadvise(worldEvents_SinkHelper.m_dwCookie);
						if (count <= 1)
						{
							Marshal.ReleaseComObject(m_ConnectionPoint);
							m_ConnectionPoint = null;
							m_aEventSinkHelpers = null;
						}
						break;
					}
					num++;
				}
				while (num < count);
			}
			finally
			{
				if (lockTaken)
				{
					Monitor.Exit(this);
				}
			}
	
		}
	}

	event IWorldEvents_ApproachVendorEventHandler IWorldEvents_Event.ApproachVendor
	{
		add
		{

			bool lockTaken = default(bool);
			try
			{
				Monitor.Enter(this, ref lockTaken);
				if (m_ConnectionPoint == null)
				{
					Init();
				}
				IWorldEvents_SinkHelper worldEvents_SinkHelper = new IWorldEvents_SinkHelper();
				int pdwCookie = 0;
				m_ConnectionPoint.Advise(worldEvents_SinkHelper, out pdwCookie);
				worldEvents_SinkHelper.m_dwCookie = pdwCookie;
				worldEvents_SinkHelper.m_ApproachVendorDelegate = value;
				m_aEventSinkHelpers.Add(worldEvents_SinkHelper);
			}
			finally
			{
				if (lockTaken)
				{
					Monitor.Exit(this);
				}
			}
	
		}
		remove
		{

			bool lockTaken = default(bool);
			try
			{
				Monitor.Enter(this, ref lockTaken);
				if (m_aEventSinkHelpers == null)
				{
					return;
				}
				int count = m_aEventSinkHelpers.Count;
				int num = 0;
				if (0 >= count)
				{
					return;
				}
				do
				{
					IWorldEvents_SinkHelper worldEvents_SinkHelper = (IWorldEvents_SinkHelper)m_aEventSinkHelpers[num];
					if (worldEvents_SinkHelper.m_ApproachVendorDelegate != null && ((worldEvents_SinkHelper.m_ApproachVendorDelegate.Equals(value) ? 1u : 0u) & 0xFFu) != 0)
					{
						m_aEventSinkHelpers.RemoveAt(num);
						m_ConnectionPoint.Unadvise(worldEvents_SinkHelper.m_dwCookie);
						if (count <= 1)
						{
							Marshal.ReleaseComObject(m_ConnectionPoint);
							m_ConnectionPoint = null;
							m_aEventSinkHelpers = null;
						}
						break;
					}
					num++;
				}
				while (num < count);
			}
			finally
			{
				if (lockTaken)
				{
					Monitor.Exit(this);
				}
			}
	
		}
	}

	public IWorldEvents_EventProvider(object P_0)
	{
		//Error decoding local variables: Signature type sequence must have at least one element.
		m_ConnectionPointContainer = (IConnectionPointContainer)P_0;
	}

	public void Finalize()
	{
		bool lockTaken = default(bool);
		try
		{
			Monitor.Enter(this, ref lockTaken);
			if (m_ConnectionPoint == null)
			{
				return;
			}
			int count = m_aEventSinkHelpers.Count;
			int num = 0;
			if (0 < count)
			{
				do
				{
					IWorldEvents_SinkHelper worldEvents_SinkHelper = (IWorldEvents_SinkHelper)m_aEventSinkHelpers[num];
					m_ConnectionPoint.Unadvise(worldEvents_SinkHelper.m_dwCookie);
					num++;
				}
				while (num < count);
			}
			Marshal.ReleaseComObject(m_ConnectionPoint);
		}
		catch (Exception)
		{
		}
		finally
		{
			if (lockTaken)
			{
				Monitor.Exit(this);
			}
		}
	}

	public void Dispose()
	{
		//Error decoding local variables: Signature type sequence must have at least one element.
		Finalize();
		GC.SuppressFinalize(this);
	}
}
