Пример #1
0
        public UpdateLatestPacakge CreateClientUpdateLatestPacakge(EntityKey selfKey)
        {
            var entity = gameContexts.GetGameEntity(selfKey);

            if (entity == null)
            {
                return(null);
            }
#pragma warning disable RefCounter001,RefCounter002
            UpdateLatestPacakge pacakge = UpdateLatestPacakge.Allocate();
#pragma warning restore RefCounter001,RefCounter002

            pacakge.Head.LastAckUserCmdSeq = LastAckUserCmdSeq;
            pacakge.Head.LastUserCmdSeq    = LastLocalUserCmd;
            pacakge.Head.LastSnapshotId    = LastAckSnapshotId;
            var components = entity.GetUpdateLatestComponents();
            AssertUtility.Assert(components.Count < 255);
            pacakge.Head.ComponentCount = (byte)components.Count;
            foreach (var gameComponent in components)
            {
                IUpdateComponent copy =
                    (IUpdateComponent)GameComponentInfo.Instance.Allocate(gameComponent.GetComponentId());
                copy.CopyFrom(gameComponent);
                pacakge.UpdateComponents.Add(copy);
            }

            return(pacakge);
        }
Пример #2
0
 public void AddMessage(UpdateLatestPacakge message)
 {
     if (_lastSeq < message.Head.UserCmdSeq)
     {
         LatestMessage = message;
         _lastSeq      = message.Head.UserCmdSeq;
         _list.Add(message);
         message.AcquireReference();
         dict.Add(message.Head.UserCmdSeq, message);
         Trun();
     }
 }