Beispiel #1
0
        public static MyObjectBuilder_ComponentBase FindComponentBuilder(MyContainerDefinition.DefaultComponent component, MyObjectBuilder_ComponentContainer builder)
        {
            MyObjectBuilder_ComponentBase base2 = null;

            if ((builder != null) && component.IsValid())
            {
                null;
                if (!component.BuilderType.IsNull)
                {
                    MyObjectBuilder_ComponentContainer.ComponentData data = builder.Components.Find(x => x.Component.TypeId == component.BuilderType);
                    if (data != null)
                    {
                        base2 = data.Component;
                    }
                }
            }
            return(base2);
        }
Beispiel #2
0
        void confirmButton_OnButtonClick(MyGuiControlButton sender)
        {
            MyContainerDefinition newDefinition = new MyContainerDefinition();

            foreach (var addComp in m_addComponentsListBox.SelectedItems)
            {
                if (addComp.UserData is MyDefinitionId)
                {
                    var defId = (MyDefinitionId)addComp.UserData;

                    MyContainerDefinition.DefaultComponent component = new MyContainerDefinition.DefaultComponent();
                    component.BuilderType = defId.TypeId;
                    component.SubtypeId   = defId.SubtypeId;

                    newDefinition.DefaultComponents.Add(component);
                }
            }

            MyObjectBuilder_EntityBase entityOb = null;

            if (m_replicableEntityCheckBox.IsChecked)
            {
                entityOb         = new MyObjectBuilder_ReplicableEntity();
                newDefinition.Id = new MyDefinitionId(typeof(MyObjectBuilder_ReplicableEntity), "DebugTest");
            }
            else
            {
                entityOb         = new MyObjectBuilder_EntityBase();
                newDefinition.Id = new MyDefinitionId(typeof(MyObjectBuilder_EntityBase), "DebugTest");
            }
            MyDefinitionManager.Static.SetEntityContainerDefinition(newDefinition);

            entityOb.SubtypeName            = newDefinition.Id.SubtypeName;
            entityOb.PositionAndOrientation = new MyPositionAndOrientation(m_position, Vector3.Forward, Vector3.Up);

            MyEntity entity = MyEntities.CreateFromObjectBuilderAndAdd(entityOb);

            Debug.Assert(entity != null, "Entity wasn't created!");

            CloseScreen();
        }
        public static MyObjectBuilder_ComponentBase FindComponentBuilder(MyContainerDefinition.DefaultComponent component, MyObjectBuilder_ComponentContainer builder)
        {
            MyObjectBuilder_ComponentBase componentBuilder = null;

            if (builder != null && component.IsValid())
            {
                MyObjectBuilderType componentObType = null;

                if (!component.BuilderType.IsNull)
                {
                    var componentData = builder.Components.Find(x => x.Component.TypeId == component.BuilderType);

                    if (componentData != null)
                    {
                        componentBuilder = componentData.Component;
                    }
                }
            }

            return(componentBuilder);
        }