Ejemplo n.º 1
0
        /// <summary>
        /// Informs all clients and the server to create arcs with the given settings.
        /// While the arcs are active, the server emits a regular pulse event with which can be subscribed to, for handling damage etc.
        /// </summary>
        /// <returns>an arc instance created on the server</returns>
        public static ElectricalArc ServerCreateNetworkedArcs(ElectricalArcSettings settings)
        {
            ElectricalArcMessage.SendToAll(settings);

            var arc = new ElectricalArc();

            arc.CreateArcs(settings);
            return(arc);
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Sends a message to all clients, informing them to create an electrical arc with the given settings.
 /// </summary>
 public static ElectricalArcMessage SendToAll(ElectricalArcSettings arcSettings)
 {
     if (arcSettings.arcEffectPrefab.TryGetComponent <NetworkIdentity>(out var identity))
     {
         var msg = new ElectricalArcMessage
         {
             prefabAssetID = identity.assetId,
             startObject   = arcSettings.startObject,
             endObject     = arcSettings.endObject,
             startPosition = arcSettings.startPosition,
             endPosition   = arcSettings.endPosition,
             arcCount      = arcSettings.arcCount,
             duration      = arcSettings.duration,
         };
         msg.SendToAll();
         return(msg);
     }
     else
     {
         Logger.LogError($"No {nameof(NetworkIdentity)} found on {arcSettings.arcEffectPrefab}!", Category.NetMessage);
         return(default);