How should I manage my entities on the server?

Options
storm33229
edited March 2013 in Photon Server
I want to have an entity stored for every peer; this entity will represent the player as far as the application is concerned. It stores its name, and position. My server looks like this:
public sealed class Server : ApplicationBase
{
    private Map m_map;

    protected override PeerBase CreatePeer(InitRequest initRequest)
    {
        var peer = new Peer(this, initRequest.Protocol, initRequest.PhotonPeer);

        CreateEntity(peer);

        return peer;
    }

    private static void CreateEntity(Peer peer)
    {
        CustomTypes.Register();

        Entity avatar = new Entity();
        avatar.Name = "avatar";
        avatar.Position = Vector2.zero;

        EventData createEntityEventData = new EventData((byte)EventCodes.CreateEntity);
        createEntityEventData.Parameters = new Dictionary<byte, object>();
        createEntityEventData.Parameters[0] = avatar;

        peer.SendEvent(createEntityEventData, new SendParameters());
    }

    protected override void Setup()
    {
        m_map = new Map();
        m_map.Load();
    }

    protected override void TearDown()
    {

    }
}

On setup I create map, and every time a new peer is constructed I create a new Entity to represent that peer's player. I store the map directly in the Server instance, and I am considering storing some sort of List<Entity> on the Server as well to keep track of my Entities.

Is this configuration a recommended paradigm for photon applications? How should I manage my entities on the server?

Comments

  • chvetsov
    Options
    There is no special recomendation. This completly depneds on what you want to get.
    In my opinion - the way you choose is ok
  • chvetsov wrote:
    There is no special recomendation. This completly depneds on what you want to get.
    In my opinion - the way you choose is ok

    The reason I ask is because I couldn't find how this was done in the MMO demo... so I want to make sure I am following the best design practices.
  • xzlxt720
    Options
    There is no such thing as the best, for the better is yet to come.
  • xzlxt720 wrote:
    There is no such thing as the best, for the better is yet to come.

    Heheh. I understand, I just value the opinions and experiences that others have had with this. So the more information I can gather on the situation the better. ;)