Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //instruction: https://youtu.be/cfX7hymQsiM
- List<T> gts<T>(Func<T, bool>b=null) where T:class {b=b??(x=>true);List<T>l=new List<T>();
- Func<T,bool>f=x=>((IMyTerminalBlock)x).IsSameConstructAs(Me);GridTerminalSystem.GetBlocksOfType(l,k=>f(k)&&b(k));return l;}
- public Program() { m = Me.GetSurface(0); m.ContentType = ContentType.TEXT_AND_IMAGE; m.FontSize = 26.4f/21;
- m.TextPadding = 0; m.Font = "Monospace"; m.FontColor = Color.DarkSlateGray; m.BackgroundColor = Color.Black;
- sm = sMain(); Runtime.UpdateFrequency = UpdateFrequency.Update10;}
- IMyTextSurface m; IEnumerator sm; IMyCubeGrid tg; string s; int j;
- public void Main(string arg) { tg= gts<IMyShipConnector>()?.First().OtherConnector?.CubeGrid;
- if ( tg != null ) sm.MoveNext(); else { sm = sMain(); s = $"{"search".PadRight(j<21?++j:j=0,'.')}\n";}
- m.WriteText($"SPCE HACK v0.1 by SWG\n{"".PadRight(21,'≡')}\n{s}{sm.Current}"); var і=Runtime;
- Echo($"{System.DateTime.Now} :{і.LastRunTimeMs:F2} {і.CurrentInstructionCount} {і.CurrentCallChainDepth}\n");}
- public IEnumerator sMain() {
- yield return ""; var cl = new List <IMyCubeBlock>();
- var p = (tg.Max - tg.Min +1).Volume(); int i=0; string ts="";
- s=$"get {(tg.IsStatic?"base":"ship")} {tg.Name}\ngid {tg.EntityId}\n"; yield return "";
- foreach (var v in Vector3I.EnumerateRange(tg.Min, tg.Max +1) ) { var cb =tg.GetCubeBlock(v)?.FatBlock; if (cb!=null) cl.Add( cb );
- if (++i%(p/100)==0 || i==p) yield return ts=$"scan {100*i/p,3}% from {p}c\n{"".PadRight(21*i/p,'≡')}\nfound{cl.Count,5} raw blocks";};
- var fb = cl.Distinct(); s=$"total{fb.Count(),5} flt blocks\n{"".PadRight(21,'≡')}\n"; yield return "";
- //do what we need with blocks in fb
- var ftur = from b in fb where b is IMyLargeTurretBase select b as IMyLargeTurretBase;
- var ftim = from b in fb where b is IMyTimerBlock select b as IMyTimerBlock;
- var fdor = from b in fb where b is IMyDoor select b as IMyDoor;
- foreach (var b in ftur) b.Enabled = false;
- foreach (var b in ftim) b.StopCountdown();
- foreach (var b in fdor) b.OpenDoor();
- s+= $"disabled {ftur.Count()} turrets\nstopped {ftim.Count()} timers\nopened {fdor.Count()} doors\n{"".PadRight(21,'≡')}\nSPCE HACK complete...";
- yield return "";
- }
Add Comment
Please, Sign In to add comment