Beispiel #1
0
    /// <summary>
    /// Update the mount point with the new anchor information
    /// </summary>
    /// <param name="rMountPoint">Mount point to update</param>
    private void UpdateMountPointBone(ref MountPoint rMountPoint)
    {
        rMountPoint.AnchorTo(rMountPoint.BoneName);

        // Flag the list as needing updating
        mIsDirty = true;
    }
Beispiel #2
0
        public bool isValid()
        {
            bool rv = true;

            if (rv)
            {
                rv = this.MountPoint != null && this.MountPoint.Length == 3;
            }
            if (rv)
            {
                char[] mp = MountPoint.ToUpper().ToCharArray();
                rv = mp[0] >= 'C' && mp[0] <= 'Z';
                if (rv)
                {
                    rv = mp[1] == Path.VolumeSeparatorChar;
                }
                if (rv)
                {
                    rv = mp[2] == Path.DirectorySeparatorChar;
                }
            }
            if (rv)
            {
                rv = Files.Count > 0;
            }
            if (rv)
            {
                rv = FileHelper.isAnyData(Files);
            }
            return(rv);
        }
Beispiel #3
0
        public override IReadOnlyDictionary <string, GameFile> Mount(bool caseInsensitive = false)
        {
            var watch = new Stopwatch();

            watch.Start();
            if (Info.Version >= EPakFileVersion.PakFile_Version_PathHashIndex)
            {
                ReadIndexUpdated(caseInsensitive);
            }
            else
            {
                ReadIndexLegacy(caseInsensitive);
            }
            var elapsed = watch.Elapsed;
            var sb      = new StringBuilder($"Pak \"{Name}\": {FileCount} files");

            if (EncryptedFileCount != 0)
            {
                sb.Append($" ({EncryptedFileCount} encrypted)");
            }
            if (MountPoint.Contains("/"))
            {
                sb.Append($", mount point: \"{MountPoint}\"");
            }
            sb.Append($", version {(int) Info.Version} in {elapsed}");
            log.Information(sb.ToString());
            return(Files);
        }
    public void Unsheathe()
    {
        if (!sheathed)
        {
            return;
        }

        foreach (GameObject go in equippedWeapons)
        {
            Mount      mount = go.GetComponent <Mount>();
            MountPoint mp    = mount.Point;
            mountPoints.DisconnectMountPoints(mp);

            switch (go.GetComponent <Weapon>().item.weaponType)
            {
            case WeaponType.Sword:
                mountPoints.ConnectMountPoints("Main Hand", go, "MountPoint");
                break;

            case WeaponType.Shield:
                mountPoints.ConnectMountPoints("Off Hand", go, "MountPoint");
                break;

            case WeaponType.Crossbow:
                break;

            case WeaponType.NULL:
                break;

            default:
                break;
            }
        }
        sheathed = false;
    }
 private void SetMountPoints(ref MountPoint[] mountPoints, MyObjectBuilder_CubeBlockDefinition.MountPoint[] mpBuilders, List <MyObjectBuilder_CubeBlockDefinition.MountPoint> addedMounts)
 {
     if (mountPoints == null)
     {
         mountPoints = new MountPoint[mpBuilders.Length];
     }
     for (int i = 0; i < mountPoints.Length; ++i)
     {
         var mpBuilder = mpBuilders[i];
         if (addedMounts != null)
         {
             addedMounts.Add(mpBuilder);
         }
         // shrink mount points a little to avoid overlaps when they are very close.
         var mpStart  = new Vector3((Vector2)mpBuilder.Start + OFFSET_CONST, THICKNESS_HALF);
         var mpEnd    = new Vector3((Vector2)mpBuilder.End - OFFSET_CONST, -THICKNESS_HALF);
         var sideIdx  = (int)mpBuilder.Side;
         var mpNormal = Vector3I.Forward;
         TransformMountPointPosition(ref mpStart, sideIdx, Size, out mpStart);
         TransformMountPointPosition(ref mpEnd, sideIdx, Size, out mpEnd);
         Vector3I.TransformNormal(ref mpNormal, ref m_mountPointTransforms[sideIdx], out mpNormal);
         mountPoints[i].Start          = mpStart;
         mountPoints[i].End            = mpEnd;
         mountPoints[i].Normal         = mpNormal;
         mountPoints[i].ExclusionMask  = mpBuilder.ExclusionMask;
         mountPoints[i].PropertiesMask = mpBuilder.PropertiesMask;
         mountPoints[i].Enabled        = mpBuilder.Enabled;
     }
 }
Beispiel #6
0
    /*
     *  Use this function as the "constructor" since it occurs at the same time
     *  as instantiation.
     */
    protected override void Awake()
    {
        base.Awake();

        // setup physics sutff
        collider  = GetComponent <Collider>();
        rigidbody = GetComponent <Rigidbody>();

        // all kinematic.
        rigidbody.isKinematic = true;

        // health
        // TODO, DETERMINE WHEN TO SET THESE?
        maxHealth  = 100;
        currHealth = maxHealth;

        // Control determined later
        IsControlledByJoint = true;

        // get mount point if it exists
        mountPoint = GetComponentInChildren <MountPoint>();


        creatureInventory = GameObject.FindGameObjectWithTag("Inventory").GetComponent <Inventory>();
    }
Beispiel #7
0
        public void MountPointSelect()
        {
            if (mountPointIndex < 0 || mountPointIndex > map.mountPoints.Count)
            {
                return;
            }

            // If no country is selected (the mount point could be at sea) select it
            MountPoint mp             = map.mountPoints[mountPointIndex];
            int        mpCountryIndex = mp.countryIndex;

            if (mpCountryIndex < 0)
            {
                SetInfoMsg("Country not found in this country file.");
            }

            if (countryIndex != mpCountryIndex && mpCountryIndex >= 0)
            {
                ClearSelection();
                countryIndex       = mpCountryIndex;
                countryRegionIndex = map.countries[countryIndex].mainRegionIndex;
                CountryRegionSelect();
            }

            // Just in case makes GUICountryIndex selects appropiate value in the combobox
            GUIMountPointName = mp.name;
            SyncGUIMountPointSelection();
            if (mountPointIndex >= 0)
            {
                GUIMountPointNewName = mp.name;
                GUIMountPointNewType = mp.type.ToString();
                MountPointHighlightSelection();
            }
        }
Beispiel #8
0
        private void OnMouseUp()
        {
            // Grab the closest point that doesn't belong to this object
            MountPoint lClosestMountPoint = MountPoints.GetClosestMountPoint(mMountPoints);

            if (lClosestMountPoint != null)
            {
                // Grab the closest point from this object to the just-found point
                Vector3    lTestPosition   = lClosestMountPoint._Anchor.transform.position;
                MountPoint lThisMountPoint = mMountPoints.GetClosestMountPoint(lTestPosition);
                if (lThisMountPoint != null)
                {
                    // Disconnect any existing parent
                    for (int i = 0; i < mMountPoints.Points.Count; i++)
                    {
                        mMountPoints.Points[i].ChildTo(null);
                    }

                    // Check if we're in snap distance
                    float lDistance = Vector3.Distance(lTestPosition, lThisMountPoint._Anchor.transform.position);
                    if (lDistance < mSnapDistance)
                    {
                        // Connect this new one
                        lThisMountPoint.ChildTo(lClosestMountPoint);
                    }
                }
            }
        }
Beispiel #9
0
 public IEnumerable <EquipmentInstallationResult> GetEquipmentInMountPoint(MountPoint mp)
 {
     foreach (var v in installedKit[mp])
     {
         yield return(v);
     }
 }
Beispiel #10
0
    /// <summary>
    /// Run through the mount points to ensure everything is connected to
    /// a valid object. This way we can clean up before we process.
    /// </summary>
    private void PreProcessPoints()
    {
        // Clean up mount points to ensure everything stays in synch
        MountPoint lPoint = mTarget.Point;

        // Ensure the mount point is still valid
        if (lPoint.Owner == null)
        {
            lPoint.ChildTo(null);
            lPoint.Owner = mTarget.gameObject;
        }
        // Ensure any parent we may have is valid
        else if (lPoint.ParentMountPoint != null && lPoint.ParentMountPoint.Owner == null)
        {
            lPoint.ChildTo(null);
        }
        // Process the mount point properties
        else
        {
            // We force it here so that if the owner changes scale, we can reset it
            lPoint.IgnoreParentScale = lPoint.IgnoreParentScale;

            // Ensure all the child mount points are valid. It's possible that the
            // owner of a child mount point has been deleted. We need to check for that first
            for (int j = lPoint.ChildMountPoints.Count - 1; j >= 0; j--)
            {
                MountPoint lChildPoint = lPoint.ChildMountPoints[j].MountPoint;
                if (lChildPoint == null || lChildPoint.Owner == null)
                {
                    lPoint.ChildMountPoints.RemoveAt(j);
                    mIsDirty = true;
                }
            }
        }
    }
Beispiel #11
0
    public MountPoint GetNextMount(MountPoint oldMount, bool isUsed, bool careAboutSolution)
    {
        int startPoint = 0;

        if ((oldMount != null) && (m_Mounts.Contains(oldMount)))
        {
            startPoint = m_Mounts.IndexOf(oldMount);
        }
        else
        {
            if ((m_Mounts[0].Used == isUsed) &&
                ((careAboutSolution == false) || (m_Mounts[0].TypeID >= 0)))
            {
                return(m_Mounts[0]);
            }
        }

        // Find Next Point which matches
        int iPoint = (startPoint + 1) % m_Mounts.Count;

        while (iPoint != startPoint)
        {
            if ((m_Mounts[iPoint].Used == isUsed) &&
                ((careAboutSolution == false) || (m_Mounts[iPoint].TypeID >= 0)))
            {
                return(m_Mounts[iPoint]);
            }

            iPoint = (iPoint + 1) % m_Mounts.Count;
        }

        return(null);
    }
Beispiel #12
0
    private MountPoint getRandomOpen()
    {
        int        index = UnityEngine.Random.Range(0, opens.Count - 1);
        MountPoint mp    = opens[index];

        opens.Remove(mp);
        return(mp);
    }
Beispiel #13
0
 public void SetValues(MountPoint mp)
 {
     max_mounting = mp.max_mounting;
     index        = mp.index;
     zone         = mp.zone;
     SetIndex(mp.index.ToString());
     SetText(mp.name.ToString());
 }
Beispiel #14
0
 public MountPoint(PieceScript owner, Transform tMount)
 {
     m_TypeIndex = -1;
     m_Solution  = null;
     m_Other     = null;
     m_Mount     = tMount;
     m_Owner     = owner;
 }
Beispiel #15
0
    public void Build_Mount_Point_Drop_Panels()
    {
        //****************************
        //Get the list of mount points
        //****************************
        GameObject g = null;

        if (this.command_module == null)
        {
            //We need to hide all buttons and only show a command
            SetScreenNoCommandModule();
        }
        else
        {
            if (this.tmp_drop_panel)
            {
                Destroy(this.tmp_drop_panel);
            }
            if (drop_panels_loaded)
            {
                return;
            }
            GameObject mount_points = this.command_module.transform.Find("MountPoints").gameObject;
            ShipModule sys          = mount_points.GetComponentInParent <ShipModule>();
            mount_point_drop_zone_list = new GameObject[sys.mount_points.Count];

            foreach (MountPoint m in sys.mount_points)
            {
                if (m.zone == Enums.emun_zone.intern)
                {
                    g = Instantiate(mount_point_drop_zone_grid, mount_point_panels[(int)m.zone].gameObject.transform);
                }
                else
                {
                    g = Instantiate(mount_point_drop_zone, mount_point_panels[(int)m.zone].gameObject.transform);
                }

                mount_point_drop_zone_list[m.index] = g.transform.Find("DropZone").gameObject;
                MountPoint omp = g.GetComponent <MountPoint>();
                omp.SetValues(m);
                omp.SetSize(new Vector2(100 + (m.max_mounting * 50), 50));
                omp.mount_type_util_top  = m.mount_type_util_top;
                omp.mount_type_util_side = m.mount_type_util_side;
                omp.mount_type_thruster  = m.mount_type_thruster;
                omp.mount_type_engine    = m.mount_type_engine;

                omp.associated_mountpoint = m.gameObject;
                ItemDropHandler dh = g.GetComponentInChildren <ItemDropHandler>();
                dh.enforce_max = true;
                dh.max_items   = m.max_mounting;
            }
            DisableEnableButtons(true);
            Populate_Mount_Point_Drop_Panels();
            Build_Inventory_List_Items();
            drop_panels_loaded = true;
        }
    }
Beispiel #16
0
        internal void AddNewMountPoint(Rack rackEntity)
        {
            var mountPoint = new MountPoint
            {
                Path = _directoryMethods.GetCurrentDirectoryName()
            };

            rackEntity.MountPoints.Add(mountPoint);
        }
Beispiel #17
0
        public bool IsValidEquipmentLocation(int equipmentIdentifier, MountPoint mp)
        {
            if (InjectedEquipment == null)
            {
                throw new InvalidOperationException("Must provide injected equipment");
            }

            return(true);
        }
Beispiel #18
0
    void Start()
    {
        TextAsset textFile = (TextAsset)Resources.Load("MountingPoints");

        fileStrings        = textFile.text.Split('[');
        mounting           = new MountPoint();
        mounting.points    = new Vector3[0];
        mounting.pointType = new BuildPoints.MountType[0];
        AddPoints(type, transform);
    }
Beispiel #19
0
 public bool IsInstallationPermitted(MountPoint mountPoint)
 {
     foreach (var v in permittedPositions)
     {
         if (v == mountPoint)
         {
             return(true);
         }
     }
     return(false);
 }
Beispiel #20
0
    /// <summary>
    /// Allows us to add to a list
    /// </summary>
    /// <param name="rList"></param>
    private void OnPointListItemAdd(ReorderableList rList)
    {
        // Create the mount point and initialize it
        mSelectedPoint = mTarget.CreateMountPoint("New Mount Point", "", true);

        // Make it the selected one
        mPointList.index = mTarget.Points.Count - 1;
        OnPointListItemSelect(rList);

        mIsDirty = true;
    }
Beispiel #21
0
    /// <summary>
    /// Use this function to find the closest snap points and put them together
    /// </summary>
    /// <returns>Boolean that determines if a snap point was found</returns>
    private bool FindSnapPoints()
    {
        float      lMinDistance     = float.MaxValue;
        MountPoint lChildSnapPoint  = null;
        MountPoint lParentSnapPoint = null;

        // Cycle through our mount points and compare them to other
        // object mount points. If we find one close enough, we'll snap
        for (int i = 0; i < mTarget.Points.Count; i++)
        {
            for (int j = 0; j < mScenePointPositions.Count; j++)
            {
                float lDistance = Vector3.Distance(mTarget.Points[i].Anchor.transform.position, mScenePointPositions[j]);
                if (lDistance < MountPoints.EditorSnapDistance && lDistance < lMinDistance)
                {
                    lMinDistance     = lDistance;
                    lChildSnapPoint  = mTarget.Points[i];
                    lParentSnapPoint = mScenePoints[j];
                }
            }
        }

        // Test if we need to invert the parenting
        if (lChildSnapPoint != null && lParentSnapPoint != null)
        {
            // Flip the snap points if we have a selected point
            if (mSelectedPoint != null && mSelectedPoint == lParentSnapPoint)
            {
                lParentSnapPoint = lChildSnapPoint;
                lChildSnapPoint  = mSelectedPoint;
            }

            // Ensure they aren't already parented the other way
            if (lParentSnapPoint.ParentMountPoint == lChildSnapPoint)
            {
                MountPoint lTemp = lParentSnapPoint;
                lParentSnapPoint = lChildSnapPoint;
                lChildSnapPoint  = lTemp;
            }

            // If the parent doesn't allow children, don't snap
            if (!lParentSnapPoint.AllowChildren)
            {
                lParentSnapPoint = null;
                lChildSnapPoint  = null;
            }
        }

        // Set the resulting snap points (if found)
        mChildSnapPoint  = lChildSnapPoint;
        mParentSnapPoint = lParentSnapPoint;

        return(mChildSnapPoint != null);
    }
Beispiel #22
0
        private void UnMountOne(ChrootBox box, MountPoint mountPoint, Progress progress)
        {
            var flag = (mountPoint.Recursive ? "--recursive" : string.Empty);

            var umount = new Bash()
                         .Command($"umount --verbose {flag} {mountPoint.Path}")
                         .WithProgress(progress)
                         .Run();

            Bash.ThrowOnError(umount);
        }
        public void CanHit_VictimBehind(double atkHeading, MountPoint weapPoint, bool shouldHit)
        {
            b.Info.Flow();
            var atkPos = new Point(3, 3);
            var vikPos = new Point(3, 2);

            Bd2CombatCalculator sut = new DefaultCalcsRules();
            var canHit = sut.CanMountPointHitTarget(atkHeading, weapPoint, atkPos, vikPos);

            Assert.Equal(shouldHit, canHit);
        }
Beispiel #24
0
        public EquipmentInstallationResult AddEquipment(int equipmentIdentifier, MountPoint mp)
        {
            EquipmentInstallationResult result = new EquipmentInstallationResult();
            ActiveEquipment             ae     = provide.CreateActiveEquipmentInstance(equipmentIdentifier);

            if (ae == null)
            {
                throw new BdBaseException("The engine provider refused to create the equipment, unexpected.");
            }
            result.EquipmentId = equipmentIdentifier;
            result.InstanceId  = ae.InstanceId;
            result.Result      = InstallationResult.Installed;

            if (!installedKit.ContainsKey(mp))
            {
                // installedKit.Add(mp, new List<EquipmentInstallationResult>());
                b.Warning.Log("Warning, failing to install kit because the frame has no mountpoint at the position requested", string.Format("kitid {0} mpId {1} ", equipmentIdentifier, mp));
                result.Result = InstallationResult.Fail_InvalidMountpoint;
                return(result);
            }
            bool canInstall = provide.IsValidEquipmentLocation(equipmentIdentifier, mp);

            if (!canInstall)
            {
                result.Result = InstallationResult.Fail_InvalidMountpoint;
                return(result);
            }
            //Must check for space
            if (!WillEquipmentFitInMountPoint(ae, mp))
            {
                result.Result = InstallationResult.Fail_NoSpace;
                return(result);
            }


            installedKit[mp].Add(result);
            kitByIdentity.Add(result.InstanceId, ae);

            if (ae.Classification == ItemClassification.PowerPack)
            {
                if (hasPowerpackBeenInstalled)
                {
                    result.Result = InstallationResult.Fail_InvalidCombination;
                }
                else
                {
                    hasPowerpackBeenInstalled = true;
                }
            }


            return(result);
        }
        private static string GenerateMountPath(MountPoint mount)
        {
            var source = mount.Source;

            source = source.Replace(Directory.GetCurrentDirectory(), string.Empty);
            if (source.Contains("docker/volumes") || string.IsNullOrWhiteSpace(source))
            {
                source = "/internal";
            }

            return($"{source}:{mount.Destination}");
        }
 private void SetupMount(MountPoint mount)
 {
     mount.part.transform.SetParent(mount.point);
     mount.part.transform.localRotation = Quaternion.identity;
     mount.part.transform.localPosition = Vector3.zero;
     mount.part.transform.localScale    = Vector3.one;
     mount.part.AddToRobot(this);
     if (mount.part is Weapon)
     {
         weapons.Add(mount.part as Weapon);
     }
 }
Beispiel #27
0
    public bool freeMount()
    {
        if (m_Other != null)
        {
            // TODO :: Notify Pieces of Disconnection

            m_Other.m_Other = null;
            m_Other         = null;
            return(true);
        }

        return(false);
    }
Beispiel #28
0
        private void containerMounts_MouseDoubleClick(object sender, MouseEventArgs e)
        {
            if (containerMounts.SelectedItems.Count == 0)
            {
                return;
            }

            MountPoint mountPoint = containerMounts.Items[containerMounts.SelectedIndices[0]].Tag as MountPoint;

            string path = mountPoint.Source;

            Process.Start(path);
        }
Beispiel #29
0
        // TODO : Unit test that forces this to fail
        private bool WillEquipmentFitInMountPoint(ActiveEquipment ae, MountPoint mp)
        {
            b.Warning.Log("This is hardcoded");
            int spaceTaken = 0;

            foreach (var ep in GetEquipmentInMountPoint(mp))
            {
                spaceTaken += kitByIdentity[ep.InstanceId].UnderlyingItem.SpaceRequired;
            }
            int space = activeFrame.GetTotalSpaceForMountPoint(mp);

            return(space >= ae.UnderlyingItem.SpaceRequired);
        }
Beispiel #30
0
        public bool CanMountPointHitTarget(double sourceHeading, MountPoint mountPoint, Point sourceLoc, Point destLoc)
        {
            if (mountPoint == MountPoint.Turret)
            {
                return(true);
            }
            if (mountPoint == MountPoint.Internal)
            {
                return(false);
            }

            return(ActualCanMountPointHitTarget(sourceHeading, mountPoint, sourceLoc, destLoc));
        }
Beispiel #31
0
        private unsafe List<string> QueryMountPoints()
        {
            lock (_syncObject)
            {
                List<MountPoint> MountPoints = new List<MountPoint>();
                //First volumes with letteral defenition
                List<string> drives = new List<string>(Environment.GetLogicalDrives());
                foreach (string drive in drives)
                {
                    string dName = "\\\\.\\" + drive;
                    if (Interop.GetDriveType(dName) != Interop.DRIVE_FIXED)
                        continue;

                    dName = dName.Substring(0, 6);

                    IntPtr hVolume = Interop.CreateFile(
                        dName,
                        Interop.GENERIC_READ,
                        Interop.FILE_SHARE_READ | Interop.FILE_SHARE_WRITE,
                        IntPtr.Zero,
                        Interop.OPEN_EXISTING,
                        0,
                        IntPtr.Zero);

                    if (hVolume == (IntPtr)Interop.INVALID_HANDLE_VALUE)
                        continue;

                    IntPtr DiskExtentsBuffer = Marshal.AllocHGlobal(0x400);
                    int bytesReturned;
                    //Sends control code to volume (to get extents)
                    if (!Interop.DeviceIoControl(
                        hVolume,
                        Interop.IOCTL_VOLUME_GET_VOLUME_DISK_EXTENTS,
                        IntPtr.Zero,
                        0,
                        DiskExtentsBuffer,
                        0x400,
                        out bytesReturned,
                        IntPtr.Zero))
                    {
                        Marshal.FreeHGlobal(DiskExtentsBuffer);
                        Interop.CloseHandle(hVolume);
                        continue;
                    }

                    Interop.VOLUME_DISK_EXTENTS* DiskExtents = (Interop.VOLUME_DISK_EXTENTS*)DiskExtentsBuffer;
                    if (DiskExtents->NumberOfDiskExtents == 0)
                    {
                        Marshal.FreeHGlobal(DiskExtentsBuffer);
                        Interop.CloseHandle(hVolume);
                        continue;
                    }

                    MountPoint item = new MountPoint();

                    item.Drive = DiskExtents->Extents.DiskNumber;
                    item.Path = drive;
                    item.Offset = DiskExtents->Extents.StartingOffset;

                    MountPoints.Add(item);

                    Marshal.FreeHGlobal(DiskExtentsBuffer);
                    Interop.CloseHandle(hVolume);
                }

                //Volumes' mount points
                int Unmounted = 0;
                int Lastunm = 0; //Mount points with unrecognazed mount place
                //Cicle for enclosed points
                do
                {
                    Lastunm = Unmounted;
                    Unmounted = 0;

                    StringBuilder strBuilder = new StringBuilder(1024);

                    IntPtr hFind = Interop.FindFirstVolume(strBuilder, strBuilder.Capacity - 1);
                    if (hFind == (IntPtr)Interop.INVALID_HANDLE_VALUE)
                        continue;

                    //Cycle through volumes
                    do
                    {
                        string volumeName = strBuilder.ToString();

                        if (Interop.GetDriveType(volumeName) != Interop.DRIVE_FIXED)
                            continue;

                        if (volumeName[volumeName.Length - 1] == '\\')
                            volumeName = volumeName.Substring(0, volumeName.Length - 1);

                        IntPtr hVolume = Interop.CreateFile(
                            volumeName,
                            Interop.GENERIC_READ,
                            Interop.FILE_SHARE_READ | Interop.FILE_SHARE_WRITE,
                            IntPtr.Zero,
                            Interop.OPEN_EXISTING,
                            0,
                            IntPtr.Zero);

                        if (hVolume == (IntPtr)Interop.INVALID_HANDLE_VALUE)
                            continue;

                        IntPtr DiskExtentsBuffer = Marshal.AllocHGlobal(0x400);
                        int bytesReturned;
                        //Sends control code to volume (to get extents)
                        if (!Interop.DeviceIoControl(
                            hVolume,
                            Interop.IOCTL_VOLUME_GET_VOLUME_DISK_EXTENTS,
                            IntPtr.Zero,
                            0,
                            DiskExtentsBuffer,
                            0x400,
                            out bytesReturned,
                            IntPtr.Zero))
                        {
                            Marshal.FreeHGlobal(DiskExtentsBuffer);
                            Interop.CloseHandle(hVolume);
                            continue;
                        }

                        Interop.VOLUME_DISK_EXTENTS* DiskExtents = (Interop.VOLUME_DISK_EXTENTS*)DiskExtentsBuffer;
                        if (DiskExtents->NumberOfDiskExtents == 0)
                        {
                            Marshal.FreeHGlobal(DiskExtentsBuffer);
                            Interop.CloseHandle(hVolume);
                            continue;
                        }
                        //Search list for this volume (is it recognized before)
                        int parent;
                        for (parent = 0; parent < MountPoints.Count; parent++)
                            if (MountPoints[parent].Drive == DiskExtents->Extents.DiskNumber &&
                                MountPoints[parent].Offset == DiskExtents->Extents.StartingOffset)
                                break;

                        //Fix slash back
                        if (volumeName[volumeName.Length - 1] != '\\')
                            volumeName = volumeName + '\\';

                        //Finds mount points

                        IntPtr hMP = Interop.FindFirstVolumeMountPoint(volumeName, strBuilder, strBuilder.Capacity - 1);
                        if (hMP == (IntPtr)Interop.INVALID_HANDLE_VALUE)
                        {
                            Marshal.FreeHGlobal(DiskExtentsBuffer);
                            Interop.CloseHandle(hVolume);
                            continue;
                        }
                        //Cycle through mount points
                        do
                        {
                            string mpName = strBuilder.ToString(); ;
                            //If paretn volume not found...
                            if (parent == MountPoints.Count)
                            {
                                // ...skip this mount points
                                Unmounted++;
                                continue;
                            }
                            //Full mount point path (i.e. 'C:\mount\d\')
                            string FullMpName = MountPoints[parent].Path + mpName;

                            //Gets mount point's volume name (internal, system)
                            if (!Interop.GetVolumeNameForVolumeMountPoint(FullMpName, strBuilder, strBuilder.Capacity - 1))
                                continue;

                            string mpVolume = strBuilder.ToString();

                            //Remove '\' if it present
                            if (mpVolume[mpVolume.Length - 1] == '\\')
                                mpVolume = mpVolume.Substring(0, mpVolume.Length - 1);

                            //Opens volume's handle
                            IntPtr hMpVolume = Interop.CreateFile(
                                mpVolume,
                                Interop.GENERIC_READ,
                                Interop.FILE_SHARE_READ | Interop.FILE_SHARE_WRITE,
                                IntPtr.Zero,
                                Interop.OPEN_EXISTING,
                                0,
                                IntPtr.Zero);

                            if (hMpVolume == (IntPtr)Interop.INVALID_HANDLE_VALUE)
                                continue;

                            IntPtr VolExtentsBuffer = Marshal.AllocHGlobal(0x400);
                            //Sends control code to volume (to get extents)
                            if (!Interop.DeviceIoControl(
                                hMpVolume,
                                Interop.IOCTL_VOLUME_GET_VOLUME_DISK_EXTENTS,
                                IntPtr.Zero,
                                0,
                                VolExtentsBuffer,
                                0x400,
                                out bytesReturned,
                                IntPtr.Zero))
                            {
                                Marshal.FreeHGlobal(VolExtentsBuffer);
                                Interop.CloseHandle(hMpVolume);
                                continue;
                            }

                            Interop.VOLUME_DISK_EXTENTS* VolExtents = (Interop.VOLUME_DISK_EXTENTS*)VolExtentsBuffer;
                            if (VolExtents->NumberOfDiskExtents == 0)
                            {
                                Marshal.FreeHGlobal(VolExtentsBuffer);
                                Interop.CloseHandle(hMpVolume);
                                continue;
                            }

                            MountPoint item = new MountPoint();

                            item.Path = FullMpName;
                            item.Drive = VolExtents->Extents.DiskNumber;
                            item.Offset = VolExtents->Extents.StartingOffset;

                            MountPoints.Add(item);

                            Marshal.FreeHGlobal(VolExtentsBuffer);
                            Interop.CloseHandle(hMpVolume);
                        }
                        while (Interop.FindNextVolumeMountPoint(hMP, strBuilder, strBuilder.Capacity - 1));

                        Interop.FindVolumeMountPointClose(hMP);

                        Marshal.FreeHGlobal(DiskExtentsBuffer);
                        Interop.CloseHandle(hVolume);
                    }
                    while (Interop.FindNextVolume(hFind, strBuilder, strBuilder.Capacity - 1));
                    Interop.FindVolumeClose(hFind);
                }
                while (Unmounted != 0 && (Unmounted != Lastunm));

                List<Interop.PARTITION_INFORMATION> partInfo = _device.Layout;
                long Offset = -1;
                foreach (Interop.PARTITION_INFORMATION information in partInfo)
                    if (information.PartitionNumber == _partInfo.PartitionNumber)
                    {
                        Offset = information.StartingOffset;
                        break;
                    }

                List<string> mounts = new List<string>();
                int DevNumber = _device.GetNumber();

                foreach (MountPoint mp in MountPoints)
                    if (mp.Drive == DevNumber && mp.Offset == Offset)
                        mounts.Add(mp.Path);

                return mounts;
            } // lock
        }
		private void SetMountPoints(ref MountPoint[] mountPoints, MyObjectBuilder_CubeBlockDefinition.MountPoint[] mpBuilders, List<MyObjectBuilder_CubeBlockDefinition.MountPoint> addedMounts)
		{
			if(mountPoints == null)
				mountPoints = new MountPoint[mpBuilders.Length];
			for (int i = 0; i < mountPoints.Length; ++i)
			{
				var mpBuilder = mpBuilders[i];
				if(addedMounts != null)
					addedMounts.Add(mpBuilder);
				// shrink mount points a little to avoid overlaps when they are very close.
				var mpStart = new Vector3((Vector2)mpBuilder.Start + OFFSET_CONST, THICKNESS_HALF);
				var mpEnd = new Vector3((Vector2)mpBuilder.End - OFFSET_CONST, -THICKNESS_HALF);
				var sideIdx = (int)mpBuilder.Side;
				var mpNormal = Vector3I.Forward;
				TransformMountPointPosition(ref mpStart, sideIdx, Size, out mpStart);
				TransformMountPointPosition(ref mpEnd, sideIdx, Size, out mpEnd);
				Vector3I.TransformNormal(ref mpNormal, ref m_mountPointTransforms[sideIdx], out mpNormal);
				mountPoints[i].Start = mpStart;
				mountPoints[i].End = mpEnd;
				mountPoints[i].Normal = mpNormal;
				mountPoints[i].ExclusionMask = mpBuilder.ExclusionMask;
				mountPoints[i].PropertiesMask = mpBuilder.PropertiesMask;
				mountPoints[i].Enabled = mpBuilder.Enabled;
			}
		}
Beispiel #33
0
 public void RemountMountPoint(MountPoint mnt, bool readOnly)
 {
     throw new NotImplementedException();
 }