public DsgVarEditableEntry(OpenSpace.ROM.DsgVarInfo.Entry modelEntry, List <OpenSpace.ROM.DsgMemInfo> currentEntries)
 {
     this.entryROM      = modelEntry;
     this.entriesMemROM = currentEntries;
     if (modelEntry != null)
     {
         valueModel = new Value(modelEntry.value);
     }
     if (currentEntries.Count > 0)
     {
         if (DsgVarInfoEntry.GetDsgVarTypeFromArrayType(modelEntry.value.dsgVarType) != DsgVarInfoEntry.DsgVarType.None)
         {
             // Check for array
             valueInitial = new Value(modelEntry.value.dsgVarType, modelEntry.value.ValueArrayLength);
             for (int i = 0; i < currentEntries.Count; i++)
             {
                 if (currentEntries[i].value.paramEntry == null)
                 {
                     continue;                                              // Skip this, it just redefines the array anyway
                 }
                 ushort arrayIndex = currentEntries[i].value.paramEntry.Value.index_in_array;
                 valueInitial.AsArray[arrayIndex] = new Value(currentEntries[i].value);
             }
         }
         else
         {
             // Not an array
             valueInitial = new Value(currentEntries[0].value);
         }
         //List<OpenSpace.ROM.DsgMemInfo> entriesNoArray = currentEntries.Where(e => e.value.paramEntry == null || e.value.paramEntry.Value == null).ToList();
     }
 }
            public void InitValue(OpenSpace.ROM.DsgVarValue value)
            {
                this.type = value.dsgVarType;

                if (DsgVarInfoEntry.GetDsgVarTypeFromArrayType(type) != DsgVarInfoEntry.DsgVarType.None)
                {
                    AsArray = new Value[value.ValueArrayLength];
                    for (int i = 0; i < AsArray.Length; i++)
                    {
                        AsArray[i] = null;
                    }
                }
            }
 public DsgVarEditableEntry(DsgVarInfoEntry entry, DsgVarValue current, DsgVarValue initial, DsgVarValue model)
 {
     this.entry = entry;
     if (current != null)
     {
         valueCurrent = new Value(current);
     }
     if (initial != null)
     {
         valueInitial = new Value(initial);
     }
     if (model != null)
     {
         valueModel = new Value(model);
     }
 }
Example #4
0
    void CellGUI(Rect cellRect, TreeViewItem <DsgVarsTreeElement> item, Columns column, ref RowGUIArgs args)
    {
        // Center cell rect vertically (makes it easier to place controls, icons etc in the cells)
        CenterRectUsingSingleLineHeight(ref cellRect);
        switch (column)
        {
        case Columns.Icon:
            DsgVarType type = item.data.entry.Type;
            if (item.data.arrayIndex.HasValue)
            {
                type = DsgVarInfoEntry.GetDsgVarTypeFromArrayType(type);
            }
            if (icons.ContainsKey(type))
            {
                GUI.Label(cellRect, icons[type], CenteredLabel);
            }
            break;

        case Columns.Name:
            if (item.data.arrayIndex.HasValue)
            {
                Rect  indentedRect = cellRect;
                float indentValue  = Mathf.Min(10f, indentedRect.width);
                indentedRect.x     += indentValue;
                indentedRect.width -= indentValue;
                GUI.Label(indentedRect, new GUIContent("[" + item.data.arrayIndex.Value + "]"), EditorStyles.miniLabel);
            }
            else
            {
                GUI.Label(cellRect, new GUIContent(item.data.entry.Name), EditorStyles.miniLabel);
            }
            break;

        case Columns.CurrentValue:
            DsgVarComponentEditor.DrawDsgVarCurrent(cellRect, item.data.entry, item.data.arrayIndex);
            break;

        case Columns.InitialValue:
            DsgVarComponentEditor.DrawDsgVarInitial(cellRect, item.data.entry, item.data.arrayIndex);
            break;

        case Columns.ModelValue:
            DsgVarComponentEditor.DrawDsgVarModel(cellRect, item.data.entry, item.data.arrayIndex);
            break;
        }
    }
Example #5
0
        public EDsgVar GetExportableDsgVar(DsgMem dsgMem, DsgVar dsgVar, int infoIndex)
        {
            DsgVarInfoEntry infoEntry = dsgVar.dsgVarInfos[infoIndex];
            EDsgVar         d         = new EDsgVar();

            d.type = infoEntry.type;

            if (dsgMem.values == null || dsgMem.values[infoIndex] == null)
            {
                return(d);
            }
            DsgVarValue val = dsgMem.values[infoIndex];

            d.value = GetExportableDsgVarValueString(val);

            return(d);
        }
Example #6
0
    private WebJSON.DsgVar GetDsgVarJSON(DsgVarComponent.DsgVarEditableEntry dsg)
    {
        bool isArray = dsg.IsArray;

        WebJSON.DsgVar dsgObj = new WebJSON.DsgVar()
        {
            Name      = dsg.Name,
            Type      = dsg.Type,
            IsArray   = isArray,
            ArrayType = isArray ? (DsgVarInfoEntry.DsgVarType?)DsgVarInfoEntry.GetDsgVarTypeFromArrayType(dsg.Type) : null,
                            ArrayLength  = isArray ? (int?)dsg.ArrayLength : null,
                            ValueCurrent = GetDsgVarValueJSON(dsg.valueCurrent, isArray),
                            ValueInitial = GetDsgVarValueJSON(dsg.valueInitial, isArray),
                            ValueModel   = GetDsgVarValueJSON(dsg.valueModel, isArray)
        };
        return(dsgObj);
    }
Example #7
0
            public DsgVarEditableEntry(int number, DsgVarInfoEntry entry)
            {
                this.number = number;
                this.entry  = entry;
                //print(entry.typeNumber + " - " + entry.type + " - " + entry.debugValueOffset + " - " + entry.value);

                switch (entry.type)
                {
                case DsgVarInfoEntry.DsgVarType.Boolean: this.valueAsBool = (bool)entry.value;  break;

                case DsgVarInfoEntry.DsgVarType.Int:     this.valueAsInt = (int)entry.value;  break;

                case DsgVarInfoEntry.DsgVarType.UInt:    this.valueAsUInt = (uint)entry.value;  break;

                case DsgVarInfoEntry.DsgVarType.Short:   this.valueAsShort = (short)entry.value;  break;

                case DsgVarInfoEntry.DsgVarType.UShort:  this.valueAsUShort = (ushort)entry.value;  break;

                case DsgVarInfoEntry.DsgVarType.Byte:    this.valueAsSByte = (sbyte)entry.value;  break;

                case DsgVarInfoEntry.DsgVarType.UByte:   this.valueAsByte = (byte)entry.value;  break;

                case DsgVarInfoEntry.DsgVarType.Float:   this.valueAsFloat = (float)entry.value;  break;

                case DsgVarInfoEntry.DsgVarType.Vector:  this.valueAsVector = (Vector3)entry.value;  break;

                case DsgVarInfoEntry.DsgVarType.Text:    this.valueAsUInt = (uint)entry.value;  break;

                case DsgVarInfoEntry.DsgVarType.Perso:
                    if (entry.value != null && entry.value is Pointer)
                    {
                        Perso perso = MapLoader.Loader.persos.FirstOrDefault(p => (p.SuperObject != null && p.SuperObject.offset == (Pointer)entry.value));   // find perso that belongs to the superobject
                        if (perso != null)
                        {
                            this.valueAsPersoGao = perso.Gao;
                        }
                    }
                    break;

                case DsgVarInfoEntry.DsgVarType.SuperObject:
                    if (entry.value != null)
                    {
                        SuperObject spo = MapLoader.Loader.superObjects.FirstOrDefault(p => (p.offset != null && p.offset == (Pointer)entry.value));
                        if (spo != null)
                        {
                            this.valueAsSuperObjectGao = spo.Gao;
                        }
                    }
                    break;

                case DsgVarInfoEntry.DsgVarType.Waypoint:

                    if (entry.value != null)
                    {
                        WayPoint wp = null;
                        if (entry.value is Pointer)
                        {
                            wp = WayPoint.FromOffset(entry.value as Pointer);
                            //wp = (WayPoint)entry.value;
                        }

                        if (wp != null)
                        {
                            this.valueAsWaypointGao = wp.Gao;
                        }
                    }
                    break;
                }

                if (entry.initialValue != null)
                {
                    switch (entry.type)
                    {
                    case DsgVarInfoEntry.DsgVarType.Boolean: this.valueAsBool_initial = (bool)entry.initialValue;         break;

                    case DsgVarInfoEntry.DsgVarType.Int:     this.valueAsInt_initial = (int)entry.initialValue;          break;

                    case DsgVarInfoEntry.DsgVarType.UInt:    this.valueAsUInt_initial = (uint)entry.initialValue;         break;

                    case DsgVarInfoEntry.DsgVarType.Short:   this.valueAsShort_initial = (short)entry.initialValue;        break;

                    case DsgVarInfoEntry.DsgVarType.UShort:  this.valueAsUShort_initial = (ushort)entry.initialValue;       break;

                    case DsgVarInfoEntry.DsgVarType.Byte:    this.valueAsSByte_initial = (sbyte)entry.initialValue;        break;

                    case DsgVarInfoEntry.DsgVarType.UByte:   this.valueAsByte_initial = (byte)entry.initialValue;         break;

                    case DsgVarInfoEntry.DsgVarType.Float:   this.valueAsFloat_initial = (float)entry.initialValue;        break;

                    case DsgVarInfoEntry.DsgVarType.Vector:  this.valueAsVector_initial = (Vector3)entry.initialValue;      break;

                    case DsgVarInfoEntry.DsgVarType.Text:    this.valueAsUInt_initial = (uint)entry.initialValue;       break;

                    case DsgVarInfoEntry.DsgVarType.Perso:
                        if (entry.initialValue != null)
                        {
                            Perso perso = MapLoader.Loader.persos.FirstOrDefault(p => p.SuperObject.offset == (Pointer)entry.initialValue);
                            if (perso != null)
                            {
                                this.valueAsPersoGao_initial = perso.Gao;
                            }
                        }
                        break;

                    case DsgVarInfoEntry.DsgVarType.SuperObject:
                        if (entry.initialValue != null)
                        {
                            SuperObject spo = MapLoader.Loader.superObjects.FirstOrDefault(p => p.offset == (Pointer)entry.initialValue);
                            if (spo != null)
                            {
                                this.valueAsSuperObjectGao_initial = spo.Gao;
                            }
                        }
                        break;

                    case DsgVarInfoEntry.DsgVarType.Waypoint:

                        if (entry.initialValue != null)
                        {
                            WayPoint wp = null;
                            if (entry.initialValue is Pointer)
                            {
                                wp = WayPoint.FromOffset(entry.initialValue as Pointer);
                                //wp = (WayPoint)entry.initialValue;
                            }

                            if (wp != null)
                            {
                                this.valueAsWaypointGao_initial = wp.Gao;
                            }
                        }
                        break;
                    }
                }
            }
Example #8
0
        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);
        }
    // Update is called once per frame
    void Update()
    {
        if (raymanGAO == null)
        {
            GameObject[] gameObjects = FindObjectsOfType(typeof(GameObject)) as GameObject[];

            foreach (GameObject gao in gameObjects)
            {
                if (gao.name.Contains("YLT_RaymanModel"))
                {
                    raymanGAO = gao;
                    break;
                }
            }
        }
        else
        {
            DsgVarComponent dsgVarComponent = raymanGAO.GetComponent <DsgVarComponent>();
            if (dsgVarComponent != null)
            {
                DsgVarInfoEntry vector38Entry = null;
                DsgVarInfoEntry vector40Entry = null;

                if (Settings.s.game == Settings.Game.R2)
                {
                    vector38Entry = dsgVarComponent.dsgVarEntries[38];
                    vector40Entry = dsgVarComponent.dsgVarEntries[40];
                }
                else if (Settings.s.game == Settings.Game.R3)
                {
                    return;

                    /*vector38Entry = dsgVarComponent.dsgVarEntries[38];
                    *  vector40Entry = dsgVarComponent.dsgVarEntries[40];*/
                }

                Vector3 vector38_xzy = (Vector3)vector38Entry.value;
                Vector3 vector40_xzy = (Vector3)vector40Entry.value;

                Vector3 vector38 = new Vector3(vector38_xzy.x, vector38_xzy.z, vector38_xzy.y);
                Vector3 vector40 = new Vector3(vector40_xzy.x, vector40_xzy.z, vector40_xzy.y);

                Vector3 raymanVec = raymanGAO.transform.position;
                Vector3 dir       = (vector40) - (raymanVec);
                Vector3 dirFlat   = new Vector3(dir.x, 0, dir.z);

                for (float i = -0.05f; i <= 0.05f; i += 0.02f)
                {
                    for (float j = -0.05f; j <= 0.05f; j += 0.02f)
                    {
                        Vector3 o = new Vector3(i, 0, j);

                        Debug.DrawRay(vector38 + o, new Vector3(0, -0.9f, 0), Color.red);
                        Debug.DrawRay(vector38 + o, new Vector3(-1f, 0, 0), Color.red);
                        Debug.DrawRay(vector38 + o, new Vector3(1f, 0, 0), Color.red);
                        Debug.DrawRay(vector38 + o, new Vector3(0f, 0, -1f), Color.red);
                        Debug.DrawRay(vector38 + o, new Vector3(0f, 0, 1f), Color.red);

                        Debug.DrawRay(vector40 + o, new Vector3(0, -0.9f, 0), Color.blue);
                        Debug.DrawRay(vector40 + o, new Vector3(-1f, 0, 0), Color.blue);
                        Debug.DrawRay(vector40 + o, new Vector3(1f, 0, 0), Color.blue);
                        Debug.DrawRay(vector40 + o, new Vector3(0f, 0, -1f), Color.blue);
                        Debug.DrawRay(vector40 + o, new Vector3(0f, 0, 1f), Color.blue);


                        Debug.DrawRay(raymanVec + o, dir, Color.blue);
                        Debug.DrawRay(raymanVec + o, dirFlat, Color.blue);
                    }
                }
            }
        }

        //Debug.draw
    }