How to use the oni-save-parser.getIndexOfAccessoryType 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-editor / duplicants / appearance / reducer.ts View on Github external
behavior => {
            const oldAccessories = behavior.parsedData!.accessories;
            const accIndex = getIndexOfAccessoryType(oldAccessories, accessoryType);
            const newAccessory: Accessory = {
                guid: {
                    Guid: accessoryID
                }
            };
            let accessories: Accessory[];
            if (accIndex !== -1) {
                accessories = [
                    ...oldAccessories.slice(0, accIndex),
                    newAccessory,
                    ...oldAccessories.slice(accIndex + 1)
                ];
            }
            else {
                accessories = [
                    ...oldAccessories,
github RoboPhred / oni-duplicity / src / pages / DuplicantEditorPage / components / DuplicantEditor / components / Appearance / Appearance.tsx View on Github external
function setAccessory(type: AccessoryType, ordinal: number) {
    const index = getIndexOfAccessoryType(accessories, type);
    if (index === -1) {
      return;
    }
    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({
github RoboPhred / oni-duplicity / src / pages / SaveEditor / pages / Duplicants / pages / Appearance / component.tsx View on Github external
private _setMouth(value: string) {
        const { duplicant } = this.props;
        const accessorizer = duplicant.getBehavior(AccessorizerBehavior);
        if (!accessorizer) return;
        const accessories = accessorizer.templateData.accessories;
        const index = getIndexOfAccessoryType(accessories, "mouth");
        if (index == -1) return;
        accessories[index].guid.Guid = value;
    }
github RoboPhred / oni-duplicity / src / pages / DuplicantEditorPage / components / DuplicantEditor / components / Appearance / Appearance.tsx View on Github external
function setAccessory(type: AccessoryType, ordinal: number) {
    const index = getIndexOfAccessoryType(accessories, type);
    if (index === -1) {
      return;
    }
    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") {
github RoboPhred / oni-duplicity / src / pages / DuplicantEditorPage / components / DuplicantEditor / components / Appearance / Appearance.tsx View on Github external
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)
    });
  }