Esempio n. 1
0
 /// <summary>
 /// Inform all clients about this spawn event
 /// </summary>
 /// <param name="result">results of the spawn that was already performed server side</param>
 /// <returns></returns>
 public static void SendToAll(SpawnResult result)
 {
     foreach (var spawnedObject in result.GameObjects)
     {
         SpawnMessage msg = new SpawnMessage
         {
             SpawnedObject = spawnedObject.NetId(),
             ClonedFrom    = result.SpawnInfo.SpawnType == SpawnType.Clone ? result.SpawnInfo.ClonedFrom.NetId() : NetId.Invalid
         };
         msg.SendToAll();
     }
 }
Esempio n. 2
0
    /// <summary>
    /// NOTE: For internal lifecycle system use only.
    ///
    /// Fires all the server side spawn hooks for the given spawn and messages all clients telling them to fire their
    /// client-side hooks. Should only be called after object becomes networked / known by clients.
    /// </summary>
    /// <param name="result"></param>
    public static void _ServerFireClientServerSpawnHooks(SpawnResult result)
    {
        //fire server hooks
        foreach (var spawnedObject in result.GameObjects)
        {
            var comps = spawnedObject.GetComponents <IServerSpawn>();
            if (comps != null)
            {
                foreach (var comp in comps)
                {
                    comp.OnSpawnServer(result.SpawnInfo);
                }
            }
        }

        //fire client hooks
        SpawnMessage.SendToAll(result);
    }