コード例 #1
0
ファイル: CommandInput.cs プロジェクト: Epicguru/NotQuiteDead
    public void ButtonDown()
    {
        if (input == null)
        {
            input = GetComponentInChildren <InputField>();
        }

        if (CommandProcessing.input != this)
        {
            CommandProcessing.input = this;
        }
        try
        {
            if (CommandProcessing.Process(input.text))
            {
                input.text = "";
                index      = CommandProcessing.lastCommands.Count;
            }
        }
        catch (Exception e)
        {
            CommandProcessing.Log(RichText.InColour("Exception : " + e.Message, Color.red));
        }

        EventSystem.current.SetSelectedGameObject(input.gameObject, null);
        input.ActivateInputField();
    }
コード例 #2
0
ファイル: TeamSwap.cs プロジェクト: Epicguru/NotQuiteDead
    public override string Execute(object[] args)
    {
        if (!Player.Local.isServer)
        {
            return("You are not the host! Cannot run team commands!");
        }

        string player  = args[0] as string;
        string newTeam = args[1] as string;

        if (string.IsNullOrEmpty(player.Trim()))
        {
            return("Name of player is empty!");
        }

        if (string.IsNullOrEmpty(newTeam.Trim()))
        {
            return("Name of team is empty!");
        }

        if (!Teams.I.PlayerInSystem(player))
        {
            return("Player not found in system!");
        }

        string oldTeam = Teams.I.GetTeamName(player);

        Teams.I.GetPlayer(player).Team = newTeam;
        CommandProcessing.Log("Moved player '" + player + "' from team '" + oldTeam + "' to new team '" + newTeam + "'.");

        return(null);
    }
コード例 #3
0
    public override string Execute(object[] args)
    {
        if (!Player.Local.isServer)
        {
            return("You are not the host! Cannot run team commands!");
        }
        string newTeamName = args[0] as string;

        if (string.IsNullOrEmpty(newTeamName))
        {
            return("Team name cannot be null or empty!");
        }
        if (!Teams.I.TeamExists(newTeamName))
        {
            return("Team '" + newTeamName + "' does not exist!");
        }
        if (!Teams.I.TeamEmpty(newTeamName))
        {
            return("Team '" + newTeamName + "' is not empty!");
        }

        Teams.I.RemoveTeam(newTeamName);
        CommandProcessing.Log("Removed team: '" + newTeamName + "'. There are now " + Teams.I.GetTeamNames().Count + " teams.");
        return(null);
    }
コード例 #4
0
    public override string Execute(object[] args)
    {
        string action = (string)args[0];

        switch (action)
        {
        case "clear":

            CommandProcessing.lastCommands.Clear();
            CommandProcessing.Log("Cleared command history.");
            return(null);

        case "list":
            foreach (string s in CommandProcessing.lastCommands)
            {
                CommandProcessing.Log("   -" + s);
            }
            return(null);

        case "count":
            CommandProcessing.Log("There are " + CommandProcessing.lastCommands.Count + "commands in history.");
            return(null);

        default:
            return("Not a valid action! Use clear, list or count.");
        }
    }
コード例 #5
0
    public override string Execute(object[] args)
    {
        string action = (string)args[0];

        switch (action)
        {
        case "clear":

            int items = PlayerInventory.inv.Inventory.Contents.Count;
            PlayerInventory.inv.Inventory.Clear();

            CommandProcessing.Log("Cleared " + items + " items out of the player's inventory.");
            return(null);

        case "drop":
            items = PlayerInventory.inv.Inventory.Contents.Count;
            PlayerInventory.inv.Inventory.DropAll(2f, Player.Local.transform.position);

            CommandProcessing.Log("Dropped " + items + " items from the player's inventory.");
            return(null);

        default:
            return("Not a valid action. Valid actions are: clear, drop.");
        }
    }
コード例 #6
0
    public override string Execute(object[] args)
    {
        if (!Player.Local.isServer)
        {
            return("You are not the host! Cannot run team commands!");
        }

        int removed = 0;

        List <string> bin = new List <string>();

        foreach (string t in Teams.I.GetTeamNames())
        {
            if (Teams.I.TeamEmpty(t))
            {
                bin.Add(t);
            }
        }

        foreach (string t in bin)
        {
            Teams.I.RemoveTeam(t);
            CommandProcessing.Log("Removed team '" + t + "'.");
            removed++;
        }

        CommandProcessing.Log("Removed a total of " + removed + " teams!");

        bin.Clear();

        return(null);
    }
コード例 #7
0
ファイル: GiveCommand.cs プロジェクト: Epicguru/NotQuiteDead
    public override string Execute(object[] args)
    {
        // Give items

        string itemName = (string)args[0];

        itemName = itemName.Trim();
        int amount = (int)args[1];

        if (amount <= 0)
        {
            return("Amount of items must be more than zero!");
        }

        Item prefab = Item.GetItem(itemName);

        if (prefab == null)
        {
            return("Could not find item: '" + itemName + "'");
        }

        PlayerInventory.Add(itemName, null, amount);

        CommandProcessing.Log("Gave local player '" + prefab.Name + "' x" + amount);

        return(null);
    }
コード例 #8
0
ファイル: CommandInput.cs プロジェクト: Epicguru/NotQuiteDead
    public void Input()
    {
        if (input == null)
        {
            input = GetComponentInChildren <InputField>();
        }

        if (CommandProcessing.input != this)
        {
            CommandProcessing.input = this;
        }

        string text = input.text;

        if (!UnityEngine.Input.GetKeyDown(KeyCode.Return))
        {
            return;
        }

        try
        {
            if (CommandProcessing.Process(text))
            {
                input.text = "";
                index      = CommandProcessing.lastCommands.Count;
            }
        }catch (Exception e)
        {
            CommandProcessing.Log(RichText.InColour("Exception : " + e.Message, Color.red));
        }

        EventSystem.current.SetSelectedGameObject(input.gameObject, null);
        input.ActivateInputField();
    }
コード例 #9
0
ファイル: PoolCommand.cs プロジェクト: Epicguru/NotQuiteDead
    public override string Execute(object[] args)
    {
        string action = (string)args[0];

        switch (action)
        {
        case "clear":

            int total = ObjectPool.GetObjectCount();

            ObjectPool.Clear();
            CommandProcessing.Log("Removing all " + total + " idle pooled objects.");

            return(null);

        case "stats":

            CommandProcessing.Log(ObjectPool.GetStats());

            return(null);

        default:

            return("Invalid action. Valid action are clear, stats.");
        }
    }
コード例 #10
0
 public void RpcRemoteCommand(GameObject player, string sender, string command)
 {
     if (player.GetComponent <NetworkIdentity>().netId == Player.Local.netId)
     {
         CommandProcessing.Log("Remote command from '" + sender + "':");
         CommandProcessing.Process(command);
     }
 }
コード例 #11
0
ファイル: PingCommand.cs プロジェクト: Epicguru/NotQuiteDead
    public override string Execute(object[] args)
    {
        int time = NetworkManager.singleton.client.GetRTT();

        CommandProcessing.Log("Client RTT is " + time + "ms");

        return(null);
    }
コード例 #12
0
    public override string Execute(object[] args)
    {
        foreach (Command c in CommandProcessing.GetCommands())
        {
            CommandProcessing.Log(c.Name + " - (" + c.GetParams(builder) + ")");
        }

        return(null);
    }
コード例 #13
0
        public async Task Test_CommandProcessing_IsBroadcastCommand()
        {
            string broadcastPrefix = "@@";
            var    config          = ConfigurationGenerators.CreateApplicationConfiguration();

            config.BroadcastCommandPrefix = broadcastPrefix;
            var server = serviceProvider.GetRequiredService <IW4MServer>();

            var cmd = EventGenerators.GenerateEvent(GameEvent.EventType.Command, $"{broadcastPrefix}{nameof(MockCommand)}", server);

            var result = await CommandProcessing.ValidateCommand(cmd, config);

            Assert.AreEqual(nameof(MockCommand), result.Name);
            Assert.IsTrue(result.IsBroadcast);
        }
コード例 #14
0
        public void Initialization(CommandProcessing processing)
        {
            if (processing == null)
            {
                throw new ArgumentNullException("Метод обработки не может быть пустым!");
            }

            try
            {
                server          = new TcpListener(System.Net.IPAddress.Parse(IPAddress), Port);
                this.processing = processing;
            }
            catch (Exception ex)
            {
                //ConsoleOutput.WriteLineError($"Ошибка инициализации сервера '{ex}'.");
            }
        }
コード例 #15
0
    public override string Execute(object[] args)
    {
        // Give items

        string itemName = (string)args[0];

        itemName = itemName.Trim();
        int amount = 1;

        if (itemName.ToLower() == "all")
        {
            // Give all items.
            foreach (var x in Item.Items.Values)
            {
                PlayerInventory.Add(x.Prefab, null, amount);
            }

            // Give all tiles.
            foreach (var x in BaseTile.GetAllTiles())
            {
                Player.Local.BuildingInventory.AddItems(x, 1000);
            }

            // Give all furnitures
            foreach (var x in Furniture.Loaded.Values)
            {
                Player.Local.BuildingInventory.AddItems(x, 1000);
            }

            CommandProcessing.Log("Gave local player 1 of each and every item, and 1000 of all buildables.");

            return(null);
        }

        Item prefab = Item.GetItem(itemName);

        if (prefab == null)
        {
            return("Could not find item: '" + itemName + "'");
        }

        PlayerInventory.Add(prefab.Prefab, null, amount);
        CommandProcessing.Log("Gave local player '" + prefab.Name + "' x" + amount);

        return(null);
    }
コード例 #16
0
ファイル: NameCommand.cs プロジェクト: Epicguru/NotQuiteDead
    public override string Execute(object[] args)
    {
        string name = args[0] as string;

        if (name.Trim() == string.Empty)
        {
            return("Name cannot be blank!");
        }
        if (Player.Local.PlayerHasName(name))
        {
            return("Another player already has that name, or a very similar one!");
        }

        Player.Local.NetUtils.CmdSetName(name);
        CommandProcessing.Log("Set player name to '" + name + "'");

        return(null);
    }
コード例 #17
0
ファイル: TeamTransfer.cs プロジェクト: Epicguru/NotQuiteDead
    public override string Execute(object[] args)
    {
        if (!Player.Local.isServer)
        {
            return("You are not the host! Cannot run team commands!");
        }
        string newTeamName = args[0] as string;
        string nextTeam    = args[1] as string;

        if (string.IsNullOrEmpty(newTeamName))
        {
            return("Team name cannot be null or empty!");
        }
        if (!Teams.I.TeamExists(newTeamName))
        {
            return("Team '" + newTeamName + "' does not exist!");
        }
        if (Teams.I.TeamEmpty(newTeamName))
        {
            return("Team '" + newTeamName + "' is empty! No players to move.");
        }
        if (string.IsNullOrEmpty(nextTeam.Trim()))
        {
            return("Name of team to transfer to is empty!");
        }

        int           count = 0;
        List <string> names = new List <string>();

        foreach (Player p in Teams.I.GetTeam(newTeamName))
        {
            names.Add(p.Name);
            count++;
        }

        foreach (string p in names)
        {
            Teams.I.GetPlayer(p).Team = nextTeam; // This only works because we are server.
        }

        CommandProcessing.Log("Moved " + count + " players from team '" + newTeamName + "' to team '" + nextTeam + "'.");
        return(null);
    }
コード例 #18
0
    public override string Execute(object[] args)
    {
        string target = args[0] as string;

        Player player = Player.Local.GetPlayer(target);
        if(player == null)
        {
            return "Did not find that player...";
        }

        string command = args[1] as string;

        // Assume it works!
        Player.Local.NetUtils.CmdRemoteCommand(player.gameObject, command);

        CommandProcessing.Log("Executing remote command '" + command + "' on '" + player.Name + "'.");

        return null;
    }
コード例 #19
0
        public static bool CheckVariableComparison(
            VariableValue currentValue,
            StringVariableComparison comparison,
            Player player,
            Event instance
            )
        {
            var varVal         = CommandProcessing.ParseEventText(currentValue.String ?? "", player, instance);
            var compareAgainst = CommandProcessing.ParseEventText(comparison.Value ?? "", player, instance);

            switch (comparison.Comparator)
            {
            case StringVariableComparators.Equal:
                return(varVal == compareAgainst);

            case StringVariableComparators.Contains:
                return(varVal.Contains(compareAgainst));
            }

            return(false);
        }
コード例 #20
0
    public override string Execute(object[] args)
    {
        string arg = ((string)(args[0])).Trim().ToLower();

        if (arg == "stats")
        {
            CommandProcessing.Log("Max open nodes: " + Pathfinding.MAX);
            CommandProcessing.Log("Max pending requests: " + PathfindingManager.MAX_PENDING);
            CommandProcessing.Log(PathfindingManager.GetPendingIDs());
            return(null);
        }

        if (arg == "wipe")
        {
            CommandProcessing.Log("Wiping: " + PathfindingManager.GetPending().Count + " pending requests.");
            PathfindingManager.DissolveAllPending();
            return(null);
        }

        return("Error: Unknown pathing sub-command '" + arg + "'. Valid commands are 'stats' and 'wipe'");
    }
コード例 #21
0
ファイル: ItemsCommand.cs プロジェクト: Epicguru/NotQuiteDead
    public override string Execute(object[] args)
    {
        string action = (string)args[0];

        switch (action)
        {
        case "list":

            foreach (Item i in Item.Items.Values)
            {
                CommandProcessing.Log(i.Name);
            }

            return(null);

        case "count":

            CommandProcessing.Log("There are " + (Item.Items == null ? 0 : Item.Items.Count) + " loaded items, and " + GameObject.FindObjectsOfType <Item>().Length + " instances of items.");

            return(null);

        case "clear":

            Item[] items = GameObject.FindObjectsOfType <Item>();
            CommandProcessing.Log("Destroying " + items.Length + " items.");

            foreach (Item item in items)
            {
                Player.Local.NetUtils.CmdDestroyItem(item.gameObject);
            }

            return(null);

        default:

            return("Invalid action. Valid actions are list, count and clear.");
        }
    }
コード例 #22
0
ファイル: Event.cs プロジェクト: yanfroes/Intersect-Engine
        public void Update(long timeMs)
        {
            var sendLeave            = false;
            var originalPageInstance = PageInstance;

            if (PageInstance != null)
            {
                //Check for despawn
                if (PageInstance.ShouldDespawn())
                {
                    X            = PageInstance.X;
                    Y            = PageInstance.Y;
                    PageInstance = null;
                    CallStack.Clear();
                    PlayerHasDied = false;
                    if (HoldingPlayer)
                    {
                        PacketSender.SendReleasePlayer(Player, Id);
                        HoldingPlayer = false;
                    }

                    sendLeave = true;
                }
                else
                {
                    if (!Global)
                    {
                        PageInstance.Update(
                            CallStack.Count > 0, timeMs
                            ); //Process movement and stuff that is client specific
                    }

                    //Check to see if we should process event commands
                    if (CallStack.Count > 0)
                    {
                        var curStack = CallStack.Peek();
                        if (curStack.WaitingForResponse == CommandInstance.EventResponse.Shop && Player.InShop == null)
                        {
                            curStack.WaitingForResponse = CommandInstance.EventResponse.None;
                        }

                        if (curStack.WaitingForResponse == CommandInstance.EventResponse.Crafting &&
                            Player.CraftingTableId == Guid.Empty)
                        {
                            curStack.WaitingForResponse = CommandInstance.EventResponse.None;
                        }

                        if (curStack.WaitingForResponse == CommandInstance.EventResponse.Bank && Player.InBank == false)
                        {
                            curStack.WaitingForResponse = CommandInstance.EventResponse.None;
                        }

                        if (curStack.WaitingForResponse == CommandInstance.EventResponse.Quest &&
                            !Player.QuestOffers.Contains(((StartQuestCommand)curStack.WaitingOnCommand).QuestId))
                        {
                            curStack.WaitingForResponse = CommandInstance.EventResponse.None;
                        }

                        if (curStack.WaitingForResponse == CommandInstance.EventResponse.Timer &&
                            WaitTimer < Globals.Timing.TimeMs)
                        {
                            curStack.WaitingForResponse = CommandInstance.EventResponse.None;
                        }

                        var commandsExecuted = 0;
                        while (curStack.WaitingForResponse == CommandInstance.EventResponse.None &&
                               !PageInstance.ShouldDespawn() &&
                               commandsExecuted < Options.EventWatchdogKillThreshhold)
                        {
                            if (curStack.WaitingForRoute != Guid.Empty)
                            {
                                if (curStack.WaitingForRoute == Player.Id)
                                {
                                    if (Player.MoveRoute == null ||
                                        Player.MoveRoute.Complete && Player.MoveTimer < Globals.Timing.TimeMs)
                                    {
                                        curStack.WaitingForRoute    = Guid.Empty;
                                        curStack.WaitingForRouteMap = Guid.Empty;
                                    }
                                }
                                else
                                {
                                    //Check if the exist exists && if the move route is completed.
                                    foreach (var evt in Player.EventLookup.Values)
                                    {
                                        if (evt.MapId == curStack.WaitingForRouteMap &&
                                            evt.BaseEvent.Id == curStack.WaitingForRoute)
                                        {
                                            if (evt.PageInstance == null)
                                            {
                                                break;
                                            }

                                            if (!evt.PageInstance.MoveRoute.Complete)
                                            {
                                                break;
                                            }

                                            curStack.WaitingForRoute    = Guid.Empty;
                                            curStack.WaitingForRouteMap = Guid.Empty;

                                            break;
                                        }
                                    }
                                }

                                if (curStack.WaitingForRoute != Guid.Empty)
                                {
                                    break;
                                }
                            }
                            else
                            {
                                if (curStack.CommandIndex >= curStack.CommandList.Count)
                                {
                                    CallStack.Pop();
                                }
                                else
                                {
                                    if (WaitTimer < Globals.Timing.TimeMs)
                                    {
                                        CommandProcessing.ProcessCommand(curStack.Command, Player, this);
                                        commandsExecuted++;
                                    }
                                    else
                                    {
                                        break;
                                    }
                                }

                                if (CallStack.Count == 0)
                                {
                                    PlayerHasDied = false;

                                    break;
                                }
                            }

                            curStack = CallStack.Peek();
                        }

                        if (commandsExecuted >= Options.EventWatchdogKillThreshhold)
                        {
                            CallStack.Clear(); //Killing this event, we're over it.
                            if (this.BaseEvent.MapId == Guid.Empty)
                            {
                                Log.Error(Strings.Events.watchdogkillcommon.ToString(BaseEvent.Name));
                                if (Player.Power.IsModerator)
                                {
                                    PacketSender.SendChatMsg(
                                        Player, Strings.Events.watchdogkillcommon.ToString(BaseEvent.Name), Color.Red
                                        );
                                }
                            }
                            else
                            {
                                var map = MapInstance.Get(this.BaseEvent.MapId);
                                Log.Error(Strings.Events.watchdogkill.ToString(map.Name, BaseEvent.Name));
                                if (Player.Power.IsModerator)
                                {
                                    PacketSender.SendChatMsg(
                                        Player, Strings.Events.watchdogkill.ToString(map.Name, BaseEvent.Name),
                                        Color.Red
                                        );
                                }
                            }
                        }
                    }
                    else
                    {
                        if (PageInstance.Trigger == EventTrigger.Autorun && WaitTimer < Globals.Timing.TimeMs)
                        {
                            var newStack = new CommandInstance(PageInstance.MyPage);
                            CallStack.Push(newStack);
                        }
                    }
                }
            }

            if (PageInstance == null)
            {
                //Try to Spawn a PageInstance.. if we can
                for (var i = BaseEvent.Pages.Count - 1; i >= 0; i--)
                {
                    if (Conditions.CanSpawnPage(BaseEvent.Pages[i], Player, this))
                    {
                        if (Global)
                        {
                            if (MapInstance.Get(MapId).GetGlobalEventInstance(BaseEvent) != null)
                            {
                                PageInstance = new EventPageInstance(
                                    BaseEvent, BaseEvent.Pages[i], BaseEvent.Id, MapId, this, Player,
                                    MapInstance.Get(MapId).GetGlobalEventInstance(BaseEvent).GlobalPageInstance[i]
                                    );

                                sendLeave = false;
                                PageIndex = i;
                            }
                        }
                        else
                        {
                            PageInstance = new EventPageInstance(BaseEvent, BaseEvent.Pages[i], MapId, this, Player);
                            sendLeave    = false;
                            PageIndex    = i;
                        }

                        break;
                    }
                }

                if (sendLeave && originalPageInstance != null)
                {
                    PacketSender.SendEntityLeaveTo(Player, originalPageInstance);
                }
            }
        }
コード例 #23
0
ファイル: ClearCommand.cs プロジェクト: Epicguru/NotQuiteDead
 public override string Execute(object[] args)
 {
     CommandProcessing.ClearLog();
     return(null);
 }
コード例 #24
0
 public override string Execute(object[] args)
 {
     CommandProcessing.Log(Teams.I.Data);
     return(null);
 }
コード例 #25
0
 public override string Execute(object[] args)
 {
     Player.Local.transform.position = new Vector3((float)args[0], (float)args[1]);
     CommandProcessing.Log("Teleported player to " + Player.Local.transform.position);
     return(null);
 }
コード例 #26
0
ファイル: CommandInput.cs プロジェクト: Epicguru/NotQuiteDead
 public void Start()
 {
     CommandProcessing.RefreshCommands();
     Instance = this;
 }