private static void GetItemList(IMyTerminalBlock block, List <MyTerminalControlListBoxItem> items, List <MyTerminalControlListBoxItem> selected) { IMyProjector me = (IMyProjector)block; if (me.ProjectedGrid != null) { StringBuilder sb = new StringBuilder(); GridComponents comps = block.GameLogic.GetAs <InstantProjector>().GetComponents(); foreach (KeyValuePair <MyDefinitionId, int> kv in comps) { if (IPSession.Instance != null) { sb.Append(IPSession.Instance.GetComponentName(kv.Key)); } else { sb.Append(kv.Key.SubtypeName); } sb.Append(": ").Append(kv.Value); MyStringId s = MyStringId.GetOrCompute(sb.ToString()); MyTerminalControlListBoxItem item = new MyTerminalControlListBoxItem(s, s, 0); items.Add(item); sb.Clear(); } } }
// Context: Terminal private static Dictionary <MyItemType, int> GetItemListPB(IMyTerminalBlock block) { IMyProjector me = (IMyProjector)block; if (me.ProjectedGrid != null) { GridComponents comps = block.GameLogic.GetAs <InstantProjector>().GetComponents(); return(comps.ToDictionary(kv => new MyItemType(kv.Key.TypeId, kv.Key.SubtypeId), kv => kv.Value)); } return(new Dictionary <MyItemType, int>()); }
private int GetBlueprintTimer() { if (me.ProjectedGrid == null) { return(0); } GridComponents comps = GetComponents(); return(GetBlueprintTimer(comps.BlockCount)); }
// Context: All private GridComponents GetComponents() { if (cachedComps == null || cachedCompId != me.ProjectedGrid.EntityId) { cachedCompId = me.ProjectedGrid.EntityId; if (SupportsSubgrids(me)) { cachedComps = new GridComponents(me); } else { cachedComps = new GridComponents(me.ProjectedGrid); } cachedComps.ApplySettings(IPSession.Instance.MapSettings); } return(cachedComps); }
private void ClearCachedComps(bool subgrids) { cachedComps = null; }
private void ClearCachedComps(float cost) { cachedComps = null; }
private void ClearCachedComps(SerializableDefinitionId?id) { cachedComps = null; }