Ejemplo n.º 1
0
        /// <summary>
        /// Add prop script
        /// </summary>
        /// <param name="propScript"></param>
        public void Add(PointF point)
        {
            var propScript = new PropScriptInfo();

            propScript.X = point.X;
            propScript.Y = point.Y;
            Props.Add(propScript);

            AddedPropScript?.Invoke(this, propScript);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Load existing nflavor script
        /// </summary>
        /// <param name="buffer"></param>
        public void Load(byte[] buffer)
        {
            try
            {
                using (BinaryReader b = new BinaryReader(new MemoryStream(buffer)))
                {
                    Sign    = Encoding.Default.GetString(b.ReadBytes(16));
                    Version = b.ReadInt32();

#if DEBUG == false
                    if (!SupportedVersion.Contains(Version))
                    {
                        XLog.WriteLine(Levels.Error, $"Failed");
                        XLog.WriteLine(Levels.Fatal, "NfsManager::Load<Version> -> Incompatible version {0} is not supported", Version);
                        return;
                    }
#endif

                    /* nfs.dwEventLocationOffset = */
                    b.ReadInt32();
                    /* nfs.dwEventScriptOffset = */ b.ReadInt32();
                    /* nfs.dwPropScriptOffset = */ b.ReadInt32();

                    var nLocationCount = b.ReadInt32();
                    Respawns = new List <Location>();

                    for (int i = 0; i < nLocationCount; i++)
                    {
                        var location = new Location();
                        location.Left   = b.ReadInt32();
                        location.Top    = b.ReadInt32();
                        location.Right  = b.ReadInt32();
                        location.Bottom = b.ReadInt32();
                        var stringSize = b.ReadInt32();
                        location.Description = Encoding.Default.GetString(b.ReadBytes(stringSize));
                        Respawns.Add(location);
                    }

                    var nScriptCount = b.ReadInt32();

                    for (int i = 0; i < nScriptCount; i++)
                    {
                        var index          = b.ReadInt32();
                        var nFunctionCount = b.ReadInt32();

                        for (int f = 0; f < nFunctionCount; f++)
                        {
                            var function = new Function();
                            /* function.nTrigger = */ b.ReadInt32();
                            var nStringSize = b.ReadInt32();
                            function.FunctionString = Encoding.Default.GetString(b.ReadBytes(nStringSize));
                            Respawns[index].Scripts.Add(function);
                        }
                    }

                    var nPropCount = b.ReadInt32();
                    Props = new List <PropScriptInfo>();

                    for (int i = 0; i < nPropCount; i++)
                    {
                        var propScript = new PropScriptInfo();
                        propScript.PropId  = b.ReadInt32();
                        propScript.X       = b.ReadSingle();
                        propScript.Y       = b.ReadSingle();
                        propScript.ModelId = b.ReadInt16();
                        var nFunctionCount = b.ReadInt32();

                        for (int f = 0; f < nFunctionCount; f++)
                        {
                            var function = new Function();
                            /* function.nTrigger = */ b.ReadInt32();
                            var nStringSize = b.ReadInt32();
                            function.FunctionString = Encoding.Default.GetString(b.ReadBytes(nStringSize));
                            propScript.Scripts.Add(function);
                        }

                        Props.Add(propScript);
                    }
                }

                XLog.WriteLine(Levels.Good, "Ok");
            }
            catch (Exception exception)
            {
                Blank();
                XLog.WriteLine(Levels.Error, "Failed");
                XLog.WriteLine(Levels.Fatal, "NfsManager::Load<Exception> -> {0}", exception);
            }
        }