How to use the oni-save-parser.LIST_TYPES.indexOf function in oni-save-parser

To help you get started, we’ve selected a few oni-save-parser examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github RoboPhred / oni-duplicity / src / services / save-structure / structure / gameObjects / behaviors / default.ts View on Github external
template.fields.find(x => x.name === part) ||
        template.properties.find(x => x.name === part);
      if (!member) {
        break;
      }

      const typeInfo: TypeInfo = member.type;
      const code = getTypeCode(typeInfo.info);

      if (code === SerializationTypeCode.UserDefined) {
        template = templates.find(x => x.name === typeInfo.templateName);
        if (template == null) {
          // Unknown template.
          return null;
        }
      } else if (LIST_TYPES.indexOf(code) !== -1) {
        i++;

        if (
          getTypeCode(typeInfo.subTypes![0].info) ===
          SerializationTypeCode.UserDefined
        ) {
          const arrayTypeInfo = typeInfo.subTypes![0];
          template = templates.find(x => x.name === arrayTypeInfo.templateName);
          if (template == null) {
            // Unknown template.
            return null;
          }
        }
      } else if (code === SerializationTypeCode.Dictionary) {
        i++;
        if (
github RoboPhred / oni-duplicity / src / pages / SaveEditor / components / editors / TemplateObjectEditor / derived-state.ts View on Github external
const member =
        template.fields.find(x => x.name === part) ||
        template.properties.find(x => x.name === part);
      if (!member) {
        return null;
      }

      typeInfo = member.type;

      const typeCode = getTypeCode(typeInfo.info);

      if (typeCode === SerializationTypeCode.UserDefined) {
        template = oniSave.templates.find(
          x => x.name === member.type.templateName!
        );
      } else if (LIST_TYPES.indexOf(typeCode) !== -1) {
        i++;
        if (i === templatePath.length) {
          // Targeting an array but no index yet.
          break;
        }

        if (
          getTypeCode(typeInfo.subTypes![0].info) ===
          SerializationTypeCode.UserDefined
        ) {
          typeInfo = typeInfo.subTypes![0];
          template = oniSave.templates.find(
            x => x.name === typeInfo.templateName
          );
        }
      } else if (typeCode === SerializationTypeCode.Dictionary) {