public ThrustProfiler(IMyCubeBlock autopilot) { if (autopilot == null) { throw new NullReferenceException("autopilot"); } m_autopilot = autopilot; myGrid = autopilot.CubeGrid; Standard = new StandardFlight(autopilot, Base6Directions.Direction.Forward, Base6Directions.Direction.Up); Gravity = new StandardFlight(autopilot, Base6Directions.Direction.Up, Base6Directions.Direction.Forward); for (int i = 0; i < 6; i++) { m_thrustersInDirection[i] = new List <MyThrust>(); } CubeGridCache cache = CubeGridCache.GetFor(myGrid); if (cache == null) { return; } foreach (MyThrust thrust in cache.BlocksOfType(typeof(MyObjectBuilder_Thrust))) { newThruster(thrust); } myGrid.OnBlockAdded += grid_OnBlockAdded; myGrid.OnBlockRemoved += grid_OnBlockRemoved; MyAPIGateway.Utilities.InvokeOnGameThread(ClearOverrides); }
public ThrustProfiler(IMyCubeBlock autopilot) { if (autopilot == null) throw new NullReferenceException("autopilot"); myLogger = new Logger(GetType().Name, autopilot); myGrid = autopilot.CubeGrid; Standard = new StandardFlight(autopilot, Base6Directions.Direction.Forward, Base6Directions.Direction.Up); Gravity = new StandardFlight(autopilot, Base6Directions.Direction.Up, Base6Directions.Direction.Forward); foreach (Base6Directions.Direction direction in Base6Directions.EnumDirections) thrustersInDirection.Add(direction, new List<MyThrust>()); List<IMySlimBlock> thrusters = new List<IMySlimBlock>(); myGrid.GetBlocks(thrusters, block => block.FatBlock != null && block.FatBlock is IMyThrust); foreach (IMySlimBlock thrust in thrusters) newThruster(thrust); myGrid.OnBlockAdded += grid_OnBlockAdded; myGrid.OnBlockRemoved += grid_OnBlockRemoved; ClearOverrides(); }