Exemple #1
0
    // Token: 0x06002170 RID: 8560 RVA: 0x0007B124 File Offset: 0x00079324
    private bool ShouldDoStandardInitialization(global::NetInstance instance)
    {
        Object customInstantiator = this._customInstantiator;
        bool   result;

        try
        {
            this._customInstantiator = instance;
            if (instance.args.hasCustomInstantiator)
            {
                try
                {
                    return(instance.args.customInstantiate.InitializePrefabInstance(instance));
                }
                catch (Exception ex)
                {
                    Debug.LogError(string.Format("A exception was thrown during InitializePrefabInstance with '{0}' as custom instantiate, prefab '{1}' instance '{2}'.\r\ndoing standard initialization..\r\n{3}", new object[]
                    {
                        instance.args.customInstantiate,
                        this,
                        instance.args.prefab,
                        ex
                    }), instance);
                }
            }
            result = true;
        }
        finally
        {
            this._customInstantiator = customInstantiator;
        }
        return(result);
    }
Exemple #2
0
    // Token: 0x0600216E RID: 8558 RVA: 0x0007AEFC File Offset: 0x000790FC
    private Facepunch.NetworkView Create(ref global::CustomInstantiationArgs args, out IDMain instance)
    {
        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!");
        }
        global::NetInstance currentNetInstance = global::NetMainPrefab._currentNetInstance;

        Facepunch.NetworkView result;
        try
        {
            global::NetMainPrefab._currentNetInstance = null;
            if (args.hasCustomInstantiator)
            {
                instance = null;
                try
                {
                    instance = args.customInstantiate.CustomInstantiatePrefab(ref args);
                }
                catch (Exception arg)
                {
                    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, arg, this), this);
                    if (instance)
                    {
                        Object.Destroy(instance);
                    }
                    instance = null;
                }
                Facepunch.NetworkView networkView;
                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 arg2)
                {
                    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, arg2, this), this);
                }
                if (networkView)
                {
                    return(networkView);
                }
            }
            Facepunch.NetworkView networkView2 = (Facepunch.NetworkView)NetworkInstantiatorUtility.Instantiate(args.prefabNetworkView, args.args);
            instance = networkView2.GetComponent <IDMain>();
            result   = networkView2;
        }
        finally
        {
            global::NetMainPrefab._currentNetInstance = currentNetInstance;
        }
        return(result);
    }
Exemple #3
0
 // Token: 0x06002173 RID: 8563 RVA: 0x0007B20C File Offset: 0x0007940C
 protected virtual void StandardInitialization(bool didAppend, IDRemote appended, global::NetInstance instance, Facepunch.NetworkView view, ref uLink.NetworkMessageInfo info)
 {
     if (didAppend)
     {
         global::NetMainPrefab.IssueLocallyAppended(appended, instance.idMain);
     }
     if (this.ShouldDoStandardInitialization(instance))
     {
         NetworkInstantiatorUtility.BroadcastOnNetworkInstantiate(view, "uLink_OnNetworkInstantiate", info);
     }
 }
Exemple #4
0
    // Token: 0x0600216F RID: 8559 RVA: 0x0007B0D0 File Offset: 0x000792D0
    private global::NetInstance Summon(IDMain prefab, bool isServer, ref NetworkInstantiateArgs niargs)
    {
        global::CustomInstantiationArgs args = new global::CustomInstantiationArgs(this, this._customInstantiator, prefab, ref niargs, isServer);
        IDMain idMain;

        Facepunch.NetworkView networkView = this.Create(ref args, out idMain);
        global::NetInstance   netInstance = networkView.gameObject.AddComponent <global::NetInstance>();

        netInstance.args        = args;
        netInstance.idMain      = idMain;
        netInstance.prepared    = false;
        netInstance.networkView = networkView;
        return(netInstance);
    }
Exemple #5
0
    // Token: 0x06002175 RID: 8565 RVA: 0x0007B318 File Offset: 0x00079518
    protected uLink.NetworkView _Creator(string prefabName, NetworkInstantiateArgs args, uLink.NetworkMessageInfo info)
    {
        global::NetInstance netInstance = this.Summon(this.proxyPrefab, false, ref args);

        if (!netInstance)
        {
            return(null);
        }
        Facepunch.NetworkView networkView = netInstance.networkView;
        if (!networkView)
        {
            return(null);
        }
        info = new uLink.NetworkMessageInfo(info, networkView);
        global::NetInstance currentNetInstance = global::NetMainPrefab._currentNetInstance;

        try
        {
            global::NetMainPrefab._currentNetInstance = netInstance;
            netInstance.info     = info;
            netInstance.prepared = true;
            global::NetInstance netInstance2 = netInstance;
            uLink.NetworkViewID viewID       = args.viewID;
            netInstance2.local = viewID.isMine;
            bool     didAppend = false;
            IDRemote appended  = null;
            if (netInstance.local)
            {
                IDRemote localAppend = this.localAppend;
                if (localAppend)
                {
                    appended  = global::NetMainPrefab.DoLocalAppend(localAppend, netInstance.idMain, this.GetLocalAppendTransform(netInstance.idMain));
                    didAppend = true;
                }
            }
            netInstance.zzz___onprecreate();
            this.StandardInitialization(didAppend, appended, netInstance, networkView, ref info);
            netInstance.zzz___onpostcreate();
        }
        finally
        {
            global::NetMainPrefab._currentNetInstance = currentNetInstance;
        }
        return(networkView);
    }
Exemple #6
0
    // Token: 0x06002176 RID: 8566 RVA: 0x0007B414 File Offset: 0x00079614
    protected void _Destroyer(uLink.NetworkView networkView)
    {
        global::NetInstance currentNetInstance = global::NetMainPrefab._currentNetInstance;

        try
        {
            global::NetInstance component = networkView.GetComponent <global::NetInstance>();
            global::NetMainPrefab._currentNetInstance = component;
            if (component)
            {
                component.zzz___onpredestroy();
            }
            Object.Destroy(networkView.gameObject);
        }
        finally
        {
            global::NetMainPrefab._currentNetInstance = currentNetInstance;
        }
    }
    // Token: 0x0600098E RID: 2446 RVA: 0x0002886C File Offset: 0x00026A6C
    protected override void StandardInitialization(bool didAppend, IDRemote appended, global::NetInstance instance, Facepunch.NetworkView view, ref uLink.NetworkMessageInfo info)
    {
        global::Character    character    = (global::Character)instance.idMain;
        global::Controllable controllable = character.controllable;

        controllable.PrepareInstantiate(view, ref info);
        base.StandardInitialization(false, appended, instance, view, ref info);
        if (didAppend)
        {
            global::NetMainPrefab.IssueLocallyAppended(appended, instance.idMain);
        }
        controllable.OnInstantiated();
    }
    // Token: 0x06002158 RID: 8536 RVA: 0x0007AD0C File Offset: 0x00078F0C
    public static bool IsCurrentlyDestroying(IDRemote remote)
    {
        global::NetInstance current = global::NetInstance.current;

        return(current && current.idMain == remote.idMain);
    }
    // Token: 0x06002157 RID: 8535 RVA: 0x0007ACD8 File Offset: 0x00078ED8
    public static bool IsCurrentlyDestroying(IDLocal local)
    {
        global::NetInstance current = global::NetInstance.current;

        return(current && current.idMain == local.idMain);
    }
 // Token: 0x06002150 RID: 8528 RVA: 0x0007AC38 File Offset: 0x00078E38
 private static void CallbackFire(global::NetInstance instance, global::NetInstance.CallbackFunction func)
 {
     func(instance);
 }