Exemplo n.º 1
0
    public void SetPerso(OpenSpace.ROM.Perso perso)
    {
        this.persoROM = perso;
        if (perso != null && perso.brain?.Value != null)
        {
            dsgMemROM = perso.brain.Value.dsgMem.Value;
            dsgVarROM = perso.brain.Value.aiModel?.Value.dsgVar?.Value;
            if (dsgVarROM?.info?.Value == null)
            {
                return;
            }
            editableEntries = new DsgVarEditableEntry[dsgVarROM.info.Value.entries.Length];

            for (int i = 0; i < editableEntries.Length; i++)
            {
                List <OpenSpace.ROM.DsgMemInfo> memInfos = new List <OpenSpace.ROM.DsgMemInfo>();
                if (dsgMemROM?.info?.Value != null && dsgMemROM.info.Value.info.Length > 0)
                {
                    for (int j = 0; j < dsgMemROM.info.Value.info.Length; j++)
                    {
                        OpenSpace.ROM.DsgMemInfo       info  = dsgMemROM.info.Value.info[j].Value;
                        OpenSpace.ROM.DsgVarInfo.Entry entry = dsgVarROM.info.Value.GetEntryFromIndex(info.value.index);
                        if (entry == dsgVarROM.info.Value.entries[i])
                        {
                            memInfos.Add(info);
                        }
                    }
                }
                DsgVarEditableEntry editableEntry = new DsgVarEditableEntry(dsgVarROM.info.Value.entries[i], memInfos);
                editableEntries[i] = editableEntry;
            }
        }
    }
Exemplo n.º 2
0
 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();
     }
 }