コード例 #1
0
        bool BlockCollect(IMyTerminalBlock block)
        {
            if (!(block is IMyGasGenerator) && !(block is IMyLargeGatlingTurret) && !(block is IMySmallGatlingGun) && (block).HasInventory)
            {
                if (block.CustomName.StartsWith(inventoryPrefix) && block.CustomName.Contains("]"))
                {
                    var substring = block.CustomName.Substring(inventoryPrefix.Length, block.CustomName.IndexOf("]") - inventoryPrefix.Length);
                    if (substring.Contains(requestFlag))
                    {
                        if (block.IsSameConstructAs(Me))
                        {
                            myRequesterSet.Add(block); myContainerSet.Add(block);
                        }
                        return(false);
                    }

                    if (substring.Contains(ignoreFlag))
                    {
                        return(false);
                    }
                    if (substring.Contains(oreFlag))
                    {
                        flaggedContainers[oreFlag].Add(block);
                    }
                    if (substring.Contains(ingotFlag))
                    {
                        flaggedContainers[ingotFlag].Add(block);
                    }
                    if (substring.Contains(compFlag))
                    {
                        flaggedContainers[compFlag].Add(block);
                    }
                    if (substring.Contains(toolFlag))
                    {
                        flaggedContainers[toolFlag].Add(block);
                    }
                    if (substring.Contains(ammoFlag))
                    {
                        flaggedContainers[ammoFlag].Add(block);
                    }
                    if (substring.Contains(wasteFlag))
                    {
                        flaggedContainers[wasteFlag].Add(block);
                    }
                    if (block.IsSameConstructAs(Me))
                    {
                        myContainerSet.Add(block);
                    }
                }
                inventoryOwners.Add(block);
            }

            return(false);
        }
コード例 #2
0
 bool IsContainerOnLocalGridNotIgnored(IMyTerminalBlock container)
 {
     if (container.IsSameConstructAs(Me))
     {
         if (!IsIgnored(container))
         {
             try
             {
                 var potentialContainer = container as VRage.Game.ModAPI.Ingame.IMyEntity;
                 if (potentialContainer.HasInventory)
                 {
                     if (string.IsNullOrWhiteSpace(Responsibility) || Responsibility == "Default" || DetermineResponsibility(container) == Responsibility)
                     {
                         return(true);
                     }
                 }
                 else
                 {
                     return(false);
                 }
             }
             catch
             {
                 return(false);
             }
         }
     }
     return(false);
 }
コード例 #3
0
        private bool IsConnectedToControllerGrid()
        {
            if (!_weaponValid)
            {
                return(false);
            }

            if (_remoteControl?.SlimBlock?.CubeGrid == null || _weaponBlock?.SlimBlock?.CubeGrid == null)
            {
                _weaponValid = false;
                return(false);
            }

            if (_weaponBlock.SlimBlock.CubeGrid == _connectedCubeGrid)
            {
                return(true);
            }

            if (_weaponBlock.IsSameConstructAs(_remoteControl))
            {
                _connectedCubeGrid = _weaponBlock.SlimBlock.CubeGrid;
                return(true);
            }

            _weaponValid = false;
            return(false);
        }
コード例 #4
0
            public Payload(Program parent, string container = "")
            {
                // Retrieve blocks:
                List <IMyTerminalBlock> block_list = new List <IMyTerminalBlock>();

                if (container != string.Empty)
                {
                    IMyBlockGroup group = parent.GridTerminalSystem.GetBlockGroupWithName(container);

                    if (group == null)
                    {
                        IMyTerminalBlock block = parent.GridTerminalSystem.GetBlockWithName(container) as IMyTerminalBlock;

                        if (block != null && block.IsSameConstructAs(parent.Me))
                        {
                            block_list.Add(block);
                        }
                    }
                    else
                    {
                        group.GetBlocksOfType(block_list, x => x.IsSameConstructAs(parent.Me));
                    }

                    if (block_list.Count == 0)
                    {
                        throw new Exception($"No blocks found with argument: '{container}'");
                    }
                }
                else
                {
                    parent.GridTerminalSystem.GetBlocksOfType(block_list, x => x.IsSameConstructAs(parent.Me));
                }

                // Retrieve inventories:
                Capacity = 0.0f;

                lInventory = new List <IMyInventory>();

                foreach (IMyTerminalBlock block in block_list)
                {
                    for (int i = 0; i < block.InventoryCount; ++i)
                    {
                        lInventory.Add(block.GetInventory(i));
                        Capacity += (float)block.GetInventory(i).MaxVolume;
                    }
                }

                if (lInventory.Count == 0)
                {
                    throw new Exception("Selected blocks do not have inventories.");
                }
                else
                {
                    parent.Echo($"Observing {lInventory.Count} inventories from {block_list.Count} block(s).");
                }

                Update();
            }
コード例 #5
0
        bool CollectParts(IMyTerminalBlock block)
        {
            if (!block.IsSameConstructAs(Me))
            {
                return(false);
            }
            //if (!block.CustomName.Contains(Me.CustomName.Last())) return false;
            if (block is IMyMotorAdvancedStator && block.CustomName.Contains("Small Hinge"))
            {
                SmallHinge = (IMyMotorAdvancedStator)block;
            }
            if (block is IMyMotorAdvancedStator && block.CustomName.Contains("Large Hinge"))
            {
                LargeHinge = (IMyMotorAdvancedStator)block;
            }
            if (block is IMyMotorAdvancedStator && block.CustomName.Contains("Elevation"))
            {
                Elevation = (IMyMotorAdvancedStator)block;
            }
            if (block is IMyMotorStator && block.CustomName.Contains("Sweeper"))
            {
                Sweeper = (IMyMotorStator)block;
            }

            if (block is IMyProjector && block.CustomName.Contains("Base Projector"))
            {
                BaseProjector = (IMyProjector)block;
            }
            if (block is IMyProjector && block.CustomName.Contains("Top Projector"))
            {
                TopProjector = (IMyProjector)block;
            }

            if (block is IMyShipMergeBlock && block.CustomName.Contains("Top Release"))
            {
                TopMerge = (IMyShipMergeBlock)block;
            }
            if (block is IMyShipMergeBlock && block.CustomName.Contains("Base Release"))
            {
                BaseMerge = (IMyShipMergeBlock)block;
            }

            if (block is IMyShipWelder)
            {
                Welders.Add((IMyShipWelder)block);
            }
            if (block is IMyTextPanel)
            {
                Display = (IMyTextPanel)block;
            }

            return(false);
        }
コード例 #6
0
 protected bool BlockFilter(IMyTerminalBlock block)
 {
     if (!block.IsSameConstructAs(Me))
     {
         return(false);
     }
     if (!block.CustomName.Contains(PanelKeyword))
     {
         return(false);
     }
     return(true);
 }
コード例 #7
0
 bool CollectHangarParts(IMyTerminalBlock block)
 {
     if (block.IsSameConstructAs(Me) && block.CustomName.StartsWith(kHangarTag))
     {
         int index;
         if (int.TryParse(block.CustomName.Substring(2, 1), out index) && index < kNumHangars)
         {
             hangars[index].AddPart(block);
         }
     }
     return(false);
 }
コード例 #8
0
 bool GetBlocks(IMyTerminalBlock block)
 {
     if (!block.IsSameConstructAs(Context.Reference))
     {
         return(false);
     }
     if (!block.CustomName.Contains(LandpedoTag))
     {
         return(false);
     }
     if (block is IMyShipConnector)
     {
         LandpedoTubes.Add(new LandpedoTube(block as IMyShipConnector));
     }
     return(false);
 }
コード例 #9
0
        bool CollectDisplays(IMyTerminalBlock block)
        {
            if (!block.IsSameConstructAs(Context.Reference))
            {
                return(false);
            }
            if (block is IMyTextSurface)
            {
                AddTextSurface(block);
            }
            else if (block is IMyTextSurfaceProvider)
            {
                AddTextSurfaceProvider(block);
            }

            return(false);
        }
コード例 #10
0
        bool CollectBlocks(IMyTerminalBlock block)
        {
            if (!block.IsSameConstructAs(Context.Reference))
            {
                return(false);
            }
            if (block is IMyShipConnector)
            {
                Connectors.Add(block as IMyShipConnector);
            }
            if (block is IMyLightingBlock && block.CustomName.Contains("[ALM]"))
            {
                AlarmLight = block as IMyLightingBlock;
            }

            return(false);
        }
コード例 #11
0
 public bool GridFilter(IMyTerminalBlock block)
 {
     if (Grid == MonitorTargetGrid.MyConstruct)
     {
         if (!block.IsSameConstructAs(Me))
         {
             return(false);
         }
         else if (Grid == MonitorTargetGrid.MyGrid)
         {
             if (block.CubeGrid != Me.CubeGrid)
             {
                 return(false);
             }
         }
     }
     return(true);
 }
コード例 #12
0
    bool CollectGrids(IMyTerminalBlock b)
    {
        if (!b.IsSameConstructAs(_program.Me))
        {
            return(false);
        }

        var mech = (IMyMechanicalConnectionBlock)b;

        if (mech.CubeGrid.WorldVolume.Radius > LargestGrid.WorldVolume.Radius)
        {
            LargestGrid = mech.CubeGrid;
        }
        _grids.Add(mech.CubeGrid);
        if (mech.IsAttached)
        {
            _grids.Add(mech.TopGrid);
        }
        return(false);
    }
コード例 #13
0
        bool CollectBlocks(IMyTerminalBlock block)
        {
            if (!block.IsSameConstructAs(Context.Reference))
            {
                return(false);
            }
            if (block.CustomName.Contains("[X]"))
            {
                return(false);
            }
            if (block is IMyMotorSuspension)
            {
                Suspensions.Add(block as IMyMotorSuspension);
            }
            if (block is IMyShipController)
            {
                Controllers.Add(block as IMyShipController);
            }
            if (block is IMyGasGenerator)
            {
                O2Generators.Add(block as IMyGasGenerator);
            }
            if (block is IMyGasTank)
            {
                GasTanks.Add(block as IMyGasTank);
            }
            if (block is IMyCockpit)
            {
                Cockpits.Add(block as IMyCockpit);
            }
            if (block is IMyGyro)
            {
                Gyros.Add(block as IMyGyro);
            }
            if (block is IMyTimerBlock && block.CustomName.Contains("[W]"))
            {
                AddWheelTimer = block as IMyTimerBlock;
            }

            return(false);
        }
コード例 #14
0
 bool IsRelevantLCDsOnLocalGrid(IMyTerminalBlock lcd)
 {
     if (lcd.IsSameConstructAs(Me))
     {
         var KeywordPresent = false;
         foreach (var Keyword in LCDKeywordsMap)
         {
             if (HasKeywordAndNotIgnored(lcd, Keyword.Key))
             {
                 if (string.IsNullOrWhiteSpace(Responsibility) || Responsibility == "Default" || DetermineResponsibility(lcd) == Responsibility)
                 {
                     KeywordPresent = true;
                 }
             }
         }
         if (KeywordPresent)
         {
             return(true);
         }
     }
     return(false);
 }
コード例 #15
0
        bool CollectParts(IMyTerminalBlock block)
        {
            if (block.CustomName.Contains("[X]"))
            {
                return(false);
            }
            if (!block.IsSameConstructAs(Context.Reference))
            {
                return(false);
            }

            if (block.CubeGrid.EntityId != Context.Reference.CubeGrid.EntityId)
            {
                return(false);
            }
            if (block is IMyShipConnector && (Connector == null || block.CustomName.Contains("[D]")))
            {
                Connector = (IMyShipConnector)block;
            }
            if (block is IMyShipMergeBlock && (Merge == null || block.CustomName.Contains("[D]")))
            {
                Merge = (IMyShipMergeBlock)block;
            }
            if (block is IMyInteriorLight && (DirectionIndicator == null || block.CustomName.Contains("[D]")))
            {
                DirectionIndicator = (IMyInteriorLight)block;
            }

            if (block is IMyRadioAntenna)
            {
                TurnOnOffList.Add((IMyFunctionalBlock)block);
            }
            if (block is IMyThrust)
            {
                TurnOnOffList.Add((IMyFunctionalBlock)block);
            }
            if (block is IMyCameraBlock)
            {
                TurnOnOffList.Add((IMyFunctionalBlock)block);
            }
            if (block is IMyGyro)
            {
                TurnOnOffList.Add((IMyFunctionalBlock)block);
            }
            if (block is IMyLargeTurretBase)
            {
                TurnOnOffList.Add((IMyFunctionalBlock)block);
            }
            if (block is IMyBatteryBlock)
            {
                Batteries.Add((IMyBatteryBlock)block);
            }
            if (block is IMySmallGatlingGun)
            {
                TurnOnOffList.Add((IMySmallGatlingGun)block);
            }
            if (block is IMyTimerBlock)
            {
                TurnOnOffList.Add((IMyFunctionalBlock)block);
            }
            if (block is IMyReactor)
            {
                TurnOnOffList.Add((IMyFunctionalBlock)block);
            }
            if (block is IMyGasTank)
            {
                Tanks.Add((IMyGasTank)block);
            }

            return(false);
        }
コード例 #16
0
    bool CollectBlocks(IMyTerminalBlock b)
    {
        if (!b.IsSameConstructAs(_p.Me))
        {
            return(false);
        }
        var rotor = b as IMyMotorStator;

        if (rotor != null)
        {
            ParseRotorIni(rotor);
            if (StringExtensions.Contains(b.CustomName, _p.AzimuthName))
            {
                if (_azimuthRotor != null)
                {
                    _extraRotors.Add(rotor);
                }
                else
                {
                    _azimuthRotor = rotor;
                }
            }
            else if (StringExtensions.Contains(b.CustomName, _p.ElevationName))
            {
                if (_elevationRotor != null)
                {
                    _extraRotors.Add(rotor);
                }
                else
                {
                    _elevationRotor = rotor;
                }
            }
            else
            {
                _extraRotors.Add(rotor);
            }
        }

        var cam = b as IMyCameraBlock;

        if (cam != null)
        {
            if (_camera != null)
            {
                _tools.Add(cam);
            }
            else
            {
                _camera = cam;
            }
            _gridToToolDict[cam.CubeGrid] = cam;
        }

        var tcb = b as IMyTurretControlBlock;

        if (tcb != null)
        {
            if (_controller != null)
            {
                _setupReturnCode |= ReturnCode.MultipleTurretControllers;
            }
            else
            {
                _controller = tcb;
            }
        }

        var func = b as IMyFunctionalBlock;

        if (func != null)
        {
            if (!(func is IMyLargeTurretBase) &&
                (func is IMyUserControllableGun ||
                 func is IMyLightingBlock ||
                 func is IMyShipToolBase ||
                 func is IMyShipConnector))
            {
                _tools.Add(func);
                _gridToToolDict[func.CubeGrid] = func;
            }
        }

        return(false);
    }
コード例 #17
0
ファイル: Program.cs プロジェクト: mwnDK1402/MDK-SE
 private bool HasConfigSection(IMyTerminalBlock block, string requiredSection) =>
 block.IsSameConstructAs(this.Me) &&
 this.ini.TryParse(block.CustomData, requiredSection) &&
 this.ini.ContainsSection(InfoSection);
コード例 #18
0
 bool SameConstructAsMe(IMyTerminalBlock block)
 {
     return(block.IsSameConstructAs(Me));
 }
コード例 #19
0
        public void Render(Window window, StringBuilder text, ref MySpriteDrawFrame frame)
        {
            var info       = window.GetData <ScreenContent>();
            int refcount   = Refineries.Count;
            int totalcount = refcount + Assemblers.Count;

            if (totalcount == 0)
            {
                return;
            }
            if (info.StaticSprites.Length != totalcount || info.ProgressBars.Length != totalcount)
            {
                var cells = window.Surface.MakeTable(totalcount, 2.0f, new Vector2(0.01f, 0.01f), new Vector2(0.01f, 0.01f), window.Area).GetEnumerator();
                info.StaticSprites = new MySprite[totalcount];
                info.ProgressBars  = new ProgressBar[totalcount];
                for (int i = 0; i < totalcount; i++)
                {
                    cells.MoveNext();
                    IMyTerminalBlock b = (i < refcount)
                        ? Refineries[i] as IMyTerminalBlock
                        : Assemblers[i - Refineries.Count].Block as IMyTerminalBlock;
                    string     name   = b.IsSameConstructAs(Owner.PB.Me) ? b.CustomName : $"[{b.CustomName}]";
                    RectangleF top    = cells.Current.SubRect(0.0f, 0.0f, 1.0f, 0.5f);
                    RectangleF bottom = cells.Current.SubRect(0.0f, 0.5f, 1.0f, 0.5f);
                    info.StaticSprites[i] = window.Surface.FitText(name, top, "Debug", window.Surface.ScriptForegroundColor);
                    info.ProgressBars[i]  = new ProgressBar(window.Surface, bottom, Color.Black, Color.Transparent, window.Surface.ScriptForegroundColor);
                }
            }
            for (int i = 0; i < totalcount; i++)
            {
                if (i < refcount)
                {
                    switch (GetRefineryStatus(Refineries[i]))
                    {
                    case ProductionStatus.Disabled: info.ProgressBars[i].ForegroundColor = Color.Red; break;

                    case ProductionStatus.Producing: info.ProgressBars[i].ForegroundColor = Color.Green; break;

                    case ProductionStatus.Waiting: info.ProgressBars[i].ForegroundColor = Color.Blue; break;
                    }
                    info.ProgressBars[i].Value = CalculateProgressForRefinery(Refineries[i]);
                }
                else
                {
                    switch (Assemblers[i - refcount].Status)
                    {
                    case ProductionStatus.Disabled: info.ProgressBars[i].ForegroundColor = Color.Red; break;

                    case ProductionStatus.Producing: info.ProgressBars[i].ForegroundColor = Color.Green; break;

                    case ProductionStatus.Waiting: info.ProgressBars[i].ForegroundColor = Color.Blue; break;
                    }
                    info.ProgressBars[i].Value = Assemblers[i - refcount].GetProgress();
                }
            }
            if (BgColor != Color.Transparent)
            {
                frame.Add(window.Surface.FitSprite("SquareSimple", window.Area, BgColor));
            }
            frame.AddRange(info.StaticSprites);
            foreach (var pb in info.ProgressBars)
            {
                frame.AddRange(pb);
            }
        }
コード例 #20
0
 private bool isSameConstructAsMe(IMyTerminalBlock block)
 {
     return(block.IsSameConstructAs(Program.Me));
 }
コード例 #21
0
 bool CollectSameConstruct(IMyTerminalBlock block)
 {
     return(block.IsSameConstructAs(Me));
 }