private ListReader <ITerminalAction> GetValidActions(Type blockType, ListReader <MyTerminalBlock> blocks) { var allActions = MyTerminalControlFactory.GetActions(blockType); var validActions = new List <ITerminalAction>(); foreach (var action in allActions) { if (action.IsValidForGroups()) { bool found = false; foreach (var block in blocks) { if (action.IsEnabled(block)) { found = true; break; } } if (found) { validActions.Add(action); } } } return(validActions); }
private ListReader <ITerminalAction> GetValidActions(Type blockType) { var allActions = MyTerminalControlFactory.GetActions(blockType); var validActions = new List <ITerminalAction>(); foreach (var action in allActions) { if (action.IsValidForGroups()) { validActions.Add(action); } } return(validActions); }
void IMyTerminalActionsHelper.SearchActionsOfName(string name, Type blockType, List <Sandbox.ModAPI.Interfaces.ITerminalAction> resultList, Func <Sandbox.ModAPI.Interfaces.ITerminalAction, bool> collect = null) { if (!typeof(MyTerminalBlock).IsAssignableFrom(blockType)) { return; } MyTerminalControlFactory.GetActions(blockType, m_actionList); foreach (var action in m_actionList) { if ((collect == null || collect(action)) && action.Id.ToString().Contains(name) && action.IsValidForToolbarType(MyToolbarType.ButtonPanel)) { resultList.Add(action); } } m_actionList.Clear(); }
Sandbox.ModAPI.Interfaces.ITerminalAction IMyTerminalActionsHelper.GetActionWithName(string name, Type blockType) { if (!typeof(MyTerminalBlock).IsAssignableFrom(blockType)) { return(null); } MyTerminalControlFactory.GetActions(blockType, m_actionList); foreach (var action in m_actionList) { if (action.Id.ToString() == name && action.IsValidForToolbarType(MyToolbarType.ButtonPanel)) { m_actionList.Clear(); return(action); } } m_actionList.Clear(); return(null); }
private ListReader <ITerminalAction> GetActions(MyToolbarType?type) { if (m_block == null) { return(ListReader <ITerminalAction> .Empty); } m_tmpEnabledActions.Clear(); foreach (var action in MyTerminalControlFactory.GetActions(m_block.GetType())) { if (action.IsEnabled(m_block)) { if (type == null || action.IsValidForToolbarType(type.Value)) { m_tmpEnabledActions.Add(action); } } } return(m_tmpEnabledActionsReader); }
public TerminalBlock(IMyTerminalBlock block, bool light = true) { Name = block.CustomName; var def = block.BlockDefinition; Type = $"{def.TypeId}/{def.SubtypeId}"; Id = block.EntityId; if (light) { return; } if (block.HasInventory) { var count = block.InventoryCount; for (var i = 0; i < count; i++) { Inventories.Add(new Inventory(block.GetInventory(i))); } } block.GetProperties(new List <ITerminalProperty>(), p => { var prop = new BlockProperty(p, block); if (prop.IsValid) { Properties.Add(prop); } return(false); }); foreach (var action in MyTerminalControlFactory.GetActions(block.GetType())) { Actions.Add(action.Id); } }