LynnaLab.ObjectGroup.InsertObject C# (CSharp) Method

InsertObject() public method

public InsertObject ( int index, ObjectType type ) : void
index int
type ObjectType
return void
        public void InsertObject(int index, ObjectType type)
        {
            if (GetNumObjects() == 0 && !IsIsolated()) {
                // If this map is sharing data with other maps (as when "blank"), need to make
                // a unique section for this map.

                parser.RemoveLabel(Identifier);

                parser.InsertParseableTextAfter(null, new String[]{""}); // Newline
                parser.InsertComponentAfter(null, new Label(parser, Identifier));

                ObjectData endData = new ObjectData(Project,
                        ObjectCommands[(int)ObjectType.End],
                        null,
                        parser,
                        new int[]{-1}, // Tab at start of line
                        ObjectType.End);
                parser.InsertComponentAfter(null, endData);
                objectDataList[0] = endData;
            }

            ObjectData data = new ObjectData(Project,
                    ObjectCommands[(int)type],
                    null,
                    parser,
                    new int[]{-1}, // Tab at start of line
                    type);

            ValueReference.InitializeDataValues(data, data.GetValueReferences());

            if (type >= ObjectType.Pointer && type <= ObjectType.AntiBossPointer)
                data.SetValue(0, "objectData4000"); // Compileable default pointer

            data.InsertIntoParserBefore(objectDataList[index]);
            objectDataList.Insert(index, data);
        }

Usage Example

示例#1
0
        protected void OnAddButtonClicked(object sender, EventArgs e)
        {
            if (ObjectGroup == null)
            {
                return;
            }

            AddObjectDialog d = new AddObjectDialog();

            d.Run();
            if (d.ObjectTypeToAdd != ObjectType.End)
            {
                if (ObjectGroup == null)
                {
                    return;
                }

                ObjectGroup.InsertObject(indexSpinButton.ValueAsInt + 1, d.ObjectTypeToAdd);
                UpdateBoundaries();
                indexSpinButton.Value = indexSpinButton.ValueAsInt + 1;
            }
        }