Exemple #1
0
        public static string PrintTerminalActions(IMyEntity block)
        {
            IMyTerminalBlock myTerminalBlock = block as IMyTerminalBlock;

            if (myTerminalBlock == null)
            {
                return("");
            }
            List <ITerminalAction> results = new List <ITerminalAction>();

            myTerminalBlock.GetActions(results);
            StringBuilder sb = new StringBuilder();

            sb.AppendLine();
            sb.AppendLine();
            sb.AppendFormat("{0,-2}Terminal Actions", " ");
            sb.AppendLine();
            foreach (ITerminalAction terminalAction in results)
            {
                sb.AppendFormat("{0,-4}[{1}]{2}", " ", terminalAction.Id, terminalAction.Name);
                sb.AppendLine();
            }
            sb.AppendLine();
            return(sb.ToString());
        }
Exemple #2
0
        private void printPropertiesAndActions(IMyTerminalBlock block)
        {
            List <ITerminalProperty> prop = new List <ITerminalProperty>();

            block.GetProperties(prop);

            Echo("Properties:");
            foreach (ITerminalProperty p in prop)
            {
                Echo("ID: " + p.Id);
                Echo("Type: " + p.TypeName);
            }

            List <ITerminalAction> acts = new List <ITerminalAction>();

            block.GetActions(acts);

            Echo("Actions:");
            foreach (ITerminalAction a in acts)
            {
                //Echo("Icon: " + a.Icon);
                Echo("ID: " + a.Id);
                Echo("Name: " + a.Name);
            }
        }
            private List <ITerminalAction> getActions(IMyTerminalBlock Block)
            {
                List <ITerminalAction> Actions = new List <ITerminalAction>();

                Block.GetActions(Actions);

                return(Actions);
            }
    public void PrintActions(IMyTerminalBlock block)
    {
        List<ITerminalAction> results = new List<ITerminalAction>();
        block.GetActions(results);

        for (int i=0; i<results.Count; i++)
            Println(results[i].Name.ToString());
    }
        public bool checkBlockProperty(IDictionary <string, string> conditionProperties, IMyTerminalBlock block)
        {
            Echo(conditionProperties["property"]);


            // var hasProp = block.HasProperty(conditionProperties["property"]);



            // var test = block.GetType().GetProperty(conditionProperties["property"]).GetValue(block, null);
            // Echo(test.ToString());


            List <ITerminalAction> actions = new List <ITerminalAction>();

            block.GetActions(actions);

            foreach (var action in actions)
            {
                // Echo(action.Id + " " + action.Name);

                if (action.Id.ToString() == conditionProperties["property"].ToString())
                {
                    Echo("Found its Id!");
                }

                if (action.Name.ToString() == conditionProperties["property"])
                {
                    Echo("Found its name!");
                }
            }

            // Type type = block.GetType();
            // Echo(type.ToString());
            // PropertyInfo propInfo = type.GetProperty(conditionProperties["property"]);
            // var propInfo = type.GetProperty(conditionProperties["property"]);

            // Echo(block[conditionProperties["property"]]);

            // var hasProp = block.conditionProperties["property"];

            // Echo(propInfo.ToString());
            //
            // if(!propInfo){
            //
            //     Echo("Property ("+ conditionProperties["property"] +") does not exists in: " + conditionProperties["name"]);
            //
            //     return false;
            //
            // }

            return(false);
        }
Exemple #6
0
        public static void PrintTerminalActions(string entityType, IMyTerminalBlock block)
        {
            return;

            var actions = new List <ITerminalAction>();

            block.GetActions(actions, _ => true);
            using (Log.Scope("{0}.GetActions:", block.BlockDefinition.TypeIdString))
            {
                foreach (var action in actions)
                {
                    Log.Write("Id = {0}, Name = {1}, Icon = {2}", action.Id, action.Name, action.Icon);
                }
            }
        }
Exemple #7
0
        public static void PrintTerminalActions(IMyEntity block)
        {
            IMyTerminalBlock myTerminalBlock = block as IMyTerminalBlock;

            if (myTerminalBlock == null)
            {
                return;
            }
            List <ITerminalAction> results = new List <ITerminalAction>();

            myTerminalBlock.GetActions(results);
            foreach (ITerminalAction terminalAction in results)
            {
                StaticLog.WriteToLog("PrintTerminalActions", $"Actions: {terminalAction.Id} | {terminalAction.Name}", LogType.General);
            }
        }
Exemple #8
0
        private void echoPropertiesAndActions(IMyTerminalBlock blk)
        {
            var props = new List <ITerminalProperty>();

            blk.GetProperties(props);

            foreach (var p in props)
            {
                Echo("ID: " + p.Id + " | Type: " + p.TypeName);
            }

            var actions = new List <ITerminalAction>();

            blk.GetActions(actions);

            foreach (var a in actions)
            {
                Echo("ID: " + a.Id + " | Name: " + a.Name);
            }
        }
Exemple #9
0
        void Main()
        {
            List <IMyTerminalBlock> blocks      = GridTerminalSystem.Blocks;
            List <IMyBlockGroup>    blockGroups = GridTerminalSystem.BlockGroups;

            GridTerminalSystem.GetBlocksOfType <IMyCubeBlock>(blocks, FuncTest);
            GridTerminalSystem.SearchBlocksOfName(blockName, blocks, FuncTest);
            var block = GridTerminalSystem.GetBlockWithName(blockName);

            IMyCubeBlock cubeBlock     = block;
            bool         IsBeingHacked = cubeBlock.IsBeingHacked;
            bool         IsFunctional  = cubeBlock.IsFunctional;
            bool         IsWorking     = cubeBlock.IsWorking;

            VRageMath.Vector3I Position = cubeBlock.Position;

            IMyTerminalBlock terminalBlock         = block;
            string           CustomName            = terminalBlock.CustomName;
            string           CustomNameWithFaction = terminalBlock.CustomNameWithFaction;
            string           DetailedInfo          = terminalBlock.DetailedInfo;
            bool             HasLocalPlayerAccess  = terminalBlock.HasLocalPlayerAccess();
            bool             HasPlayerAccess       = terminalBlock.HasPlayerAccess(playerId);

            //terminalBlock.RequestShowOnHUD(enable);
            terminalBlock.SetCustomName(CustomName);
            //terminalBlock.SetCustomName(stringBuilder);
            bool ShowOnHUD = terminalBlock.ShowOnHUD;

            List <ITerminalAction> resultList = new List <ITerminalAction>();

            terminalBlock.GetActions(resultList, FuncTest);
            //terminalBlock.SearchActionsOfName(actionName, resultList, FuncTest);
            //ITerminalAction terminalAction = terminalBlock.GetActionWithName(actionName);

            //string Id = terminalAction.Id;
            //StringBuilder Name = terminalAction.Name;
            //terminalAction.Apply(cubeBlock);

            IMyFunctionalBlock functionalBlock = block as IMyFunctionalBlock;
            bool Enabled = functionalBlock.Enabled;
        }
Exemple #10
0
		private void ListContent(IMyTerminalBlock autopilot, List<MyTerminalControlListBoxItem> items, List<MyTerminalControlListBoxItem> selected)
		{
			string blockName = m_targetBlock.ToString().Trim();
			if (string.IsNullOrWhiteSpace(blockName))
				return;

			HashSet<ITerminalAction> termActs = new HashSet<ITerminalAction>();
			foreach (IMyCubeBlock block in AttachedGrid.AttachedCubeBlocks((IMyCubeGrid)autopilot.CubeGrid, AttachedGrid.AttachmentKind.Permanent, true))
			{
				if (!block.DisplayNameText.Contains(blockName, StringComparison.InvariantCultureIgnoreCase))
					continue;
				IMyTerminalBlock term = block as IMyTerminalBlock;
				if (term == null)
					continue;
				term.GetActions(null, action => {
					if (termActs.Add((ITerminalAction)action))
						items.Add(new MyTerminalControlListBoxItem(MyStringId.GetOrCompute(action.Id), MyStringId.NullOrEmpty, action));
					return false;
				});
			}
		}
Exemple #11
0
    void Main()
    {
        var actions    = new List <ITerminalAction>();
        var properties = new List <ITerminalProperty>();

        jd.GetProperties(properties);
        string log = "";

        log += "---Properties";
        foreach (var i in properties)
        {
            log += "\n" + i.Id;
        }

        jd.GetActions(actions);
        log += "\n\n---Actions";
        foreach (var i in actions)
        {
            log += "\n" + i.Id;
        }

        LCDPB.WriteText(log);
    }
        private void printPropertiesAndActions(IMyTerminalBlock block)
        {
            List<ITerminalProperty> prop = new List<ITerminalProperty>();
            block.GetProperties(prop);

            Echo("Properties:");
            foreach (ITerminalProperty p in prop)
            {
                Echo("ID: " + p.Id);
                Echo("Type: " + p.TypeName);
            }

            List<ITerminalAction> acts = new List<ITerminalAction>();
            block.GetActions(acts);

            Echo("Actions:");
            foreach (ITerminalAction a in acts)
            {
                //Echo("Icon: " + a.Icon);
                Echo("ID: " + a.Id);
                Echo("Name: " + a.Name);
            }
        }
Exemple #13
0
        public void Main(string argument, UpdateType updateSource)
        {
            var actions    = new List <ITerminalAction>();
            var properties = new List <ITerminalProperty>();

            block.GetProperties(properties);
            block.GetActions(actions);

            StringBuilder sb = new StringBuilder();

            sb.Append("--- properties");
            foreach (var item in properties)
            {
                sb.Append("\n").Append(item.Id);
            }
            sb.Append("\n--- actions");
            foreach (var item in actions)
            {
                sb.Append("\n").Append(item.Id);
            }

            Me.GetSurface(0).WriteText(sb.ToString());
            Echo(block.ToString());
        }
        public void Main(string argument, UpdateType updateSource)
        {
            /**/

            String[] eval = argument.Split(' ');

            if (eval.Length <= 0)
            {
                SwitchRedAlert();
            }
            else
            {
                switch (eval[0].ToLower())
                {
                case "lazy":
                    List <IMyLightingBlock> temp = new List <IMyLightingBlock>();
                    GridTerminalSystem.GetBlocksOfType(temp);
                    foreach (IMyLightingBlock bl in temp)
                    {
                        if (
                            !CheckForIgnore(bl) &&
                            !bl.CustomName.Equals(ALARM_LIGHT) &&
                            !bl.CustomName.Equals(ROTAT_LIGHT) &&
                            !bl.CustomName.Equals(SWITCH_LIGHT) &&
                            !bl.CustomName.Equals(OTHER_LIGHT) &&
                            bl.CubeGrid.Equals(Me.CubeGrid)
                            )
                        {
                            if (bl.BlockDefinition.SubtypeName.Equals("RotatingLightLarge") ||
                                bl.BlockDefinition.SubtypeName.Equals("RotatingLightSmall"))
                            {
                                bl.CustomName = ROTAT_LIGHT;
                            }
                            else
                            if (bl.BlockDefinition.SubtypeName.Equals("LargeBlockFrontLight") ||
                                bl.BlockDefinition.SubtypeName.Equals("SmallBlockFrontLight"))
                            {
                                bl.CustomName = SHIP_NAME + "/Spotlight";
                            }
                            else
                            {
                                bl.CustomName = OTHER_LIGHT;
                            }
                        }
                    }
                    break;

                case "test":
                    string           chckName = argument.Substring(eval[0].Length + 1);
                    IMyTerminalBlock block    = GridTerminalSystem.GetBlockWithName(chckName) as IMyTerminalBlock;
                    if (block == null)
                    {
                        Echo("UnU");
                        return;
                    }
                    Echo(block.GetType().FullName);
                    List <ITerminalAction> list = new List <ITerminalAction>();
                    block.GetActions(list);
                    Echo(block.BlockDefinition.SubtypeId);
                    Echo(UnpackList(list));
                    break;


                default: SwitchRedAlert(); break;
                }
            }
        }
Exemple #15
0
        void ProcessMiscBlock(IMyTerminalBlock terminalBlock, string Keyword)
        {
            var             Percentage             = ToPercentage(CurrentVolumeAll, MaxVolumeAll);
            var             DoAction               = false;
            GroupActionEnum ActionToPerform        = GroupActionEnum.None;
            GroupActionEnum InverseActionToPerform = GroupActionEnum.None;
            int             PercentileCriteria     = 0;
            var             StrippedKeyword        = Keyword.Replace("[", "");

            StrippedKeyword = StrippedKeyword.Replace("]", "");
            GroupActionKeywordsEnum KeywordEnum = GroupActionKeywordsEnum.None;


            if (GroupActionKeywordsMap.ContainsValue(Keyword))
            {
                DoAction    = true;
                KeywordEnum = (GroupActionKeywordsEnum)Enum.Parse(typeof(GroupActionKeywordsEnum), StrippedKeyword);

                if (GroupActionKeywordAction[KeywordEnum] == GroupActionEnum.TurnOff)
                {
                    ActionToPerform        = GroupActionEnum.TurnOff;
                    InverseActionToPerform = GroupActionEnum.TurnOn;
                }
                else if (GroupActionKeywordAction[KeywordEnum] == GroupActionEnum.TurnOn)
                {
                    ActionToPerform        = GroupActionEnum.TurnOn;
                    InverseActionToPerform = GroupActionEnum.TurnOff;
                }

                var fullKeywords = new List <string>
                {
                    GroupActionKeywordsMap[GroupActionKeywordsEnum.OffWhenTotalStorageFull],
                    GroupActionKeywordsMap[GroupActionKeywordsEnum.OnWhenTotalStorageFull]
                };
                if (fullKeywords.Contains(Keyword))
                {
                    PercentileCriteria = 98;
                }
                else
                {
                    PercentileCriteria = FindFirstNumberForKeyword(terminalBlock, Keyword);
                }
            }


            if (DoAction)
            {
                var ApplyAction   = false;
                var DesiredAction = "";
                if (GroupActionsExpressionMap[KeywordEnum] == GroupActionExpression.MoreThan)
                {
                    ApplyAction   = true;
                    DesiredAction = Percentage > PercentileCriteria ? GroupActionsMap[ActionToPerform] : GroupActionsMap[InverseActionToPerform];
                }
                else if (GroupActionsExpressionMap[KeywordEnum] == GroupActionExpression.MoreThanEqualTo)
                {
                    ApplyAction   = true;
                    DesiredAction = Percentage >= PercentileCriteria ? GroupActionsMap[ActionToPerform] : GroupActionsMap[InverseActionToPerform];
                }

                if (ApplyAction)
                {
                    var ActionList = new List <ITerminalAction>();
                    terminalBlock.GetActions(ActionList, (x) => x.Id.Equals(DesiredAction));
                    if (ActionList.Count > 0)
                    {
                        ActionList[0].Apply(terminalBlock);
                    }
                }
            }
        }