Ejemplo n.º 1
0
 public IHairType GetType(string str)
 {
     return(GetType(Hashing.FNV1Hash(str)));
 }
Ejemplo n.º 2
0
            public void Read(BinaryReader reader)
            {
                try
                {
                    MemoryStream currentReader = new MemoryStream(reader.ReadBytes((int)reader.BaseStream.Length));
                    XDocument    document      = XDocument.Load(currentReader);
                    XElement     root          = document.Element("root");

                    if (root != null)
                    {
                        XElement dashesElement = root.Element("dashes");
                        if (dashesElement != null)
                        {
                            foreach (XElement dashCountElement in dashesElement.Elements("dash"))
                            {
                                XAttribute dashAttr = dashCountElement.Attribute("count");
                                if (dashAttr != null)
                                {
                                    int dash = (int)dashAttr;
                                    if (dash < Hyperline.MAX_DASH_COUNT)
                                    {
                                        XElement hairLengthElement = dashCountElement.Element("hairLength");
                                        if (hairLengthElement != null)
                                        {
                                            hairLengthList[dash] = (int)hairLengthElement;
                                            if (hairLengthList[dash] > HyperlineSettings.MAX_HAIR_LENGTH || hairLengthList[dash] < HyperlineSettings.MIN_HAIR_LENGTH)
                                            {
                                                hairLengthList[dash] = 4;
                                            }
                                        }
                                        else
                                        {
                                            Logger.Log(LogLevel.Warn, "Hyperline", "Hyperline settings XML missing dash hair length element.");
                                        }

                                        XElement hairSpeedElement = dashCountElement.Element("hairSpeed");
                                        if (hairSpeedElement != null)
                                        {
                                            hairSpeedList[dash] = (int)hairSpeedElement;
                                            if (hairSpeedList[dash] > HyperlineSettings.MAX_HAIR_SPEED || hairSpeedList[dash] < HyperlineSettings.MIN_HAIR_SPEED)
                                            {
                                                hairSpeedList[dash] = 0;
                                            }
                                        }
                                        else
                                        {
                                            Logger.Log(LogLevel.Warn, "Hyperline", "Hyperline settings XML missing dash hair speed element.");
                                        }

                                        XElement hairBangsElement = dashCountElement.Element("bangsTexture");
                                        if (hairBangsElement != null)
                                        {
                                            hairBangsSource[dash] = (string)hairBangsElement;
                                        }
                                        XElement hairTextureElement = dashCountElement.Element("hairTexture");
                                        if (hairTextureElement != null)
                                        {
                                            hairTextureSource[dash] = (string)hairTextureElement;
                                        }

                                        string   chosenType      = SolidHair.id;
                                        XElement hairTypeElement = dashCountElement.Element("type");
                                        if (hairTypeElement != null)
                                        {
                                            chosenType = (string)hairTypeElement;
                                        }
                                        else
                                        {
                                            Logger.Log(LogLevel.Warn, "Hyperline", "Hyperline settings XML missing dash hair type element.");
                                        }
                                        if (Hyperline.Instance.hairTypes.Has(Hashing.FNV1Hash(chosenType)))
                                        {
                                            hairTypeList[dash] = Hashing.FNV1Hash(chosenType);
                                        }

                                        XElement tp = dashCountElement.Element("types");
                                        if (tp != null)
                                        {
                                            foreach (XElement currentType in tp.Elements())
                                            {
                                                uint type = Hashing.FNV1Hash(currentType.Name.LocalName);
                                                try
                                                {
                                                    IHairType hair = Hyperline.Instance.hairTypes.CreateNewHairType(type);
                                                    if (hair != null)
                                                    {
                                                        hair.Read(currentType);
                                                        hairList[dash][type] = hair;
                                                    }
                                                    else
                                                    {
                                                        Logger.Log(LogLevel.Warn, "Hyperline", "Hyperline contained invalid hair type " + currentType.Name);
                                                    }
                                                }
                                                catch (Exception exception)
                                                {
                                                    Logger.Log(LogLevel.Warn, "Hyperline", "Exception occured while loading hair type " + currentType.Name.LocalName + " dash count " + dash + "\n" + exception);
                                                }
                                            }
                                        }
                                        else
                                        {
                                            Logger.Log(LogLevel.Warn, "Hyperline", "XML file missing types for dash count " + dash);
                                        }
                                    }
                                }
                            }
                        }
                        else
                        {
                            Logger.Log(LogLevel.Warn, "Hyperline", "Hyperline settings XML missing dashs element.");
                        }
                    }
                    else
                    {
                        Logger.Log(LogLevel.Warn, "Hyperline", "Hyperline settings XML missing root element.");
                    }
                }
                catch (Exception exception)
                {
                    Logger.Log(LogLevel.Error, "Hyperline", "Error while loading save file...\n" + exception.ToString());
                }
            }
Ejemplo n.º 3
0
        public IHairType CreateNewHairType(string str)
        {
            uint id = Hashing.FNV1Hash(str);

            return(CreateNewHairType(id));
        }