Пример #1
0
 private void Safeguard_Check()
 {
     if (GridProgram.Echo == null)
     {
         throw new ArgumentNullException("Passed Echo reference was null.");
     }
     if (GridProgram.GridTerminalSystem == null)
     {
         throw new ArgumentNullException("Passed GTS reference was null.");
     }
     GridProgram.Echo("Running SafeGuard check..");
     if (Projector == null)
     {
         throw new NullReferenceException("Projector reference was null.");
     }
     if (!Projector.IsProjecting)
     {
         ProjectionState = ProjectionState.Idle;
     }
     else if (Projector.IsProjecting && Projector.RemainingBlocks == 0)
     {
         ProjectionState = ProjectionState.Finished;
     }
     else if (Projector.IsProjecting && Projector.RemainingBlocks != 0)
     {
         ProjectionState = ProjectionState.Projecting;
     }
     ApplyConfig();
     GridProgram.Echo("OK.");
 }
Пример #2
0
        public bool IsPlatformSafe(TrackedPlatform platform)
        {
            double displacement = CalculatePlatformDisplacement(platform);

            gridProgramRef.Echo("Platform displacement = {displacement}");
            gridProgramRef.Echo("X1: {platform.X1} X2: {platform.X2}");
            gridProgramRef.Echo("Y1: {platform.Y1} Y2: {platform.Y2}");
            return(false);
        }
Пример #3
0
        public bool BlockWithNameExistsAndIsOfType <T>(string Name)
        {
            List <IMyTerminalBlock> __l = new List <IMyTerminalBlock>();

            GridProgramRef.GridTerminalSystem.SearchBlocksOfName(Name, __l);
            bool a = __l.Count > 0;
            bool b = __l is T;

            GridProgramRef.Echo($"a = {a}");
            GridProgramRef.Echo($"b = {b}");
            return(a && b);
        }
Пример #4
0
        public long GetItemAmount(MyItemType itemType)
        {
            long amount = 0;

            GridProgramRef.Echo($"TypeId: {itemType.TypeId}, SubtypeId: {itemType.SubtypeId}");
            foreach (IMyCargoContainer container in CargoContainers)
            {
                List <MyInventoryItem> _items = new List <MyInventoryItem>();
                container.GetInventory().GetItems(_items, i => i.Type == itemType);
                _items.ForEach(new Action <MyInventoryItem>((b) => { amount += b.Amount.RawValue; }));
            }

            return(amount / 1000000);
        }