private void OfferPotentialDestination(IMyCubeGrid grid) { foreach (var remoteControl in grid.GetTerminalBlocksOfType <IMyRemoteControl>()) { // TODO: need a reference to the whole base grid to properly determine ownership if (!remoteControl.IsControlledByFaction("GCORP")) { // continue; } // TODO: add multiple source and desitinations. also should check CustomData if (remoteControl.CustomName.Contains("AIR_DELIVERY_DESTINATION")) { // If the destination has not yet been setup (ie restored from a save), do so now if (Vector3D.IsZero(airConvoyDestinationPosition)) { airConvoyDestinationPosition = remoteControl.GetPosition() + remoteControl.GetNaturalGravity() * -23f; } } else if (remoteControl.CustomName.Contains("GROUND_DELIVERY_DESTINATION")) { //basesToInit.Add(remoteControl); // Is in the same place as the air destination, so disabled this // If the destination has not yet been setup (ie restored from a save), do so now if (Vector3D.IsZero(groundConvoyDestinationPosition)) { groundConvoyDestinationPosition = remoteControl.GetPosition() + remoteControl.GetNaturalGravity() * -0.3f; // 3M above for Ground Destination } } } }
private void SetFurnaceDoorsEnabled(bool powered) { foreach (var door in mikiScrapGrid.GetTerminalBlocksOfType <IMyDoor>("FURNACE_DOOR")) { door.Enabled = powered; if (powered) { door.OpenDoor(); } } }
private static void ApplyBackFixes(IMyCubeGrid grid) { // Worried these might be causing lag as there are a lot of them foreach (var productionBlock in grid.GetTerminalBlocksOfType <IMyProductionBlock>()) { productionBlock.Enabled = false; } foreach (var buttonPanel in grid.GetTerminalBlocksOfTypeInSubgrids <IMyButtonPanel>()) { buttonPanel.AnyoneCanUse = true; } }
public override void GridInitialising(IMyCubeGrid grid) { if (!grid.IsStatic) { return; } var slimBlocks = new List <IMySlimBlock>(); grid.GetBlocks(slimBlocks, b => b.FatBlock is IMyRemoteControl); foreach (var slim in slimBlocks) { var remoteControl = slim.FatBlock as IMyRemoteControl; if (remoteControl.CustomName.Contains("RC_FURNACE") && remoteControl.IsOwnedByFaction("MIKI")) { grid.SetAllSubgridsInvulnerable(true); var mikiScrap = new MikiScrap(grid, remoteControl, grid.GetContainerInventoryOfName("MIKISCRAP_INPUT"), grid.GetContainerInventoryOfName("MIKISCRAP_OUTPUT"), grid.GetTerminalBlockMatchingName <IMyDoor>("FURNACE_DOOR"), grid.GetTerminalBlockMatchingName <IMySoundBlock>("MIKISCRAP_SPEAKER"), grid.GetTerminalBlocksOfType <IMyTextPanel>("FURNACE_LCD"), grid.GetTerminalBlocksOfType <IMyReflectorLight>("FURNACE_SPOTLIGHT"), grid.GetContainerInventoryOfName("FURNACE_OUTPUT"), audioSystem); MikiScrapSaveData saveData; if (restoredMikiScrapSavaData.TryGetValue(grid.EntityId, out saveData)) { mikiScrap.RestoreSavedData(saveData); } ApplyBackFixes(grid); mikiScraps.Add(mikiScrap); return; } } }
private void OfferPotentialDestination(IMyCubeGrid grid) { // ModLog.Info("Potential Destination:" + grid.CustomName); foreach (var remoteControl in grid.GetTerminalBlocksOfType <IMyRemoteControl>()) { // ModLog.Info(" RC:" + remoteControl.CustomName); if (!remoteControl.IsControlledByFaction("GCORP")) { continue; } if (remoteControl.CustomName.Contains("AIR_DELIVERY_DESTINATION")) { // If the destination has not yet been setup (ie restored from a save), do so now if (Vector3D.IsZero(airConvoyDestinationPosition)) { // ModLog.Info(" Setting airConvoyDestinationPosition:" + remoteControl.GetPosition().ToString()); airConvoyDestinationPosition = remoteControl.GetPosition() + remoteControl.GetNaturalGravity() * -23f; // ModLog.Info(" Gravity:" + remoteControl.GetNaturalGravity()); // ModLog.Info(" Set airConvoyDestinationPosition:" + airConvoyDestinationPosition.ToString()); } else { // ModLog.Info(" Using Saved airConvoyDestinationPosition:" + airConvoyDestinationPosition.ToString()); } } else if (remoteControl.CustomName.Contains("GROUND_DELIVERY_DESTINATION")) { //basesToInit.Add(remoteControl); // Is in the same place as the air destination, so disabled this // If the destination has not yet been setup (ie restored from a save), do so now if (Vector3D.IsZero(groundConvoyDestinationPosition)) { // ModLog.Info(" Setting groundConvoyDestinationPosition:" + remoteControl.GetPosition().ToString()); groundConvoyDestinationPosition = remoteControl.GetPosition() + remoteControl.GetNaturalGravity() * -0.3f; // // 3M above for Ground Destination // ModLog.Info(" Gravity:" + remoteControl.GetNaturalGravity()); // ModLog.Info(" Set groundConvoyDestinationPosition:" + groundConvoyDestinationPosition.ToString()); } else { // ModLog.Info(" using Saved groundConvoyDestinationPosition:" + groundConvoyDestinationPosition.ToString()); } } } // ModLog.Info("EO:Potential Destination:" + grid.CustomName); }