Exemplo n.º 1
0
        public void TEST_GetVolume()
        {
            TinVolumeSurface tinVolumeSurface;

            if (!ObjectCollector.TrySelectAllowedClassObject(out tinVolumeSurface, "\nВыберить поверхность для вычисления объема"))
            {
                return;
            }

            Polyline border;

            if (!ObjectCollector.TrySelectAllowedClassObject(out border, "\nВыбирите ограничивающею полилинию"))
            {
                return;
            }

            var volumeInfo = CivilSurfaces.SurfaceTools.GetVolumeInfo(tinVolumeSurface, border);

            if (!volumeInfo.HasValue)
            {
                Tools.GetAcadEditor().WriteMessage("\nОшибка определения объема");
                return;
            }

            Tools.GetAcadEditor().WriteMessage(string.Format("\n\nПоверхность: {0}", tinVolumeSurface.Name));

            Tools.GetAcadEditor().WriteMessage(string.Format("\nНасыпь составила: {0}\nВыемка составила: {1}\nЧистый объем: {2}",
                                                             volumeInfo.Value.Fill.ToString("#0.00"), volumeInfo.Value.Cut.ToString("#0.00"), volumeInfo.Value.Net.ToString("#0.00")));
        }
Exemplo n.º 2
0
        public static void TestPerpendicularToPolyline()
        {
            Matrix3d ucs = Tools.GetAcadEditor().CurrentUserCoordinateSystem;
            Curve    pline;

            if (!ObjectCollector.TrySelectAllowedClassObject(out pline))
            {
                return;
            }

            /*PromptPointOptions ppo = new PromptPointOptions("\nУкажите точку: ");
             * PromptPointResult ppr = Tools.GetAcadEditor().GetPoint(ppo);
             * if (ppr.Status != PromptStatus.OK)
             *  return;*/

            Tools.StartTransaction(() =>
            {
                /*Point3d? perpendicularPoint = pline.GetNormalPoint(ppr.Value);
                 * if (perpendicularPoint.HasValue)
                 * {
                 *  Line perpendicular = new Line(ppr.Value, perpendicularPoint.Value);
                 *  perpendicular.SaveToDatebase();
                 * }*/

                Drawing.PerpendicularVectorJigView view = new Drawing.PerpendicularVectorJigView(pline, ucs);
                view.StartJig();
            });
        }
Exemplo n.º 3
0
 public override void Map(string input, ObjectCollector <string, int> objectCollector)
 {
     foreach (var word in input.Split(' ', ',', '.'))
     {
         objectCollector(word, 1);
     }
 }
Exemplo n.º 4
0
        public void SetTextDataToBuffer()
        {
            const string  sep = "\t";
            List <DBText> data;

            if (!ObjectCollector.TrySelectObjects(out data, "\nВыберете текстовые объекты для импорта в буфер обмена: "))
            {
                return;
            }
            if (data.Count == 0)
            {
                return;
            }
            string res = "";

            using (Transaction trans = Tools.StartTransaction())
            {
                foreach (var text in data)
                {
                    res += text.TextString + sep;
                }
            }
            res = res.Remove(res.Length - sep.Length);
            System.Windows.Forms.Clipboard.SetText(res);
        }
Exemplo n.º 5
0
        public static void TestDotProductVectors()
        {
            Line firstLine;
            Line secondLine;

            if (!ObjectCollector.TrySelectAllowedClassObject(out firstLine))
            {
                return;
            }

            if (!ObjectCollector.TrySelectAllowedClassObject(out secondLine))
            {
                return;
            }

            double ang     = (firstLine.EndPoint - firstLine.StartPoint).GetAngle2d(secondLine.EndPoint - secondLine.StartPoint);
            double dot     = (firstLine.EndPoint - firstLine.StartPoint).DotProduct(secondLine.EndPoint - secondLine.StartPoint);
            double cos     = (firstLine.EndPoint - firstLine.StartPoint).GetCos2d(secondLine.EndPoint - secondLine.StartPoint);
            double project = cos * secondLine.Length;

            Tools.GetAcadEditor().WriteMessage("\nAngle = {0}", ang * 180d / Math.PI);
            Tools.GetAcadEditor().WriteMessage("\nDotProduct = {0}", dot);
            Tools.GetAcadEditor().WriteMessage("\nCos = {0}", cos);
            Tools.GetAcadEditor().WriteMessage("\nProject = {0}", project);
        }
Exemplo n.º 6
0
        protected virtual ProbeResultBuilder CollectInformation(CollectInfo collectInfo)
        {
            CollectedObject collectedObject    = null;
            var             probeResultBuilder = new ProbeResultBuilder();

            int idOfItems = 1;

            //  var objectsOfAnEspecificType = this.GetObjectsOfType(collectInfo.ObjectTypes);

            ObjectCollector.PrepareCollectionOfObjects(collectInfo.ObjectTypes, collectInfo.Variables);
            foreach (var ovalObject in collectInfo.ObjectTypes)
            {
                ExecutionLogBuilder.CollectingInformationFrom(ovalObject.id);

                if (this.ObjectTypeHasSet(ovalObject))
                {
                    collectedObject = this.ProcessSet(ovalObject, collectInfo);
                }
                else
                {
                    collectedObject = this.ProcessCollect(ovalObject, collectInfo, probeResultBuilder, ref idOfItems);
                }

                probeResultBuilder.AddCollectedObject(collectedObject);
            }

            return(probeResultBuilder);
        }
    public override void Interact(GameObject interactor)
    {
        if (isLocked)
        {
            if (interactor.tag == "Player")
            {
                FMODUnity.RuntimeManager.PlayOneShot(sfxDoorLocked, transform.position);

                /* (Bernardo) TODO: Adicionar dialogo de "trancado"
                 *
                 * interactor.GetComponentInChildren<PlayerDialogueState>().dialogue = lockedDialogue;
                 * interactor.transform.GetChild(2).GetComponent<ConcurrentStateMachine>().ChangeState(typeof(PlayerDialogueState));*/
            }
        }
        else
        {
            if (!hasBeenOpened)
            {
                FMODUnity.RuntimeManager.PlayOneShot(sfxChestOpening, transform.position);
                hasBeenOpened = true;
                animator.SetTrigger("Open");
                ObjectCollector collector = interactor.GetComponent <ObjectCollector>();

                collector.GetItem(containedItem);
                FMODUnity.RuntimeManager.PlayOneShot(sfxCollectingItem, transform.position);
            }
            else
            {
                PlayerDialogueState dialogueState = interactor.GetComponentInChildren <PlayerDialogueState>();

                dialogueState.dialogue = emptyDialogue;
                dialogueState.GetComponent <ConcurrentStateMachine>().ChangeState(typeof(PlayerDialogueState));
            }
        }
    }
Exemplo n.º 8
0
 /// <summary>
 /// Collects all reference.
 /// </summary>
 static void CollectAllReference()
 {
     allReferenceInfo.Clear();
     foreach (var component in allComponents)
     {
         allReferenceInfo.AddRange(ObjectCollector.FindReferenceInfo(component));
     }
 }
Exemplo n.º 9
0
        public void EditPointElevationRandom()
        {
            var keywords = new { PositiveOnly = "PositiveOnly", NegativeOnly = "NegativeOnly", Both = "Both" };

            List <CogoPoint> points;

            if (!ObjectCollector.TrySelectObjects(out points, "\nSelect points"))
            {
                return;
            }

            PromptDoubleOptions valueOption = new PromptDoubleOptions("\nEnter value");

            valueOption.AllowNone     = false;
            valueOption.DefaultValue  = 0d;
            valueOption.AllowNegative = false;

            PromptDoubleResult valueResult = Tools.GetAcadEditor().GetDouble(valueOption);

            if (valueResult.Status != PromptStatus.OK)
            {
                return;
            }

            PromptKeywordOptions options = new PromptKeywordOptions("\nEnter method");

            options.AppendKeywordsToMessage = true;
            options.AllowArbitraryInput     = true;
            options.Keywords.Add(keywords.PositiveOnly);
            options.Keywords.Add(keywords.NegativeOnly);
            options.Keywords.Add(keywords.Both);
            options.AppendKeywordsToMessage = true;
            options.AllowNone        = true;
            options.Keywords.Default = keywords.Both;

            PromptResult keywordResult = Tools.GetAcadEditor().GetKeywords(options);

            if (keywordResult.Status != PromptStatus.OK)
            {
                return;
            }

            double ratio = keywordResult.StringResult == keywords.Both ? -0.5 : 0d;
            double sign  = keywordResult.StringResult == keywords.NegativeOnly ? -1d : 1d;

            if (keywordResult.StringResult == keywords.Both)
            {
                sign = 2d;
            }

            Random random = new Random(DateTime.Now.Second);

            foreach (CogoPoint point in points)
            {
                point.Elevation += (random.NextDouble() + ratio) * valueResult.Value * sign;
            }
        }
Exemplo n.º 10
0
        public void TEST_ExtractSurfaceBorder()
        {
            CivilSurface surface;

            if (!ObjectCollector.TrySelectAllowedClassObject(out surface, "\nSelect a Surface: "))
            {
                return;
            }
            CivilSurfaces.SurfaceTools.ExtractBorder((ITerrainSurface)surface);
        }
Exemplo n.º 11
0
        public static void Test()
        {
            TinVolumeSurface volSurface;

            if (!ObjectCollector.TrySelectAllowedClassObject(out volSurface))
            {
                return;
            }
            var b = volSurface.BoundariesDefinition[0];
        }
Exemplo n.º 12
0
        public void DynamicBlockTest()
        {
            BlockReference br;

            if (!ObjectCollector.TrySelectAllowedClassObject(out br))
            {
                return;
            }

            Tools.StartTransaction(() =>
            {
                br       = br.Id.GetObjectForRead <BlockReference>();
                var pSet = br.DynamicBlockReferencePropertyCollection;

                BlockTableRecord btr = br.BlockTableRecord.GetObjectForRead <BlockTableRecord>();

                if (pSet == null)
                {
                    return;
                }

                foreach (DynamicBlockReferenceProperty p in pSet)
                {
                    if (p.PropertyTypeCode == (short)PropertyTypeCodes.Mirror)
                    {
                        Type t  = p.Value.GetType();
                        p.Value = (short)((short)p.Value == 0 ? 1 : 0);
                    }
                }

                BlockTableRecord btrDyn = br.DynamicBlockTableRecord.GetObjectForRead <BlockTableRecord>();

                foreach (ObjectId id in btrDyn.GetBlockReferenceIds(false, false))
                {
                    var brDyn = id.GetObjectForRead <BlockReference>();
                    pSet      = brDyn.DynamicBlockReferencePropertyCollection;

                    if (pSet == null)
                    {
                        return;
                    }

                    foreach (DynamicBlockReferenceProperty p in pSet)
                    {
                        object obj = p;
                    }
                }

                var rbuffer    = btrDyn.XData;
                byte[] buffer  = new byte[System.Runtime.InteropServices.Marshal.SizeOf(rbuffer.UnmanagedObject)];
                IntPtr destPtr = System.Runtime.InteropServices.Marshal.AllocHGlobal(rbuffer.UnmanagedObject);
                System.Runtime.InteropServices.Marshal.Copy(rbuffer.UnmanagedObject, buffer, 0,
                                                            System.Runtime.InteropServices.Marshal.SizeOf(rbuffer.UnmanagedObject));
            });
        }
Exemplo n.º 13
0
        public static List <BlockReference> PromptBlocks(string msg = "\nSelect block references: ")
        {
            List <BlockReference> blocks;

            if (!ObjectCollector.TrySelectObjects(out blocks, msg))
            {
                return(null);
            }
            else
            {
                return(blocks);
            }
        }
Exemplo n.º 14
0
 public Factory()
 {
     PlaneCollector = new ObjectCollector <PlaneObject>(
         delegate(PlaneObject Object) {
         Object.Entity.SetActive(true);
         return(true);
     },
         delegate(PlaneObject Object) {
         Object.Entity.SetActive(false);
         return(true);
     }
         );
 }
Exemplo n.º 15
0
        public static Vector3d?PromptVector()
        {
            Curve curve;

            if (!ObjectCollector.TrySelectAllowedClassObject(out curve))
            {
                return(null);
            }
            else
            {
                return(curve.EndPoint - curve.StartPoint);
            }
        }
Exemplo n.º 16
0
        public static Curve PromptCurve()
        {
            Curve curve;

            if (!ObjectCollector.TrySelectAllowedClassObject(out curve))
            {
                return(null);
            }
            else
            {
                return(curve);
            }
        }
Exemplo n.º 17
0
        public void ReplacePointDescriptionToName()
        {
            List <CogoPoint> points;

            if (!ObjectCollector.TrySelectObjects(out points, "\nSelect points"))
            {
                return;
            }
            foreach (CogoPoint point in points)
            {
                point.PointName = point.FullDescription;
            }
        }
Exemplo n.º 18
0
        public static void TestPerpendicular()
        {
            Matrix3d ucs = Tools.GetAcadEditor().CurrentUserCoordinateSystem;
            Curve    line;

            if (!ObjectCollector.TrySelectAllowedClassObject(out line))
            {
                return;
            }

            PromptPointOptions ppo = new PromptPointOptions("\nУкажите точку: ");
            PromptPointResult  ppr = Tools.GetAcadEditor().GetPoint(ppo);

            if (ppr.Status != PromptStatus.OK)
            {
                return;
            }

            Tools.StartTransaction(() =>
            {
                /*Vector3d vector = ppr.Value - line.StartPoint;
                 * Vector3d lineVector = line.EndPoint - line.StartPoint;
                 *
                 * double cos = lineVector.GetCos2d(vector);
                 * if (cos >=0d && cos*vector.Length <= lineVector.Length)
                 * {
                 *  Point3d p = line.GetPointAtDist(cos * vector.Length);
                 *  Line perpendicular = new Line(ppr.Value, p);
                 *  perpendicular.SaveToDatebase();
                 * }*/

                if (line is Line)
                {
                    Line perpendicular = ((Line)line).GetOrthoNormalLine(ppr.Value, null, false);
                    if (perpendicular != null)
                    {
                        perpendicular.SaveToDatebase();
                    }
                }
                else if (line is Arc)
                {
                    Line perpendicular = ((Arc)line).GetOrthoNormalLine(ppr.Value, false);
                    if (perpendicular != null)
                    {
                        perpendicular.SaveToDatebase();
                    }
                }
            });
        }
        public static (GameObjectContainer, float) ReadSavegameFile(string fileName, string jsonFileName)
        {
            if (new FileInfo(fileName).Length > int.MaxValue)
            {
                throw new Exception("Input file is too large.");
            }

            Stream stream = new MemoryStream(File.ReadAllBytes(fileName));

            ArkSavegame arkSavegame = new ArkSavegame();

            // We're actually converting to json so we don't want to eliminate everything besides dinos.
            //bool PredicateCreatures(GameObject o) => !o.IsItem && (o.Parent != null || o.Components.Any());
            //bool PredicateCreaturesAndCryopods(GameObject o) => (!o.IsItem && (o.Parent != null || o.Components.Any())) || o.ClassString.Contains("Cryopod") || o.ClassString.Contains("SoulTrap_");

            using (ArkArchive archive = new ArkArchive(stream))
            {
                arkSavegame.ReadBinary(archive, ReadingOptions.Create()
                                       .WithDataFiles(false)
                                       .WithEmbeddedData(false)
                                       .WithDataFilesObjectMap(false)
                                       //.WithObjectFilter(new Predicate<GameObject>(PredicateCreaturesAndCryopods))
                                       .WithBuildComponentTree(true));
            }

            // Jenny's addition - immediately write the json format for any binary file we read in.
            using (StreamWriter file = File.CreateText(jsonFileName))
                using (JsonTextWriter writer = new JsonTextWriter(file))
                {
                    writer.Formatting = Formatting.Indented;
                    arkSavegame.WriteJson(writer, WritingOptions.Create());
                }
            // End of Jenny's addition.

            if (!arkSavegame.HibernationEntries.Any())
            {
                return(arkSavegame, arkSavegame.GameTime);
            }

            List <GameObject> combinedObjects = arkSavegame.Objects;

            foreach (HibernationEntry entry in arkSavegame.HibernationEntries)
            {
                ObjectCollector collector = new ObjectCollector(entry, 1);
                combinedObjects.AddRange(collector.Remap(combinedObjects.Count));
            }

            return(new GameObjectContainer(combinedObjects), arkSavegame.GameTime);
        }
        /// <summary>
        /// Generates concrete items type to collect from object type.
        /// </summary>
        public virtual IEnumerable <ItemType> GetItemsToCollect(Definitions.ObjectType objectType, VariablesEvaluated variables)
        {
            var itemsToCollect    = new List <ItemType>();
            var variableEvaluator = new RegKeyEffectiveRightsVariableEvaluator(objectType, variables);

            var hiveValue = variableEvaluator.AllObjectEntities[HiveEntityValue].Value;

            var processedKeys = variableEvaluator.TryToProcessObjectEntity(KeyEntityName);

            if (processedKeys != null)
            {
                processedKeys = this.OperationEvaluator.ProcessOperationForKeyEntity(objectType, processedKeys.ToArray());
            }
            if (processedKeys == null)
            {
                return new ItemType[] { }
            }
            ;

            var processedTrustees = variableEvaluator.TryToProcessObjectEntity(TrusteeSIDEntityName);
            var trusteeSidEntity  = variableEvaluator.AllObjectEntities[TrusteeSIDEntityName];

            if (processedTrustees == null)
            {
                return new ItemType[] { }
            }
            ;

            foreach (var regKey in processedKeys)
            {
                foreach (var sid in processedTrustees)
                {
                    if (trusteeSidEntity.operation.Equals(OperationEnumeration.equals))
                    {
                        var newItemToCollect = this.createRegKeyEffectiveRights(hiveValue, regKey, sid);
                        newItemToCollect.status = StatusEnumeration.notcollected;
                        itemsToCollect.Add(newItemToCollect);
                    }
                    else
                    {
                        var alreadyCollectedItems = ObjectCollector.CollectItemsApplyingOperation(hiveValue, regKey, sid, trusteeSidEntity.operation);
                        itemsToCollect.AddRange(alreadyCollectedItems);
                    }
                }
            }

            return(itemsToCollect);
        }
Exemplo n.º 21
0
        public void TEST_CloningSurface()
        {
            TinSurface surface;

            if (!ObjectCollector.TrySelectAllowedClassObject(out surface))
            {
                return;
            }
            TinSurface newSurface = surface.Clone() as TinSurface;

            newSurface.Name = "Clone_" + surface.Name;
            using (Transaction trans = Tools.StartTransaction())
            {
                Tools.AppendEntityEx(trans, newSurface);
            }
        }
Exemplo n.º 22
0
        public void TEST_GetCroppingSurface()
        {
            TinSurface surface;

            if (!ObjectCollector.TrySelectAllowedClassObject(out surface))
            {
                return;
            }
            Polyline border;

            if (!ObjectCollector.TrySelectAllowedClassObject(out border))
            {
                return;
            }

            CivilSurfaces.SurfaceTools.CroppingSurface5(surface, border);
        }
Exemplo n.º 23
0
        public static void TestEditText()
        {
            string controlName = "Рандом редактор (Настройки)";

            Views.EntitiesRandomEditorView view = null;
            MainMenu.MainPaletteSet        pset = MainMenu.MainPaletteSet.CreatedInstance;
            if ((view = pset.FindVisual(controlName) as Views.EntitiesRandomEditorView) == null)
            {
                view = new Views.EntitiesRandomEditorView();
                view.CommandAction = TestEditText;
                view.DataHost      = _dataHost;
                pset.AddControl(controlName, view);
                pset.Show();
                return;
            }
            pset.Show();

            EntitiesRandomEditor mainBlock = new EntitiesRandomEditor();

            List <DBObject> objects;

            if (!ObjectCollector.TrySelectObjects(out objects))
            {
                return;
            }
            if (objects.Count == 0)
            {
                return;
            }

            Tools.StartTransaction(() => {
                foreach (DBObject obj in objects)
                {
                    if (obj is Entity)
                    {
                        mainBlock._editEntity((Entity)obj);
                    }
                }
            });

            _dataHost.Write("minTolerance", mainBlock._minTolerance);
            _dataHost.Write("maxTolerance", mainBlock._maxTolerance);
        }
Exemplo n.º 24
0
        public void SelectTextAtBounds()
        {
            DBText sourceObj;

            if (!ObjectCollector.TrySelectAllowedClassObject <DBText>(out sourceObj))
            {
                return;
            }
            TypedValue[] tvs = new[] {
                new TypedValue((int)DxfCode.Start, "TEXT")
            };
            Tools.StartTransaction(() =>
            {
                Rectangle3d?bounds = sourceObj.GetTextBoxCorners();
                if (!bounds.HasValue)
                {
                    return;
                }

                Polyline pline = new Polyline(5);
                pline.AddVertexAt(0, bounds.Value.LowerLeft.Add((bounds.Value.LowerLeft - bounds.Value.UpperRight).MultiplyBy(0.1)));
                pline.AddVertexAt(1, bounds.Value.UpperLeft.Add((bounds.Value.UpperLeft - bounds.Value.LowerRight).MultiplyBy(0.1)));
                pline.AddVertexAt(2, bounds.Value.UpperRight.Add((bounds.Value.UpperRight - bounds.Value.LowerLeft).MultiplyBy(0.1)));
                pline.AddVertexAt(3, bounds.Value.LowerRight.Add((bounds.Value.LowerRight - bounds.Value.UpperLeft).MultiplyBy(0.1)));
                pline.AddVertexAt(4, bounds.Value.LowerLeft.Add((bounds.Value.LowerLeft - bounds.Value.UpperRight).MultiplyBy(0.1)));

                var spres = Tools.GetAcadEditor().SelectWindowPolygon(pline.GetPoints(), new SelectionFilter(tvs));

                pline.SaveToDatebase();

                if (spres.Status == PromptStatus.OK)
                {
                    DBText text = spres.Value.GetSelectedItems <DBText>().FirstOrDefault();
                    if (text != null)
                    {
                        text.UpgradeOpen();
                        text.ColorIndex = 181;
                        text.DowngradeOpen();
                    }
                }
            });
        }
        private static async Task <(GameObjectContainer, float)> ReadSavegameFile(string fileName)
        {
            return(await Task.Run(() =>
            {
                if (new FileInfo(fileName).Length > int.MaxValue)
                {
                    throw new Exception("Input file is too large.");
                }

                Stream stream = new MemoryStream(File.ReadAllBytes(fileName));

                ArkSavegame arkSavegame = new ArkSavegame();

                bool PredicateCreatures(GameObject o) => !o.IsItem && (o.Parent != null || o.Components.Any());
                bool PredicateCreaturesAndCryopods(GameObject o) => (!o.IsItem && (o.Parent != null || o.Components.Any())) || o.ClassString.Contains("Cryopod") || o.ClassString.Contains("SoulTrap_");

                using (ArkArchive archive = new ArkArchive(stream))
                {
                    arkSavegame.ReadBinary(archive, ReadingOptions.Create()
                                           .WithDataFiles(false)
                                           .WithEmbeddedData(false)
                                           .WithDataFilesObjectMap(false)
                                           .WithObjectFilter(Properties.Settings.Default.SaveImportCryo ? new Predicate <GameObject>(PredicateCreaturesAndCryopods) : new Predicate <GameObject>(PredicateCreatures))
                                           .WithBuildComponentTree(true));
                }

                if (!arkSavegame.HibernationEntries.Any())
                {
                    return (arkSavegame, arkSavegame.GameTime);
                }

                List <GameObject> combinedObjects = arkSavegame.Objects;

                foreach (HibernationEntry entry in arkSavegame.HibernationEntries)
                {
                    ObjectCollector collector = new ObjectCollector(entry, 1);
                    combinedObjects.AddRange(collector.Remap(combinedObjects.Count));
                }

                return (new GameObjectContainer(combinedObjects), arkSavegame.GameTime);
            }));
        }
Exemplo n.º 26
0
        public static void CopyMLeaderTextContext()
        {
            MLeader sourceLeader;
            MLeader destLeader;

            if (!ObjectCollector.TrySelectAllowedClassObject(out sourceLeader, "\nВыберите мультивыноску - источник"))
            {
                return;
            }
            if (!ObjectCollector.TrySelectAllowedClassObject(out destLeader, "\nВыберите мультивыноску - назначение"))
            {
                return;
            }

            //destLeader = trans.GetObject(destLeader.Id, OpenMode.ForWrite) as MLeader;
            string res = MLeaders.MLeaderTools.CopyTextContents(sourceLeader, destLeader);

            //trans.Commit();
            Tools.GetAcadEditor().WriteMessage("\n" + res);
        }
Exemplo n.º 27
0
    private static Task <GameObjectContainer> ReadSavegameFile(string fileName)
    {
        return(Task.Run(() =>
        {
            if (new FileInfo(fileName).Length > int.MaxValue)
            {
                throw new Exception("Input file is too large.");
            }

            var arkSavegame = new ArkSavegame();

            using (var stream = new MemoryStream(File.ReadAllBytes(fileName)))
                using (var archive = new ArkArchive(stream))
                {
                    arkSavegame.ReadBinary(archive, ReadingOptions.Create()
                                           .WithDataFiles(false)
                                           .WithEmbeddedData(false)
                                           .WithDataFilesObjectMap(false)
                                           .WithObjectFilter(o => !o.IsItem && (o.Parent != null || o.Components.Any()))
                                           .WithBuildComponentTree(true));
                }

            if (!arkSavegame.HibernationEntries.Any())
            {
                return (arkSavegame);
            }

            var combinedObjects = arkSavegame.Objects;

            foreach (var entry in arkSavegame.HibernationEntries)
            {
                var collector = new ObjectCollector(entry, 1);
                combinedObjects.AddRange(collector.Remap(combinedObjects.Count));
            }

            return new GameObjectContainer(combinedObjects);
        }));
    }
Exemplo n.º 28
0
        public void SelectPointAtPolygon()
        {
            Polyline pline;

            if (!ObjectCollector.TrySelectAllowedClassObject(out pline))
            {
                return;
            }

            Vector3d vector = pline.Bounds.Value.MaxPoint - pline.Bounds.Value.MinPoint;

            Point3d centralPoint = pline.Bounds.Value.MinPoint.Add(vector.DivideBy(2d));
            var     randomPoints = centralPoint.CreateRandomCirclePoints(10000, vector.Length);

            List <ObjectId> pointIds = new List <ObjectId>();

            Tools.StartTransaction(() =>
            {
                pointIds = Tools.AppendEntity(
                    randomPoints.Select(x =>
                {
                    return(new DBPoint(x));
                }));
            });

            Tools.StartTransaction(() =>
            {
                foreach (var id in pointIds)
                {
                    DBPoint p = id.GetObjectForRead <DBPoint>();
                    if (pline.IsInsidePolygon(p.Position))
                    {
                        p.UpgradeOpen();
                        p.Highlight();
                    }
                }
            });
        }
Exemplo n.º 29
0
        public void EditPointElevation()
        {
            List <CogoPoint> points;

            if (!ObjectCollector.TrySelectObjects(out points, "\nSelect points"))
            {
                return;
            }

            PromptDoubleOptions valueOption = new PromptDoubleOptions("\nEnter value");

            valueOption.AllowNone    = false;
            valueOption.DefaultValue = 0d;

            PromptDoubleResult valueResult = Tools.GetAcadEditor().GetDouble(valueOption);

            if (valueResult.Status != PromptStatus.OK)
            {
                return;
            }

            IgorKL.ACAD3.Model.CogoPoints.CogoPointEditor.EditElevation(points, valueResult.Value);
        }
    public override void Interact(GameObject player)
    {
        ObjectCollector collector = player.GetComponent <ObjectCollector>();

        if (isLocked && collector.CheckQty(keyType) == 0)
        {
            FMODUnity.RuntimeManager.PlayOneShot(sfxDoorLocked, transform.position);
            PlayerDialogueState dialogueState = player.GetComponentInChildren <PlayerDialogueState>();
            dialogueState.dialogue = lockedDialogue;
            dialogueState.GetComponent <ConcurrentStateMachine>().ChangeState(typeof(PlayerDialogueState));
        }
        else if (isLocked && collector.CheckQty(keyType) > 0)
        {
            FMODUnity.RuntimeManager.PlayOneShot(sfxDoorUnlocked, transform.position);
            isLocked = false;
            collector.UseItem(keyType);
            lockObject.SetActive(false);
        }
        else if (!isLocked)
        {
            animator.SetTrigger("Open");
            FMODUnity.RuntimeManager.PlayOneShot(sfxDoorOpening, transform.position);
        }
    }
        /// <summary>
        /// Create a topology to be played with a MediaSession from a filepath.
        /// </summary>
        internal static Topology CreateTopology(ByteStream mediaInputStream, out MediaSource mediaSource)
        {
            // collector to dispose all the created Media Foundation native objects.
            var collector = new ObjectCollector();

            // Get the MediaSource object.
            var sourceResolver = new SourceResolver();
            collector.Add(sourceResolver);
            ComObject mediaSourceObject;

            // Try to load music
            try
            {
                mediaSourceObject = sourceResolver.CreateObjectFromStream(mediaInputStream, null, SourceResolverFlags.MediaSource | SourceResolverFlags.ContentDoesNotHaveToMatchExtensionOrMimeType);
            }
            catch (SharpDXException)
            {
                collector.Dispose();
                throw new InvalidOperationException("Music stream format not supported");
            }

            Topology retTopo;

            try
            {
                mediaSource = mediaSourceObject.QueryInterface<MediaSource>();
                collector.Add(mediaSourceObject);

                // Get the PresentationDescriptor
                PresentationDescriptor presDesc;
                mediaSource.CreatePresentationDescriptor(out presDesc);
                collector.Add(presDesc);

                // Create the topology
                MediaFactory.CreateTopology(out retTopo);
                for (var i = 0; i < presDesc.StreamDescriptorCount; i++)
                {
                    Bool selected;
                    StreamDescriptor desc;
                    presDesc.GetStreamDescriptorByIndex(i, out selected, out desc);
                    collector.Add(desc);

                    if (selected)
                    {
                        // Test that the audio file data is valid and supported.
                        var typeHandler = desc.MediaTypeHandler;
                        collector.Add(typeHandler);

                        var majorType = typeHandler.MajorType;

                        if (majorType != MediaTypeGuids.Audio)
                            throw new InvalidOperationException("The music stream is not a valid audio stream.");

                        for (int mType = 0; mType < typeHandler.MediaTypeCount; mType++)
                        {
                            MediaType type;
                            typeHandler.GetMediaTypeByIndex(mType, out type);
                            collector.Add(type);

                            var nbChannels = type.Get(MediaTypeAttributeKeys.AudioNumChannels);
                            if (nbChannels > 2)
                                throw new InvalidOperationException("The provided audio stream has more than 2 channels.");
                        }

                        // create the topology (source,...)
                        TopologyNode sourceNode;
                        MediaFactory.CreateTopologyNode(TopologyType.SourceStreamNode, out sourceNode);
                        collector.Add(sourceNode);

                        sourceNode.Set(TopologyNodeAttributeKeys.Source, mediaSource);
                        sourceNode.Set(TopologyNodeAttributeKeys.PresentationDescriptor, presDesc);
                        sourceNode.Set(TopologyNodeAttributeKeys.StreamDescriptor, desc);

                        TopologyNode outputNode;
                        MediaFactory.CreateTopologyNode(TopologyType.OutputNode, out outputNode);
                        collector.Add(outputNode);

                        Activate activate;
                        MediaFactory.CreateAudioRendererActivate(out activate);
                        collector.Add(activate);
                        outputNode.Object = activate;

                        retTopo.AddNode(sourceNode);
                        retTopo.AddNode(outputNode);
                        sourceNode.ConnectOutput(0, outputNode, 0);
                    }
                }
            }
            finally
            {
                collector.Dispose();
            }

            return retTopo;
        }
Exemplo n.º 32
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ComponentBase"/> class.
 /// </summary>
 /// <param name="name">The name attached to this component</param>
 protected ComponentBase(string name)
 {
     collector = new ObjectCollector();
     Tags = new PropertyContainer(this);
     Name = name ?? GetType().Name;
 }
Exemplo n.º 33
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ComponentBase"/> class.
 /// </summary>
 protected DisposeBase()
 {
     collector = new ObjectCollector();
     Tags = new PropertyContainer(this);
 }