Beispiel #1
0
    private Facepunch.NetworkView Create(ref CustomInstantiationArgs args, out IDMain instance)
    {
        Facepunch.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)
            {
                Facepunch.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)
                    {
                        UnityEngine.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);
                }
            }
            Facepunch.NetworkView view2 = (Facepunch.NetworkView)NetworkInstantiatorUtility.Instantiate(args.prefabNetworkView, args.args);
            instance = view2.GetComponent <IDMain>();
            view3    = view2;
        }
        finally
        {
            _currentNetInstance = instance2;
        }
        return(view3);
    }
 protected void SMSet(uLink.NetworkViewID masterViewID)
 {
     Facepunch.NetworkView networkView = Facepunch.NetworkView.Find(masterViewID);
     if (networkView)
     {
         global::StructureMaster component = networkView.GetComponent <global::StructureMaster>();
         if (component)
         {
             component.AppendStructureComponent(this);
         }
         else
         {
             Debug.LogWarning("No Master On GO", networkView);
         }
     }
     else
     {
         Debug.LogWarning("Couldnt find master view", this);
     }
 }
Beispiel #3
0
 protected void SMSet(uLink.NetworkViewID masterViewID)
 {
     Facepunch.NetworkView context = Facepunch.NetworkView.Find(masterViewID);
     if (context != null)
     {
         StructureMaster component = context.GetComponent <StructureMaster>();
         if (component != null)
         {
             component.AppendStructureComponent(this);
         }
         else
         {
             Debug.LogWarning("No Master On GO", context);
         }
     }
     else
     {
         Debug.LogWarning("Couldnt find master view", this);
     }
 }