public JsmGroup(ushort executionOrder, ushort label, byte scriptsCount, JsmModuleType type) { ExecutionOrder = executionOrder; Label = label; ScriptsCount = scriptsCount; Type = type; }
private JsmGroup ReadJsmGroup(BinaryReader br, ushort index, JsmModuleType type) { ushort group = br.ReadUInt16(); ushort label = (ushort)(group >> 7); byte count = (byte)((group & 0x7F) + 1); return(new JsmGroup(index, label, count, type)); }
public void IncrementCount(JsmModuleType type) { switch (type) { case JsmModuleType.Area: CountAreas++; break; case JsmModuleType.Door: CountDoors++; break; case JsmModuleType.Module: CountModules++; break; case JsmModuleType.Object: CountObjects++; break; } }
public bool ReadScripts(Location location) { if (_root == null) { return(false); } XmlElement node = _root["Scripts"]; if (node == null) { return(false); } if (!node.GetBoolean("IsExists")) { return(true); } string scriptsFile = Path.ChangeExtension(_xmlPath, ".sct"); if (!File.Exists(scriptsFile)) { return(false); } using (Stream input = new FileStream(scriptsFile, FileMode.Open, FileAccess.Read, FileShare.Read)) using (BinaryReader br = new BinaryReader(input, Encoding.UTF8)) { string magicNumber = br.ReadString(); if (magicNumber != "FF8S") { throw Exceptions.CreateException("Неверное магическое число: '{0}'", magicNumber); } int groupsCount = br.ReadInt32(); AsmModule previousModule = null; AsmCollection groups = new AsmCollection(groupsCount); for (ushort g = 0; g < groupsCount; g++) { ushort executionOrder = br.ReadUInt16(); ushort label = br.ReadUInt16(); string title = br.ReadString(); JsmModuleType type = (JsmModuleType)br.ReadInt32(); int scriptsCount = br.ReadInt32(); AsmModule module = AsmModuleFactory.Create(type); module.Index = g; module.ExecutionOrder = executionOrder; module.Label = label; module.Title = title; module.PreviousModule = previousModule; if (previousModule != null) { previousModule.NextModule = module; } previousModule = module; groups.Add(label, module); for (int s = 0; s < scriptsCount; s++) { string scriptLabel = br.ReadString(); int operationsCount = br.ReadInt32(); AsmEvent script = new AsmEvent(module, operationsCount) { Label = (ushort)(label + s + 1), Title = scriptLabel }; module.SetEventByIndex(s, script); for (int o = 0; o < operationsCount; o++) { JsmOperation operation = new JsmOperation(br.ReadUInt32()); script.Add(operation); } } } location.Scripts = groups; } location.SaveRequest &= ~LocationProperty.Scripts; location.Importable |= LocationProperty.Scripts; return(true); }
public AsmModule(JsmModuleType type) { Type = type; }