How to use the oni-save-parser.Accessory 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 / reducer / behaviors / set-accessory.ts View on Github external
return produceFromBehavior(state, AccessorizerBehavior, behavior => {
    const { accessoryName, accessoryType } = action.payload;
    const { accessories } = behavior.templateData;

    const accessoryIndex = getIndexOfAccessoryType(accessories, accessoryType);

    if (accessoryName === null) {
      // Remove
      accessories.splice(accessoryIndex, 1);
      return;
    }

    const newAccessory = Accessory(accessoryName);

    if (accessoryIndex === -1) {
      // Add
      accessories.push(newAccessory);
    } else {
      // Replace
      accessories[accessoryIndex] = newAccessory;
    }
  });
}
github RoboPhred / oni-duplicity / src / pages / DuplicantEditorPage / components / DuplicantEditor / components / Appearance / Appearance.tsx View on Github external
const accessoryMod: Record = {
      [index]: Accessory(`${type}_${padStart(String(ordinal), 3, "0")}`)
    };
    if (type === "hair") {
      const hatHair = getIndexOfAccessoryType(accessories, "hat_hair");
      if (hatHair !== -1) {
        accessoryMod[hatHair] = Accessory(
          `hat_hair_${padStart(String(ordinal), 3, "0")}`
        );
      }
      const hairAlways = getIndexOfAccessoryType(
        accessories,
        "hair_always"
      );
      if (hairAlways !== -1) {
        accessoryMod[hairAlways] = Accessory(
          `hair_always_${padStart(String(ordinal), 3, "0")}`
        );
      }
    }
    if (type === "body") {
      const arm = getIndexOfAccessoryType(accessories, "arm");
      accessoryMod[arm] = Accessory(
        `arm_${padStart(String(ordinal), 3, "0")}`
      );
    }
    onTemplateDataModify({
      accessories: merge([], accessories, accessoryMod)
    });
  }