Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

😱😎🙂💀😈 #51

Merged
merged 4 commits into from
Aug 27, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions EXILED/Exiled.API/Extensions/MirrorExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,7 @@ public static void MessageTranslated(this Player player, string words, string tr
/// <param name="targetType"><see cref="NetworkBehaviour"/>'s type.</param>
/// <param name="propertyName">Property name starting with Network.</param>
/// <param name="value">Value of send to target.</param>
[Obsolete("Use overload with type-template instead.")]
public static void SendFakeSyncVar(this Player target, NetworkIdentity behaviorOwner, Type targetType, string propertyName, object value)
{
if (!target.IsConnected)
Expand All @@ -386,6 +387,38 @@ void CustomSyncVarGenerator(NetworkWriter targetWriter)
}
}

/// <summary>
/// Send fake values to client's <see cref="SyncVarAttribute"/>.
/// </summary>
/// <typeparam name="T">Target SyncVar property type.</typeparam>
/// <param name="target">Target to send.</param>
/// <param name="behaviorOwner"><see cref="NetworkIdentity"/> of object that owns <see cref="NetworkBehaviour"/>.</param>
/// <param name="targetType"><see cref="NetworkBehaviour"/>'s type.</param>
/// <param name="propertyName">Property name starting with Network.</param>
/// <param name="value">Value of send to target.</param>
public static void SendFakeSyncVar<T>(this Player target, NetworkIdentity behaviorOwner, Type targetType, string propertyName, T value)
{
if (!target.IsConnected)
return;

NetworkWriterPooled writer = NetworkWriterPool.Get();
NetworkWriterPooled writer2 = NetworkWriterPool.Get();
MakeCustomSyncWriter(behaviorOwner, targetType, null, CustomSyncVarGenerator, writer, writer2);
target.Connection.Send(new EntityStateMessage
{
netId = behaviorOwner.netId,
payload = writer.ToArraySegment(),
});

NetworkWriterPool.Return(writer);
NetworkWriterPool.Return(writer2);
void CustomSyncVarGenerator(NetworkWriter targetWriter)
{
targetWriter.WriteULong(SyncVarDirtyBits[$"{targetType.Name}.{propertyName}"]);
WriterExtensions[typeof(T)]?.Invoke(null, new object[2] { targetWriter, value });
}
}

/// <summary>
/// Force resync to client's <see cref="SyncVarAttribute"/>.
/// </summary>
Expand Down
5 changes: 5 additions & 0 deletions EXILED/Exiled.Events/Patches/Generic/DoorList.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@ namespace Exiled.Events.Patches.Generic
[HarmonyPatch(typeof(DoorVariant), nameof(DoorVariant.RegisterRooms))]
internal class DoorList
{
private static bool Prefix(DoorVariant __instance)
{
return __instance.Rooms == null;
}
IRacle1 marked this conversation as resolved.
Show resolved Hide resolved

private static void Postfix(DoorVariant __instance)
{
if (Door.DoorVariantToDoor.ContainsKey(__instance))
Expand Down
Loading