private void OnEntityAdd(IMyEntity e) { MyEntity entity = e as MyEntity; EntityDescription description = new EntityDescription() { EntityId = entity.EntityId, Name = entity.DisplayNameText, ObjectType = entity.GetType().Name, TypeId = ((entity.DefinitionId.HasValue) ? entity.DefinitionId.Value.TypeId.ToString() : string.Empty), SubtypeId = ((entity.DefinitionId.HasValue) ? entity.DefinitionId.Value.SubtypeId.ToString() : string.Empty), Created = Tools.DateTime }; SQLQueryData.WriteToDatabase(description); if (conf.LogGrids) { if (entity is MyCubeGrid) { gridManager.AddGrid(entity as MyCubeGrid); } if (conf.LogInventory && !RegisteredInventories.ContainsKey(entity.EntityId)) { RegisteredInventories.Add(entity.EntityId, new InventoryComponent(entity)); } } }
private void OnEntityRemove(IMyEntity e) { if (!((MySession)MyAPIGateway.Session).Ready) { return; } MyEntity entity = e as MyEntity; EntityDescription description = new EntityDescription() { EntityId = entity.EntityId, Name = entity.DisplayNameText, ObjectType = entity.GetType().Name, TypeId = ((entity.DefinitionId.HasValue) ? entity.DefinitionId.Value.TypeId.ToString() : string.Empty), SubtypeId = ((entity.DefinitionId.HasValue) ? entity.DefinitionId.Value.SubtypeId.ToString() : string.Empty), Removed = Tools.DateTime }; SQLQueryData.WriteToDatabase(description); if (conf.LogGrids) { if (entity is MyCubeGrid) { gridManager.RemoveGrid(entity as MyCubeGrid); } if (conf.LogInventory && RegisteredInventories.ContainsKey(entity.EntityId)) { RegisteredInventories[entity.EntityId].Close(); RegisteredInventories.Remove(entity.EntityId); } } }
private void ButtonSave_Click(object sender, RoutedEventArgs e) { if (sender is Button button) { if (button.Parent != null && button.Parent is StackPanel panel) { TextBox textBoxes = panel.Children.OfType <TextBox>().FirstOrDefault(); textBoxes.IsEnabled = false; if (DataContext is Parametor view && view.Paramet is IMyEntity MyEntity) { Type Entity = MyEntity.GetType(); PropertyInfo property = Entity.GetProperty(textBoxes.Name); if (property != null) { property.SetValue(MyEntity, textBoxes.Text); } ///// IEnumerable <Button> Allbutton = panel.Children.OfType <Button>(); foreach (Button box in Allbutton) { if (box.Name == "Save" || box.Name == "Сancel") { box.Visibility = Visibility.Collapsed; } else if (box.Name == "Edit") { box.Visibility = Visibility.Visible; } } } } } }
public static void Show(MyTerminalPageEnum page, MyCharacter user, MyEntity interactedEntity) { if (!MyPerGameSettings.TerminalEnabled) return; bool showProperties = MyInput.Static.IsAnyShiftKeyPressed(); Debug.Assert(m_instance == null); m_instance = new MyGuiScreenTerminal(); m_instance.m_user = user; m_openInventoryInteractedEntity = interactedEntity; if(MyFakes.ENABLE_TERMINAL_PROPERTIES) m_instance.m_initialPage = showProperties ? MyTerminalPageEnum.Properties : page; else m_instance.m_initialPage = page; InteractedEntity = interactedEntity; m_instance.RecreateControls(true); MyGuiSandbox.AddScreen(MyGuiScreenGamePlay.ActiveGameplayScreen = m_instance); m_screenOpen = true; string target = interactedEntity != null ? interactedEntity.GetType().Name : ""; MyAnalyticsHelper.ReportActivityStart(user, "show_terminal", target, "gui", string.Empty); }
private bool IsEntityUnsupported(MyEntity entity, Type[] disabledTypes) { var entityType = entity.GetType(); return(disabledTypes.Any(s => s.IsAssignableFrom(entityType))); }