private void UnbanButtonClicked(Button sender)
        {
            NetOutgoingMessage msg = _networkManager.CreateMessage();

            msg.Write((byte)NetMessage.RequestBanList);
            _networkManager.SendMessage(msg, NetDeliveryMethod.ReliableUnordered);
            Dispose();
        }
        public void HandleDeletion(IEntity entity)
        {
            if (!IsActive || !Eraser)
            {
                return;
            }

            NetOutgoingMessage message = NetworkManager.CreateMessage();

            message.Write((byte)NetMessage.RequestEntityDeletion);
            message.Write(entity.Uid);
            NetworkManager.SendMessage(message, NetDeliveryMethod.ReliableUnordered);
        }
Example #3
0
        public NetOutgoingMessage CreateEntityMessage()
        {
            NetOutgoingMessage message = _networkManager.CreateMessage();

            message.Write((byte)NetMessage.EntityMessage);
            return(message);
        }
Example #4
0
        private void CraftButtonClicked(ImageButton sender)
        {
            //craftTimer = new Timer_Bar(new Size(200,15), new TimeSpan(0,0,0,10));
            if (_craftSlot1.ContainingEntity == null || _craftSlot2.ContainingEntity == null)
            {
                return;
            }

            if (_playerManager != null)
            {
                if (_playerManager.ControlledEntity != null)
                {
                    if (_playerManager.ControlledEntity.HasComponent(ComponentFamily.Inventory))
                    {
                        var invComp =
                            (InventoryComponent)_playerManager.ControlledEntity.GetComponent(ComponentFamily.Inventory);
                        if (invComp.ContainedEntities.Count >= invComp.MaxSlots)
                        {
                            _craftStatus.Text  = "Status: Not enough Space";
                            _craftStatus.Color = Color.DarkRed;
                            return;
                        }
                    }
                }
            }

            NetOutgoingMessage msg = _networkManager.CreateMessage();

            msg.Write((byte)NetMessage.CraftMessage);
            msg.Write((byte)CraftMessage.StartCraft);
            msg.Write(_craftSlot1.ContainingEntity.Uid);
            msg.Write(_craftSlot2.ContainingEntity.Uid);
            _networkManager.SendMessage(msg, NetDeliveryMethod.ReliableUnordered);
        }
Example #5
0
        private void button_admin_Clicked(Button sender)
        {
            NetOutgoingMessage message = _netMgr.CreateMessage();

            message.Write((byte)NetMessage.RequestAdminPlayerlist);
            _netMgr.SendMessage(message, NetDeliveryMethod.ReliableUnordered);
            Dispose();
        }
Example #6
0
        private void UnbanButtClicked(Button sender)
        {
            NetOutgoingMessage msg = _networkManager.CreateMessage();

            msg.Write((byte)NetMessage.RequestAdminUnBan);
            msg.Write((string)sender.UserData);
            _networkManager.SendMessage(msg, NetDeliveryMethod.ReliableUnordered);
            Dispose();
        }
Example #7
0
 private void Selected(TargetingDummyElement sender)
 {
     //Send server targeted location
     NetOutgoingMessage msg = _networkManager.CreateMessage();
     msg.Write((byte) NetMessage.PlayerSessionMessage);
     msg.Write((byte) PlayerSessionMessage.SetTargetArea);
     msg.Write((byte) sender.BodyPart);
     _networkManager.SendMessage(msg, NetDeliveryMethod.ReliableOrdered);
 }
Example #8
0
        /// <summary>
        /// Verb sender
        /// If UID is 0, it means its a global verb.
        /// </summary>
        /// <param name="verb">the verb</param>
        /// <param name="uid">a target entity's Uid</param>
        public void SendVerb(string verb, int uid)
        {
            NetOutgoingMessage message = _networkManager.CreateMessage();

            message.Write((byte)NetMessage.PlayerSessionMessage);
            message.Write((byte)PlayerSessionMessage.Verb);
            message.Write(verb);
            message.Write(uid);
            _networkManager.SendMessage(message, NetDeliveryMethod.ReliableOrdered);
        }
        private void TryAdminLogin(string password)
        {
            NetOutgoingMessage msg = _networkManager.CreateMessage();

            msg.Write((byte)NetMessage.RequestAdminLogin);
            msg.Write(password);

            _networkManager.SendMessage(msg, NetDeliveryMethod.ReliableUnordered);

            Dispose();
        }
Example #10
0
        /// <summary>
        /// Processes commands (chat messages starting with /)
        /// </summary>
        /// <param name="text">input text</param>
        private void ProcessCommand(string text)
        {
            //Commands are processed locally and then sent to the server to be processed there again.
            var args = new List <string>();

            CommandParsing.ParseArguments(text, args);

            string command = args[0];

            //Entity player;
            //var entMgr = IoCManager.Resolve<IEntityManager>();
            //var plrMgr = IoCManager.Resolve<IPlayerManager>();
            //player = plrMgr.ControlledEntity;
            //IoCManager.Resolve<INetworkManager>().

            switch (command)
            {
            case "cls":
                components.Clear();
                last_y = 0;
                //this.scrollbarH.Value = 0;
                this.scrollbarV.Value = 0;
                break;

            case "quit":
                Environment.Exit(0);
                break;

            case "addparticles":     //This is only clientside.
                if (args.Count >= 3)
                {
                    Entity target = null;
                    if (args[1].ToLowerInvariant() == "player")
                    {
                        var plrMgr = IoCManager.Resolve <IPlayerManager>();
                        if (plrMgr != null)
                        {
                            if (plrMgr.ControlledEntity != null)
                            {
                                target = plrMgr.ControlledEntity;
                            }
                        }
                    }
                    else
                    {
                        var entMgr = IoCManager.Resolve <IEntityManagerContainer>();
                        if (entMgr != null)
                        {
                            int entUid = int.Parse(args[1]);
                            target = entMgr.EntityManager.GetEntity(entUid);
                        }
                    }

                    if (target != null)
                    {
                        if (!target.HasComponent(ComponentFamily.Particles))
                        {
                            var entMgr = IoCManager.Resolve <IEntityManagerContainer>();
                            var compo  = (IParticleSystemComponent)entMgr.EntityManager.ComponentFactory.GetComponent("ParticleSystemComponent");
                            target.AddComponent(ComponentFamily.Particles, compo);
                        }
                        else
                        {
                            var entMgr = IoCManager.Resolve <IEntityManagerContainer>();
                            var compo  = (IParticleSystemComponent)entMgr.EntityManager.ComponentFactory.GetComponent("ParticleSystemComponent");
                            target.AddComponent(ComponentFamily.Particles, compo);
                        }
                    }
                }
                SendServerConsoleCommand(text);     //Forward to server.
                break;

            case "removeparticles":
                if (args.Count >= 3)
                {
                    Entity target = null;
                    if (args[1].ToLowerInvariant() == "player")
                    {
                        var plrMgr = IoCManager.Resolve <IPlayerManager>();
                        if (plrMgr != null)
                        {
                            if (plrMgr.ControlledEntity != null)
                            {
                                target = plrMgr.ControlledEntity;
                            }
                        }
                    }
                    else
                    {
                        var entMgr = IoCManager.Resolve <IEntityManagerContainer>();
                        if (entMgr != null)
                        {
                            int entUid = int.Parse(args[1]);
                            target = entMgr.EntityManager.GetEntity(entUid);
                        }
                    }

                    if (target != null)
                    {
                        if (target.HasComponent(ComponentFamily.Particles))
                        {
                            IParticleSystemComponent compo = (IParticleSystemComponent)target.GetComponent(ComponentFamily.Particles);
                            compo.RemoveParticleSystem(args[2]);
                        }
                    }
                }
                SendServerConsoleCommand(text);     //Forward to server.
                break;

            case "sendchat":
                if (args.Count < 2)
                {
                    return;
                }

                INetworkManager    NetworkManager = IoCManager.Resolve <INetworkManager>();
                NetOutgoingMessage message        = NetworkManager.CreateMessage();
                message.Write((byte)NetMessage.ChatMessage);
                message.Write((byte)ChatChannel.Player);
                message.Write(args[1]);
                NetworkManager.SendMessage(message, NetDeliveryMethod.ReliableUnordered);

                break;

            // To debug console scrolling and stuff.
            case "fill":
                SFML.Graphics.Color[] colors = { SFML.Graphics.Color.Green, SFML.Graphics.Color.Blue, SFML.Graphics.Color.Red };
                Random random = new Random();
                for (int x = 0; x < 50; x++)
                {
                    AddLine("filling...", colors[random.Next(0, colors.Length)]);
                }
                break;

            default:
                SendServerConsoleCommand(text);     //Forward to server.
                break;
            }
        }