Ejemplo n.º 1
0
    void SavePartsToFile()
    {
        var partData = new WeaponPartData[weaponParts.Count];

        for (int i = 0; i < partData.Length; i++)
        {
            partData[i] = new WeaponPartData();
            partData[i].partShortCode = weaponParts[i].stortCode;
            partData[i].level         = weaponParts[i].level;
            partData[i].quality       = weaponParts[i].quality.index;
        }

        SaveToFile(partData, "parts");
    }
Ejemplo n.º 2
0
    public WeaponData GetWeaponData(ModularWeapon weapon)
    {
        var weaponData = new WeaponData
        {
            weaponName = weapon.weaponName
        };

        var wpd = new WeaponPartData();

        weaponData.rootPart = wpd;

        SavePart(ref wpd, weapon.bodySlot.part);

        return(weaponData);
    }
Ejemplo n.º 3
0
    void SavePart(ref WeaponPartData wpd, WeaponPart part)
    {
        if (part == null)
        {
            wpd.partShortCode = "";
            return;
        }

        wpd.partShortCode = part.stortCode;
        wpd.level         = part.level;
        wpd.quality       = part.quality.index;
        wpd.dataParts     = new WeaponPartData[part.slots.Length];

        for (int i = 0; i < part.slots.Length; i++)
        {
            wpd.dataParts[i] = new WeaponPartData();
            SavePart(ref wpd.dataParts[i], part.slots[i].part);
        }
    }
Ejemplo n.º 4
0
    void LoadPart(ref WeaponPartSlot slot, WeaponPartData wpd)
    {
        if (wpd.partShortCode == "")
        {
            return;
        }

        var loadedPart = WeaponParts.GetPart(wpd.partShortCode);

        loadedPart.level   = wpd.level;
        loadedPart.quality = Qualities.GetQuality(wpd.quality);

        slot.SetPart(loadedPart);

        for (int i = 0; i < wpd.dataParts.Length; i++)
        {
            var childSlot = loadedPart.slots[i];
            var childData = wpd.dataParts[i];
            LoadPart(ref childSlot, childData);
        }
    }