public override void GridInitialising(IMyCubeGrid grid) { BlocksFixup(grid); if (grid.IsStatic && grid.IsControlledByFaction("GCORP")) { 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.IsControlledByFaction("GCORP") && remoteControl.CustomName.Contains("DELIVERY") // AIR_DELIVERY_SPAWNER // GROUND_DELIVERY_SPAWNER //Remote Control ) { var planet = DuckUtils.FindPlanetInGravity(remoteControl.GetPosition()); if (planet == null) { continue; // Space bases not yet supported. } bases.Add(new GCorpBase(remoteControl, ZeroDate, planet, heatSystem, audioSystem)); return; // Accepted grid, no need to keep looping } } } }
public override void GridInitialising(IMyCubeGrid grid) { /* Try to fix text not showing on text panels * * (on further testing, panels are showing.. maybe Keen fixed this themselves?) * * Saw on Rity's stream that they were NOT showing in all places. * And on EpikTek's https://www.youtube.com/watch?v=CkpGGPZd78k * */ var slimBlocks2 = new List <IMySlimBlock>(); grid.GetBlocks(slimBlocks2, b => b.FatBlock is IMyTextPanel); foreach (var slim in slimBlocks2) { var textPanel = slim.FatBlock as IMyTextPanel; bool bShow = textPanel.GetValueBool("ShowTextOnScreen"); // bool bShow = textPanel.ShowOnScreen != VRage.Game.GUI.TextPanel.ShowTextOnScreenFlag.NONE; if (bShow) { textPanel.SetValue("ShowTextOnScreen", false); // textPanel.SetShowOnScreen(VRage.Game.GUI.TextPanel.ShowTextOnScreenFlag.NONE); textPanel.SetValue("ShowTextOnScreen", true); // textPanel.SetShowOnScreen(VRage.Game.GUI.TextPanel.ShowTextOnScreenFlag.PUBLIC); } else { // TODO: go through entityIDs and fix up graphics references } } // if (grid.IsStatic && grid.IsControlledByFaction("GCORP")) { 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.IsControlledByFaction("GCORP")) //TODO: use another method to determine NPC bases. { var planet = DuckUtils.FindPlanetInGravity(remoteControl.GetPosition()); if (planet == null) { continue; // Space bases not yet supported. } //TODO determine faction owner in above code bases.Add(new GCorpBase(remoteControl, ZeroDate, planet, audioSystem, CalFactions.Gcorp)); return; // Accepted grid, no need to keep looping } } } }
private void GiveOrdersToUnassignedShips() { bool bFoundBackup = false; while (unitialisedNewGrids.Count > 0) { var grid = unitialisedNewGrids.Dequeue(); if (!grid.IsControlledByFaction("GCORP")) { continue; } var roleAndUnitType = PrefabGrid.GetRoleAndUnitType(grid); if (roleAndUnitType == null) { // V26 debug ModLog.Info("Discarding grid because no role found"); continue; } var unitType = roleAndUnitType.Value.UnitType; switch (roleAndUnitType.Value.UnitRole) { case UnitRole.Delivery: var cargoType = CargoType.GenerateRandomCargo(random); LoadCargo(grid, cargoType); if (cargoType.subtypeName == "SteelPlate") { audioSystem.PlayAudioRandomChance(0.1, AudioClip.SteelPlateConvoyDispatched, AudioClip.ConvoyDispatched1); } else if (cargoType.subtypeName == "MetalGrid") { audioSystem.PlayAudioRandomChance(1, AudioClip.MetalGridConvoyDispatched); } else if (cargoType.subtypeName == "Construction") { audioSystem.PlayAudioRandomChance(0.1, AudioClip.ConstructionConvoyDispatched); } else if (cargoType.subtypeName == "InteriorPlate") { audioSystem.PlayAudioRandomChance(0.1, AudioClip.InteriorPlateConvoyDispatched); } else if (cargoType.subtypeName == "Girder") { audioSystem.PlayAudioRandomChance(0.1, AudioClip.GirderConvoyDispatched); } else if (cargoType.subtypeName == "SmallTube") { audioSystem.PlayAudioRandomChance(0.1, AudioClip.SmallTubeConvoyDispatched); } else if (cargoType.subtypeName == "LargeTube") { audioSystem.PlayAudioRandomChance(0.2, AudioClip.LargeTubeConvoyDispatched); } else if (cargoType.subtypeName == "Motor") { audioSystem.PlayAudioRandomChance(0.75, AudioClip.MotorConvoyDispatched); } else if (cargoType.subtypeName == "Display") { audioSystem.PlayAudioRandomChance(0.2, AudioClip.DisplayConvoyDispatched); } else if (cargoType.subtypeName == "BulletproofGlass") { audioSystem.PlayAudioRandomChance(0.3, AudioClip.BulletproofGlassConvoyDispatched); } else if (cargoType.subtypeName == "Computer") { audioSystem.PlayAudioRandomChance(0.2, AudioClip.ComputerConvoyDispatched); } else if (cargoType.subtypeName == "Reactor") { audioSystem.PlayAudioRandomChance(0.75, AudioClip.ReactorConvoyDispatched); } else if (cargoType.subtypeName == "Medical") { audioSystem.PlayAudioRandomChance(0.7, AudioClip.MedicalConvoyDispatched); } else if (cargoType.subtypeName == "RadioCommunication") { audioSystem.PlayAudioRandomChance(0.5, AudioClip.RadioCommunicationConvoyDispatched); } else if (cargoType.subtypeName == "Explosives") { audioSystem.PlayAudioRandomChance(0.5, AudioClip.ExplosivesConvoyDispatched); } else if (cargoType.subtypeName == "SolarCell") { audioSystem.PlayAudioRandomChance(0.5, AudioClip.SolarCellConvoyDispatched); } else if (cargoType.subtypeName == "PowerCell") { audioSystem.PlayAudioRandomChance(0.75, AudioClip.PowerCellConvoyDispatched); } else if (cargoType.subtypeName == "NATO_5p56x45mm") { audioSystem.PlayAudioRandomChance(0.5, AudioClip.NATO_5p56x45mmConvoyDispatched); } else if (cargoType.subtypeName == "NATO_25x184mm") { audioSystem.PlayAudioRandomChance(0.5, AudioClip.NATO25x184mmConvoyDispatched); } else if (cargoType.subtypeName == "Missile200mm") { audioSystem.PlayAudioRandomChance(0.5, AudioClip.Missile200mmConvoyDispatched); } else if (cargoType.subtypeName == "Uranium") { audioSystem.PlayAudioRandomChance(1, AudioClip.UraniumConvoyDispatched); } else // we don't know what it is.. { audioSystem.PlayAudioRandomChance(0.1, AudioClip.ConvoyDispatched1, AudioClip.ConvoyDispatched2, AudioClip.ConvoyDispatched3); } string sPrefix = "T"; if (unitType == UnitType.Air) { sPrefix += "A"; } else { sPrefix += "G"; } grid.SetAllBeaconNames(sPrefix + random.Next(10000, 99999) + " - " + cargoType.GetDisplayName() + " Shipment", 200f); // V31 set short until initialize check timeout var destination = unitType == UnitType.Air ? airConvoyDestinationPosition : groundConvoyDestinationPosition; // ModLog.Info("Air Destination=" + airConvoyDestinationPosition.ToString()); // ModLog.Info("GND Destination=" + groundConvoyDestinationPosition.ToString()); // ModLog.Info("Chosen Dest=" + destination.ToString()); SetDestination(grid, destination); RegisterConvoy(grid, NpcGroupState.Travelling, unitType, destination, MyAPIGateway.Session.GameDateTime); var planet = DuckUtils.FindPlanetInGravity(grid.GetPosition()); if (planet != null) { convoySpawner.SpawnConvoyEscorts(grid, unitType, planet); } break; case UnitRole.Escort: var group = FindNearestJoinableNpcGroup(grid.GetPosition(), unitType); if (group == null) { ModLog.Error("Escort ship spawned but can't find a group to join!"); grid.CloseAll(); } else { grid.SetAllBeaconNames("E" + random.Next(10000, 99999) + " - " + EscortName, 2500f); // V31 shorten escort beacon range to decrease hud spam var nearestPlanet = DuckUtils.FindPlanetInGravity(grid.GetPosition()); if (nearestPlanet != null) { group.JoinAsEscort(grid, unitType, nearestPlanet); } } break; case UnitRole.Backup: var gCorpBase = baseManager.FindBaseWantingBackup(); // V26 bFoundBackup = true; if (gCorpBase == null) { gCorpBase = baseManager.FindBaseNear(grid.GetPosition()); } if (gCorpBase == null) { ModLog.Error("Backup ship spawned but can't find the base that asked for it!"); grid.CloseAll(); break; } var backupPosition = gCorpBase.GetBackupPosition(); grid.SendToPosition(backupPosition); // backup debug string sBeacon = "M" + random.Next(10000, 99999) + " Investigating Backup Call"; // ModLog.Info("Backup Found:" + sBeacon); // ModLog.Info(" Destination=" + backupPosition.ToString()); grid.SetAllBeaconNames(sBeacon, 20000f); var backupGroup = new BackupGroup(NpcGroupState.Travelling, backupPosition, grid, heatSystem, audioSystem, MyAPIGateway.Session.GameDateTime); //damageSensor.RegisterDamageObserver(grid.EntityId, backupGroup); npcGroups.Add(backupGroup); break; case UnitRole.Bomb: bool hasSensors = false; var slimBlocks = new List <IMySlimBlock>(); grid.GetBlocks(slimBlocks, b => b.FatBlock is IMySensorBlock); if (slimBlocks.Count > 0) { hasSensors = true; } grid.GetBlocks(slimBlocks, b => b.FatBlock is IMyWarhead); foreach (var slim in slimBlocks) { var wh = slim.FatBlock as IMyWarhead; wh.IsArmed = true; if (!hasSensors) // if no sensors, start the countdown { ModLog.Info("BOMB: no sensors: Starting timer"); wh.StartCountdown(); } } break; default: continue; } } if (bFoundBackup) { baseManager.ClearBaseBackupRequests(); } }
private void GiveOrdersToUnassignedShips() { while (unitialisedNewGrids.Count > 0) { var grid = unitialisedNewGrids.Dequeue(); if (!grid.IsControlledByNpcFaction()) { continue; } var roleAndUnitType = PrefabGrid.GetRoleAndUnitType(grid); if (roleAndUnitType == null) { continue; } var unitType = roleAndUnitType.Value.UnitType; switch (roleAndUnitType.Value.UnitRole) { case UnitRole.Delivery: var cargoType = CargoType.GenerateRandomCargo(random); LoadCargo(grid, cargoType); grid.SetAllBeaconNames("T" + random.Next(10000, 99999) + " - " + cargoType.GetDisplayName() + " Shipment", 20000f); var destination = unitType == UnitType.Air ? airConvoyDestinationPosition : groundConvoyDestinationPosition; SetDestination(grid, destination); RegisterConvoy(grid, NpcGroupState.Travelling, unitType, destination, MyAPIGateway.Session.GameDateTime); var planet = DuckUtils.FindPlanetInGravity(grid.GetPosition()); if (planet != null) { CalFactions.Gcorp.Ships.SpawnConvoyEscorts(grid, unitType, planet); } break; case UnitRole.Escort: var group = FindNearestJoinableNpcGroup(grid.GetPosition(), unitType); if (group == null) { ModLog.Error("Escort ship spawned but can't find a group to join!"); grid.CloseAll(); } else { grid.SetAllBeaconNames("E" + random.Next(10000, 99999) + " - Convoy Escort", 20000f); var nearestPlanet = DuckUtils.FindPlanetInGravity(grid.GetPosition()); if (nearestPlanet != null) { group.JoinAsEscort(grid, unitType, nearestPlanet); } } break; case UnitRole.Backup: var gCorpBase = baseManager.FindBaseWantingBackup(); if (gCorpBase == null) { ModLog.Error("Backup ship spawned but can't find the base that asked for it!"); grid.CloseAll(); break; } var backupPosition = gCorpBase.GetBackupPosition(); grid.SendToPosition(backupPosition); grid.SetAllBeaconNames("M" + random.Next(10000, 99999) + " Investigating Backup Call", 20000f); var backupGroup = new BackupGroup(NpcGroupState.Travelling, backupPosition, grid, heatSystem, audioSystem, MyAPIGateway.Session.GameDateTime); //damageSensor.RegisterDamageObserver(grid.EntityId, backupGroup); npcGroups.Add(backupGroup); break; default: continue; } } }