Пример #1
0
        public static RWPtr ReadNetObj <T>(this RWPtr str, out T?netObj)
            where T : NetworkBehaviour
        {
            var res = str.ReadStruct(out NetworkInstanceId id);

            netObj = id.FindLocalObj <T>();
            return(res);
        }
Пример #2
0
        public static RWPtr Read(this RWPtr str, out HurtBox?hurtbox)
        {
            var   res   = str.ReadNetObj(out CharacterBody body).ReadStruct(out Byte by);
            var   r     = body?.hurtBoxGroup?.hurtBoxes;
            Int32 index = by;

            index--;
            hurtbox = r is not null && index < r.Length ? r[index] : null;
            return(res);
        }
Пример #3
0
        public static RWPtr ReadStruct <T>(this RWPtr str, out T item)
            where T : unmanaged
        {
            var ptr = (T *)str.ptr;

            item = ptr[0];
            ptr++;
            str.ptr = (void *)ptr;
            return(str);
        }
Пример #4
0
        public static RWPtr WriteStruct <T>(this RWPtr str, T item)
            where T : unmanaged
        {
            var ptr = (T *)str.ptr;

            ptr[0] = item;
            ptr++;
            str.ptr = (void *)ptr;
            return(str);
        }
Пример #5
0
 public static RWPtr Write(this RWPtr str, HurtBox hurtbox) => str
 .WriteNetObj(hurtbox?.healthComponent?.body)
 .WriteStruct((Byte)(hurtbox.indexInGroup + 1));
Пример #6
0
 public static RWPtr WriteNetObj <T>(this RWPtr str, T netObj)
     where T : NetworkBehaviour
 => str.WriteStruct(netObj.netId);