示例#1
0
        public override bool Invoke(ulong steamId, long playerId, string messageText)
        {
            if (messageText.Equals("/repair", StringComparison.InvariantCultureIgnoreCase))
            {
                var entity     = Support.FindLookAtEntity(MyAPIGateway.Session.ControlledObject, true, false, false, false, false, false);
                var shipEntity = entity as IMyCubeGrid;
                if (shipEntity != null)
                {
                    MessageSyncGridChange.SendMessage(SyncGridChangeType.Repair, shipEntity.EntityId, null, MyAPIGateway.Session.Player.IdentityId);
                    return(true);
                }
                MyAPIGateway.Utilities.SendMessage(steamId, "repair", "No ship targeted.");
                return(true);
            }

            var match = Regex.Match(messageText, @"/repair\s{1,}(?<Key>.+)", RegexOptions.IgnoreCase);

            if (match.Success)
            {
                var shipName = match.Groups["Key"].Value;
                MessageSyncGridChange.SendMessage(SyncGridChangeType.Repair, 0, shipName, MyAPIGateway.Session.Player.IdentityId);
                return(true);
            }

            return(false);
        }
        public override bool Invoke(ulong steamId, long playerId, string messageText)
        {
            var match = Regex.Match(messageText, @"/((destructible)|(destruct))\s+(?<switch>(on)|(off)|1|0)(\s+|$)(?<name>.*)|$", RegexOptions.IgnoreCase);

            if (match.Success)
            {
                bool switchOn     = false;
                var  switchString = match.Groups["switch"].Value;
                var  shipName     = match.Groups["name"].Value;

                if (switchString == "")
                {
                    return(false);
                }

                if (switchString.Equals("on", StringComparison.InvariantCultureIgnoreCase) || switchString.Equals("1", StringComparison.InvariantCultureIgnoreCase))
                {
                    switchOn = true;
                }

                if (switchString.Equals("off", StringComparison.InvariantCultureIgnoreCase) || switchString.Equals("0", StringComparison.InvariantCultureIgnoreCase))
                {
                    switchOn = false;
                }

                // set destructible on the ship in the crosshairs.
                if (string.IsNullOrEmpty(shipName))
                {
                    var entity     = Support.FindLookAtEntity(MyAPIGateway.Session.ControlledObject, true, false, false, false, false, false);
                    var shipEntity = entity as IMyCubeGrid;
                    if (shipEntity != null)
                    {
                        MessageSyncGridChange.SendMessage(SyncGridChangeType.Destructible, shipEntity.EntityId, null, MyAPIGateway.Session.Player.PlayerID, switchOn);
                        return(true);
                    }

                    MyAPIGateway.Utilities.ShowMessage("destructible", "No ship targeted.");
                    return(true);
                }

                MessageSyncGridChange.SendMessage(SyncGridChangeType.Destructible, 0, shipName, MyAPIGateway.Session.Player.PlayerID, switchOn);
                return(true);
            }

            return(false);
        }
示例#3
0
        public override bool Invoke(ulong steamId, long playerId, string messageText)
        {
            var match = Regex.Match(messageText, @"/builtby\s+(?<player>.+)", RegexOptions.IgnoreCase);

            if (match.Success)
            {
                var playerName = match.Groups["player"].Value;

                var entity     = Support.FindLookAtEntity(MyAPIGateway.Session.ControlledObject, true, false, false, false, false, false);
                var shipEntity = entity as IMyCubeGrid;
                if (shipEntity != null)
                {
                    MessageSyncGridChange.SendMessage(SyncGridChangeType.BuiltBy, shipEntity.EntityId, playerName);
                    return(true);
                }
                MyAPIGateway.Utilities.ShowMessage("BuiltBy", "No ship targeted.");
                return(true);
            }

            return(false);
        }