コード例 #1
0
ファイル: SerializedPersoData.cs プロジェクト: Zax37/raymap
        public EDsgVar GetExportableDsgVar(DsgVarInfoEntry infoEntry)
        {
            EDsgVar d = new EDsgVar();

            d.type = infoEntry.type;

            if (infoEntry.value == null)
            {
                return(d);
            }

            switch (infoEntry.type)
            {
            default:
                d.value = infoEntry.value;
                break;

            case DsgVarInfoEntry.DsgVarType.None:
                break;

            case DsgVarInfoEntry.DsgVarType.List:     // TODO: figure out lists
                break;

            case DsgVarInfoEntry.DsgVarType.Comport:     // TODO: comport
                break;

            case DsgVarInfoEntry.DsgVarType.Action:     // TODO: action
                break;

            case DsgVarInfoEntry.DsgVarType.Input:     // TODO: check if this works
                //d.value = infoEntry.value
                break;

            case DsgVarInfoEntry.DsgVarType.SoundEvent:     // TODO: check
                break;

            case DsgVarInfoEntry.DsgVarType.Light:     // TODO: check
                break;

            case DsgVarInfoEntry.DsgVarType.GameMaterial:
                d.value = HashUtils.MD5Hash(GameMaterial.FromOffset((Pointer)(infoEntry.value)).ToJSON());
                break;

            case DsgVarInfoEntry.DsgVarType.VisualMaterial:
                d.value = HashUtils.MD5Hash(VisualMaterial.FromOffset((Pointer)(infoEntry.value)).ToJSON());
                break;

            case DsgVarInfoEntry.DsgVarType.Perso:
                d.value = Perso.FromOffset((Pointer)(infoEntry.value))?.namePerso;
                break;

            case DsgVarInfoEntry.DsgVarType.Waypoint:     // TODO
                d.value = ((Pointer)infoEntry.value).ToString();
                break;

            case DsgVarInfoEntry.DsgVarType.Graph:     // TODO
                d.value = ((Pointer)infoEntry.value).ToString();
                break;

            case DsgVarInfoEntry.DsgVarType.Text:     // TODO: check
                goto default;

            case DsgVarInfoEntry.DsgVarType.SuperObject:     // TODO: check
                break;

            case DsgVarInfoEntry.DsgVarType.SOLinks:     // TODO
                break;

            case DsgVarInfoEntry.DsgVarType.PersoArray:

                List <string> persoNames = new List <string>();
                foreach (object persoPointer in (object[])infoEntry.value)
                {
                    if (persoPointer == null)
                    {
                        continue;
                    }

                    if (!(persoPointer is Pointer))
                    {
                        persoNames.Add("Not a valid pointer: " + (persoPointer).ToString());     // TODO: fix
                        continue;
                    }

                    Perso perso = Perso.FromOffset((Pointer)persoPointer);
                    if (perso != null)
                    {
                        persoNames.Add(perso.namePerso);
                    }
                    else
                    {
                        persoNames.Add("NullPointer");
                    }
                }

                break;

            case DsgVarInfoEntry.DsgVarType.WayPointArray:     // TODO
                break;

            case DsgVarInfoEntry.DsgVarType.TextArray:     // TODO: check
                goto default;

            //break;
            case DsgVarInfoEntry.DsgVarType.TextRefArray:     // TODO: check
                goto default;

            case DsgVarInfoEntry.DsgVarType.Array6:
                break;

            case DsgVarInfoEntry.DsgVarType.Array9:
                break;

            case DsgVarInfoEntry.DsgVarType.SoundEventArray:     // TODO: check
                goto default;

            case DsgVarInfoEntry.DsgVarType.Array11:
                break;

            case DsgVarInfoEntry.DsgVarType.Way:
                break;

            case DsgVarInfoEntry.DsgVarType.ActionArray:     // TODO
                break;

            case DsgVarInfoEntry.DsgVarType.SuperObjectArray:     // TODO
                break;
            }

            return(d);
        }
コード例 #2
0
ファイル: SerializedPersoData.cs プロジェクト: byvar/raymap
        public string GetExportableDsgVarValueString(DsgVarValue val)
        {
            string value = "";

            switch (val.type)
            {
            default:
                value = val.ToString();
                break;

            case DsgVarType.GameMaterial:
                value = HashUtils.MD5Hash(val.valueGameMaterial?.ToJSON());
                break;

            case DsgVarType.VisualMaterial:
                value = HashUtils.MD5Hash(val.valueVisualMaterial?.ToJSON());
                break;

            case DsgVarType.Perso:
                value = val.valuePerso?.namePerso;
                break;

            case DsgVarType.PersoArray:
                List <string> persoNames = new List <string>();
                foreach (DsgVarValue child in val.valueArray)
                {
                    Perso perso = child.valuePerso;
                    if (perso != null)
                    {
                        persoNames.Add(perso.namePerso);
                    }
                    else
                    {
                        persoNames.Add("NullPointer");
                    }
                }
                value = "{ " + string.Join(", ", persoNames) + " }";
                break;

            case DsgVarType.WayPointArray:     // TODO
                break;

            case DsgVarType.TextArray:     // TODO: check
                goto default;

            //break;
            case DsgVarType.TextRefArray:     // TODO: check
                goto default;

            case DsgVarType.GraphArray:
                break;

            case DsgVarType.SOLinksArray:
                break;

            case DsgVarType.SoundEventArray:     // TODO: check
                goto default;

            case DsgVarType.VisualMatArray:
                break;

            case DsgVarType.Way:
                break;

            case DsgVarType.ActionArray:     // TODO
                break;

            case DsgVarType.SuperObjectArray:     // TODO
                break;
            }

            return(value);
        }
コード例 #3
0
ファイル: MapExporter.cs プロジェクト: Zax37/raymap
        private void ExportFamilies(string path)
        {
            foreach (Family fam in loader.families)
            {
                string familyDirectory = Path.Combine(path, fam.name);

                if (!Directory.Exists(familyDirectory))
                {
                    Directory.CreateDirectory(familyDirectory);
                }

                string filePath = Path.Combine(familyDirectory, "Family_" + fam.name + ".json");
                if (File.Exists(filePath))
                {
                    File.Delete(filePath);
                }

                using (StreamWriter aiModelFileStream = File.CreateText(filePath)) {
                    aiModelFileStream.Write(fam.ToJSON());
                    aiModelFileStream.Flush();
                    aiModelFileStream.Close();
                }

                foreach (State state in fam.states)
                {
                    ExportState exportState = ExportState.CreateFromState(state);

                    string stateFilePath = Path.Combine(familyDirectory, "State_" + state.index + ".json");
                    if (File.Exists(stateFilePath))
                    {
                        File.Delete(stateFilePath);
                    }

                    using (StreamWriter stateFileStream = File.CreateText(stateFilePath)) {
                        stateFileStream.Write(exportState.ToJSON());
                        stateFileStream.Flush();
                        stateFileStream.Close();
                    }
                }

                foreach (ObjectList objectList in fam.objectLists)
                {
                    if (objectList == null)
                    {
                        continue;
                    }
                    string objectListJSON = objectList.ToJSON();
                    string objectListHash = HashUtils.MD5Hash(objectListJSON);

                    string objectListFilePath = Path.Combine(familyDirectory, "ObjectList_" + objectListHash + ".json");
                    if (File.Exists(objectListFilePath))
                    {
                        File.Delete(objectListFilePath);
                    }

                    using (StreamWriter aiModelFileStream = File.CreateText(objectListFilePath)) {
                        aiModelFileStream.Write(objectListJSON);
                        aiModelFileStream.Flush();
                        aiModelFileStream.Close();
                    }
                }
            }
        }