System.Collections.Generic.List.ToArray()

Here are the examples of the csharp api System.Collections.Generic.List.ToArray() taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

22147 Examples 7

19 Source : EncodingUtil.cs
with MIT License
from 404Lcc

public static byte[] LengthDecode(ref List<byte> cacheList)
        {
            byte[] bytes;
            using (MemoryStream stream = new MemoryStream(cacheList.ToArray()))
            {
                using (BinaryReader reader = new BinaryReader(stream))
                {
                    int length = reader.ReadInt32();
                    if (length > stream.Length - stream.Position)
                    {
                        return null;
                    }
                    bytes = reader.ReadBytes(length);
                    cacheList.Clear();
                    cacheList.AddRange(reader.ReadBytes((int)(stream.Length - stream.Position)));
                }
            }
            return bytes;
        }

19 Source : QQTea.cs
with MIT License
from 499116344

public static byte[] Decrypt(byte[] In, byte[] key)
        {
            var into = new List<byte>();
            var tail = true;
            for (var i = In.Length - 1; i >= 0; i--)
            {
                if (tail)
                {
                    if (In[i] == 0x03)
                    {
                        tail = false;
                    }
                    else if (In[i] == 0x00)
                    {
                    }
                    else
                    {
                        into.Insert(0, In[i]);
                        tail = false;
                    }
                }
                else
                {
                    into.Insert(0, In[i]);
                }
            }

            return Decrypt(into.ToArray(), 0, into.Count, key);
        }

19 Source : CommandManager.cs
with MIT License
from 404Lcc

public void AddCommands(CommandData[] commandDatas)
        {
            if (commandDatas == null) return;
            List<CommandData> targetList = new List<CommandData>();
            foreach (CommandData item in commandDatas)
            {
                CommandData target;
                switch (item.dataType)
                {
                    default:
                        target = new CommandData();
                        break;
                }
                FieldInfo[] fieldInfos = target.GetType().GetFields();
                foreach (FieldInfo fieldinfoitem in fieldInfos)
                {
                    fieldinfoitem.SetValue(target, fieldinfoitem.GetValue(item));
                }
                targetList.Add(target);
            }
            commandDataList.AddRange(targetList.ToArray());
        }

19 Source : TrainTrainDalTests.cs
with MIT License
from 42skillz

[Test]
        public void Should_retrieve_all_trains()
        {
            var trains = new List<TrainEnreplacedy>
            {
                MakeTrain("express_2001", 1),
                MakeTrain("express_2002", 2),
                MakeTrain("express_2003", 3),
                MakeTrain("express_2004", 4),
                MakeTrain("express_2005", 5),
                MakeTrain("express_2006", 6),
                MakeTrain("express_2007", 7),
                MakeTrain("express_2008", 8),
                MakeTrain("express_2009", 9),
                MakeTrain("express_2010", 10),
            };

            var repository = Factory.Create();
            repository.SaveAll(trains.ToArray());

            Check.That(repository.GetAll().Count).IsEqualTo(trains.Count);
        }

19 Source : Config.cs
with MIT License
from 5minlab

internal IModifier[] CreateCurrentModifiers() {
            var targetGroup = BuildTargetGroup;
            var modifiers = new List<IModifier>();
            foreach (var t in CreateCurrentBased(targetGroup)) {
                if (t.data.Count > 0) {
                    modifiers.Add(t.modifier);
                }
            }
            return modifiers.ToArray();
        }

19 Source : Menu_PackageExporter.cs
with MIT License
from 5minlab

public string[] GetList() {
            var dirs = new string[] {
                    "replacedets/Minamo"
                };
            var set = new HashSet<string>();
            var founds = replacedetDatabase.Findreplacedets("", dirs);
            foreach (var guid in founds) {
                var replacedetPath = replacedetDatabase.GUIDToreplacedetPath(guid);
                if (replacedetPath.EndsWith(".cs")) {
                    set.Add(replacedetPath);
                }
            }

            var list = new List<string>(set);
            return list.ToArray();
        }

19 Source : Menu_PackageExporter.cs
with MIT License
from 5minlab

internal string[] GetreplacedetPaths() {
            var finders = new IreplacedetFinder[] {
                new MinamoreplacedetFinder(),
            };

            var replacedetPaths = new List<string>();
            foreach (var f in finders) {
                replacedetPaths.AddRange(f.GetList());
            }
            return replacedetPaths.ToArray();
        }

19 Source : Modifier_DefineSymbol.cs
with MIT License
from 5minlab

public void Reload(AnyDictionary dict) {
            var prev = PlayerSettings.GetScriptingDefineSymbolsForGroup(targetGroup);

            var tokens = new List<string>();
            if (prev.Length > 0) {
                tokens.Add(prev);
            }

            for(int i = 0; i < dict.Count; i++) {
                var s = dict.GetAt<string>(i);
                if(s == null || s == "") {
                    continue;
                }
                tokens.Add(s);
            }

            this.defines = string.Join(";", tokens.ToArray());
        }

19 Source : Modifier_Publishing.cs
with MIT License
from 5minlab

public void Reload(AnyDictionary dict) {
            android_useApkExpansion = replacedignableType<bool>.FromDict(dict, "android_useApkExpansion");

            var l = dict.GetList("uwpCapability");
            var list = new List<string>();
            for(int i = 0; l != null && i < l.Count; i++) {
                var v = l[i] as string;
                if(v != null) {
                    list.Add(v);
                }
            }
            this.uwp_capability = list.ToArray();

            ps4_attribExclusiveVR = replacedignableType<bool>.FromDict(dict, "ps4_attribExclusiveVR");
            ps4_attribShareSupport = replacedignableType<bool>.FromDict(dict, "ps4_attribShareSupport");
            ps4_attribMoveSupport = replacedignableType<bool>.FromDict(dict, "ps4_attribMoveSupport");
            ps4_category = replacedignableType<PlayerSettings.PS4.PS4AppCategory>.FromEnumDict(dict, "ps4_category");
            ps4_masterVersion = replacedignableType<string>.FromDict(dict, "ps4_masterVersion");
            ps4_contentID = replacedignableType<string>.FromDict(dict, "ps4_contentID");
            ps4_applicationParameter1 = replacedignableType<int>.FromDict(dict, "ps4_applicationParameter1");
            ps4_applicationParameter2 = replacedignableType<int>.FromDict(dict, "ps4_applicationParameter2");
            ps4_applicationParameter3 = replacedignableType<int>.FromDict(dict, "ps4_applicationParameter3");
            ps4_applicationParameter4 = replacedignableType<int>.FromDict(dict, "ps4_applicationParameter4");
            ps4_enterButtonreplacedignment = replacedignableType<PlayerSettings.PS4.PS4EnterButtonreplacedignment>.FromEnumDict(dict, "ps4_enterButtonreplacedignment");
        }

19 Source : Modifier_Publishing.cs
with MIT License
from 5minlab

internal static Modifier_Publishing Current() {
            var capabilityList = new List<string>();
            var table = StringEnumConverter.Get<PlayerSettings.WSACapability>();
            foreach(var kv in table) {
                var f = PlayerSettings.WSA.GetCapability(kv.Value);
                if(f) {
                    capabilityList.Add(kv.Key);
                }
            }

            return new Modifier_Publishing()
            {
                android_useApkExpansion = replacedignableType<bool>.Create(PlayerSettings.Android.useAPKExpansionFiles),

                uwp_capability = capabilityList.ToArray(),

                ps4_attribExclusiveVR = replacedignableType<bool>.Create(PlayerSettings.PS4.attribExclusiveVR),
                ps4_attribShareSupport = replacedignableType<bool>.Create(PlayerSettings.PS4.attribShareSupport),
                ps4_attribMoveSupport = replacedignableType<bool>.Create(PlayerSettings.PS4.attribMoveSupport),
                ps4_category = replacedignableType<PlayerSettings.PS4.PS4AppCategory>.Create(PlayerSettings.PS4.category),
                ps4_masterVersion = replacedignableType<string>.Create(PlayerSettings.PS4.masterVersion),
                ps4_contentID = replacedignableType<string>.Create(PlayerSettings.PS4.contentID),
                ps4_applicationParameter1 = replacedignableType<int>.Create(PlayerSettings.PS4.applicationParameter1),
                ps4_applicationParameter2 = replacedignableType<int>.Create(PlayerSettings.PS4.applicationParameter2),
                ps4_applicationParameter3 = replacedignableType<int>.Create(PlayerSettings.PS4.applicationParameter3),
                ps4_applicationParameter4 = replacedignableType<int>.Create(PlayerSettings.PS4.applicationParameter4),
                ps4_enterButtonreplacedignment = replacedignableType<PlayerSettings.PS4.PS4EnterButtonreplacedignment>.Create(PlayerSettings.PS4.enterButtonreplacedignment),
            };
        }

19 Source : Modifier_XR.cs
with MIT License
from 5minlab

public void Reload(AnyDictionary dict) {
            enabled = dict.GetValue<bool>("enabled");

            var rawDeviceList = dict.GetList("devices");
            var deviceList = new List<string>();
            for(var i = 0; i < rawDeviceList.Count;i++) {
                var el = rawDeviceList[i] as string;
                if(el != null) {
                    deviceList.Add(el);
                }
            }
            this.devices = deviceList.ToArray();

            var table = StringEnumConverter.Get<StereoRenderingPath>();
            stereoRenderingPath = table[dict.GetValue<string>("stereoRenderingPath")];
        }

19 Source : PlayerBuildExecutor.cs
with MIT License
from 5minlab

static string[] GetScenes() {
            List<string> scenes = new List<string>();
            foreach (EditorBuildSettingsScene scene in EditorBuildSettings.scenes) {
                if (scene.enabled) {
                    scenes.Add(scene.path);
                }
            }
            return scenes.ToArray();
        }

19 Source : EntityAssertionQuery.cs
with MIT License
from 5argon

public CD[] ComponentObjects<CD>(Func<CD, bool> where = null) where CD : clreplaced, IComponentData
        {
            CD[] array;
            using (var eq = em.CreateEnreplacedyQuery(
                ComponentType.ReadOnly<CD>()
            ))
            {
                var na = eq.ToEnreplacedyArray(Allocator.TempJob);
                array = new CD[na.Length];
                for (int i = 0; i < na.Length; i++)
                {
                    array[i] = em.GetComponentObject<CD>(na[i]);
                }
            }

            if (where == null)
            {
                return array;
            }

            List<CD> list = new List<CD>();
            for (int i = 0; i < array.Length; i++)
            {
                if (where.Invoke(array[i]) == true)
                {
                    list.Add(array[i]);
                }
            }

            return list.ToArray();
        }

19 Source : GradientGenerator.cs
with MIT License
from 5argon

[ContextMenu("Generate")]
    public void Generate()
    {
        var gradients = new List<Gradient>();
        for (int k = 0; k < gradientSpecs.Length; k++)
        {
            var spec = gradientSpecs[k];

            var eightRainbow = Enumerable.Range(0, 9).Select(x => Mathf.InverseLerp(0, 9, x)).Take(8).Select(x =>
            Color.HSVToRGB(spec.hProgression.Evaluate(x), spec.sProgression.Evaluate(x), spec.vProgression.Evaluate(x))).ToArray();

            for (int mode = 0; mode < 2; mode++)
            {
                GradientMode gm = (GradientMode)mode;
                var modePlus = gm == GradientMode.Fixed ? 1 : 0;
                for (int i = 1; i < 8; i++)
                {
                    var timeRange = Enumerable.Range(0, i + 1).Select(x => Mathf.InverseLerp(0, i + modePlus, x + modePlus)).ToArray();
                    var g = new Gradient();
                    g.mode = gm;
                    var colorKeys = new GradientColorKey[i + 1];
                    var alphaKeys = new GradientAlphaKey[i + 1];
                    for (int j = 0; j < i + 1; j++)
                    {
                        colorKeys[j].color = eightRainbow[j];
                        colorKeys[j].time = spec.timeRemap.Evaluate(timeRange[j]);
                        alphaKeys[j].alpha = spec.aProgression.Evaluate(timeRange[j]);
                        alphaKeys[j].time = spec.timeRemap.Evaluate(timeRange[j]);
                    }
                    g.SetKeys(colorKeys, alphaKeys);
                    gradients.Add(g);
                }
            }

        }
        generatedGradients = gradients.ToArray();
#if UNITY_EDITOR
        EditorUtility.SetDirty(this);
        replacedetDatabase.Savereplacedets();
#endif
    }

19 Source : JobAnimationCurveTests.cs
with MIT License
from 5argon

private AnimationCurve RandomCurve(int resolution)
        {
            Random.InitState(1234567);
            var kf = new List<Keyframe>();
            for (int i = 0; i < resolution; i++)
            {
                kf.Add(new Keyframe(math.unlerp(0, resolution - 1, i), Random.value, math.tan(math.radians(Random.value * 360)), math.tan(math.radians(Random.value * 360))));
            }
            return new AnimationCurve(kf.ToArray());
        }

19 Source : NotchSimulatorUtility.cs
with MIT License
from 5argon

internal static Rect[] CalculateSimulatorCutoutsRelative(SimulationDevice device)
        {
            var orientation = GetGameViewOrientation();
            var cutouts = device.Screens.FirstOrDefault().orientations[orientation].cutouts;
            if (cutouts is null) return new Rect[0];
            var screenSize = new Vector2(device.Screens.FirstOrDefault().width, device.Screens.FirstOrDefault().height);
            if (orientation == ScreenOrientation.Landscape)
            {
                var swap = screenSize.x;
                screenSize.x = screenSize.y;
                screenSize.y = swap;
            }

            System.Collections.Generic.List<Rect> rects = new System.Collections.Generic.List<Rect>();
            foreach (var cutout in cutouts) rects.Add(GetRectRelativeToScreenSize(cutout, screenSize));
            return rects.ToArray();
        }

19 Source : Config.cs
with MIT License
from 5minlab

internal IModifier[] CreateConfigModifiers() {
            var targetGroup = BuildTargetGroup;
            var modifiers = new List<IModifier>();
            foreach(var t in CreateConfigBased(targetGroup)) {
                if (t.data.Count > 0) {
                    t.modifier.Reload(t.data);
                    modifiers.Add(t.modifier);
                }
            }
            return modifiers.ToArray();
        }

19 Source : Shell.cs
with MIT License
from 5minlab

public static string Output() {
            return string.Join("\n", Instance.m_output.ToArray());
        }

19 Source : ExtendableEnums.cs
with MIT License
from 7ark

public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
    {
        currentProperty = property;
        ExtendEnumAttribute source = (ExtendEnumAttribute)attribute;
        System.Enum enumVal = GetBaseProperty<System.Enum>(property);

        enumNames = (property.enumDisplayNames).OfType<string>().ToList();
        if (source.display)
        {
            int[] enumValues = (int[])(System.Enum.GetValues(enumVal.GetType()));
            for (int i = 0; i < enumNames.Count; i++)
            {
                enumNames[i] += " | " + enumValues[i];
            }
        }

        EditorGUI.BeginProperty(position, label, property);
        if (!showWindow)
        {
            if (enumNames.Count != 0)
            {
                enumNames.Add("Add New...");
                int newValue = EditorGUI.Popup(position, property.displayName, property.intValue, enumNames.ToArray());

                if (newValue == enumNames.Count - 1)
                {
                    NewValuePopup popup = new NewValuePopup();
                    PopupWindow.Show(new Rect(Screen.width / 2 - popupWidth / 2, position.y - popupHeight / 2, 0, 0), popup);

                    newValueText = "";
                }
                else
                {
                    property.intValue = newValue;
                }
            }
            else
            {
                EditorGUI.LabelField(position, "Extendable Enums needs at least one value in your declared enum.");
            }
        }
        else
        {
            EditorGUI.LabelField(position, "Waiting for new value input.");
        }

        EditorGUI.EndProperty();
    }

19 Source : Dialogues.cs
with MIT License
from 7ark

public string[] GetChoices()
    {
        if (Current.Type != WindowTypes.Choice)
            return new string[] { };
        else
        {
            List<string> Choices = new List<string>();
            for (int i = 0; i < Current.Connections.Count; i++)
            {
                Choices.Add(Set[CurrentSet].GetWindow(Current.Connections[i]).Text);
            }
            return Choices.ToArray();
        }
    }

19 Source : AINavMeshGenerator.cs
with MIT License
from 7ark

private Node[] GetAStar(Vector2 currentPosition, Vector2 destination, GameObject obj = null)
    {
        Node start = generator.FindClosestNode(currentPosition, false, obj);
        Node end = generator.FindClosestNode(destination, true, obj);
        if (start == null || end == null)
        {
            return null;
        }

        openSet.Clear();
        closedSet.Clear();
        openSet.Add(start);
        while (openSet.Count > 0)
        {
            Node current = openSet[0];

            //Evaluate costs
            for (int i = 1; i < openSet.Count; i++)
            {
                if (openSet[i].fCost < current.fCost || openSet[i].fCost == current.fCost)
                {
                    if (openSet[i].hCost < current.hCost)
                    {
                        current = openSet[i];
                    }
                }
            }

            openSet.Remove(current);
            closedSet.Add(current);

            if (current.Equals(end))
            {
                break;
            }

            //Go through neighbors
            foreach (Node neighbor in current.connections.Where(x => x != null))
            {
                //The replacedociated object check is so the enemy ignores pathing through it's own bad sector
                if ((!neighbor.valid && neighbor.replacedociatedObject != obj) || closedSet.Contains(neighbor))
                {
                    continue;
                }

                float newCost = current.gCost + Heuristic(current, neighbor);
                if (newCost < neighbor.gCost || !openSet.Contains(neighbor))
                {
                    neighbor.gCost = newCost;
                    neighbor.hCost = Heuristic(neighbor, end);
                    neighbor.parent = current;

                    if (!openSet.Contains(neighbor))
                    {
                        openSet.Add(neighbor);
                    }
                }
            }
        }

        if(end.parent == null)
        {
            return null;
        }

        //Calculate path
        path.Clear();
        Node currentCheck = end;
        while (!path.Contains(currentCheck) && currentCheck != null)
        {
            path.Add(currentCheck);
            currentCheck = currentCheck.parent;
        }
        path.Reverse();
        if(path[0] != start)
        {
            return null;
        }
        return path.ToArray();
    }

19 Source : AINavMeshGenerator.cs
with MIT License
from 7ark

public Vector2[] FindPath(Vector2 currentPosition, Vector2 destination, GameObject replacedociatedObject = null)
    {
        Node[] points = GetAStar(currentPosition, destination, replacedociatedObject);
        if(points == null)
        {
            return null;
        }

        List<Vector2> shortPath = ShortenPointsByVisibility(points);
        //shortPath.Insert(0, currentPosition);
        return shortPath.ToArray();
    }

19 Source : String.Extension.cs
with MIT License
from 7Bytes-Studio

public static string Slice(this string str, char sliceLChar,char sliceRChar)
        {
            var arr = str.ToCharArray();
            List<char> charArr = new List<char>();
            bool startRead = false;
            for (int i = 0; i < arr.Length; i++)
            {
                if (arr[i]==sliceLChar)
                {
                    startRead = true;
                    continue;
                }
                else if (arr[i] == sliceRChar)
                {
                    startRead = false;
                    return new string(charArr.ToArray());
                }

                if (startRead)
                {
                    charArr.Add(arr[i]);
                }
            }
            return string.Empty;
        }

19 Source : Utility.Reflection.cs
with MIT License
from 7Bytes-Studio

public static Type[] GetImplTypes(string replacedemblyName,Type typeBase)
            {
                replacedembly replacedembly = replacedembly.Load(replacedemblyName);
                if (null != replacedembly)
                {
                    List<Type> list = new List<Type>();
                    var types = replacedembly.GetTypes();
                    if (null != types)
                        for (int i = 0; i < types.Length; i++)
                        {
                            if (types[i].IsClreplaced && !types[i].IsAbstract && typeBase.IsreplacedignableFrom(types[i]))
                            {
                                list.Add(types[i]);
                            }
                        }
                    return list.ToArray();
                }
                return null;
            }

19 Source : Utility.Reflection.cs
with MIT License
from 7Bytes-Studio

public static Type[] GetImplTypes(string[] replacedemblyNames,Type typeBase)
            {
                List<Type> list = new List<Type>();
                for (int i = 0; i < replacedemblyNames.Length; i++)
                {
                    var tps = GetImplTypes(replacedemblyNames[i], typeBase);
                    if (null!=tps)
                    {
                        for (int j = 0; j < tps.Length; j++)
                        {
                            list.Add(tps[j]);
                        }
                    }
                }
                return list.ToArray();
            }

19 Source : ObjectPool.PoolFactoryBinder.partial.cs
with MIT License
from 7Bytes-Studio

public Type[] GetBindingTypes()
            {
                List<Type> list = new List<Type>();
                foreach (var k in m_BindDic.Keys)
                {
                    list.Add(k);
                }
                return list.ToArray();
            }

19 Source : EndianBinaryReader.cs
with MIT License
from 91Act

public string ReadStringToNull()
        {
            var bytes = new List<byte>();
            byte b;
            while (BaseStream.Position != BaseStream.Length && (b = ReadByte()) != 0)
                bytes.Add(b);
            return Encoding.UTF8.GetString(bytes.ToArray());
        }

19 Source : ServiceInvoker.cs
with MIT License
from 99x

public static Task Invoke(Kernel kernel, RadiumContext context)
        {
            DefaultResponseBody responseBody = new DefaultResponseBody();

            var req = context.Request;
            var res = context.Response;


            string reqContentType = req.ContentType;
            if (String.IsNullOrEmpty(reqContentType))
                reqContentType = "application/json";
            else
                reqContentType = reqContentType.ToLower();

            PathExecutionParams exeParams = ResourceRepository.Repo[req.Method, req.Path.Value];

            try
            {
                if (exeParams != null)
                {

                    Filters.FilterChainResponse chainResponse =  kernel.FilterManager.ExecuteChain();
                    bool isSuccess = chainResponse.LastResponse !=null ? chainResponse.LastResponse.Success : true;

                    if (!isSuccess)
                    {
                        res.ContentType = reqContentType;
                        responseBody.success = false; 
                        responseBody.result = chainResponse.LastResponse.Message;
                        responseBody.error = chainResponse.LastResponse.Error;
                        res.StatusCode = chainResponse.LastResponse.StatusCode;
                    }
                    else
                    {
                        RestResourceHandler newObj = (RestResourceHandler)Activator.CreateInstance(exeParams.ExecutionInfo.Type);
                        newObj.OContext = context;
                        newObj.DataBag = chainResponse.FilterResponse;
                        var exeMethod = exeParams.ExecutionInfo.Method;
                        List<object> activatorParams = new List<object>();
                        var methodParams = exeMethod.GetParameters();

                        foreach (var mParam in methodParams)
                        {
                            if (exeParams.Parameters.ContainsKey(mParam.Name))
                            {
                                var strValue = exeParams.Parameters[mParam.Name];
                                object convertedValue = Convert.ChangeType(strValue, mParam.ParameterType);
                                activatorParams.Add(convertedValue);
                            }
                            else
                            {
                                throw new ParameterMismatchException();
                            }
                        }

                        object output = exeMethod.Invoke(newObj, activatorParams.ToArray());
                        responseBody.success = true;
                        responseBody.result = output;
                        res.ContentType = reqContentType;
                    }

                }
                else
                {
                    res.ContentType = reqContentType;
                    responseBody.success = false;
                    responseBody.result = "404 Not Found";
                    res.StatusCode = 404;
                }
            }
            catch (Exception ex) 
            {
                res.ContentType = reqContentType;
                responseBody.success = false;
                responseBody.result = ex;
                res.StatusCode = 500;
            }

            var formatter = kernel.ResponseFormatter.GetFormatter(reqContentType);
            return res.WriteAsync(formatter.Format(responseBody));
        }

19 Source : CloudBoxCrop.cs
with GNU Lesser General Public License v3.0
from 9and3

public PointCloud CropBox(PointCloud cloud, List<Brep> boxes, bool inverse = false, bool parallel = false) {


            bool[] flags = new bool[cloud.Count];

            foreach (var brep in boxes) {


                brep.Surfaces[0].TryGetPlane(out Plane plane);
                Box box = new Box(plane, brep);

                Transform xform = Transform.PlaneToPlane(box.Plane, Plane.WorldXY);
                Transform xformI = Transform.PlaneToPlane(Plane.WorldXY, box.Plane);

                PointCloud cloudCopy = new PointCloud(cloud);

                Box b = new Box(box.Plane, new Point3d[] { box.PointAt(0, 0, 0), box.PointAt(1, 1, 1) });
             
                cloudCopy.Transform(xform);
                b.Transform(xform);
                Point3d Min = b.PointAt(0, 0, 0);
                Point3d Max = b.PointAt(1, 1, 1);
                //Rhino.RhinoDoc.ActiveDoc.Objects.AddBox(b);

                System.Threading.Tasks.Parallel.For(0, cloudCopy.Count, i => {

                    if (flags[i]) return;
                    var p = cloudCopy[i].Location;
                    bool flag = (Min.X < p.X) && (Max.X > p.X) && (Min.Y < p.Y) && (Max.Y > p.Y) &&  (Min.Z < p.Z) && (Max.Z > p.Z);
                    if (flag) flags[i] = true;

                });
            }



            int count = 0;
            List<int> idList = new List<int>();
            for (int i = 0; i < cloud.Count; i++) {
                bool f = inverse ? !flags[i] : flags[i];
                if (f) {
                    idList.Add(i);
                    count++;
                }
            }

            int[] idArray = idList.ToArray();
            Point3d[] points = new Point3d[count];
            Vector3d[] normals = new Vector3d[count];
            Color[] colors = new Color[count];

            System.Threading.Tasks.Parallel.For(0, idArray.Length, i => {


                int id = idArray[i];
                var p = cloud[(int)id];
                points[i] = p.Location;
                normals[i] = p.Normal;
                colors[i] = p.Color;

            });

            PointCloud croppedCloud = new PointCloud();
            croppedCloud.AddRange(points, normals, colors);



           
            //for (int i = 0; i < cloud.Count; i++) {
            //    bool f = inverse ? !flags[i] : flags[i];
            //    if (f) {
            //        if (cloud.ContainsNormals) {
            //            croppedCloud.Add(cloud[i].Location, cloud[i].Normal, cloud[i].Color);
            //        } else {
            //            croppedCloud.Add(cloud[i].Location, cloud[i].Color);
            //        }
            //    }
            //}
            return croppedCloud;

        }

19 Source : CloudSection.cs
with GNU Lesser General Public License v3.0
from 9and3

public PointCloud SectionCloud(PointCloud cloud, List<Plane> planes,  double tol = 0.001, bool project = false) {

            bool[] flags = new bool[cloud.Count];
            int[] cID = new int[cloud.Count];

          

            int count = 1;
            foreach (Plane plane in planes) {

                   double[] eq = plane.GetPlaneEquation();
                   double denom = 1 / Math.Sqrt(eq[0] * eq[0] + eq[1] * eq[1] + eq[2] * eq[2]);


                System.Threading.Tasks.Parallel.For(0, cloud.Count, i => {
                    // for (int i = 0; i < cloud_.Count; i++) {

                    if (flags[i]) return;

                    if (Math.Abs(FastPlaneToPt(denom, eq[0], eq[1], eq[2], eq[3], cloud[i].Location)) <= tol) {
                        flags[i] = true;
                        cID[i] = count;
                    }


                });

                count++;
            }

            int cc = 0;
            List<int> idList = new List<int>();
            for (int i = 0; i < cloud.Count; i++) {
                //bool f = inverse ? !flags[i] : flags[i];
                if (flags[i]) {
                    idList.Add(i);
                    cc++;
                }
            }

            int[] idArray = idList.ToArray();
            Point3d[] points = new Point3d[cc];
            Vector3d[] normals = new Vector3d[cc];
            Color[] colors = new Color[cc];

            System.Threading.Tasks.Parallel.For(0, idArray.Length, i => {


                int id = idArray[i];
                var p = cloud[(int)id];
                points[i] = p.Location;
                normals[i] = p.Normal;
                colors[i] = p.Color;

            });

            PointCloud croppedCloud = new PointCloud();
            croppedCloud.AddRange(points, normals, colors);

            //PointCloud croppedCloud = new PointCloud();
            //for (int i = 0; i < cloud.Count; i++) {
            //    //bool f = inverse ? !flags[i] : flags[i];
            //    bool f =  flags[i];
            //    if (f) {
            //        if (cloud.ContainsNormals) {
            //            croppedCloud.Add(cloud[i].Location, cloud[i].Normal, cloud[i].Color);
            //        } else {
            //            croppedCloud.Add(cloud[i].Location, cloud[i].Color);
            //        }
            //    }
            //}


            if (project) {
               // if (planes.Count == 1) {
                    croppedCloud.Transform(Rhino.Geometry.Transform.PlanarProjection(planes[0]));
                //} else {

                //    for (int i = 0; i < cloud.Count; i++) {

                //    }
                }
                return croppedCloud;

            }

19 Source : MeshBoolean.cs
with GNU Lesser General Public License v3.0
from 9and3

protected override void SolveInstance(IGH_DataAccess DA) {

            Random random = new Random();
            //Input
            GH_Structure<GH_Mesh> B0 = new GH_Structure<GH_Mesh>();
            GH_Structure<GH_Mesh> B1 = new GH_Structure<GH_Mesh>();
            DA.GetDataTree(0, out B0);
            DA.GetDataTree(1, out B1);

            int t = 0;
            DA.GetData(2, ref t);



            double scale = 1.001;
            DA.GetData(3, ref scale);


            bool showEdges = false;
            DA.GetData(5, ref showEdges);


            var color = System.Drawing.Color.White;
            bool f = DA.GetData(4, ref color);
            if (color.R == 255 && color.G == 255 && color.B == 255) {
                f = false;
            }

            //Match trees

            var result = new DataTree<Mesh>();



            for (int i = 0; i < B0.PathCount; i++) {

                var path = B0.Paths[i];


                result.Add(B0.get_DataItem(path, 0).Value, path);
                if (!B1.PathExists(path)) continue;

                HashSet<Point3d> cylindersCenters = new HashSet<Point3d>();

  

                var nonNulls = new List<GH_Mesh>();
                foreach (var v in B1[path]) {
                    if (v != null) {
                        nonNulls.Add(v);
                    }
                }


                for (int j = 0; j < nonNulls.Count; j++) {

                    var brep = nonNulls[j].Value.DuplicateMesh();
                    brep.Transform(Rhino.Geometry.Transform.Scale(brep.GetBoundingBox(true).Center, scale));
                    Mesh mesh = brep;
                    result.Add(mesh, path);
                }

            }



            //Perform boolean
            var resultBoolean = new DataTree<Mesh>();

            for (int b = 0; b < result.BranchCount; b++) {
                GH_Path path = result.Paths[b];
                List<Mesh> m = result.Branch(path);

                //Rhino.RhinoApp.WriteLine(m.Count.ToString());
                if (m.Count == 1) {
                    Mesh mm = m[0].DuplicateMesh();
                    mm.Unweld(0, true);

                    //DA.SetDataList(0, new Mesh[] { mm });

                    //if (!f) 
                    mm.VertexColors.CreateMonotoneMesh(System.Drawing.Color.FromArgb(200, 200, 200));
                    m_.Append(mm);
                    if(showEdges)
                        l_.AddRange(MeshEdgesByAngle(mm, 0.37));
                    if (bbox_.IsValid) bbox_.Union(m_.GetBoundingBox(false)); else bbox_ = m_.GetBoundingBox(false);


                    resultBoolean.Add(mm, path);

                } else {
                    try {
                        //Mesh r = f ? PInvokeCSharp.TestLIBIGL.CreateLIBIGLMeshBoolean(m.ToArray(), t) : PInvokeCSharp.TestCGAL.CreateMeshBooleanArray(m.ToArray(), t);
                        Mesh r = f ? PInvokeCSharp.TestCGAL.CreateMeshBooleanArrayTrackColors(m.ToArray(), color,Math.Abs( t)) : PInvokeCSharp.TestCGAL.CreateMeshBooleanArray(m.ToArray(), Math.Abs(t));
                        // Mesh r = PInvokeCSharp.TestCGAL.CreateMeshBooleanArrayTrackColors(m.ToArray(), color, t) ;
                        //resultBoolean.Add(r, path);
                        if (r.IsValid) {

                            Mesh[] s = null;
                            if (t == 0 || t == 1) {
                              s = r.SplitDisjointPieces();

                                double[] a = new double[s.Length];
                                for (int i = 0; i < s.Length; i++)
                                    a[i] = s[i].GetBoundingBox(false).Diagonal.Length;

                                Array.Sort(a, s);
                            } else {
                                s = new Mesh[] { r };
                            }

                            if (!f) s[s.Length - 1].VertexColors.CreateMonotoneMesh(System.Drawing.Color.FromArgb(200, 200, 200));
                            m_.Append(s[s.Length - 1]);

                            if (showEdges)
                                l_.AddRange(MeshEdgesByAngle(s[s.Length - 1], 0.37));
                            if (bbox_.IsValid) bbox_.Union(m_.GetBoundingBox(false)); else bbox_ = m_.GetBoundingBox(false);
                            resultBoolean.Add(s[s.Length - 1], path);

                        }
                    } catch (Exception e) {
                        Rhino.RhinoApp.WriteLine(e.ToString());
                    }
                }
            }

            DA.SetDataTree(0, resultBoolean);

        }

19 Source : CloudMeshCrop.cs
with GNU Lesser General Public License v3.0
from 9and3

public PointCloud CropCloud(PointCloud cloud, List<Mesh> M, bool inverse = false) {

            RTree rTree = Rhino.Geometry.RTree.CreatePointCloudTree(cloud);

            
            bool[] flags = new bool[cloud.Count];

            for (int i = 0; i < M.Count; i++) {
                Mesh m = M[i];

                BoundingBox bBox = m.GetBoundingBox(false);
                var boxSearchData = new BoxSearchData();
                rTree.Search(bBox, BoundingBoxCallback, boxSearchData);

                foreach (int id in boxSearchData.Ids) {
              
                    if (m.IsPointInside(cloud[id].Location, 0, true)) {
                        flags[id] = true;
                    }
                }
            }


            int count = 0;
            List<int> idList = new List<int>();
            for (int i = 0; i < cloud.Count; i++) {
                bool f = inverse ? !flags[i] : flags[i];
                if (f) {
                    idList.Add(i);
                    count++;
                }
            }

            int[] idArray = idList.ToArray();
            Point3d[] points = new Point3d[count];
            Vector3d[] normals = new Vector3d[count];
            Color[] colors = new Color[count];

            System.Threading.Tasks.Parallel.For(0, idArray.Length, i => {


                int id = idArray[i];
                var p = cloud[(int)id];
                points[i] = p.Location;
                normals[i] = p.Normal;
                colors[i] = p.Color;

            });

            PointCloud croppedCloud = new PointCloud();
            croppedCloud.AddRange(points, normals, colors);


            //for (int i = 0; i < f.Length; i++) {
            //    bool flag = inverse ? !f[i] : f[i];
            //    if (flag)
            //        if (cloud.ContainsNormals) {
            //            c.Add(cloud[i].Location, cloud[i].Normal, cloud[i].Color);
            //        } else {
            //            c.Add(cloud[i].Location, cloud[i].Color);
            //        }
            //}

            return croppedCloud;

        }

19 Source : CloudPolygonCrop.cs
with GNU Lesser General Public License v3.0
from 9and3

public PointCloud CropCloud(PointCloud cloud, List<Curve> curves, bool inverse = false, double scale = 1e10, double tol = 0.001) {

            bool[] flags = new bool[cloud.Count];

       

            foreach (Curve crv in curves) {

                bool f = crv.TryGetPolyline(out Polyline polyline_); if (!f) continue;


                PointCloud cloud_ = new PointCloud(cloud);


                Polyline polyline = new Polyline(polyline_);
                Plane plane;
                Plane.FitPlaneToPoints(polyline, out plane);
                Transform xform = Transform.PlaneToPlane(plane, Plane.WorldXY);

                polyline.Transform(xform);
                cloud_.Transform(xform);
                var input = Geometry.RhinClip.PolylineToIntPoint(polyline, scale);

                System.Threading.Tasks.Parallel.For(0, cloud.Count, i => {
                    // for (int i = 0; i < cloud_.Count; i++) {

                    if (flags[i]) return;

                    Point3d p = new Point3d(cloud_[i].Location);
                    var inputP = new IntPoint(p.X * scale, p.Y * scale);

                    bool flag = Clipper642.Clipper.PointInPolygon(inputP, input) != 0;//;: Clipper642.Clipper.PointInPolygon(inputP, input) == 0;
                    if (flag)
                        flags[i] = true;
                    // }
                });



            }


            int count = 0;
            List<int> idList = new List<int>();
            //System.Threading.Tasks.Parallel.For(0, cloud.Count, i => {
                for (int i = 0; i < cloud.Count; i++) {
                    bool f = inverse ? !flags[i] : flags[i];
                    if (f) {
                        idList.Add(i);
                        count++;
                    }
                }
            //});

            int[] idArray = idList.ToArray();
            Point3d[] points = new Point3d[count];
            Vector3d[] normals = new Vector3d[count];
            Color[] colors = new Color[count];

            System.Threading.Tasks.Parallel.For(0, idArray.Length, i => {


                int id = idArray[i];
                var p = cloud[(int)id];
                points[i] = p.Location;
                normals[i] = p.Normal;
                colors[i] = p.Color;

            });

            PointCloud croppedCloud = new PointCloud();
            croppedCloud.AddRange(points, normals, colors);

            //PointCloud croppedCloud = new PointCloud();
            //for (int i = 0; i < cloud.Count; i++) {
            //    bool f = inverse ? !flags[i] : flags[i];
            //    if (f) {
            //        if (cloud.ContainsNormals) {
            //            croppedCloud.Add(cloud[i].Location, cloud[i].Normal, cloud[i].Color);
            //        } else {
            //            croppedCloud.Add(cloud[i].Location, cloud[i].Color);
            //        }
            //    }
            //}
            return croppedCloud;

        }

19 Source : ReaderHelper.cs
with GNU General Public License v3.0
from 9vult

public static Chapter[] SortChapters(List<Chapter> aList)
        {
            Chapter[] items = aList.ToArray();
            // Get the numeric values of the items.
            int num_items = items.Length;
            const string float_pattern = @"-?\d+\.?\d*";
            double[] values = new double[num_items];
            for (int i = 0; i < num_items; i++)
            {
                string match = Regex.Match(items[i].GetNum(), float_pattern).Value;
                if (!double.TryParse(match, out double value))
                    value = double.MinValue;
                values[i] = value;
            }

            // Sort the items array using the keys to determine order.
            Array.Sort(values, items);
            return items;
        }

19 Source : ReaderHelper.cs
with GNU General Public License v3.0
from 9vult

public static Page[] SortPages(List<Page> aList)
        {
            Page[] items = aList.ToArray();

            // Get the numeric values of the items.
            int num_items = items.Length;
            const string float_pattern = @"-?\d+\.?\d*";
            double[] values = new double[num_items];
            for (int i = 0; i < num_items; i++)
            {
                string match = Regex.Match(items[i].GetID(), float_pattern).Value;
                if (!double.TryParse(match, out double value))
                    value = double.MinValue;
                values[i] = value;
            }

            // Sort the items array using the keys to determine order.
            Array.Sort(values, items);
            return items;
        }

19 Source : KissManga.cs
with GNU General Public License v3.0
from 9vult

public override Chapter[] GetSetPrunedChapters(bool overrideDlc)
        {
            chapters.Clear();
            
            List<Chapter> result = new List<Chapter>();

            String[] dlc = GetDLChapters();
            bool doFullSetup;

            if (!overrideDlc)
            {
                doFullSetup = true;
            }
            else // override
            {
                doFullSetup = false;
            }

            foreach (string chapterUrl in KissMangaHelper.GetChapterUrls(KissMangaHelper.KISS_URL + "/manga/" + mangaRoot.Name))
            {
                string[] urlSplits = chapterUrl.Split('/');
                string chapID = urlSplits[urlSplits.Length - 1];
                string chapNum = chapID.Substring(8); // remove "chapter_"
                if ((!doFullSetup) || (doFullSetup && dlc == null) || (doFullSetup && dlc[0].Equals("-1")) || (doFullSetup && dlc.Contains(chapNum)))
                {                    
                    DirectoryInfo chapDir = null; // Only create folder if doing full setup
                    if (doFullSetup)
                        chapDir = FileHelper.CreateFolder(mangaRoot, chapID);
                    Chapter newchapter = new Chapter(chapDir, chapID, chapNum, doFullSetup);
                    chapters.Add(newchapter);
                    result.Add(newchapter);
                }
            }

            chapters = result;
            return result.ToArray();
        }

19 Source : KissManga.cs
with GNU General Public License v3.0
from 9vult

public override Chapter[] GetUpdates()
        {
            List<Chapter> result = new List<Chapter>();

            String[] dlc = GetDLChapters();
            bool doFullSetup = true;

            foreach (string chapterUrl in KissMangaHelper.GetChapterUrls(KissMangaHelper.KISS_URL + "/manga/" + mangaRoot.Name))
            {
                string[] urlSplits = chapterUrl.Split('/');
                string chapID = urlSplits[urlSplits.Length - 1];
                string chapNum = chapID.Substring(8); // remove "chapter_"
                if ((!doFullSetup) || (doFullSetup && dlc == null) || (doFullSetup && dlc[0].Equals("-1")) || (doFullSetup && dlc.Contains(chapNum)))
                {
                    if (!Directory.Exists(Path.Combine(mangaRoot.FullName, chapID)))
                    {
                        DirectoryInfo chapDir = FileHelper.CreateFolder(mangaRoot, chapID);
                        Chapter newchapter = new Chapter(chapDir, chapID, chapNum, doFullSetup);
                        chapters.Add(newchapter);
                        result.Add(newchapter);
                    }
                }
            }

            return result.ToArray();
        }

19 Source : KissMangaHelper.cs
with GNU General Public License v3.0
from 9vult

public static string[] GetChapterUrls(string mUrl)
        {
            var doreplacedent = new HtmlWeb().Load(mUrl);
            string[] urls = doreplacedent.DoreplacedentNode.Descendants("a")
                            .Select(e => e.GetAttributeValue("href", null))
                            .Where(s => !string.IsNullOrEmpty(s)).ToArray<string>();

            List<string> chapterUrls = new List<string>();

            foreach (string url in urls)
            {
                if (url.StartsWith("/chapter/"))
                {
                    chapterUrls.Add(url);
                }
            }

            chapterUrls.Reverse(); // Switch to increasing (1->2)

            return chapterUrls.ToArray();
        }

19 Source : KissMangaHelper.cs
with GNU General Public License v3.0
from 9vult

public static string[] GetPageUrls(string cUrl)
        {
            var doreplacedent = new HtmlWeb().Load(cUrl);
            string[] urls = doreplacedent.DoreplacedentNode.Descendants("img")
                            .Select(e => e.GetAttributeValue("src", null))
                            .Where(s => !string.IsNullOrEmpty(s)).ToArray<string>();

            List<string> pageUrls = new List<string>();

            foreach (string url in urls)
            {
                if (!url.Contains("/static/"))
                {
                    pageUrls.Add(url);
                }
            }

            return pageUrls.ToArray();
        }

19 Source : MangaDex.cs
with GNU General Public License v3.0
from 9vult

public override Chapter[] GetUpdates()
        {
            List<Chapter> result = new List<Chapter>();
            string jsonText = MangaDexHelper.GetMangaJSON(MangaDexHelper.GetMangaUrl(GetID()));
            JObject jobj = JObject.Parse(jsonText);

            String[] dlc = GetDLChapters();
            bool doFullSetup = true;

            foreach (JProperty p in jobj["chapter"])
            {
                JToken value = p.Value;
                if (value.Type == JTokenType.Object)
                {
                    JObject o = (JObject)value;
                    string chapNum = (String)o["chapter"];
                    if (usergroup == "^any-group")
                    {
                        if (((string)o["lang_code"]).Equals(userlang))
                        {
                            if ((!doFullSetup) || (doFullSetup && dlc == null) || (doFullSetup && dlc[0].Equals("-1")) || (doFullSetup && dlc.Contains(chapNum)))
                            {
                                string chapID = ((JProperty)value.Parent).Name;
                                if (!Directory.Exists(Path.Combine(mangaRoot.FullName, chapID)))
                                {
                                    DirectoryInfo chapDir = FileHelper.CreateFolder(mangaRoot, chapID);
                                    Chapter newchapter = new Chapter(chapDir, chapID, chapNum, doFullSetup);
                                    chapters.Add(newchapter);
                                    result.Add(newchapter);
                                }
                            }
                        }
                    }
                    else
                    {
                        if (((string)o["lang_code"]).Equals(userlang) && ((string)o["group_name"]).Equals(usergroup))
                        {
                            // Console.WriteLine(chapNum);
                            string chapID = ((JProperty)value.Parent).Name;
                            if (!Directory.Exists(Path.Combine(mangaRoot.FullName, chapID)))
                            {
                                if ((!doFullSetup) || (doFullSetup && dlc == null) || (doFullSetup && dlc[0].Equals("-1")) || (doFullSetup && dlc.Contains(chapNum)))
                                {
                                    DirectoryInfo chapDir = FileHelper.CreateFolder(mangaRoot, chapID);
                                    Chapter newchapter = new Chapter(chapDir, chapID, chapNum, doFullSetup);
                                    chapters.Add(newchapter);
                                    result.Add(newchapter);
                                }
                            }
                        }
                    }
                    
                }
            }
            return result.ToArray();
        }

19 Source : MangaDex.cs
with GNU General Public License v3.0
from 9vult

public override string[] GetGroups(string langCode)
        {
            List<string> result = new List<string>();
            string jsonText = MangaDexHelper.GetMangaJSON(MangaDexHelper.GetMangaUrl(GetID()));
            JObject jobj = JObject.Parse(jsonText);

            foreach (JProperty p in jobj["chapter"])
            {
                JToken value = p.Value;
                if (value.Type == JTokenType.Object)
                {
                    JObject o = (JObject)value;
                    if (((string)o["lang_code"]).Equals(langCode))
                    {
                        string groupName = (String)o["group_name"];
                        if (!result.Contains(groupName))
                        {
                            result.Add(groupName);
                        }
                    }
                }
            }
            return result.ToArray();
        }

19 Source : MangaDex.cs
with GNU General Public License v3.0
from 9vult

public override string[] GetLangs()
        {
            List<string> result = new List<string>();
            string jsonText = MangaDexHelper.GetMangaJSON(MangaDexHelper.GetMangaUrl(GetID()));
            JObject jobj = JObject.Parse(jsonText);

            foreach (JProperty p in jobj["chapter"])
            {
                JToken value = p.Value;
                if (value.Type == JTokenType.Object)
                {
                    JObject o = (JObject)value;
                    string langCode = (string)o["lang_code"];
                    if (!result.Contains(langCode))
                    {
                        result.Add(langCode);
                    }
                }
            }
            return result.ToArray();
        }

19 Source : FrmChapterSelect.cs
with GNU General Public License v3.0
from 9vult

private void BtnDone_Click(object sender, EventArgs e)
        {
            DialogResult result = MessageBox.Show("Altering chapter downloads will disable the Update Chapters feature for this replacedle.\n" +
                                                    "If you wish to revert this decision in the future, use the Default button.\n\n" +
                                                    "Proceed?", "Are you sure?", MessageBoxButtons.YesNo, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button2);
            if (result == DialogResult.Yes)
            {
                List<string> selected = new List<string>();
                foreach (object item in lstChapters.CheckedItems)
                {
                    selected.Add(item.ToString());
                }

                ReturnValue = selected.ToArray();
                this.DialogResult = DialogResult.OK;
                this.Close();
            }            
        }

19 Source : MangaDex.cs
with GNU General Public License v3.0
from 9vult

public override Chapter[] GetSetPrunedChapters(bool overrideDlc)
        {
            chapters.Clear();
            List<Chapter> result = new List<Chapter>();
            string jsonText = MangaDexHelper.GetMangaJSON(id);
            JObject jobj = JObject.Parse(jsonText);

            String[] dlc = GetDLChapters();
            bool doFullSetup;

            if (!overrideDlc)
            {
                doFullSetup = true;
            }
            else // override
            {
                doFullSetup = false;
            }

            foreach (JProperty p in jobj["chapter"])
            {
                JToken value = p.Value;
                if (value.Type == JTokenType.Object)
                {
                    JObject o = (JObject)value;
                    string chapNum = (String)o["chapter"];
                    if (usergroup == "^any-group")
                    {
                        if (((string)o["lang_code"]).Equals(userlang))
                        {
                            if ((!doFullSetup) || (doFullSetup && dlc == null) || (doFullSetup && dlc[0].Equals("-1")) || (doFullSetup && dlc.Contains(chapNum)))
                            {
                                string chapID = ((JProperty)value.Parent).Name;
                                DirectoryInfo chapDir = null; // Only create folder if doing full setup
                                if (doFullSetup)
                                    chapDir = FileHelper.CreateFolder(mangaRoot, chapID);
                                Chapter newchapter = new Chapter(chapDir, chapID, chapNum, doFullSetup);
                                chapters.Add(newchapter);
                                result.Add(newchapter);
                            }
                        }
                    }
                    else
                    {
                        if (((string)o["lang_code"]).Equals(userlang) && ((string)o["group_name"]).Equals(usergroup))
                        {
                            if ((!doFullSetup) || (doFullSetup && dlc == null) || (doFullSetup && dlc[0].Equals("-1")) || (doFullSetup && dlc.Contains(chapNum)))
                            {
                                string chapID = ((JProperty)value.Parent).Name;
                                DirectoryInfo chapDir = FileHelper.CreateFolder(mangaRoot, chapID);
                                Chapter newchapter = new Chapter(chapDir, chapID, chapNum, doFullSetup);
                                chapters.Add(newchapter);
                                result.Add(newchapter);
                            }
                        }
                    }

                }
            }
            chapters = result;
            return result.ToArray(); 
        }

19 Source : FsmUtil.cs
with GNU General Public License v3.0
from a2659802

public static FsmState CopyState(PlayMakerFSM fsm, string stateName, string newState)
        {
            var state = new FsmState(fsm.GetState(stateName)) {Name = newState};

            List<FsmState> fsmStates = fsm.FsmStates.ToList();
            fsmStates.Add(state);
            fsm.Fsm.States = fsmStates.ToArray();

            return state;
        }

19 Source : SkeletonModifierPropertyDrawer.cs
with Apache License 2.0
from A7ocin

public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
        {
            int startingIndent = EditorGUI.indentLevel;
            EditorGUI.BeginProperty(position, label, property);
            var valR = new Rect(position.xMin, position.yMin, position.width, EditorGUIUtility.singleLineHeight);
            string betterLabel = label.text;
            if (property.FindPropertyRelative("property").enumDisplayNames[property.FindPropertyRelative("property").enumValueIndex] != "")
            {
                betterLabel += " (" + property.FindPropertyRelative("property").enumDisplayNames[property.FindPropertyRelative("property").enumValueIndex] + ")";
            }
            List<string> boneNames = new List<string>();
            if (bonesInSkeleton != null)
            {
                boneNames = new List<string>(bonesInSkeleton);
            }
            else
            {
                boneNames = new List<string>(hashNames);
            }
            string thisHashName = property.FindPropertyRelative("hashName").stringValue;
            int hashNameIndex = boneNames.IndexOf(thisHashName);
            if (hashNameIndex == -1 && bonesInSkeleton != null)
            {
                boneNames.Insert(0, thisHashName + " (missing)");
                hashNameIndex = 0;
                var warningRect = new Rect((valR.xMin), valR.yMin, 20f, valR.height);
                var warningIconGUI = new GUIContent("", thisHashName + " was not a bone in the Avatars Skeleton. Please choose another bone for this modifier or delete it.");
                warningIconGUI.image = warningIcon;
                betterLabel += " (missing)";
                GUI.Label(warningRect, warningIconGUI, warningStyle);
            }
            property.isExpanded = EditorGUI.Foldout(valR, property.isExpanded, betterLabel, true);
            if (property.isExpanded)
            {
                EditorGUI.indentLevel++;
                valR = new Rect(valR.xMin, valR.yMax + padding, valR.width, EditorGUIUtility.singleLineHeight);
                if (boneNames.Count > 0)
                {
                    int newHashNameIndex = hashNameIndex;
                    EditorGUI.BeginChangeCheck();
                    newHashNameIndex = EditorGUI.Popup(valR, "Hash Name", hashNameIndex, boneNames.ToArray());
                    if (EditorGUI.EndChangeCheck())
                    {
                        if (newHashNameIndex != hashNameIndex)
                        {
                            property.FindPropertyRelative("hashName").stringValue = boneNames[newHashNameIndex];
                            property.FindPropertyRelative("hash").intValue = UMAUtils.StringToHash(boneNames[newHashNameIndex]);
                            property.serializedObject.ApplyModifiedProperties();
                        }
                    }
                }
                else
                {
                    EditorGUI.PropertyField(valR, property.FindPropertyRelative("hashName"));
                }
                valR = new Rect(valR.xMin, valR.yMax + padding, valR.width, EditorGUIUtility.singleLineHeight);
                EditorGUI.PropertyField(valR, property.FindPropertyRelative("property"));
                valR = new Rect(valR.xMin, valR.yMax + padding, valR.width, EditorGUIUtility.singleLineHeight);
                var valXR = valR;
                var valYR = valR;
                var valZR = valR;
                valXR.width = valYR.width = valZR.width = valR.width / 3;
                valYR.x = valYR.x + valXR.width;
                valZR.x = valZR.x + valXR.width + valYR.width;
                SerializedProperty subValsToOpen = null;
                var valuesX = property.FindPropertyRelative("valuesX");
                var valuesY = property.FindPropertyRelative("valuesY");
                var valuesZ = property.FindPropertyRelative("valuesZ");
                if (valuesX.isExpanded)
                {
                    var valXRB = valXR;
                    valXRB.x = valXRB.x + (EditorGUI.indentLevel * 10f);
                    valXRB.width = valXRB.width - (EditorGUI.indentLevel * 10f);
                    EditorGUI.DrawRect(valXRB, new Color32(255, 255, 255, 100));
                }
                valuesX.isExpanded = EditorGUI.Foldout(valXR, valuesX.isExpanded, "ValuesX", true);
                if (valuesX.isExpanded)
                {
                    valuesY.isExpanded = false;
                    valuesZ.isExpanded = false;
                    subValsToOpen = valuesX;
                }
                if (valuesY.isExpanded)
                {
                    EditorGUI.DrawRect(valYR, new Color32(255, 255, 255, 100));
                }
                valuesY.isExpanded = EditorGUI.Foldout(valYR, valuesY.isExpanded, "ValuesY", true);
                if (valuesY.isExpanded)
                {
                    valuesX.isExpanded = false;
                    valuesZ.isExpanded = false;
                    subValsToOpen = valuesY;
                }
                if (valuesZ.isExpanded)
                {
                    EditorGUI.DrawRect(valZR, new Color32(255, 255, 255, 100));
                }
                valuesZ.isExpanded = EditorGUI.Foldout(valZR, valuesZ.isExpanded, "ValuesZ", true);
                if (valuesZ.isExpanded)
                {
                    valuesX.isExpanded = false;
                    valuesY.isExpanded = false;
                    subValsToOpen = valuesZ;
                }
                if (subValsToOpen != null)
                {
                    valR = new Rect(valR.xMin, valR.yMax + padding + 4f, valR.width, EditorGUIUtility.singleLineHeight);
                    valR.width = valR.width - 30;
                    var boxR1 = valR;
                    boxR1.x = boxR1.x + EditorGUI.indentLevel * 10f;
                    boxR1.y = boxR1.y - 6;
                    boxR1.height = boxR1.height + 12;
                    //topbox
                    EditorGUI.DrawRect(boxR1, new Color32(255, 255, 255, 100));
                    var valSXR = valR;
                    var valSYR = valR;
                    var valSZR = valR;
                    valSXR.width = valSYR.width = valSZR.width = valR.width / 3;
                    valSYR.x = valSYR.x + valSXR.width;
                    valSZR.x = valSZR.x + valSXR.width + valSYR.width;
                    var subValuesVal = subValsToOpen.FindPropertyRelative("val");
                    var subValuesMin = subValsToOpen.FindPropertyRelative("min");
                    var subValuesMax = subValsToOpen.FindPropertyRelative("max");
                    var valSXRF = valSXR;
                    valSXRF.x = valSXRF.x + 38f;
                    valSXRF.width = valSXRF.width - 35f;
                    if (!enableSkelModValueEditing) EditorGUI.BeginDisabledGroup(true);
                    EditorGUI.LabelField(valSXR, "Value");
                    subValuesVal.FindPropertyRelative("value").floatValue = EditorGUI.FloatField(valSXRF, subValuesVal.FindPropertyRelative("value").floatValue);
                    subValuesVal.serializedObject.ApplyModifiedProperties();
                    if (!enableSkelModValueEditing) EditorGUI.EndDisabledGroup();
                    var valSYRF = valSYR;
                    valSYRF.x = valSYRF.x + 30f;
                    valSYRF.width = valSYRF.width - 30f;
                    EditorGUI.LabelField(valSYR, "Min");
                    subValuesMin.floatValue = EditorGUI.FloatField(valSYRF, subValuesMin.floatValue);
                    var valSZRF = valSZR;
                    valSZRF.x = valSZRF.x + 30f;
                    valSZRF.width = valSZRF.width - 30f;
                    EditorGUI.LabelField(valSZR, "Max");
                    subValuesMax.floatValue = EditorGUI.FloatField(valSZRF, subValuesMax.floatValue);
                    var thisModifiersProp = subValuesVal.FindPropertyRelative("modifiers");
                    var modifiersi = thisModifiersProp.arraySize;
                    valR = new Rect(valR.xMin, valR.yMax + padding + 4f, valR.width, EditorGUIUtility.singleLineHeight);
                    var boxR = valR;
                    boxR.y = boxR.y - 2f;
                    boxR.x = boxR.x + EditorGUI.indentLevel * 10f;
                    boxR.height = boxR.height + 6f + ((EditorGUIUtility.singleLineHeight + padding) * (modifiersi + 1));
                    //bottombox
                    EditorGUI.DrawRect(boxR, new Color32(255, 255, 255, 100));
                    EditorGUI.LabelField(valR, "Value Modifiers");
                    for (int i = 0; i < modifiersi; i++)
                    {
                        valR = new Rect(valR.xMin, valR.yMax + padding, valR.width, EditorGUIUtility.singleLineHeight);
                        var propsR = valR;
                        propsR.width = valR.width;
                        var valRBut = new Rect((propsR.width + 35f), valR.y, 20f, EditorGUIUtility.singleLineHeight);
                        thisSpValDrawer.OnGUI(propsR, thisModifiersProp.GetArrayElementAtIndex(i), new GUIContent(""));
                        if (GUI.Button(valRBut, "X"))
                        {
                            thisModifiersProp.DeleteArrayElementAtIndex(i);
                        }
                    }
                    var addBut = new Rect(valR.xMin, valR.yMax + padding, valR.width, EditorGUIUtility.singleLineHeight);
                    addBut.x = addBut.xMax - 35f;
                    addBut.width = 60f;
                    if (GUI.Button(addBut, "Add"))
                    {
                        thisModifiersProp.InsertArrayElementAtIndex(modifiersi);
                    }
                    thisModifiersProp.serializedObject.ApplyModifiedProperties();
                }

            }
            EditorGUI.indentLevel = startingIndent;
            EditorGUI.EndProperty();
        }

19 Source : SkeletonModifierPropertyDrawer.cs
with Apache License 2.0
from A7ocin

public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
        {
            int startingIndent = EditorGUI.indentLevel;
            EditorGUI.BeginProperty(position, label, property);
            var valR = new Rect(position.xMin, position.yMin, position.width, EditorGUIUtility.singleLineHeight);
            var ddOne = valR;
            var ddTwo = valR;
            ddOne.width = valR.width / 2f + ((EditorGUI.indentLevel - 1) * 10);
            ddTwo.width = valR.width / 2f - ((EditorGUI.indentLevel - 1) * 10);
            ddTwo.x = ddTwo.x + ddOne.width;
            var modifieri = property.FindPropertyRelative("modifier").enumValueIndex;
            EditorGUI.PropertyField(ddOne, property.FindPropertyRelative("modifier"), new GUIContent(""));
            EditorGUI.indentLevel = 0;
            if (modifieri > 3)
            {
                string currentVal = property.FindPropertyRelative("DNATypeName").stringValue;
                if (dnaNames == null || dnaNames.Length == 0)
                {
                    //If there are no names show a field with the dna name in it with a warning tooltip
                    EditorGUI.BeginDisabledGroup(true);
                    EditorGUI.LabelField(ddTwo, new GUIContent(property.FindPropertyRelative("DNATypeName").stringValue, "You do not have any DNA Names set up in your DNA replacedet. Add some names for the Skeleton Modifiers to use."), EditorStyles.textField);
                    EditorGUI.EndDisabledGroup();
                }
                else
                {
                    int selectedIndex = -1;
                    List<GUIContent> niceDNANames = new List<GUIContent>();
                    niceDNANames.Add(new GUIContent("None"));
                    bool missing = currentVal != "";
                    for (int i = 0; i < dnaNames.Length; i++)
                    {
                        niceDNANames.Add(new GUIContent(dnaNames[i]));
                        if (dnaNames[i] == currentVal)
                        {
                            selectedIndex = i;
                            missing = false;
                        }
                    }
                    if (missing)
                    {
                        niceDNANames[0].text = currentVal+" (missing)";
                        niceDNANames[0].tooltip = currentVal+ " was not in the DNAreplacedets names list. This modifier wont do anything until you change the dna name it uses or you add this name to your DNA replacedet names.";
                    }
                    int newSelectedIndex = selectedIndex == -1 ? 0 : selectedIndex + 1;
                    EditorGUI.BeginChangeCheck();
                    newSelectedIndex = EditorGUI.Popup(ddTwo, newSelectedIndex,  niceDNANames.ToArray());
                    if (EditorGUI.EndChangeCheck())
                    {
                        //if its actually changed
                        if (newSelectedIndex != selectedIndex + 1)
                        {
                            if (newSelectedIndex == 0)
                            {
                                if(niceDNANames[0].text.IndexOf("(missing) ") < 0)
                                    property.FindPropertyRelative("DNATypeName").stringValue = "";
                            }
                            else
                            {
                                property.FindPropertyRelative("DNATypeName").stringValue = dnaNames[newSelectedIndex - 1];
                            }
                        }
                    }
                }
            }
            else
            {
                EditorGUI.PropertyField(ddTwo, property.FindPropertyRelative("modifierValue"), new GUIContent(""));
            }
            EditorGUI.indentLevel = startingIndent;
            EditorGUI.EndProperty();
        }

19 Source : GridAcademy.cs
with Apache License 2.0
from A7ocin

public void SetEnvironment()
    {
        trueAgent = GameObject.Find("trueAgent");
        List<string> playersList = new List<string>();
        actorObjs = new List<GameObject>();
        for (int i = 0; i < (int)resetParameters["numObstacles"]; i++)
        {
            playersList.Add("pit");
        }
        playersList.Add("agent");

        for (int i = 0; i < (int)resetParameters["numGoals"]; i++)
        {
            playersList.Add("goal");
        }
        players = playersList.ToArray();
        Camera cam = GameObject.Find("Main Camera").GetComponent<Camera>();

        cam.transform.position = new Vector3(-((int)resetParameters["gridSize"] - 1) / 2f, (int)resetParameters["gridSize"] * 1.25f, -((int)resetParameters["gridSize"] - 1) / 2f);
        cam.orthographicSize = ((int)resetParameters["gridSize"] + 5f) / 2f;
        GameObject.Find("Plane").transform.localScale = new Vector3((int)resetParameters["gridSize"] / 10.0f, 1f, (int)resetParameters["gridSize"] / 10.0f);
        GameObject.Find("Plane").transform.position = new Vector3(((int)resetParameters["gridSize"] - 1) / 2f, -0.5f, ((int)resetParameters["gridSize"] - 1) / 2f);
        GameObject.Find("sN").transform.localScale = new Vector3(1, 1, (int)resetParameters["gridSize"] + 2);
        GameObject.Find("sS").transform.localScale = new Vector3(1, 1, (int)resetParameters["gridSize"] + 2);
        GameObject.Find("sN").transform.position = new Vector3(((int)resetParameters["gridSize"] - 1) / 2f, 0.0f, (int)resetParameters["gridSize"]);
        GameObject.Find("sS").transform.position = new Vector3(((int)resetParameters["gridSize"] - 1) / 2f, 0.0f, -1);
        GameObject.Find("sE").transform.localScale = new Vector3(1, 1, (int)resetParameters["gridSize"] + 2);
        GameObject.Find("sW").transform.localScale = new Vector3(1, 1, (int)resetParameters["gridSize"] + 2);
        GameObject.Find("sE").transform.position = new Vector3((int)resetParameters["gridSize"], 0.0f, ((int)resetParameters["gridSize"] - 1) / 2f);
        GameObject.Find("sW").transform.position = new Vector3(-1, 0.0f, ((int)resetParameters["gridSize"] - 1) / 2f);
        Camera aCam = GameObject.Find("agentCam").GetComponent<Camera>();
        aCam.orthographicSize = ((int)resetParameters["gridSize"]) / 2f;
        aCam.transform.position = new Vector3(((int)resetParameters["gridSize"] - 1) / 2f, (int)resetParameters["gridSize"] + 1f, ((int)resetParameters["gridSize"] - 1) / 2f);

    }

19 Source : DynamicCharacterSystem.cs
with Apache License 2.0
from A7ocin

public void RefreshRaceKeys()
		{
			if (!initialized)
			{
				Init();
				return;
			}
			if (addAllRecipesFromDownloadedBundles)
			{
				Refresh(false, "");
				return;
			}
			var possibleRaces = (context.raceLibrary as DynamicRaceLibrary).GetAllRacesBase();
			for (int i = 0; i < possibleRaces.Length; i++)
			{
				if (!Recipes.ContainsKey(possibleRaces[i].raceName) && possibleRaces[i].raceName != "RaceDataPlaceholder")
				{
					Recipes.Add(possibleRaces[i].raceName, new Dictionary<string, List<UMATextRecipe>>());
				}
				//then make sure any currently added recipes are also replacedigned to this race if they are compatible
				foreach (string race in Recipes.Keys)
				{
					if (race != possibleRaces[i].raceName)
					{
						foreach (KeyValuePair<string, List<UMATextRecipe>> kp in Recipes[race])
						{
							AddRecipes(kp.Value.ToArray());
						}
					}
				}
			}
		}

19 Source : UMAAssetIndexer.cs
with Apache License 2.0
from A7ocin

void ISerializationCallbackReceiver.OnAfterDeserialize()
        {
            var st = StartTimer();
            #region typestuff
            List<System.Type> newTypes = new List<System.Type>()
        {
        (typeof(SlotDatareplacedet)),
        (typeof(OverlayDatareplacedet)),
        (typeof(RaceData)),
        (typeof(UMATextRecipe)),
        (typeof(UMAWardrobeRecipe)),
        (typeof(UMAWardrobeCollection)),
        (typeof(RuntimeAnimatorController)),
#if UNITY_EDITOR
        (typeof(AnimatorController)),
#endif
        (typeof(DynamireplacedADnareplacedet)),
        (typeof(Textreplacedet))
        };

            TypeToLookup = new Dictionary<System.Type, System.Type>()
        {
        { (typeof(SlotDatareplacedet)),(typeof(SlotDatareplacedet)) },
        { (typeof(OverlayDatareplacedet)),(typeof(OverlayDatareplacedet)) },
        { (typeof(RaceData)),(typeof(RaceData)) },
        { (typeof(UMATextRecipe)),(typeof(UMATextRecipe)) },
        { (typeof(UMAWardrobeRecipe)),(typeof(UMAWardrobeRecipe)) },
        { (typeof(UMAWardrobeCollection)),(typeof(UMAWardrobeCollection)) },
        { (typeof(RuntimeAnimatorController)),(typeof(RuntimeAnimatorController)) },
#if UNITY_EDITOR
        { (typeof(AnimatorController)),(typeof(RuntimeAnimatorController)) },
#endif
        {  typeof(Textreplacedet), typeof(Textreplacedet) },
        { (typeof(DynamireplacedADnareplacedet)), (typeof(DynamireplacedADnareplacedet)) }
        };

            List<string> invalidTypeNames = new List<string>();
            // Add the additional Types.
            foreach (string s in IndexedTypeNames)
            {
                if (s == "")
                    continue;
                System.Type sType = System.Type.GetType(s);
                if (sType == null)
                {
                    invalidTypeNames.Add(s);
                    Debug.LogWarning("Could not find type for " + s);
                    continue;
                }
                newTypes.Add(sType);
                if (!TypeToLookup.ContainsKey(sType))
                {
                    TypeToLookup.Add(sType, sType);
                }
            }

            Types = newTypes.ToArray();

            if (invalidTypeNames.Count > 0)
            {
                foreach (string ivs in invalidTypeNames)
                {
                    IndexedTypeNames.Remove(ivs);
                }
            }
            BuildStringTypes();
            #endregion
            UpdateSerializedDictionaryItems();
            StopTimer(st, "Before Serialize");
        }

See More Examples