예제 #1
0
        public void Write(NWriter wtr)
        {
            wtr.Write(Id);
            Position.Write(wtr);

            wtr.Write((short)Stats.Length);
            foreach (var i in Stats)
            {
                wtr.Write((byte)i.Key);
                if (i.Value is string)
                {
                    wtr.WriteUTF(i.Value as string);
                }
                else
                {
                    wtr.Write((int)i.Value);
                }
            }
        }
예제 #2
0
파일: Structures.cs 프로젝트: maximan20/CJ
 public void Write(Client psr, NWriter wtr)
 {
     try
     {
         wtr.Write(Id);
         Position.Write(psr, wtr);
         wtr.Write((ushort)Stats.Length);
         foreach (KeyValuePair <StatsType, object> i in Stats)
         {
             wtr.Write((byte)i.Key);
             if (i.Key.IsUTF() && i.Value != null)
             {
                 wtr.WriteUTF(i.Value.ToString());
             }
             else
             {
                 wtr.Write((int)i.Value);
             }
         }
     }
     catch (Exception) { }
 }
예제 #3
0
        public void Write(NWriter wtr)
        {
            wtr.Write(Id);
            Position.Write(wtr);

            wtr.Write((short)Stats.Length);
            foreach (var i in Stats)
            {
                wtr.Write((byte)i.Key);

                if (i.Value is int)
                {
                    wtr.Write((int)i.Value);
                    continue;
                }

                if (i.Value is string)
                {
                    //Console.WriteLine(i.Key);
                    wtr.WriteUTF(i.Value as string);
                    continue;
                }

                if (i.Value is bool)
                {
                    wtr.Write((bool)i.Value ? 1 : 0);
                    continue;
                }

                if (i.Value is ushort)
                {
                    wtr.Write((int)(ushort)i.Value);
                    continue;
                }

                throw new InvalidOperationException(
                          $"Stat '{i.Key}' of type '{i.Value?.GetType().ToString() ?? "null"}' not supported.");
            }
        }
예제 #4
0
 public void Write(NWriter wtr)
 {
     try
     {
         wtr.Write(Id);
         Position.Write(wtr);
         wtr.Write((ushort)Stats.Length);
         foreach (var i in Stats)
         {
             wtr.Write((byte)i.Key);
             if (i.Value is int)
             {
                 wtr.Write((int)i.Value);
                 continue;
             }
             if (i.Value is string)
             {
                 wtr.WriteUTF(i.Value.ToString());
                 continue;
             }
             if (i.Value is bool)
             {
                 wtr.Write(i.Value.GetHashCode());
                 continue;
             }
             if (!(i.Value is ushort))
             {
                 throw new InvalidOperationException($"Stat '{i.Key}' of type '{i.Value?.GetType().ToString() ?? "null"}' not supported.");
             }
             wtr.Write((int)(ushort)i.Value);
         }
     }
     catch (Exception ex)
     {
         log.Error(ex);
     }
 }
예제 #5
0
파일: Structures.cs 프로젝트: maximan20/CJ
 public void Write(Client psr, NWriter wtr)
 {
     wtr.Write(Time);
     Position.Write(psr, wtr);
 }
예제 #6
0
 public void Write(NWriter wtr)
 {
     wtr.Write(Time);
     Position.Write(wtr);
 }