Ejemplo n.º 1
0
    public override void BeforeFixedUpdate(int deltaTime)
    {
        List <EntityBase> list = GetEntityList();

        if (list.Count > 1)
        {
            Debug.LogError("CommandSyncSystem Error exist two selfComponet!");
            return;
        }

        if (list.Count > 0)
        {
            EntityBase          entity = list[0];
            FrameCountComponent fc     = m_world.GetSingletonComp <FrameCountComponent>();
            T comp = new T();

            BuildCommand(comp);
            entity.ChangeComp(comp);

            //缓存起来
            RecordComponent rc = m_world.GetSingletonComp <RecordComponent>();
            rc.m_inputCache = comp;

            ChangeComponentMsg msg = new ChangeComponentMsg();
            msg.frame           = fc.count;
            msg.id              = entity.ID;
            msg.info            = new ComponentInfo();
            msg.info.m_compName = comp.GetType().Name;
            msg.info.content    = Serializer.Serialize(comp);

            ProtocolAnalysisService.SendCommand(msg);
        }
    }
Ejemplo n.º 2
0
        static void ReceviceSyncMsg(SyncSession session, ChangeComponentMsg msg)
        {
            ConnectionComponent commandComp = session.m_connect;

            if (commandComp != null)
            {
                Type type = Type.GetType(msg.info.m_compName);

                if (type != null)
                {
                    PlayerCommandBase comp = (PlayerCommandBase)deserializer.Deserialize(msg.info.m_compName, msg.info.content);
                    commandComp.m_commandList.Add(comp);
                }
            }
            else
            {
            }
        }