示例#1
0
        public string GetPlacedModels()
        {
            if (!CanFitModels())
            {
                LogManager.Log("VmfZoo: Can not fit models with specified offsets");
                throw new Exception($"Can't fit models with current offsets! {_inLineOffset} {_betweenLineOffset}");
            }

            List <VmfModel> list          = _vmfModels.ToList();
            StringBuilder   stringBuilder = new StringBuilder();

            // in Source Z axis is up, so Y and Z are swapped
            Vector3 position    = new Vector3(MinMapDimensionValue, MinMapDimensionValue, 0);
            int     index       = 0;
            bool    passedHalfY = false;
            bool    passedHalfX = false;

            LogManager.Log("VmfZoo: Placing models");
            for (position.Y = MinMapDimensionValue; position.Y <= MaxMapDimensionValue; position.Y += _betweenLineOffset)
            {
                if (!passedHalfY && position.Y > 0)
                {
                    passedHalfY = true;
                }
                for (position.X = MinMapDimensionValue; position.X <= MaxMapDimensionValue; position.X += _inLineOffset)
                {
                    if (!passedHalfX && position.X > 0)
                    {
                        passedHalfX = true;
                    }
                    if (index >= list.Count)
                    {
                        if (!passedHalfX)
                        {
                            LogManager.Log("VmfZoo: Warning! Did not passed half of X axis (pretty normal for user offset)!");
                        }
                        if (!passedHalfY)
                        {
                            LogManager.Log("VmfZoo: Warning! Did not passed half of Y axis (pretty normal for user offset)!");
                        }
                        return(stringBuilder.ToString());
                    }

                    LogManager.Log($"VmfZoo: Prop #{index} {position.X} {position.Y} {position.Z}");
                    VmfModel model = list[index];
                    stringBuilder.Append(model.ToStringWithOriginAndNumber(position, index));
                    index++;
                }
            }

            // wtf
            LogManager.Log($"VmfZoo: Warning! Prop placing loops ended by themselves");
            Console.WriteLine(
                "Something strange happened: writing loops ended by themselves, not by \"return\" condition. Result might be corrupted or not full.");
            return(stringBuilder.ToString());
        }
示例#2
0
        private static IEnumerable <VmfModel> FindModels(string fileContent, out List <string> corruptedModels)
        {
            List <VmfModel> models = new List <VmfModel>();

            corruptedModels = new List <string>();

            const string regex = "(entity(\r|\n|\r\n|\n\r)|hidden)";

            MatchCollection matches = Regex.Matches(fileContent, regex, RegexOptions.None, TimeSpan.FromMinutes(5.0));

            for (int i = 0; i < matches.Count; i++)
            {
                Match match = matches[i];
                // if some entity found
                if (match.Value.Contains("entity"))
                {
                    // check if it is not hidden
                    if (i - 1 < 0 || !matches[i - 1].Value.Contains("hidden"))
                    {
                        // check if it static prop
                        int entityValueStartIndex = match.Index;
                        int entityValueEndIndex   =
                            i + 1 >= matches.Count ? fileContent.Length - 1 : matches[i + 1].Index;
                        string entityContent = fileContent.Substring(entityValueStartIndex,
                                                                     entityValueEndIndex - entityValueStartIndex);
                        try
                        {
                            if (entityContent.Contains("prop_static"))
                            {
                                // yep this is static prop
                                VmfModel model = new VmfModel(entityContent);
                                models.Add(model);
                            }
                        }
                        catch (Exception)
                        {
                            corruptedModels.Add(entityContent);
                        }
                    }
                }
            }

            return(models);
        }
示例#3
0
 protected bool Equals(VmfModel other)
 {
     return(Name == other.Name);
 }