コード例 #1
0
 // Token: 0x06005A57 RID: 23127 RVA: 0x001F7830 File Offset: 0x001F5C30
 private static void AssignObjectParameter(VRC_EventLog.EventLogEntry entry, VRC_EventDispatcherRFC Dispatcher)
 {
     if (entry != null && entry.Event != null && entry.Event.ParameterObject == null && !string.IsNullOrEmpty(entry.ObjectPath))
     {
         GameObject gameObject = VRC.Network.FindGameObject(entry.ObjectPath, true);
         if (gameObject != null)
         {
             entry.Event.ParameterObject = gameObject;
         }
     }
 }
コード例 #2
0
    // Token: 0x060058F8 RID: 22776 RVA: 0x001ED1C4 File Offset: 0x001EB5C4
    public GameObject InstantiateObject(VRC_EventHandler.VrcBroadcastType broadcast, string prefabName, Vector3 position, Quaternion rotation)
    {
        if (VRC.Network.SceneEventHandler == null)
        {
            Debug.LogError("Could not instantiate " + prefabName + ": Instantiator is not initialized", base.gameObject);
            return(null);
        }
        if (!VRC_EventDispatcherRFC.IsValidExecutor(VRC.Network.LocalPlayer, broadcast, base.gameObject))
        {
            Debug.LogError("Could not instantiate " + prefabName + ": Client is not a valid remote for " + broadcast.ToString(), base.gameObject);
            return(null);
        }
        VRC_EventHandler.VrcTargetType vrcTargetType;
        switch (broadcast)
        {
        case VRC_EventHandler.VrcBroadcastType.Always:
        case VRC_EventHandler.VrcBroadcastType.Master:
        case VRC_EventHandler.VrcBroadcastType.Owner:
            vrcTargetType = VRC_EventHandler.VrcTargetType.AllBuffered;
            break;

        case VRC_EventHandler.VrcBroadcastType.Local:
            vrcTargetType = VRC_EventHandler.VrcTargetType.Local;
            break;

        default:
            Debug.LogError("Could not instantiate " + prefabName + ": Instantiation cannot be unbuffered.", base.gameObject);
            return(null);
        }
        if (broadcast > VRC_EventHandler.VrcBroadcastType.Owner)
        {
            Debug.LogError("Could not instantiate " + prefabName + ": Instantiation cannot be unbuffered.", base.gameObject);
            return(null);
        }
        ObjectInstantiator.PrefabInfo prefabInfo = this._FetchPrefab(prefabName);
        if (prefabInfo == null)
        {
            Debug.LogError("Could not instantiate " + prefabName + ": Could not locate prefab", base.gameObject);
            return(null);
        }
        int num = Math.Max(1, prefabInfo.viewCount);

        int[] array = VRC.Network.AllocateSubIDs(num);
        if (array == null)
        {
            Debug.LogError("Could not instantiate " + prefabName + ": could not allocate IDs.", base.gameObject);
            return(null);
        }
        byte[] array2 = new byte[2 + 4 * num + 28];
        int    num2   = 0;

        Protocol.Serialize(position.x, array2, ref num2);
        Protocol.Serialize(position.y, array2, ref num2);
        Protocol.Serialize(position.z, array2, ref num2);
        Protocol.Serialize(rotation.x, array2, ref num2);
        Protocol.Serialize(rotation.y, array2, ref num2);
        Protocol.Serialize(rotation.z, array2, ref num2);
        Protocol.Serialize(rotation.w, array2, ref num2);
        Protocol.Serialize((short)num, array2, ref num2);
        foreach (int value in array)
        {
            Protocol.Serialize(value, array2, ref num2);
        }
        int?num3 = this.MakeID();

        if (num3 == null)
        {
            Debug.LogError("Could not instantiate " + prefabName + ": Ran out of IDs", base.gameObject);
            VRC.Network.UnAllocateSubIDs(array);
            return(null);
        }
        this.spawnedObjects.Add(num3.Value, new ObjectInstantiator.ObjectInfo
        {
            data       = array2,
            gameObject = null,
            prefabName = prefabName,
            localId    = num3.Value
        });
        this.DebugPrint("Instantiating " + prefabName, new object[]
        {
            base.gameObject
        });
        VRC.Network.RPC(vrcTargetType, base.gameObject, "_InstantiateObject", new object[]
        {
            prefabName,
            array2,
            num3.Value
        });
        VRC.Network.RPC((vrcTargetType != VRC_EventHandler.VrcTargetType.Local) ? VRC_EventHandler.VrcTargetType.All : VRC_EventHandler.VrcTargetType.Local, base.gameObject, "_SendOnSpawn", new object[]
        {
            num3.Value
        });
        return(this.spawnedObjects[num3.Value].gameObject);
    }