Ejemplo n.º 1
0
        public static void SendText(string text, Target target)
        {
            {
                if (BoltNetwork.isRunning)
                {
                    ChatEvent chatEvent = null;
                    switch (target)
                    {
                    case Target.OnlyServer:
                        chatEvent = ChatEvent.Create(GlobalTargets.OnlyServer);
                        break;

                    case Target.Everyone:
                        chatEvent = ChatEvent.Create(GlobalTargets.Everyone);
                        break;

                    case Target.Clients:
                        chatEvent = ChatEvent.Create(GlobalTargets.AllClients);
                        break;

                    case Target.Others:
                        chatEvent = ChatEvent.Create(GlobalTargets.Others);
                        break;

                    default:
                        break;
                    }
                    chatEvent.Message = text;
                    chatEvent.Sender  = ChatBoxMod.ModNetworkID;
                    chatEvent.Send();
                }
            }
        }
Ejemplo n.º 2
0
 private void SendLine(string line)
 {
     if (BoltNetwork.isRunning)
     {
         if (line[0] == '/')
         {
             line = line.Trim(new char[]
             {
                 ' ',
                 '/'
             });
             int num = line.IndexOf(' ');
             if (num == -1)
             {
                 CoopAdminCommand.Send(line, string.Empty);
             }
             else
             {
                 CoopAdminCommand.Send(line.Substring(0, num), line.Substring(num + 1, line.Length - (num + 1)));
             }
         }
         else
         {
             ChatEvent chatEvent = ChatEvent.Create(GlobalTargets.OnlyServer);
             chatEvent.Message = line;
             chatEvent.Sender  = LocalPlayer.Entity.networkId;
             chatEvent.Send();
         }
     }
 }
        public override void OnEvent(ChatEvent evnt)
        {
            if (!this.ValidateSender(evnt, global::SenderTypes.Any))
            {
                return;
            }
            if (evnt.Sender == NetworkChatMod.ModNetworkID)
            {
                return;
            }

            for (int i = 0; i < TheForest.Utils.Scene.SceneTracker.allPlayerEntities.Count; i++)
            {
                if (TheForest.Utils.Scene.SceneTracker.allPlayerEntities[i].source == evnt.RaisedBy)
                {
                    if (TheForest.Utils.Scene.SceneTracker.allPlayerEntities[i].networkId == evnt.Sender)
                    {
                        ChatEvent chatEvent = ChatEvent.Create(GlobalTargets.AllClients);
                        chatEvent.Sender  = evnt.Sender;
                        chatEvent.Message = evnt.Message;
                        chatEvent.Send();
                    }
                    return;
                }
            }
            if (BoltNetwork.isServer && evnt.RaisedBy == null)
            {
                ChatEvent chatEvent2 = ChatEvent.Create(GlobalTargets.AllClients);
                chatEvent2.Sender  = evnt.Sender;
                chatEvent2.Message = evnt.Message;
                chatEvent2.Send();
            }
        }
Ejemplo n.º 4
0
    private static void SendNetworkMessage(string message, BoltConnection source)
    {
        ChatEvent chatEvent = ChatEvent.Create(source);

        chatEvent.Message = message;
        chatEvent.Send();
    }
Ejemplo n.º 5
0
        private void SendChatMessage(string message)
        {
            ChatEvent c = ChatEvent.Create(GlobalTargets.AllClients);

            c.Message = message;
            c.Send();
        }
        private void sendChatMessage(NetworkId id, string message)
        {
            ChatEvent c = ChatEvent.Create(GlobalTargets.AllClients);

            c.Message = message;
            c.Sender  = id;
            c.Send();
        }
Ejemplo n.º 7
0
    private static void SendNetworkMessageAll(string message)
    {
        ChatEvent chatEvent = ChatEvent.Create(GlobalTargets.AllClients);

        chatEvent.Message = message;
        chatEvent.Sender  = CoopServerInfo.Instance.entity.networkId;
        chatEvent.Send();
    }
Ejemplo n.º 8
0
    public override void OnEvent(ChatEvent evnt)
    {
        ChatEvent chatEvent = ChatEvent.Raise(GlobalTargets.AllClients);

        chatEvent.Sender  = evnt.Sender;
        chatEvent.Message = evnt.Message;
        chatEvent.Send();
    }
Ejemplo n.º 9
0
 private void SendLine(string line)
 {
     if (BoltNetwork.isRunning)
     {
         ChatEvent chatEvent = ChatEvent.Create(GlobalTargets.OnlyServer);
         chatEvent.Message = line;
         chatEvent.Sender  = LocalPlayer.Entity.networkId;
         chatEvent.Send();
     }
 }
Ejemplo n.º 10
0
 /// <summary>
 /// Sends bytes to targets, calls RecieveCommand on them
 /// </summary>
 /// <param name="bytearray">Bytes to send</param>
 /// <param name="target">Choose between possible recievers</param>
 public static void SendCommand(byte[] bytearray, GlobalTargets target)
 {
     if (BoltNetwork.isRunning)
     {
         ChatEvent chatEvent = ChatEvent.Create(target);
         chatEvent.Message = BytesToString(bytearray);
         chatEvent.Sender  = NetworkConfig.ModNetworkID;
         chatEvent.Send();
     }
 }
Ejemplo n.º 11
0
 public static void SendLine(byte[] bytearray, BoltConnection con)
 {
     if (GameSetup.IsSinglePlayer || !BoltNetwork.isRunning)
     {
         RecieveLine(bytearray);
     }
     else
     {
         if (BoltNetwork.isRunning)
         {
             ChatEvent chatEvent = ChatEvent.Create(con);
             chatEvent.Message = EncodeCommand(bytearray);
             chatEvent.Sender  = ChatBoxMod.ModNetworkID;
             chatEvent.Send();
         }
     }
 }
Ejemplo n.º 12
0
 public static void SendLine(string s, BoltConnection con)
 {
     if (GameSetup.IsSinglePlayer || !BoltNetwork.isRunning)
     {
         RecieveLine(s);
     }
     else
     {
         if (BoltNetwork.isRunning)
         {
             ChatEvent chatEvent = ChatEvent.Create(con);
             chatEvent.Message = s;
             chatEvent.Sender  = ChatBoxMod.ModNetwokrID;
             chatEvent.Send();
         }
     }
 }
Ejemplo n.º 13
0
        /// <summary>
        /// Sends a string to all players on the server
        /// </summary>
        /// <param name="s">Content of the message, make sure it ends with ';'</param>
        public static void SendLine(string s, Target target)
        {
            if (GameSetup.IsSinglePlayer || !BoltNetwork.isRunning)
            {
                RecieveLine(s);
            }
            else
            {
                if (BoltNetwork.isRunning)
                {
                    ChatEvent chatEvent = null;
                    switch (target)
                    {
                    case Target.OnlyServer:
                        chatEvent = ChatEvent.Create(GlobalTargets.OnlyServer);
                        break;

                    case Target.Everyone:
                        chatEvent = ChatEvent.Create(GlobalTargets.Everyone);
                        break;

                    case Target.Clinets:
                        chatEvent = ChatEvent.Create(GlobalTargets.AllClients);
                        break;

                    case Target.Others:
                        chatEvent = ChatEvent.Create(GlobalTargets.Others);
                        break;

                    default:
                        break;
                    }

                    chatEvent.Message = s;
                    chatEvent.Sender  = ChatBoxMod.ModNetwokrID;
                    chatEvent.Send();

                    Debug.Log("Sent: " + s);
                }
            }
        }
        public override void OnEvent(ChatEvent evnt)
        {
            //the host would resend all commands to the clients.
            //this is okay for chat messages
            //but with commands sent directly there is no need. This adds unnecessary latency.
            //additionally all events like experience after a kill would be proc twice for clients.


            if (!this.ValidateSender(evnt, global::SenderTypes.Any))
            {
                return;
            }
            if (evnt.Sender == ChatBoxMod.ModNetworkID)
            {
                return;
            }

            for (int i = 0; i < TheForest.Utils.Scene.SceneTracker.allPlayerEntities.Count; i++)
            {
                if (TheForest.Utils.Scene.SceneTracker.allPlayerEntities[i].source == evnt.RaisedBy)
                {
                    if (TheForest.Utils.Scene.SceneTracker.allPlayerEntities[i].networkId == evnt.Sender)
                    {
                        ChatEvent chatEvent = ChatEvent.Create(GlobalTargets.AllClients);
                        chatEvent.Sender  = evnt.Sender;
                        chatEvent.Message = evnt.Message;
                        chatEvent.Send();
                    }
                    return;
                }
            }
            if (BoltNetwork.isServer && evnt.RaisedBy == null)
            {
                ChatEvent chatEvent2 = ChatEvent.Create(GlobalTargets.AllClients);
                chatEvent2.Sender  = evnt.Sender;
                chatEvent2.Message = evnt.Message;
                chatEvent2.Send();
            }
        }
Ejemplo n.º 15
0
        /// <summary>
        /// Sends a string to all players on the server
        /// </summary>
        /// <param name="s">Content of the message, make sure it ends with ';'</param>
        public static void SendLine(byte[] bytearray, Target target)
        {
            if (GameSetup.IsSinglePlayer || !BoltNetwork.isRunning)
            {
                RecieveLine(bytearray);
            }
            else
            {
                if (BoltNetwork.isRunning)
                {
                    ChatEvent chatEvent = null;
                    switch (target)
                    {
                    case Target.OnlyServer:
                        chatEvent = ChatEvent.Create(GlobalTargets.OnlyServer);
                        break;

                    case Target.Everyone:
                        chatEvent = ChatEvent.Create(GlobalTargets.Everyone);
                        break;

                    case Target.Clients:
                        chatEvent = ChatEvent.Create(GlobalTargets.AllClients);
                        break;

                    case Target.Others:
                        chatEvent = ChatEvent.Create(GlobalTargets.Others);
                        break;

                    default:
                        break;
                    }
                    chatEvent.Message = EncodeCommand(bytearray);
                    chatEvent.Sender  = ChatBoxMod.ModNetworkID;
                    chatEvent.Send();
                }
            }
        }
Ejemplo n.º 16
0
        public override void OnEvent(ChatEvent evnt)
        {
            if (evnt.Sender == NetworkConfig.ModNetworkID)
            {
                //Chat events work like this
                //Client sends a event to the host that a msg is sent;
                //The host broadcasts the message to everyone
                NetworkManager.RecieveCommand(NetworkManager.StringToBytes(evnt.Message));
                return;
            }

            if (!this.ValidateSender(evnt, global::SenderTypes.Any))
            {
                return;
            }

            for (int i = 0; i < TheForest.Utils.Scene.SceneTracker.allPlayerEntities.Count; i++)
            {
                if (TheForest.Utils.Scene.SceneTracker.allPlayerEntities[i].source == evnt.RaisedBy)
                {
                    if (TheForest.Utils.Scene.SceneTracker.allPlayerEntities[i].networkId == evnt.Sender)
                    {
                        ChatEvent chatEvent = ChatEvent.Create(GlobalTargets.AllClients);
                        chatEvent.Sender  = evnt.Sender;
                        chatEvent.Message = evnt.Message;
                        chatEvent.Send();
                    }
                    return;
                }
            }
            if (BoltNetwork.isServer && evnt.RaisedBy == null)
            {
                ChatEvent chatEvent2 = ChatEvent.Create(GlobalTargets.AllClients);
                chatEvent2.Sender  = evnt.Sender;
                chatEvent2.Message = evnt.Message;
                chatEvent2.Send();
            }
        }