Beispiel #1
0
        protected void EnableDrills(bool enable)
        {
            if (enable)
            {
                Log.DebugLog("Enabling drills", Logger.severity.DEBUG);
            }
            else
            {
                Log.DebugLog("Disabling drills", Logger.severity.DEBUG);
            }

            CubeGridCache cache = CubeGridCache.GetFor(m_controlBlock.CubeGrid);

            if (cache == null)
            {
                Log.DebugLog("Failed to get cache", Logger.severity.INFO);
                return;
            }

            MyAPIGateway.Utilities.TryInvokeOnGameThread(() => {
                foreach (IMyShipDrill drill in cache.BlocksOfType(typeof(MyObjectBuilder_Drill)))
                {
                    if (!drill.Closed)
                    {
                        ((MyFunctionalBlock)drill).Enabled = enable;
                    }
                }
            });
        }
Beispiel #2
0
        public void UpdateTarget(AntennaRelay.LastSeen enemy)
        {
            if (enemy == null)
            {
                return;
            }

            foreach (IMyCubeGrid grid in AttachedGrid.AttachedGrids(m_block.CubeGrid, AttachedGrid.AttachmentKind.Terminal, true))
            {
                CubeGridCache cache = CubeGridCache.GetFor(grid);
                if (cache == null)
                {
                    continue;
                }
                foreach (IMyCubeBlock warhead in cache.BlocksOfType(typeof(MyObjectBuilder_Warhead)))
                {
                    if (m_block.canControlBlock(warhead))
                    {
                        Log.DebugLog("Starting countdown for " + warhead.getBestName(), Logger.severity.DEBUG);
                        warhead.ApplyAction("StartCountdown");
                    }
                }
            }
            m_countingDown = true;
        }
Beispiel #3
0
        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);
        }
Beispiel #4
0
        public RotorPicker(IMyTerminalBlock cockpit, string rotorName, ControlRotorParams rotorParams, SetControlRotors onComplete)
        {
            m_block      = cockpit;
            m_onComplete = onComplete;

            IEnumerable <IMyMotorStator> selected;

            rotorParams(out selected, out m_sensitivity, out m_trim);
            m_trim = MathHelper.ToDegrees(m_trim);

            m_listbox              = new MyTerminalControlListbox <MyCockpit>("Arms_RotorPicker", MyStringId.GetOrCompute(rotorName + " Rotors"), MyStringId.NullOrEmpty, true, 14);
            m_listbox.ListContent  = ListContent;
            m_listbox.ItemSelected = ItemSelected;

            m_sensitivitySlider = new MyTerminalControlSlider <MyCockpit>("Arms_RotorPickerSensitivity", MyStringId.GetOrCompute("Control Sensitivity"), MyStringId.GetOrCompute("How sensitive the ship will be to input"));
            m_sensitivitySlider.DefaultValue = 1f;
            m_sensitivitySlider.Getter       = b => m_sensitivity;
            m_sensitivitySlider.Setter       = (b, value) => m_sensitivity = value;
            m_sensitivitySlider.SetLogLimits(0.01f, 100f);
            m_sensitivitySlider.Writer = (b, sb) => sb.Append(m_sensitivity);

            m_trimSlider = new MyTerminalControlSlider <MyCockpit>("Arms_RotorPickerTrim", MyStringId.GetOrCompute("Trim"), MyStringId.GetOrCompute("Default angle of rotors"));
            m_trimSlider.DefaultValue = 0f;
            m_trimSlider.Getter       = b => m_trim;
            m_trimSlider.Setter       = (b, value) => m_trim = value;
            m_trimSlider.SetLimits(-45f, 45f);
            m_trimSlider.Writer = (b, sb) => {
                sb.Append(m_trim);
                sb.Append('°');
            };

            m_save = new MyTerminalControlButton <MyCockpit>("Arms_RotorPickerSave", MyStringId.GetOrCompute("Save & Exit"), MyStringId.NullOrEmpty, SaveAndExit);

            CubeGridCache cache = CubeGridCache.GetFor(m_block.CubeGrid);

            if (cache == null)
            {
                return;
            }

            foreach (IMyMotorStator stator in cache.BlocksOfType(typeof(MyObjectBuilder_MotorStator)))
            {
                MyGuiControlListbox.Item item = new MyGuiControlListbox.Item(new StringBuilder(stator.DisplayNameText), userData: stator);
                m_allItems.Add(item);
                if (selected.Contains(stator))
                {
                    m_selected.Add(item);
                }
            }

            MyTerminalControls.Static.CustomControlGetter += CustomControlGetter;
            cockpit.RebuildControls();
        }
Beispiel #5
0
        /// <summary>
        /// Determines if the ship is capable of digging a tunnel.
        /// </summary>
        private bool CanTunnel()
        {
            CubeGridCache cache = CubeGridCache.GetFor(m_grid);

            if (cache == null)
            {
                return(false);
            }

            BoundingSphere[] sensors = new BoundingSphere[cache.CountByType(typeof(MyObjectBuilder_Drill))];
            int drillIndex           = 0;

            foreach (MyShipDrill drill in cache.BlocksOfType(typeof(MyObjectBuilder_Drill)))
            {
                float offset = (float)MyShipDrillDefinition__SensorOffset.GetValue(drill.BlockDefinition);
                float radius = (float)MyShipDrillDefinition__SensorRadius.GetValue(drill.BlockDefinition);
                sensors[drillIndex++] = new BoundingSphere(drill.LocalPosition() + drill.PositionComp.LocalMatrix.Forward * offset, radius + MyVoxelConstants.VOXEL_SIZE_IN_METRES_HALF);
            }

            Vector3 forward = m_navBlock.LocalMatrix.Forward;

            foreach (Vector3I cell in m_grid.FirstBlocks(m_navBlock.LocalMatrix.Backward))
            {
                IMySlimBlock block = m_grid.GetCubeBlock(cell);
                if (!(block.FatBlock is IMyShipDrill))
                {
                    Ray ray = new Ray(cell * m_grid.GridSize, forward);

                    foreach (BoundingSphere sensor in sensors)
                    {
                        if (ray.Intersects(sensor).HasValue)
                        {
                            //Log.DebugLog(block.getBestName() + " is behind a drill");
                            goto NextBlock;
                        }
                    }

                    //Log.DebugLog(block.getBestName() + " is not behind any drill");
                    return(false);
                }

                NextBlock :;
            }

            return(true);
        }
Beispiel #6
0
        private void calculateLocalMatrix()
        {
            if (Grid.MarkedForClose)
            {
                return;
            }

            CubeGridCache cache = CubeGridCache.GetFor(Grid);

            if (cache == null)
            {
                return;
            }
            Block = null;

            FunctionalBlocks = 0;
            Matrix  LocalMatrix = Matrix.Zero;
            Vector3 Translation = Vector3.Zero;

            foreach (IMyCubeBlock block in  cache.BlocksOfType(typeof(T)))
            {
                if (Block == null)
                {
                    Block       = block;
                    LocalMatrix = block.LocalMatrix;
                }

                if (block.IsFunctional)
                {
                    FunctionalBlocks++;
                    Translation   += block.LocalMatrix.Translation;
                    block.OnClose -= block_OnClose;
                    block.OnClose += block_OnClose;
                }
            }

            if (FunctionalBlocks == 0)
            {
                return;
            }
            LocalMatrix.Translation = Translation / FunctionalBlocks;
            this.LocalMatrix        = LocalMatrix;

            return;
        }
Beispiel #7
0
        private void CalcGyroForce()
        {
            float         force = 0f;
            CubeGridCache cache = CubeGridCache.GetFor(myGrid);

            if (cache == null)
            {
                return;
            }
            foreach (MyGyro g in cache.BlocksOfType(typeof(MyObjectBuilder_Gyro)))
            {
                if (g.IsWorking)
                {
                    force += g.MaxGyroForce;                     // MaxGyroForce accounts for power ratio and modules
                }
            }
            GyroForce = force;
        }
Beispiel #8
0
 private bool BatteriesCharged(IMyCubeGrid startGrid)
 {
     foreach (IMyCubeGrid attachedGrid in AttachedGrid.AttachedGrids(startGrid, AttachedGrid.AttachmentKind.Permanent, true))
     {
         CubeGridCache cache = CubeGridCache.GetFor(attachedGrid);
         if (cache == null)
         {
             return(false);
         }
         foreach (IMyBatteryBlock battery in cache.BlocksOfType(typeof(MyObjectBuilder_BatteryBlock)))
         {
             if (battery.IsCharging)
             {
                 return(false);
             }
         }
     }
     Logger.DebugLog("All batteries are recharged", Logger.severity.DEBUG);
     return(true);
 }
Beispiel #9
0
        public TextPanelMonitor GetTextPanelMonitor(IMyTerminalBlock autopilot, AutopilotCommands autoCmds)
        {
            string panelName = m_panelName.ToString();

            IMyTextPanel textPanel       = null;
            int          bestMatchLength = int.MaxValue;

            foreach (IMyCubeGrid grid in Attached.AttachedGrid.AttachedGrids((IMyCubeGrid)autopilot.CubeGrid, Attached.AttachedGrid.AttachmentKind.Permanent, true))
            {
                CubeGridCache cache = CubeGridCache.GetFor(grid);
                if (cache == null)
                {
                    continue;
                }
                foreach (IMyTextPanel panel in cache.BlocksOfType(typeof(MyObjectBuilder_TextPanel)))
                {
                    if (!((IMyCubeBlock)autopilot).canControlBlock((IMyCubeBlock)panel))
                    {
                        continue;
                    }

                    string name = panel.DisplayNameText;
                    if (name.Length < bestMatchLength && name.Contains(panelName))
                    {
                        textPanel       = panel;
                        bestMatchLength = name.Length;
                        if (name.Length == panelName.Length)
                        {
                            return(new TextPanelMonitor(textPanel, autoCmds, m_identifier.ToString()));
                        }
                    }
                }
            }

            if (textPanel == null)
            {
                return(null);
            }

            return(new TextPanelMonitor(textPanel, autoCmds, m_identifier.ToString()));
        }
Beispiel #10
0
        /// <summary>
        /// Adds a disruption effect to a grid.
        /// </summary>
        /// <param name="grid">Grid that will be disrupted</param>
        /// <param name="duration">Duration of disruption</param>
        /// <param name="strength">Strength of disruption (in hackyness)</param>
        /// <param name="effectOwner">The owner of the disruption.</param>
        public void Start(IMyCubeGrid grid, TimeSpan duration, ref float strength, long effectOwner)
        {
            if (strength < MinCost)
            {
                Logger.DebugLog("strength: " + strength + ", below minimum: " + MinCost);
                return;
            }

            CubeGridCache cache   = CubeGridCache.GetFor(grid);
            float         applied = 0;

            if (!EffectOwnerCanAccess)
            {
                effectOwner = long.MinValue;
            }
            m_effectOwner = effectOwner;
            foreach (MyObjectBuilderType type in BlocksAffected)
            {
                foreach (IMyCubeBlock block in cache.BlocksOfType(type).OrderBy(OrderBy))
                {
                    if (!block.IsWorking || m_allAffected.Contains(block))
                    {
                        Logger.DebugLog("cannot disrupt: " + block);
                        continue;
                    }
                    float cost = BlockCost(block);
                    if (cost > strength)
                    {
                        Logger.DebugLog("cannot disrupt block: " + block + ", cost: " + cost + " is greater than strength available: " + strength);
                        continue;
                    }

                    StartEffect(block);
                    Logger.DebugLog("disrupting: " + block + ", cost: " + cost + ", remaining strength: " + strength);
                    strength -= cost;
                    applied  += cost;
                    MyCubeBlock cubeBlock = block as MyCubeBlock;
                    MyIDModule  idMod     = new MyIDModule()
                    {
                        Owner = cubeBlock.IDModule.Owner, ShareMode = cubeBlock.IDModule.ShareMode
                    };
                    m_affected.Add(block, idMod);
                    m_allAffected.Add(block);

                    block.SetDamageEffect(true);
                    cubeBlock.ChangeOwner(effectOwner, MyOwnershipShareModeEnum.Faction);

                    if (strength < MinCost)
                    {
                        goto FinishedBlocks;
                    }
                }
            }
FinishedBlocks:
            if (m_affected.Count != 0)
            {
                Logger.DebugLog("Added new effect, strength: " + applied);
                m_expire = Globals.ElapsedTime.Add(duration);

                UpdateManager.Register(UpdateFrequency, UpdateEffect);                 // don't unregister on grid close, blocks can still be valid
                AllDisruptions.Add(this);
            }
        }
Beispiel #11
0
        /// <summary>
        /// Gets the best block to target from a grid.
        /// </summary>
        /// <param name="grid">The grid to search</param>
        /// <param name="tType">Checked for destroy</param>
        /// <param name="target">The best block fromt the grid</param>
        /// <param name="distanceValue">The value assigned based on distance and position in blocksToTarget.</param>
        /// <remarks>
        /// <para>Decoy blocks will be given a distanceValue of the distance squared to weapon.</para>
        /// <para>Blocks from blocksToTarget will be given a distanceValue of the distance squared * (index + 1)^3.</para>
        /// <para>Other blocks will be given a distanceValue of the distance squared * (1e12).</para>
        /// </remarks>
        public bool GetTargetBlock(IMyCubeGrid grid, TargetType tType, out IMyCubeBlock target, out double distanceValue, bool doRangeTest = true)
        {
            Vector3D      myPosition = ProjectilePosition();
            CubeGridCache cache      = CubeGridCache.GetFor(grid);

            target        = null;
            distanceValue = double.MaxValue;

            if (cache == null)
            {
                return(false);
            }

            if (cache.TerminalBlocks == 0)
            {
                Log.TraceLog("no terminal blocks on grid: " + grid.DisplayName);
                return(false);
            }

            // get decoy block
            {
                foreach (IMyCubeBlock block in cache.BlocksOfType(typeof(MyObjectBuilder_Decoy)))
                {
                    if (!TargetableBlock(block, true))
                    {
                        continue;
                    }

                    double distanceSq = Vector3D.DistanceSquared(myPosition, block.GetPosition());
                    if (doRangeTest && distanceSq > Options.TargetingRangeSquared)
                    {
                        continue;
                    }

                    if (distanceSq < distanceValue && CanConsiderHostile(block))
                    {
                        target        = block;
                        distanceValue = distanceSq;
                    }
                }
                if (target != null)
                {
                    Log.TraceLog("for type = " + tType + " and grid = " + grid.DisplayName + ", found a decoy block: " + target.DisplayNameText + ", distanceValue: " + distanceValue);
                    return(true);
                }
            }

            // get block from blocksToTarget
            if (!Options.blocksToTarget.IsNullOrEmpty())
            {
                int          index        = 0;
                IMyCubeBlock in_target    = target;
                double       in_distValue = distanceValue;

                foreach (MyDefinitionId[] ids in Options.listOfBlocks.IdGroups())
                {
                    index++;
                    foreach (MyDefinitionId id in ids)
                    {
                        //Log.TraceLog("searching for blocks of type: " + id + ", count: " + cache.BlocksOfType(id).Count());
                        foreach (IMyCubeBlock block in cache.BlocksOfType(id))
                        {
                            if (!TargetableBlock(block, true))
                            {
                                continue;
                            }

                            double distSq = Vector3D.DistanceSquared(myPosition, block.GetPosition());
                            if (doRangeTest && distSq > Options.TargetingRangeSquared)
                            {
                                Log.TraceLog("out of range: " + block.nameWithId());
                                continue;
                            }

                            distSq *= index * index * index;

                            if (distSq < in_distValue && CanConsiderHostile(block))
                            {
                                in_target    = block;
                                in_distValue = distSq;
                            }
                        }
                    }
                }

                target        = in_target;
                distanceValue = in_distValue;

                if (target != null)                 // found a block from blocksToTarget
                {
                    Log.TraceLog("for type = " + tType + " and grid = " + grid.DisplayName + ", target = " + target.DisplayNameText +
                                 ", distance = " + Vector3D.Distance(myPosition, target.GetPosition()) + ", distanceValue = " + distanceValue);
                    return(true);
                }
            }

            // get any IMyTerminalBlock
            bool destroy = (tType & TargetType.Moving) != 0 || (tType & TargetType.Destroy) != 0;

            if (destroy || Options.blocksToTarget.IsNullOrEmpty())
            {
                double closest = double.MaxValue;
                foreach (MyCubeBlock block in cache.AllCubeBlocks())
                {
                    if (block is IMyTerminalBlock && TargetableBlock(block, !destroy))
                    {
                        double distanceSq = Vector3D.DistanceSquared(myPosition, block.PositionComp.GetPosition());
                        if (doRangeTest && distanceSq > Options.TargetingRangeSquared)
                        {
                            continue;
                        }
                        distanceSq *= 1e12;

                        if (distanceSq < closest && CanConsiderHostile(block))
                        {
                            target        = block;
                            distanceValue = distanceSq;
                        }
                    }
                }

                if (target != null)
                {
                    Log.TraceLog("for type = " + tType + " and grid = " + grid.DisplayName + ", found a block: " + target.DisplayNameText + ", distanceValue = " + distanceValue);
                    return(true);
                }
            }

            return(false);
        }
Beispiel #12
0
        /// <summary>
        /// Tests if a section of space can be travelled without hitting the specified entity.
        /// </summary>
        /// <param name="entity">The potential obstruction</param>
        /// <param name="ignoreBlock">Null or the block autopilot is trying to connect with.</param>
        /// <param name="input"><see cref="TestInput"/></param>
        /// <param name="result"><see cref="GridTestResult"/></param>
        /// <returns>True if the specified entity obstructs the path.</returns>
        public bool ObstructedBy(MyEntity entity, MyCubeBlock ignoreBlock, ref TestInput input, out GridTestResult result)
        {
            //Logger.DebugLog("checking: " + entity.getBestName() + ", offset: " + offset + ", rejection vector: " + rejectionVector + ", rejection distance: " + rejectionDistance);
#if DEBUG
            if (!input.Direction.IsValid() || Math.Abs(1f - input.Direction.LengthSquared()) > 0.01f)
            {
                throw new Exception("rejection vector is invalid. entity: " + entity.nameWithId() + ", input: " + input);
            }
#endif

            result          = GridTestResult.Default;
            result.Distance = input.Length;
            MyCubeGrid grid = entity as MyCubeGrid;
            if (grid != null)
            {
                // check for dangerous tools on grid
                CubeGridCache cache = CubeGridCache.GetFor(grid);
                if (cache == null)
                {
                    return(false);
                }
                Profiler.StartProfileBlock("Checking Tools");
                foreach (MyShipDrill drill in cache.BlocksOfType(typeof(MyObjectBuilder_Drill)))
                {
                    if (drill.IsShooting)
                    {
                        if (SphereTest(drill, ref input, ref result))
                        {
                            Profiler.EndProfileBlock();
                            return(true);
                        }
                    }
                }
                foreach (MyShipGrinder grinder in cache.BlocksOfType(typeof(MyObjectBuilder_ShipGrinder)))
                {
                    if (grinder.IsShooting)
                    {
                        if (SphereTest(grinder, ref input, ref result))
                        {
                            Profiler.EndProfileBlock();
                            return(true);
                        }
                    }
                }
                Profiler.EndProfileBlock();

                if (ExtensionsRelations.canConsiderFriendly(Controller.CubeBlock, grid) && EndangerGrid(grid, ref input, ref result))
                {
                    Logger.DebugLog("Movement would endanger: " + grid.getBestName());
                    return(true);
                }

                Profiler.StartProfileBlock("RejectionIntersects");
                if (RejectionIntersects(grid, ignoreBlock, ref input, ref result))
                {
                    Profiler.EndProfileBlock();
                    return(true);
                }
                Profiler.EndProfileBlock();
            }
            else
            {
                return(SphereTest(entity, ref input, ref result));
            }

            return(false);
        }
Beispiel #13
0
        public string HostileName()
        {
            switch (Type)
            {
            case EntityType.Character:
                if (string.IsNullOrEmpty(Entity.DisplayName))
                {
                    return("Creature");
                }
                return(Entity.DisplayName);

            case EntityType.Grid:
                break;

            default:
                return(Type.ToString());
            }

            if (!isRecent_Broadcast())
            {
                return(((IMyCubeGrid)Entity).SimpleName());
            }

            CubeGridCache cache = CubeGridCache.GetFor((IMyCubeGrid)Entity);

            if (cache == null)
            {
                return("Error");
            }

            float  longestRange = float.MinValue;
            string name         = null;

            foreach (IMyCubeBlock b in cache.BlocksOfType(typeof(MyObjectBuilder_Beacon)))
            {
                if (b.IsWorking)
                {
                    float radius = ((Sandbox.ModAPI.Ingame.IMyBeacon)b).Radius;
                    if (radius > longestRange)
                    {
                        longestRange = radius;
                        name         = b.DisplayNameText;
                    }
                }
            }

            foreach (IMyCubeBlock ra in cache.BlocksOfType(typeof(MyObjectBuilder_RadioAntenna)))
            {
                if (ra.IsWorking)
                {
                    Sandbox.ModAPI.Ingame.IMyRadioAntenna asRA = (Sandbox.ModAPI.Ingame.IMyRadioAntenna)ra;
                    if (asRA.IsBroadcasting && asRA.Radius > longestRange)
                    {
                        longestRange = asRA.Radius;
                        name         = ra.DisplayNameText;
                    }
                }
            }

            return(name ?? ((IMyCubeGrid)Entity).SimpleName());
        }
Beispiel #14
0
        private void Arm()
        {
            if (!ServerSettings.GetSetting <bool>(ServerSettings.SettingName.bAllowWeaponControl))
            {
                Log.DebugLog("Cannot arm, weapon control is disabled.", Logger.severity.WARNING);
                return;
            }

            Log.DebugLog("Arming", Logger.severity.DEBUG);

            Log.DebugLog("Fixed weapons has not been cleared", Logger.severity.FATAL, condition: m_weapons_fixed.Count != 0);
            Log.DebugLog("All weapons has not been cleared", Logger.severity.FATAL, condition: m_weapons_all.Count != 0);

            m_weaponRange_min = float.MaxValue;

            CubeGridCache cache = CubeGridCache.GetFor(m_controlBlock.CubeGrid);

            foreach (FixedWeapon weapon in Registrar.Scripts <FixedWeapon, WeaponTargeting>())
            {
                if (weapon.CubeBlock.CubeGrid == m_controlBlock.CubeGrid)
                {
                    if (weapon.EngagerTakeControl())
                    {
                        Log.DebugLog("Took control of " + weapon.CubeBlock.DisplayNameText);
                        m_weapons_fixed.Add(weapon);
                        m_weapons_all.Add(weapon);

                        weapon.CubeBlock.OnClosing += Weapon_OnClosing;
                    }
                    else
                    {
                        Log.DebugLog("failed to get control of: " + weapon.CubeBlock.DisplayNameText);
                    }
                }
                if (weapon.MotorTurretBaseGrid() == m_controlBlock.CubeGrid)
                {
                    Log.DebugLog("Active motor turret: " + weapon.CubeBlock.DisplayNameText);
                    m_weapons_all.Add(weapon);

                    weapon.CubeBlock.OnClosing += Weapon_OnClosing;
                }
            }

            foreach (MyObjectBuilderType weaponType in TurretWeaponTypes)
            {
                foreach (IMyCubeBlock block in cache.BlocksOfType(weaponType))
                {
                    WeaponTargeting weapon;
                    if (!Registrar.TryGetValue(block.EntityId, out weapon))
                    {
                        Logger.AlwaysLog("Failed to get block: " + block.nameWithId(), Logger.severity.WARNING);
                        continue;
                    }
                    if (weapon.CurrentControl != WeaponTargeting.Control.Off)
                    {
                        Log.DebugLog("Active turret: " + weapon.CubeBlock.DisplayNameText);
                        m_weapons_all.Add(weapon);

                        weapon.CubeBlock.OnClosing += Weapon_OnClosing;
                    }
                }
            }

            m_weapons_fixed.ApplyAdditions();
            m_weapons_all.ApplyAdditions();

            m_weaponArmed     = m_weapons_all.Count != 0;
            m_weaponDataDirty = m_weaponArmed;
            if (m_weaponArmed)
            {
                Log.DebugLog("Now armed", Logger.severity.DEBUG);
            }
            else
            {
                Log.DebugLog("Failed to arm", Logger.severity.DEBUG);
            }
        }