//add objects to this ships local known objects collection (within detection range - 2km by defualt) //Turn weapons on and off SetWeaponPower(true) turns weapons online: vice versa public void SetWeaponPower(bool isOn) { foreach (var w in _allWeapons) { if (isOn) { _blockOn.Apply(w.FatBlock); } else { _blockOff.Apply(w.FatBlock); } } //foreach (var w in _manualGuns) //{ // if (isOn) // _blockOn.Apply(w.FatBlock); // else // _blockOff.Apply(w.FatBlock); //} //foreach (var w in _manualRockets) //{ // if (isOn) // _blockOn.Apply(w.FatBlock); // else // _blockOff.Apply(w.FatBlock); //} }
private void DrillsOff() { List <IMySlimBlock> blocks = new List <IMySlimBlock>(); Ship.GetBlocks(blocks, (x) => x.FatBlock != null && x.FatBlock is IMyShipDrill); var drills = blocks.Select(x => x.FatBlock).ToList(); drills.ForEach(x => _blockOff.Apply(x)); }
//turn on all weapons public void ManualFire(bool doFire) { SetWeaponPower(doFire); if (doFire) { Util.GetInstance() .Log(_fireGun + "[Drone.ManualFire] Number of guns -> " + _manualGuns.Count, "weapons.txt"); Util.GetInstance() .Log(_fireGun + "[Drone.ManualFire] number of all weapons -> " + _allWeapons.Count, "weapons.txt"); foreach (var gun in _manualGuns) { _fireGun.Apply(gun.FatBlock); } if (Math.Abs((DateTime.Now - _lastRocketFired).TotalMilliseconds) > 200 && _fireRocket != null && _manualRockets.Count > 0) { var launcher = _manualRockets[missileStaggeredFireIndex]; _fireGun.Apply(launcher.FatBlock); if (missileStaggeredFireIndex + 1 < _manualRockets.Count()) { missileStaggeredFireIndex++; } else { missileStaggeredFireIndex = 0; } _lastRocketFired = DateTime.Now; } } //else //{ // foreach (var VARIABLE in _allWeapons) // { // _blockOff.Apply((IMyCubeBlock)VARIABLE.FatBlock); // } //} _isFiringManually = doFire; }
//Disables all beacons and antennas and deletes the ship. public void DeleteShip() { var lstSlimBlock = new List <IMySlimBlock>(); Ship.GetBlocks(lstSlimBlock, (x) => x.FatBlock is IMyRadioAntenna); foreach (var block in lstSlimBlock) { IMyRadioAntenna antenna = (IMyRadioAntenna)block.FatBlock; ITerminalAction act = antenna.GetActionWithName("OnOff_Off"); 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; ITerminalAction act = beacon.GetActionWithName("OnOff_Off"); act.Apply(beacon); } MyAPIGateway.Entities.RemoveEntity(Ship as IMyEntity); Ship = null; }
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(); SetupActions(); //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", 10000);//antenna.GetMaximum<float>("Radius")); _blockOn.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", 10000);//beacon.GetMaximum<float>("Radius")); _blockOn.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++; }