Exemple #1
0
        /// <summary>
        /// Sends an already constructed SpaceMessage to others, if Spacemessage has an ID of 0 it will pick the next id.
        /// </summary>
        /// <param name="message">SpaceMessage being sent or resent</param>
        /// <returns>Returns SpaceMessage with populated ID</returns>
        public SpaceMessage SendToOthers(SpaceMessage message)
        {
            var msg = Encode(ref message);

            MyAPIGateway.Multiplayer.SendMessageToOthers(HUDAPI_ADVMSG, msg, true);
            return(message);
        }
Exemple #2
0
        private byte[] Encode(ref SpaceMessage message)
        {
            ushort msgtype = 1;

            if (message.id == 0)
            {
                message.id = GetNextID();
            }

            byte[] ver    = BitConverter.GetBytes(MOD_VER);
            byte[] type   = BitConverter.GetBytes(msgtype);
            byte[] modid  = BitConverter.GetBytes(m_modId);
            byte[] mid    = BitConverter.GetBytes(message.id);
            byte[] ttl    = BitConverter.GetBytes(message.ttl);
            byte[] orient = new byte[1] {
                (byte)message.t_orientation
            };
            byte[] pos    = Encode(message.pos);
            byte[] up     = Encode(message.up);
            byte[] left   = Encode(message.left);
            byte[] scale  = BitConverter.GetBytes(message.scale);
            byte[] encode = Encoding.UTF8.GetBytes(message.message);
            byte[] msg    = new byte[ver.Length + type.Length + modid.Length + mid.Length + ttl.Length + pos.Length + up.Length + left.Length + scale.Length + encode.Length + 1];
            int    lth    = 0;

            Copy(ref msg, ref ver, ref lth);
            Copy(ref msg, ref type, ref lth);
            Copy(ref msg, ref modid, ref lth);
            Copy(ref msg, ref mid, ref lth);
            Copy(ref msg, ref ttl, ref lth);
            Copy(ref msg, ref orient, ref lth);
            Copy(ref msg, ref pos, ref lth);
            Copy(ref msg, ref up, ref lth);
            Copy(ref msg, ref left, ref lth);
            Copy(ref msg, ref scale, ref lth);
            Copy(ref msg, ref encode, ref lth);
            return(msg);
        }
Exemple #3
0
        private byte[] Encode(ref SpaceMessage message)
        {
            ushort msgtype = 1;
            if (message.id == 0)
            {

                message.id = GetNextID();
            }

            byte[] ver = BitConverter.GetBytes(MOD_VER);
            byte[] type = BitConverter.GetBytes(msgtype);
            byte[] modid = BitConverter.GetBytes(m_modId);
            byte[] mid = BitConverter.GetBytes(message.id);
            byte[] ttl = BitConverter.GetBytes(message.ttl);
            byte[] orient = new byte[1] { (byte)message.t_orientation };
            byte[] pos = Encode(message.pos);
            byte[] up = Encode(message.up);
            byte[] left = Encode(message.left);
            byte[] scale = BitConverter.GetBytes(message.scale);
            byte[] encode = Encoding.UTF8.GetBytes(message.message);
            byte[] msg = new byte[ver.Length + type.Length + modid.Length + mid.Length + ttl.Length + pos.Length + up.Length + left.Length + scale.Length + encode.Length + 1];
            int lth = 0;
            Copy(ref msg, ref ver, ref lth);
            Copy(ref msg, ref type, ref lth);
            Copy(ref msg, ref modid, ref lth);
            Copy(ref msg, ref mid, ref lth);
            Copy(ref msg, ref ttl, ref lth);
            Copy(ref msg, ref orient, ref lth);
            Copy(ref msg, ref pos, ref lth);
            Copy(ref msg, ref up, ref lth);
            Copy(ref msg, ref left, ref lth);
            Copy(ref msg, ref scale, ref lth);
            Copy(ref msg, ref encode, ref lth);
            return msg;
        }
Exemple #4
0
 /// <summary>
 /// Sends an already constructed SpaceMessage to others, if Spacemessage has an ID of 0 it will pick the next id. 
 /// </summary>
 /// <param name="message">SpaceMessage being sent or resent</param>
 /// <returns>Returns SpaceMessage with populated ID</returns>
 public SpaceMessage SendToOthers(SpaceMessage message)
 {
     var msg = Encode(ref message);
     MyAPIGateway.Multiplayer.SendMessageToOthers(HUDAPI_ADVMSG, msg, true);
     return message;
 }