예제 #1
0
 /// <summary>Returns whether the grid belongs to the meta grid</summary>
 /// <param name="grid">grid to test</param>
 /// <returns>Whether <paramref name="grid"/> belongs to the MetaGrid</returns>
 public bool IsSameMetaGrid(IMyCubeGrid grid) => this.grids.Contains(grid.EntityId) || grid.IsSameConstructAs(this.grid);
        private static void ShieldBlockGridOwnershipChanged(IMyCubeGrid cubeGrid)
        {
            IMyUpgradeModule shield = null;

            if (!_activeNpcShields.TryGetValue(cubeGrid, out shield))
            {
                return;
            }

            if (shield?.SlimBlock?.CubeGrid != null || !MyAPIGateway.Entities.Exist(shield?.SlimBlock?.CubeGrid) || !cubeGrid.IsSameConstructAs(shield.SlimBlock.CubeGrid))
            {
                _activeNpcShields.Remove(cubeGrid);
                return;
            }

            bool npcOwned = true;

            if (cubeGrid.BigOwners.Count == 0)
            {
                npcOwned = false;
            }
            else
            {
                foreach (var owner in cubeGrid.BigOwners)
                {
                    if (!IsNPC(owner))
                    {
                        npcOwned = false;
                    }
                }
            }

            if (npcOwned)
            {
                return;
            }

            //TODO: Set LoS Requirement to True
        }