Exemplo n.º 1
0
        public void Network_RequestSpawnObject(Identity ident, string bundle, string asset, Vector3 position,
                                               Quaternion rotation, uint callbackId)
        {
            List <Action <uint, bool, GameObject> > serverCallbacks = null;

            if (_callbacks.ContainsKey(ident) && _callbacks[ident].ContainsKey(callbackId))
            {
                serverCallbacks = _callbacks[ident][callbackId];
            }
            AssetBundle             assetBundle  = AssetManager.GetAssetBundle(bundle);
            ObjectSpawnRequestEvent requestEvent = new ObjectSpawnRequestEvent(bundle, asset, position, rotation, callbackId);

            requestEvent.Fire();
            if (requestEvent.IsCancelled)
            {
                Channel.Send(nameof(Networn_SpawnObject), ident, bundle, asset, position, rotation, callbackId, false);
                if (serverCallbacks != null)
                {
                    foreach (var t in serverCallbacks)
                    {
                        t.Invoke(callbackId, false, null);
                    }

                    _callbacks[ident].Remove(callbackId);
                }
                return;
            }

            var obj = SpawnObject(assetBundle, asset, position, rotation, true, callbackId);

            if (serverCallbacks != null)
            {
                foreach (var t in serverCallbacks)
                {
                    t.Invoke(callbackId, true, obj);
                }

                _callbacks[ident].Remove(callbackId);
            }
        }
Exemplo n.º 2
0
 private void OnSpawnObject(ObjectSpawnRequestEvent e)
 {
     SpawnObject(e.ObjectPrefab, Level.ObjectSpawnTiles);
 }
Exemplo n.º 3
0
 /// <summary>
 /// React to \ref RoundManager.Events.ObjectSpawnRequestEvent "ObjectSpawnRequestEvent".
 /// Place logic to spawn preperation objects here.
 /// </summary>
 /// <param name="e">Event.</param>
 public void OnObjectSpawnRequest(ObjectSpawnRequestEvent e)
 {
 }