Ejemplo n.º 1
0
            public Buffer(NetBuffer b, NetworkActor a, Syncronizer s)
            {
                buffer = b;

                sender      = a;
                syncronizer = s;
            }
Ejemplo n.º 2
0
            public EntityManager(Syncronizer s)
            {
                next_entity_id = 1;

                entitys_by_id     = new Dictionary <int, Entity>();
                entitys_by_target = new Dictionary <object, Entity>();

                syncronizer = s;
            }
Ejemplo n.º 3
0
            public SystemManager(Syncronizer s, IEnumerable <object> ts)
            {
                systems_by_id = ts.ConvertWithIndex((i, t) => new System(i + 1, t, this))
                                .ToDictionaryValues(z => z.GetId());

                systems_by_target = systems_by_id.Values
                                    .ToDictionaryValues(z => z.GetTarget());

                syncronizer = s;
            }
Ejemplo n.º 4
0
            public MessageProcessor(Syncronizer s, TryProcess <Buffer> r)
            {
                message_queue           = new List <Buffer>();
                sequenced_message_queue = new Dictionary <int, Buffer>();
                ordered_message_queue   = new Dictionary <int, List <Buffer> >();

                read_process = r;

                syncronizer = s;
            }
Ejemplo n.º 5
0
            public ConstantManager(Syncronizer s)
            {
                constant_managers = new List <ConstantSubManager>();

                string_sub_manager        = AddSubManager(new ConstantSubManager_String(this));
                type_sub_manager          = AddSubManager(new ConstantSubManager_Type(this));
                entity_method_sub_manager = AddSubManager(new ConstantSubManager_EntityMethod(this));
                system_method_sub_manager = AddSubManager(new ConstantSubManager_SystemMethod(this));

                syncronizer = s;
            }
Ejemplo n.º 6
0
            public override void ReadMethodInvoke(Entity entity, Buffer buffer)
            {
                Syncronizer  syncronizer = entity.GetSyncronizer();
                NetworkActor actor       = syncronizer.GetNetworkActor();

                object[] arguments = ReadArguments(buffer);

                if (actor.IsServer())
                {
                    Invoke(entity.GetTarget(), arguments);
                }
            }
Ejemplo n.º 7
0
            public override void ReadMethodInvoke(System system, Buffer buffer)
            {
                Syncronizer  syncronizer = system.GetSyncronizer();
                NetworkActor actor       = syncronizer.GetNetworkActor();

                object[] arguments = ReadArguments(buffer);

                if (actor.IsServer())
                {
                    SendMethodInvoke(system, arguments);
                }
                else
                {
                    Invoke(system.GetTarget(), arguments);
                }
            }
Ejemplo n.º 8
0
            public override void SendMethodInvoke(Entity entity, object[] arguments)
            {
                Syncronizer  syncronizer = entity.GetSyncronizer();
                NetworkActor actor       = syncronizer.GetNetworkActor();

                syncronizer.CreateMessage(MessageType.InvokeEntityMethod, delivery_method, delegate(Buffer buffer) {
                    buffer.WriteEntityReference(entity);
                    buffer.WriteEntityMethod(this);

                    WriteArguments(arguments, buffer);

                    if (actor.IsServer())
                    {
                        Invoke(entity.GetTarget(), arguments);
                    }
                }).Send();
            }
Ejemplo n.º 9
0
            public override void SendMethodInvoke(System system, object[] arguments)
            {
                Syncronizer  syncronizer = system.GetSyncronizer();
                NetworkActor actor       = syncronizer.GetNetworkActor();

                if (actor.IsServer())
                {
                    object spawned        = Invoke(system.GetTarget(), arguments);
                    Entity spawned_entity = syncronizer.entity_manager.RegisterEntityTarget(spawned, system, this, arguments);

                    SendConstructorReplay(system, NetworkRecipient_All.INSTANCE, arguments, spawned_entity);
                }
                else
                {
                    SendConstructorReplay(system, NetworkRecipient_All.INSTANCE, arguments, null);
                }
            }
Ejemplo n.º 10
0
            public void SendConstructorReplay(System system, NetworkRecipient recipient, object[] arguments, Entity spawned_entity)
            {
                Syncronizer  syncronizer = system.GetSyncronizer();
                NetworkActor actor       = syncronizer.GetNetworkActor();

                syncronizer.CreateMessage(MessageType.InvokeSystemMethod, NetDeliveryMethod.ReliableOrdered, delegate(Buffer buffer) {
                    buffer.WriteSystemReference(system);
                    buffer.WriteSystemMethod(this);

                    WriteArguments(arguments, buffer);

                    if (actor.IsServer())
                    {
                        buffer.WriteInt32(spawned_entity.GetId());
                        spawned_entity.WriteSync(buffer);
                    }
                }).Send(recipient);
            }
Ejemplo n.º 11
0
            public override void ReadMethodInvoke(System system, Buffer buffer)
            {
                Syncronizer  syncronizer = system.GetSyncronizer();
                NetworkActor actor       = syncronizer.GetNetworkActor();

                object[] arguments = ReadArguments(buffer);

                if (actor.IsServer())
                {
                    SendMethodInvoke(system, arguments);
                }
                else
                {
                    object spawned        = Invoke(system.GetTarget(), arguments);
                    Entity spawned_entity = syncronizer.entity_manager.RegisterEntityTarget(buffer.ReadInt32(), spawned, system, this, arguments);

                    spawned_entity.ReadSync(buffer);
                }
            }
Ejemplo n.º 12
0
            public Message(NetworkEnvelope e, Syncronizer s)
            {
                envelope = e;

                buffer = new Buffer(envelope.GetMessage(), s.GetNetworkActor(), s);
            }