public PciSurveyor(IEnumerable <Probe> probes, MachineEntity powerSource)
 {
     this.Probes      = probes.Index().Loop().GetEnumerator();
     this.Surveyor    = new BlockSurveyor(powerSource);
     this.Pcis        = Enumerable.Repeat <PowerConsumerInterface>(null, probes.Count()).ToList();
     this.PowerSource = powerSource;
 }
        void TryToDelink(bool delinkSelf = true)
        {
            var surveyor = new BlockSurveyor(this.Control);

            foreach (var block in this.Fillers.Where((f) => !this.Delinked[f.Index]))
            {
                var material = surveyor.Look().At(block.Value).Block();
                if (material == null || IsPlacement(material.Value))
                {
                    continue;
                }
                else if (material == this.Materials.Filler)
                {
                    var filler = surveyor.Look().At(block.Value).For <Filler <Machine> >();
                    this.Delink(filler, block.Index);
                    this.Replace(filler);
                }
                // block is long gone, while we are still in delinking process
                else
                {
                    this.Delinked[block.Index] = true;
                }
            }

            if (delinkSelf && this.Fillers.All((f) => this.Delinked[f.Index]))
            {
                this.LinkState = LinkState.Delinked;
                this.Replace(this.Control);
            }
        }
 // Checks if box of provided size filled with provided material exists around finishing block.
 // This clas DO NOT check if finishing block is filled itself.
 public FilledBoxChecker(
     BlockSurveyor surveyor,
     Position finishingBlock,
     Position size,
     Material filler)
 {
     this.Surveyor       = surveyor;
     this.FinishingBlock = finishingBlock;
     this.Size           = size;
     this.Filler         = filler;
 }
Exemplo n.º 4
0
        public void Update(BlockSurveyor Surveyor)
        {
            var from  = this.StartBlock + Direction.Up().Shift *this.LastCheckedPosition;
            var to    = from + Direction.Up().Shift *CheckChunk;
            var clear = new GridBox(new Box(from, to)).Blocks()
                        .Select(b => CubeHelper.IsCubeSolid(Surveyor.Look().At(b).Block()?.Type ?? 1))
                        .NoneTrue();

            if (clear)
            {
                this.LastCheckedPosition = (this.LastCheckedPosition + CheckChunk) % ClearHeight;
                if (this.LastCheckedPosition == 0)
                {
                    this.Clear = true;
                }
            }
            else
            {
                this.Clear = false;
                this.LastCheckedPosition = 0;
            }
        }
        void TryToLink()
        {
            var surveyor = new BlockSurveyor(this.Control);

            foreach (var block in this.Fillers.Where((f) => !this.Linked[f.Index]))
            {
                var material = surveyor.Look().At(block.Value).Block();
                // not loaded or actual filler block is not created yet
                if (material == null || IsPlacement(material.Value))
                {
                    continue;
                }
                else if (material == this.Materials.Filler)
                {
                    var filler = surveyor.Look().At(block.Value).For <Filler <Machine> >();
                    if (filler == null)
                    { // game put material in place, but not entity yet.
                        continue;
                    }
                    filler.Control = this.Control;
                    filler.mSegment.RequestRegenerateGraphics();
                    this.Linked[block.Index] = true;
                }
                // block was destroyed before link process completed, so it could not call delink in OnDestroy method
                // we should do it ourselves
                else
                {
                    this.StartDelinking();
                    this.TryToDelink();
                    return;
                }
            }
            if (this.Fillers.All((f) => this.Linked[f.Index]))
            {
                this.Control.mSegment.RequestRegenerateGraphics();
                this.LinkState = LinkState.Linked;
            }
        }
Exemplo n.º 6
0
 Box?FilledBox(BlockSurveyor surveyor, Position finishingBlock)
 {
     return(new FilledBoxChecker(surveyor, finishingBlock, this.Size, this.Materials.Placements[0]).MachineSpace());
 }
Exemplo n.º 7
0
 public SurveyorTest()
 {
     this.Surveyor = new BlockSurveyor(this.Provider);
 }
 public FilledBoxCheckerTest()
 {
     this.Surveyor = new BlockSurveyor(this.Provider);
 }