void CalculateTotalPower() { try { TotalRadarPower = 0; Term.GetBlocksOfType <IMyUpgradeModule>(collect: x => Controls.IsRadar(x) && x.IsWorking).ForEach(x => TotalRadarPower += Controls.RadarReturn(x, r => r.PowerModule.EffectiveRadarPower)); } catch (Exception Scrap) { RadarCore.LogError(RadarBlock.CustomName + ".CalculateTotalPower", Scrap); } }
//...or IMyGyroControl looks for all gyros on the grid of the programmable block public void UpdateGyroList(IMyProgrammableBlock PB, IMyGridTerminalSystem GTS) { Gyros.Clear(); if ((GTS != null) && (PB != null)) { GTS.GetBlocksOfType <IMyGyro>(Gyros, x => ((x.CubeGrid == PB.CubeGrid) && x.IsFunctional)); } if (Gyros.Count > 0) { MaxYPR = Gyros[0].GetMaximum <float>("Yaw"); } }
private IEnumerable <object> ScanBlocksIfNecessary(IMyGridTerminalSystem gts) { if (rescanBlocks) { Debug.Write(Debug.Level.Debug, "Scanning blocks on grid..."); // get stuff displays.Clear(); scanBlocks.Clear(); var displayBlocks = new List <IMyTextPanel>(10); var displayRendererFactory = new DisplayRendererFactory(); foreach (var displayConfiguration in configuration.Displays) { gts.GetBlocksOfType(displayBlocks, b => b.CustomName == displayConfiguration.DisplayName); if (!displayBlocks.Any()) { Debug.Write(Debug.Level.Warning, new Message("Display does not exist: {0}", displayConfiguration.DisplayName)); continue; } if (!displayBlocks.Any(d => d.IsOperational())) { Debug.Write(Debug.Level.Info, new Message("Display is not operational: {0}", displayConfiguration.DisplayName)); continue; } displays.Add(displayRendererFactory.Create(displayBlocks, displayConfiguration)); } gts.GetBlocksOfType(scanBlocks, blockRuleFilter.Filter); foreach (var display in displays) { foreach (var yieldPoint in display.RescanBlocks(scanBlocks)) { yield return(yieldPoint); } } scanBlocks.Clear(); rescanBlocks = false; } }
private void updateRadar() { m_radar = null; if (cockpit.CustomName == null) { return; } string title = cockpit.CustomName; Regex reg = new Regex("(.*?)!(.*)"); if (title == null || title.Length == 0) { return; } var res = reg.Split(title); if (res.Length > 2) { foreach (var word in res) { Log.DebugWrite(DebugLevel.Info, word); } radarname = res[2].ToLowerInvariant().Trim(); } else { return; //nothing } system = MyAPIGateway.TerminalActionsHelper.GetTerminalSystemForGrid((IMyCubeGrid)cockpit.CubeGrid); List <IMyTerminalBlock> blocks = new List <IMyTerminalBlock>(); system.GetBlocksOfType <IMySensorBlock>(blocks, null); //getRadarValues(); foreach (var block in blocks) { var sens = (IMySensorBlock)block; if (sens.OwnerId == cockpit.OwnerId) { if (sens.CustomName.ToLowerInvariant().Trim() == radarname) { ent = sens.EntityId; //ActiveAdjust = PrivateAdjust; break; } } } Log.DebugWrite(DebugLevel.Verbose, "Entityid " + ent.ToString()); if (ent != 0) { m_radar = CoreHolo.GetRadar(ent); } }
private void FindCmdLine() { if (Ship == null || cmdline != null) { return; } IMyGridTerminalSystem gridTerminal = MyAPIGateway.TerminalActionsHelper.GetTerminalSystemForGrid(Ship); List <Sandbox.ModAPI.Ingame.IMyTerminalBlock> T = new List <Sandbox.ModAPI.Ingame.IMyTerminalBlock>(); gridTerminal.GetBlocksOfType <IMyTerminalBlock>(T); cmdline = T.FirstOrDefault(x => (x).CustomName.Contains("#PlayerDrone#")) as IMyRemoteControl; }
/* http://steamcommunity.com/sharedfiles/filedetails/?id=360966557 */ void Main() { List <IMyTerminalBlock> blocks = new List <IMyTerminalBlock>(); GridTerminalSystem.GetBlocksOfType <IMyRadioAntenna>(blocks); if (blocks.Count == 0) { return; } IMyRadioAntenna antenna = blocks[0] as IMyRadioAntenna; antenna.SetCustomName("Hello Galaxy!"); }
} // UnloadCargo method /// <summary> /// Not completed /// </summary> /// <param name="gts"></param> /// <param name="minUR"></param> public void ReactorRefuel(IMyGridTerminalSystem gts, VRage.MyFixedPoint minUR) { int i = 0; // counter int j = 0; // counter //IMyTerminalBlock reactor = null; //IMyTerminalBlock sourceReactor = null; blockList.Clear(); gts.GetBlocksOfType <IMyReactor>(blockList, g => g.CubeGrid != rc.CubeGrid); for (i = 0; i < blockList.Count; i++) { if (blockList[i].GetInventory(0).GetItems()[0].Amount < 2 * minUR) { blockList.Remove(blockList[i]); // remove item from list i = 0; // reset index to 0 } // if amount < 2 * minUR } // for i (block traverse) if (blockList.Count == 0) { return; } // no source reactors //reactor = GridTerminalSystem.GetBlockWithName(shipName + reactorName); // get ship reactor //if (reactor == null) // kill the program so it can be fixed //throw new Exception("ReactorRefuel: Cannot find reactor named " + shipName + reactorName); //sourceReactor = GridTerminalSystem.GetBlockWithName(baseReactorFuelName); // get source reactor //if (sourceReactor == null) //{ return; } // do not crash the program, return without refueling //if (reactor.GetInventory(0).GetItems()[0].Amount >= minUR) //{ return; } // no need to refuel //if (sourceReactor.GetInventory(0).GetItems()[0].Amount >= (2 * minUR)) //{ // sourceReactor.GetInventory(0).TransferItemTo(reactor.GetInventory(0), 0, null, true, // (minUR - reactor.GetInventory(0).GetItems()[0].Amount)); //} for (i = 0; i < reactorList.Count; i++) { if (reactorList[i].GetInventory(0).GetItems()[0].Amount < minUR) { } } } // ReactorRefuel method
private void printShieldStatus() { if (MyAPIGateway.Multiplayer.IsServer) { if (Entity.InScene) { Sandbox.ModAPI.IMyFunctionalBlock funcBlock = Entity as Sandbox.ModAPI.IMyFunctionalBlock; if (funcBlock.CustomName.Contains(":")) { String name = funcBlock.CustomName; long gridID = funcBlock.CubeGrid.EntityId; int index = name.IndexOf(':'); if ((index + 1) < name.Length) { name = name.Remove(index + 1); } IMyGridTerminalSystem tsystem = MyAPIGateway.TerminalActionsHelper.GetTerminalSystemForGrid(funcBlock.CubeGrid as IMyCubeGrid); List <IMyTerminalBlock> shieldsConnected = new List <IMyTerminalBlock> (); if (tsystem != null) { tsystem.GetBlocksOfType <Sandbox.ModAPI.Ingame.IMyRefinery> (shieldsConnected, EnergyShieldsCore.shieldFilter); float shipCurrentShieldPoints = 0f; float shipMaximumShieldPoints = 0f; foreach (var shield in shieldsConnected) { ShieldGeneratorGameLogic generatorLogic = ((IMyTerminalBlock)shield).GameLogic.GetAs <ShieldGeneratorGameLogic> (); shipCurrentShieldPoints += generatorLogic.m_currentShieldPoints; shipMaximumShieldPoints += generatorLogic.m_maximumShieldPoints; } name = name + " (" + Math.Round(shipCurrentShieldPoints) + "/" + Math.Round(shipMaximumShieldPoints) + ")"; funcBlock.SetCustomName(name); } else { name = name + " (" + Math.Round(m_currentShieldPoints) + "/" + Math.Round(m_maximumShieldPoints) + ")"; funcBlock.SetCustomName(name); } } } } }
//Used For Fast Finding/Dynamically Renaming A Block Based On CustomData public static void Renam_Block_Cust(IMyGridTerminalSystem GTS, string customnam, string RenameTo) { List <IMyTerminalBlock> TempCollection = new List <IMyTerminalBlock>(); GTS.GetBlocksOfType <IMyTerminalBlock>(TempCollection, a => a.CustomData == customnam); if (TempCollection.Count < 1) { return; } else { TempCollection[0].CustomName = RenameTo; } }
public static IMyProgrammableBlock FindRunningPB(IMyGridTerminalSystem system) { List <IMyProgrammableBlock> blocks = new List <IMyProgrammableBlock>(); system.GetBlocksOfType <IMyProgrammableBlock>(blocks); foreach (IMyProgrammableBlock block in blocks) { if (block.IsRunning) { return(block); } } return(null); }
public static T FindBlockOfType <T>(IMyGridTerminalSystem system, Spaceship spaceship, string tag = "") where T : class { List <T> temp = new List <T>(); system.GetBlocksOfType <T>(temp); foreach (T block in temp) { if ((spaceship.cpu.CubeGrid == ((IMyTerminalBlock)block).CubeGrid) && ((tag.Length == 0) || ((IMyTerminalBlock)block).CustomName.Contains(tag))) { return((T)block); } } return(default(T)); }
public List <T> GetBlockOfType <T>() where T : IMyTerminalBlock { var l = new List <IMyTerminalBlock> (); self.GetBlocksOfType <T> (l); var nl = new List <T>(); for (int i = 0; i < l.Count; i++) { nl.Add((T)l[i]); } return(nl); }
public WheelController(IMyGridTerminalSystem myGridTerminalSystem, IMyShipController controlReference) { // TODO tweak these values propulsionController = new pidControllerData(.05, .01, .1); steeringController = new pidControllerData(.05, .01, .1); steeringDirection.Add(true, new List <IMyMotorSuspension>()); steeringDirection.Add(false, new List <IMyMotorSuspension>()); propulsionDirection.Add(true, new List <IMyMotorSuspension>()); propulsionDirection.Add(false, new List <IMyMotorSuspension>()); myGridTerminalSystem.GetBlocksOfType <IMyMotorSuspension>(wheels); Vector3D propulsionCenter = new Vector3D(); foreach (IMyMotorSuspension w in wheels) { if (w != null) { propulsionCenter += w.GetPosition(); } } propulsionCenter /= wheels.Count; foreach (IMyMotorSuspension w in wheels) { if (w != null) { Vector3D relPos = Vector3D.TransformNormal(w.GetPosition() - propulsionCenter, MatrixD.Transpose(controlReference.WorldMatrix)); if (relPos.Z <= 0) { steeringDirection[true].Add(w); } else { steeringDirection[false].Add(w); } if (relPos.X <= 0) { propulsionDirection[true].Add(w); } else { propulsionDirection[false].Add(w); } } } ReleaseWheels(); }
/// <summary> /// Finds all containers on the currently-connected grid. /// </summary> public void FindAllContainers() { var all_containers = new List <IMyFunctionalBlock>(); _grid.GetBlocksOfType(all_containers); _containers.Clear(); foreach (var c in all_containers) { if (c.HasInventory) { _containers.Add(c); } } }
public static IMyCockpit GetMainCockpit(this IMyGridTerminalSystem src) { var cockpits = src.GetBlocksOfType <IMyCockpit>(); foreach (var cockpit in cockpits) { if (cockpit.IsMainCockpit) { return(cockpit); } } return(null); }
public string LoadEntities(IMyGridTerminalSystem aGTS, Func <IMyTerminalBlock, bool> pCheck = null) { string aOut = ""; aGTS.GetBlocksOfType(mCameras, pCheck); // TODO: give every camera a CustomData and set there if you want to be raycast enabled or not // this would make it possible to exclude cameras foreach (IMyCameraBlock aCamera in mCameras) { aCamera.EnableRaycast = true; } return(aOut); }
public IMyTextPanel findLcd(string id) { string pattern = ARGS_LCDNAME_FORMAT.Replace("{ID}", id); IMyTextPanel LcdBlock = null; List <IMyTerminalBlock> Blocks = new List <IMyTerminalBlock>(); GridTerminalSystem.GetBlocksOfType <IMyTextPanel>(Blocks, (x => (x as IMyTerminalBlock).CustomName.Contains(pattern))); if (Blocks.Count > 0) { LcdBlock = Blocks[0] as IMyTextPanel; } return(LcdBlock); }
virtual public bool Init(IMyRemoteControl RC = null) { this.RC = RC ?? Term.GetBlocksOfType <IMyRemoteControl>(collect: x => x.IsFunctional).FirstOrDefault(); if (RC == null) { return(false); } DroneName = DroneNameProvider; Antennae = Term.GetBlocksOfType <IMyRadioAntenna>(collect: x => x.IsFunctional); bool HasSetup = ParseSetup(); if (!HasSetup) { return(false); } AISessionCore.AddDamageHandler(Grid, (Block, Damage) => OnDamaged(Block, Damage)); Grid.OnBlockAdded += (Block) => OnBlockPlaced(Block); OwnerFaction = Grid.GetOwnerFaction(RecalculateOwners: true); BotOperable = true; return(true); }
public CollisionController(IMyGridTerminalSystem myGridTerminalSystem, bool enabled) { this.enabled = enabled; List <IMyCameraBlock> blocks = new List <IMyCameraBlock>(); myGridTerminalSystem.GetBlocksOfType(blocks); foreach (IMyCameraBlock cam in blocks) { if (cam.CustomName.Contains("[RC]")) {// TODO check camera direction and aligment! cameras.Add(cam); cam.EnableRaycast = true; } } }
private void UpdateToolList() { Tools.Clear(); List <IMyShipWelder> welders = new List <IMyShipWelder>(); Term.GetBlocksOfType(welders); foreach (IMyShipWelder welder in welders) { LaserToolKernel kernel; if (welder.TryGetComponent(out kernel)) { Tools.Add(kernel); } } }
public void update(IMyGridTerminalSystem terminal, IMyShipController cockpit) { _cockpit = cockpit; Base6Directions.Direction cockpitForward = _cockpit.Orientation.TransformDirection(Base6Directions.Direction.Forward); for (int i = 0; i < 6; ++i) { _thrust[i].Clear(); terminal.GetBlocksOfType(_thrust[i], b => // The desired direction, transformed by the cockpit, is equal to the direction of thrust _cockpit.Orientation.TransformDirection(GRID_THRUST_DIRECTIONS[i]) == Base6Directions.GetFlippedDirection(b.Orientation.Forward)); _effectiveThrust[i] = computeTotalEffectiveThrust(_thrust[i]); } }
/// <summary> /// Create autopilot and let it find the required blocks. /// </summary> /// <param name="gts">GridTerminalSystem to use for block lookup.</param> /// <param name="basis">Only blocks on the exact same grid as this one will be used.</param> public AutoPilot(IMyGridTerminalSystem gts, IMyTerminalBlock basis) { Controller = basis as IMyShipController; if (Controller == null) { gts.GetBlocksOfType <IMyShipController>(null, (b) => { if (b.IsFunctional && b.CubeGrid.EntityId == basis.CubeGrid.EntityId) { Controller = b; } return(false); }); } if (Controller == null) { throw new Exception("No controller found on this grid!"); } Thrusters = new List <IMyThrust>(); gts.GetBlocksOfType(Thrusters, (t) => t.IsFunctional && t.CubeGrid.EntityId == Controller.CubeGrid.EntityId); ThrustValues = new double[Thrusters.Count]; Gyros = new List <IMyGyro>(); gts.GetBlocksOfType(Gyros, (g) => g.IsFunctional && g.CubeGrid.EntityId == Controller.CubeGrid.EntityId); }
public void Scan(IMyGridTerminalSystem gts) { this.log("Scanning..."); this._metaGrids.Clear(); gts.GetBlocksOfType(this._tmpMechs, mech => mech.TopGrid != null); gts.GetBlocksOfType(this._tmpCons); var connectedGrids = new HashSet <IMyCubeGrid>(); connectedGrids.Add(this._block.CubeGrid); connectedGrids.UnionWith( this._tmpCons.Select(c => c.CubeGrid) .Concat(this._tmpMechs.Select(m => m.CubeGrid)) .Concat(this._tmpMechs.Select(m => m.TopGrid).Where(g => g != null))); var grids = new Dictionary <int, IMyCubeGrid>(); foreach (IMyCubeGrid grid in connectedGrids) { bool found = false; foreach (MetaGrid mg in this._metaGrids) { if (mg.IsSameMetaGrid(grid)) { mg.AddGrid(grid); found = true; break; } } if (!found) { this._metaGrids.Add(new MetaGrid(grid)); } } this.log($"We found {this._metaGrids.Count} grids"); }
private void GetRelevantBlocks() { List <IMyTerminalBlock> found = new List <IMyTerminalBlock>(); switch (DisplayValue) { case ShipDisplayValue.BatteryPercentRemaining: GridTerminalSystem.GetBlocksOfType <IMyBatteryBlock>(found, b => b.IsSameConstructAs(Me)); this.blocks = found; break; case ShipDisplayValue.StorageCapacityUsed: GridTerminalSystem.GetBlocksOfType <IMyCargoContainer>(found, b => b.IsSameConstructAs(Me)); this.blocks = found; break; case ShipDisplayValue.ThrustCapacityUsed: List <IMyThrust> thrusters = new List <IMyThrust>(); GridTerminalSystem.GetBlocksOfType <IMyThrust>(thrusters, b => b.IsSameConstructAs(Me)); thrusters = BlockUtils.GetThrustersEmittingInDirection(thrusters, Base6Directions.Direction.Down); this.blocks = thrusters.Cast <IMyTerminalBlock>().ToList(); break; } }
void GrabRemotes() { GridTerminalSystem.SearchBlocksOfName(gyroName, gyroList); GridTerminalSystem.GetBlocksOfType <IMyRemoteControl>(remotes); for (int i = 0; i < remotes.Count; i++) { var thisRemote = remotes[i] as IMyRemoteControl; if (thisRemote.CustomName.Contains(shooterReferenceName)) { shooterRefrenceList.Add(thisRemote as IMyRemoteControl); Echo("Found Shooter"); } if (thisRemote.CustomName.Contains(missileReferenceName)) { missileRefrenceList.Add(thisRemote as IMyRemoteControl); Echo("Found Missile"); } } //---Check if we do not have an shooter remote if (shooterRefrenceList.Count == 0) { Echo("No shooter refrence block found"); hasRun = false; return; } //---Check if we do not have a missile remote else if (missileRefrenceList.Count == 0) { Echo("No missile refrence block found"); hasRun = false; return; } else if (gyroList.Count == 0) { Echo("No control gyro found"); hasRun = false; return; } else { Echo("Ready to run"); shooterRefrence = shooterRefrenceList[0] as IMyRemoteControl; missileRefrence = missileRefrenceList[0] as IMyRemoteControl; hasRun = true; } }
public void CollectUniqueContainers(List <IMyEntity> containers, IMyGridTerminalSystem gts) { if (inventoryBlockNames.Count == 0) { gts.GetBlocksOfType(containers, DefaultInventoryOwnerFilter); } else { var blocks = new List <IMyTerminalBlock>(); for (var i = 0; i < inventoryBlockNames.Count; i++) { gts.SearchBlocksOfName(inventoryBlockNames[i], blocks); } containers.AddRange(blocks.OfType <IMyEntity>().Where(b => b.HasInventory).Distinct()); } }
public DrillTower Build(StaticState.DrillTowerDef definition) { gridTerminalSystem.GetBlockGroupWithName(definition.PistonGroupName)?.GetBlocksOfType(local_static_pistons); gridTerminalSystem.GetBlockGroupWithName(definition.DrillGroupName)?.GetBlocksOfType(local_static_drills); gridTerminalSystem.GetBlockGroupWithName(definition.DrillClampsGroupName)?.GetBlocksOfType(local_static_clamps); gridTerminalSystem.GetBlocksOfType(local_static_floodlights, b => b.CustomName == definition.FloodlightsName); var rotor = gridTerminalSystem.GetBlockWithName(definition.RotorName) as IMyMotorStator; var display = gridTerminalSystem.GetBlockWithName(definition.DisplayName) as IMyTextPanel; var stacks = new PistonTopology().GetPistonStacks(local_static_pistons); var drills = new DrillHead(local_static_drills.ToArray()); var clamps = new ClampGroup(local_static_clamps.ToArray()); var lights = new LightGroup(local_static_floodlights.ToArray()); return(new DrillTower(stacks, drills, clamps, rotor, lights, display)); }
private static T FindBlockOfType <T>(string CustomName, IMyGridTerminalSystem gts, IMyTerminalBlock anyBlock, string Tag = null) where T : class { List <T> Blocks = new List <T>(); IMyTerminalBlock block; bool flag = false; try { gts.GetBlocksOfType <T>(Blocks, b => { if (flag) { throw new Exception(); } block = (IMyTerminalBlock)b; if (!block.IsSameConstructAs(anyBlock)) { return(false); } if (CustomName == null) { if (block.CustomName.Contains(Tag)) { flag = true; return(true); } } else { if (block.CustomName == CustomName) { flag = true; return(true); } } return(false); }); } catch { } if (Blocks.Count == 0) { return(null); } return(Blocks[0]); }
public List <T> findAllByTag <T>(string tag, IMyGridTerminalSystem GridTerminalSystem, IMyCubeGrid CubeGrid = null) where T : IMyTerminalBlock { if (tag.StartsWith("T:")) { tag = tag.Remove(0, 2); } else { CubeGrid = null; } List <IMyTerminalBlock> MatchingBlocks = new List <IMyTerminalBlock>(); GridTerminalSystem.GetBlocksOfType <T>(MatchingBlocks, (x => x.CustomName.Contains(tag) && (CubeGrid == null || x.CubeGrid.Equals(CubeGrid)))); return(MatchingBlocks.ConvertAll <T>(x => (T)x)); }
public void CheckAssemblersANDContainer(ref Dictionary <string, List <string> > factoryAssembler, string nameOfFinalContainer, ref StringBuilder displayInfoLayout, ref StringBuilder displayDebugg, bool scriptLanguageEnglish, bool systemDebug) { List <IMyAssembler> gridAssemblers = new List <IMyAssembler>(); IMyGridTerminalSystem.GetBlocksOfType <IMyAssembler>(gridAssemblers); int assemblerFound = 0; if (systemDebug == true && scriptLanguageEnglish == false) { displayDebugg.AppendLine("VERIFICAÇÃO DOS ASSEMBLERS E CONTAINER FINAL"); } else { (systemDebug == true && scriptLanguageEnglish == true)displayDebugg.AppendLine("VERIFICATION OF ASSEMBLERS AND FINAL CONTAINER"); } if (scriptLanguageEnglish == false) { displayInfoLayout.AppendLine("Assembler Qtd Nome Informado Qtd Encontrado") else { displayInfoLayout.AppendLine("Assembler Qty Name Reported Qty Found") foreach (KeyValuePair <string, List <string> > assembler in factoryAssembler) { assemblerFound = 0; for (var i = 0; i < assembler.Value.Count; i++) { if (gridAssemblers.Name.Equals(assembler.Value[i])) { assemblerFound = assemblerFound + 1; if (systemDebug == true) { displayDebugg.AppendLine("Assembler da Extrutura: " + assembler.key + " Assembler com o Nome: " + gridAssemblers.name); } } } displayInfoLayout.AppendLine(assembler.key + " " assembler.Value.Count + " " + assemblerFound) } } }
public Drone(IMyEntity ent, BroadcastingTypes broadcasting) { var ship = (IMyCubeGrid)ent; double maxEngagementRange = ConquestMod.MaxEngagementRange; broadcastingType = broadcasting; Ship = ship; var lstSlimBlock = new List<IMySlimBlock>(); GridTerminalSystem = MyAPIGateway.TerminalActionsHelper.GetTerminalSystemForGrid(ship); //If it has any type of cockipt ship.GetBlocks(lstSlimBlock, (x) => x.FatBlock is IMyShipController); FindWeapons(); //If no cockpit the ship is either no ship or is broken. if (lstSlimBlock.Count != 0) { //Make the controls be the cockpit ShipControls = lstSlimBlock[0].FatBlock as IMyControllableEntity; _ownerId = ((Sandbox.ModAPI.IMyTerminalBlock)ShipControls).OwnerId; #region Activate Beacons && Antennas //Maximise radius on antennas and beacons. lstSlimBlock.Clear(); ship.GetBlocks(lstSlimBlock, (x) => x.FatBlock is IMyRadioAntenna); foreach (var block in lstSlimBlock) { IMyRadioAntenna antenna = (IMyRadioAntenna)block.FatBlock; if (antenna != null) { //antenna.GetActionWithName("SetCustomName").Apply(antenna, new ListReader<TerminalActionParameter>(new List<TerminalActionParameter>() { TerminalActionParameter.Get("Combat Drone " + _manualGats.Count) })); antenna.SetValueFloat("Radius", 5000);//antenna.GetMaximum<float>("Radius")); ITerminalAction act = antenna.GetActionWithName("OnOff_On"); act.Apply(antenna); } } lstSlimBlock = new List<IMySlimBlock>(); ship.GetBlocks(lstSlimBlock, (x) => x.FatBlock is IMyBeacon); foreach (var block in lstSlimBlock) { IMyBeacon beacon = (IMyBeacon)block.FatBlock; if (beacon != null) { beacon.SetValueFloat("Radius", 5000);//beacon.GetMaximum<float>("Radius")); ITerminalAction act = beacon.GetActionWithName("OnOff_On"); act.Apply(beacon); } } #endregion //SetWeaponPower(true); //AmmoManager.ReloadReactors(_allReactors); //AmmoManager.ReloadGuns(_manualGats); ship.GetBlocks(lstSlimBlock, x => x is IMyEntity); List<IMyTerminalBlock> massBlocks = new List<IMyTerminalBlock>(); GridTerminalSystem.GetBlocksOfType<IMyVirtualMass>(massBlocks); List<IMyTerminalBlock> allTerminalBlocks = new List<IMyTerminalBlock>(); GridTerminalSystem.GetBlocksOfType<IMyCubeBlock>(allTerminalBlocks); HealthBlockBase = allTerminalBlocks.Count; if (ShipControls != null) { navigation = new DroneNavigation(ship, ShipControls, _nearbyFloatingObjects, maxEngagementRange); } } Ship.OnBlockAdded += RecalcMaxHp; myNumber = numDrones; numDrones++; }
public AutoHoverController(IMyGridTerminalSystem gts, IMyProgrammableBlock pb) { Me = pb; GridTerminalSystem = gts; remote = GridTerminalSystem.GetBlockWithName(RemoteControlName) as IMyRemoteControl; gyro = GridTerminalSystem.GetBlockWithName(GyroName) as IMyGyro; if (!String.IsNullOrEmpty(TextPanelName)) screen = GridTerminalSystem.GetBlockWithName(TextPanelName) as IMyTextPanel; var list = new List<IMyTerminalBlock>(); GridTerminalSystem.GetBlocksOfType<IMyGyro>(list, x => x.CubeGrid == Me.CubeGrid && x != gyro); gyros = list.ConvertAll(x => (IMyGyro)x); gyros.Insert(0, gyro); gyros = gyros.GetRange(0, GyroCount); mode = "Hover"; setSpeed = 0; }