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); }
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); }
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); }
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); }
public static RWPtr Write(this RWPtr str, HurtBox hurtbox) => str .WriteNetObj(hurtbox?.healthComponent?.body) .WriteStruct((Byte)(hurtbox.indexInGroup + 1));
public static RWPtr WriteNetObj <T>(this RWPtr str, T netObj) where T : NetworkBehaviour => str.WriteStruct(netObj.netId);