/// <summary>
    /// Serialize the specified commandName and param.
    /// </summary>
    /// <param name='commandName'>
    /// Command name.
    /// </param>
    /// <param name='param'>
    /// Parameter.
    /// </param>
    public byte[] Serialize(params object[] param)
    {
        // validate that the packet has an array of shorts, and a vector3
        if (param.Length == 0 || !(param[0] is int))
        {
            throw new System.InvalidCastException("This module requires no params");
        }

        DFNetwork.Helpers.Serializer serialize = new DFNetwork.Helpers.Serializer();

        serialize.AddBits(((int)param[0]));

        return(serialize.ToArray());
    }
Exemple #2
0
    /// <summary>
    /// Serialize the specified commandName and param.
    /// </summary>
    /// <param name='commandName'>
    /// Command name.
    /// </param>
    /// <param name='param'>
    /// Parameter.
    /// </param>
    public byte[] Serialize(params object[] param)
    {
        // validate that the packet has an array of shorts, and a vector3
        if (param.Length == 0 || !(param[0] is short) || !(param[1] is Vector3) || !(param[2] is Quaternion))
        {
            throw new System.InvalidCastException("This module requires a short sent as param[0] and a vector3 sent as param[1] and a quaternion as param[2]");
        }

        DFNetwork.Helpers.Serializer serialize = new DFNetwork.Helpers.Serializer();

        serialize.AddBits(((short)param[0]));
        serialize.AddBits(((Vector3)param[1]));
        serialize.AddBits(((Quaternion)param[2]));
        serialize.AddBits(((int)param[3]));

        return(serialize.ToArray());
    }