public static bool Prefix(MenuScript __instance) { if (GadgetNetwork.connectTime < 0) { GadgetNetwork.connectTime = Time.realtimeSinceStartup; } if (!GadgetNetwork.MatrixReady && GadgetNetwork.GetTimeSinceConnect() < GadgetNetwork.MatrixTimeout) { if (InstanceTracker.GameScript.gameObject.GetComponent <RPCHooks>() == null) { InstanceTracker.GameScript.gameObject.AddComponent <RPCHooks>(); } RPCHooks.InitiateGadgetNetwork(); __instance.StartCoroutine(WaitAndTryAgain(__instance)); return(false); } else { if (!GadgetNetwork.MatrixReady) { GadgetNetwork.InitializeVanillaIDMatrix(); } return(true); } }
public static bool Prefix(ref UnityEngine.Object prefab, Vector3 position, Quaternion rotation, int group, ref UnityEngine.Object __result) { if (GadgetCoreAPI.resourcePaths.ContainsKey(prefab.GetInstanceID())) { __result = RPCHooks.Instantiate(GadgetCoreAPI.resourcePaths[prefab.GetInstanceID()], position, rotation, group); return(false); } return(true); }
/// <summary> /// Disconnects the target player from this server with a provided message. /// </summary> public static void DisconnectPlayerWithMessage(NetworkPlayer player, string message) { if (Network.isServer) { RPCHooks.DisconnectWithMessage(player, message); } else { throw new InvalidOperationException("Only the server may disconnect other players!"); } }
public static bool Prefix(NetworkViewID viewID) { NetworkView view = NetworkView.Find(viewID); if (Network.isServer && view != null && (view.hideFlags & (HideFlags)64) != 0) { view.hideFlags &= ~(HideFlags)64; RPCHooks.Destroy(viewID); return(false); } return(true); }
public static bool Prefix(ChunkWorld __instance) { if (!GadgetNetwork.MatrixReady && GadgetNetwork.GetTimeSinceConnect() < GadgetNetwork.MatrixTimeout) { if (InstanceTracker.GameScript.gameObject.GetComponent <RPCHooks>() == null) { InstanceTracker.GameScript.gameObject.AddComponent <RPCHooks>(); } RPCHooks.InitiateGadgetNetwork(); __instance.StartCoroutine(WaitAndTryAgain(__instance)); return(false); } else { return(true); } }
public static bool Prefix(GameScript __instance) { if (!GadgetNetwork.MatrixReady && GadgetNetwork.GetTimeSinceConnect() < GadgetNetwork.MatrixTimeout) { if (InstanceTracker.GameScript.gameObject.GetComponent <RPCHooks>() == null) { InstanceTracker.GameScript.gameObject.AddComponent <RPCHooks>(); } RPCHooks.InitiateGadgetNetwork(); __instance.StartCoroutine(WaitAndTryAgain(__instance)); return(false); } else { if (GadgetNetwork.GetTimeSinceConnect() > GadgetNetwork.MatrixTimeout && Gadgets.ListAllGadgetInfos().Any(x => x.Attribute.RequiredOnClients)) { GadgetCore.CoreLogger.LogWarning("Disconnecting from server due to timout! You can try raising NetworkTimeout in the config."); Network.Disconnect(); return(false); } return(true); } }