private NetworkView Create(ref CustomInstantiationArgs args, out IDMain instance) { NetworkView view3; if ((float.IsNaN(args.position.x) || float.IsNaN(args.position.y)) || float.IsNaN(args.position.z)) { Debug.LogWarning("NetMainPrefab -> Create - args.position = " + args.position); Debug.LogWarning("This means you're creating an object with a bad position!"); } NetInstance instance2 = _currentNetInstance; try { _currentNetInstance = null; if (args.hasCustomInstantiator) { NetworkView networkView; instance = null; try { instance = args.customInstantiate.CustomInstantiatePrefab(ref args); } catch (Exception exception) { Debug.LogError(string.Format("Thrown Exception during custom instantiate via '{0}' with instantiation '{2}'\r\ndefault instantiation will now occur -- exception follows..\r\n{1}", args.customInstantiate, exception, this), this); if (instance != null) { Object.Destroy(instance); } instance = null; } try { networkView = instance.networkView; if (networkView == null) { Debug.LogWarning(string.Format("The custom instantiator '{0}' with instantiation '{1}' did not return a idmain with a network view. so its being added", args.customInstantiate, this), this); networkView = instance.gameObject.AddComponent <uLinkNetworkView>(); } } catch (Exception exception2) { networkView = null; Debug.LogError(string.Format("The custom instantiator '{0}' did not instantiate a IDMain with a networkview or something else with instantiation '{2}'.. \r\n {1}", args.customInstantiate, exception2, this), this); } if (networkView != null) { return(networkView); } } NetworkView view2 = (NetworkView)NetworkInstantiatorUtility.Instantiate(args.prefabNetworkView, args.args); instance = view2.GetComponent <IDMain>(); view3 = view2; } finally { _currentNetInstance = instance2; } return(view3); }
private NetInstance Summon(IDMain prefab, bool isServer, ref NetworkInstantiateArgs niargs) { IDMain main; CustomInstantiationArgs args = new CustomInstantiationArgs(this, this._customInstantiator, prefab, ref niargs, isServer); NetworkView view = this.Create(ref args, out main); NetInstance instance = view.gameObject.AddComponent <NetInstance>(); instance.args = args; instance.idMain = main; instance.prepared = false; instance.networkView = view; return(instance); }
private NetInstance Summon(IDMain prefab, bool isServer, ref NetworkInstantiateArgs niargs) { IDMain dMain; CustomInstantiationArgs customInstantiationArg = new CustomInstantiationArgs(this, this._customInstantiator, prefab, ref niargs, isServer); Facepunch.NetworkView networkView = this.Create(ref customInstantiationArg, out dMain); NetInstance netInstance = networkView.gameObject.AddComponent <NetInstance>(); netInstance.args = customInstantiationArg; netInstance.idMain = dMain; netInstance.prepared = false; netInstance.networkView = networkView; return(netInstance); }
private CustomInstantiationArgs(NetMainPrefab netMain, UnityEngine.Object customInstantiator, IDMain prefab, ref NetworkInstantiateArgs args, bool server, bool checkCustomInstantitorArgument) { this.netMain = netMain; this.prefab = prefab; this.prefabNetworkView = prefab.networkView; this.args = args; this.server = server; if (!checkCustomInstantitorArgument || !customInstantiator) { this.hasCustomInstantiator = CustomInstantiationArgs.CheckNetworkViewCustomInstantiator(this.prefabNetworkView, this.prefab, out this.customInstantiate); } else { this.customInstantiate = customInstantiator as IPrefabCustomInstantiate; if (this.customInstantiate != null) { this.hasCustomInstantiator = true; } else { this.hasCustomInstantiator = CustomInstantiationArgs.CheckNetworkViewCustomInstantiator(this.prefabNetworkView, this.prefab, out this.customInstantiate); } } }
private static bool CheckNetworkViewCustomInstantiator(uLink.NetworkView view, IDMain character, out IPrefabCustomInstantiate custom) { return(CustomInstantiationArgs.CheckNetworkViewCustomInstantiator(view, out custom) ? true : CustomInstantiationArgs.CheckNetworkViewCustomInstantiator(character, out custom)); }