예제 #1
0
    void OnValidate()
    {
        if (!prefab)
        {
            string[] guids = AssetDatabase.FindAssets("Item t:GameObject", new[] { "Assets/Prefabs" }).ToArray();
            guids = guids.Select(guid => AssetDatabase.GUIDToAssetPath(guid)).ToArray();
            guids = guids.Where(path2 => path2.EndsWith("/Item.prefab")).ToArray();
            string path = guids.FirstOrDefault();
            if (path != null)
            {
                prefab = AssetDatabase.LoadAssetAtPath <Item>(path);
            }
        }

        ScriptableObjectMasterList masterList = ScriptableObjectMasterList.LoadAsset();

        if (!masterList)
        {
            return;
        }

        if (!masterList.items.Any(item => item && item.itemName == itemName))
        {
            masterList.items = masterList.items.Append(this);
        }

        MachineInfo[] machineInfos = masterList.machines;
        MachineAnalysis.CalculateProfit(machineInfos, new HashSet <MachineInfo>());
        machineInfos.SetDirty();

        EditorUtility.SetDirty(this);
        EditorUtility.SetDirty(masterList);
    }
예제 #2
0
    public void ValidateProgressionId()
    {
        ScriptableObjectMasterList masterList = ScriptableObjectMasterList.LoadAsset();

        if (masterList && masterList.progressionInfos.Count(progressionInfo => progressionInfo.progressionId == progressionId) > 1)
        {
            progressionId = masterList.nextProgressionId++;
            EditorUtility.SetDirty(this);
            EditorUtility.SetDirty(masterList);
        }
    }
예제 #3
0
    void OnValidate()
    {
        ScriptableObjectMasterList masterList = ScriptableObjectMasterList.LoadAsset();

        if (!masterList)
        {
            return;
        }

        if (!masterList.catalogItemInfos.Contains(this))
        {
            masterList.catalogItemInfos = masterList.catalogItemInfos.Append(this);
            EditorUtility.SetDirty(masterList);
        }

        EditorUtility.SetDirty(this);
    }
예제 #4
0
    void OnValidate()
    {
        ScriptableObjectMasterList masterList = ScriptableObjectMasterList.LoadAsset();

        if (!masterList)
        {
            return;
        }

        if (!masterList.progressionInfos.Contains(this))
        {
            masterList.progressionInfos = masterList.progressionInfos.Append(this);
            masterList.progressionInfos = masterList.progressionInfos.Where(progressionInfo => progressionInfo).ToArray();
            EditorUtility.SetDirty(masterList);
        }

        ValidateProgressionId();
    }
예제 #5
0
    void OnValidate()
    {
        assemblers = assemblers.Where(machine => machine).ToArray();
        purchasers = purchasers.Where(machine => machine).ToArray();
        sellers    = sellers.Where(machine => machine).ToArray();
        BuildMembersArray();

        ScriptableObjectMasterList masterList = ScriptableObjectMasterList.LoadAsset();

        if (masterList)
        {
            if (!masterList.machineGroups.Contains(this))
            {
                masterList.machineGroups = masterList.machineGroups.Append(this);
            }

            masterList.machineGroups = masterList.machineGroups.OrderBy(machineInfo => machineInfo.groupOrder != 0 ? machineInfo.groupOrder : float.MaxValue).ToArray();

            EditorUtility.SetDirty(masterList);
        }
        EditorUtility.SetDirty(this);
    }
예제 #6
0
    void OnValidate()
    {
        if (!sprite)
        {
            string[] guids = AssetDatabase.FindAssets("Machine t:Sprite", new[] { "Assets/MaterialTextures" }).ToArray();
            guids = guids.Select(guid => AssetDatabase.GUIDToAssetPath(guid)).ToArray();
            guids = guids.Where(path2 => path2.EndsWith("/Machine.psd")).ToArray();
            string path = guids.FirstOrDefault();
            if (path != null)
            {
                sprite = AssetDatabase.LoadAssetAtPath <Sprite>(path);
            }
        }

        ScriptableObjectMasterList masterList = ScriptableObjectMasterList.LoadAsset();

        if (!masterList)
        {
            return;
        }

        if (!masterList.machines.Any(machine => machine.machineName == machineName))
        {
            masterList.machines = masterList.machines.Append(this);
            EditorUtility.SetDirty(masterList);
        }

        if (machineGroup)
        {
            if (assembler && !machineGroup.assemblers.Contains(this))
            {
                machineGroup.assemblers = machineGroup.assemblers.Append(this).ToArray();
            }
            if (purchaseItem.itemInfo != null && !machineGroup.purchasers.Contains(this))
            {
                machineGroup.purchasers = machineGroup.purchasers.Append(this).ToArray();
            }
            if (sellItem.itemInfo != null && !machineGroup.sellers.Contains(this))
            {
                machineGroup.sellers = machineGroup.sellers.Append(this).ToArray();
            }

            machineGroup.BuildMembersArray();
            EditorUtility.SetDirty(machineGroup);
        }
        else
        {
            for (int i = 0, len = masterList.machineGroups.Length; i < len; i++)
            {
                MachineGroupInfo machineGroup = masterList.machineGroups[i];
                if (machineGroup.members.Contains(this))
                {
                    if (machineGroup.assemblers.Contains(this))
                    {
                        machineGroup.assemblers = machineGroup.assemblers.Except(this).ToArray();
                    }
                    if (machineGroup.purchasers.Contains(this))
                    {
                        machineGroup.purchasers = machineGroup.purchasers.Except(this).ToArray();
                    }
                    if (machineGroup.sellers.Contains(this))
                    {
                        machineGroup.sellers = machineGroup.sellers.Except(this).ToArray();
                    }
                    machineGroup.BuildMembersArray();
                    EditorUtility.SetDirty(machineGroup);
                }
            }
        }

        MachineInfo[] machineInfos = masterList.machines;
        MachineAnalysis.CalculateProfit(machineInfos, new HashSet <MachineInfo>());
        machineInfos.SetDirty();

        EditorUtility.SetDirty(this);
    }