using System;
using Woodpecker.Sessions;
using Woodpecker.Game;
namespace Woodpecker.Net.Game
{
public class reactorHandler
{
#region Fields
private Session Session;
public Reactor[] Reactors = new Reactor[10];
#endregion
#region Constructors
public reactorHandler(Session Session)
{
this.Session = Session;
}
#endregion
#region Methods
///
/// Registers a reactor (if not registered yet) and makes it available for processing messages.
///
/// The Reactor instance to register.
public void Register(Reactor Reactor)
{
for (int i = 0; i < 10; i++) // 10 = max reactors
{
if (this.Reactors[i] == null)
{
Reactor.setSession(Session);
this.Reactors[i] = Reactor;
return;
}
}
}
///
/// Unregisters the reactor of a certain type.
///
/// The System.Type of the Reactor to unregister.
public void unRegister(Type reactorType)
{
try
{
for (int i = 0; i < 10; i++) // 10 = max reactors
{
if (this.Reactors[i].GetType() == reactorType)
{
this.Reactors[i] = null;
return;
}
}
}
catch { }
}
#endregion
}
}