private void InitRoadTypesProperty() { _roadTypesControl = new GenericTableRowControl <RoadType>() { TitleValue = "Используемые типы дорог", TitleToolTip = "Представляет собой набор допустимых типов маршрутов в сети, используется при добавлении или обновлении маршрута", OnAdd = alreadyUsedRoadTypes => { var addDialog = new AddStringDialog() { Title = "Новый тип дороги", IsViable = newRoadTypeName => { if (newRoadTypeName.Trim() == "") { ComponentUtils.ShowMessage("Введите не пустое название", MessageBoxImage.Error); return(false); } if (alreadyUsedRoadTypes.Contains(new RoadType() { Name = newRoadTypeName.Trim() })) { ComponentUtils.ShowMessage("Тип дороги с таким названием уже существует", MessageBoxImage.Error); return(false); } return(true); }, RowControl = { TitleValue = "Введите название", Value = "" } }; if (addDialog.ShowDialog() != true) { return(null); } var created = new RoadType() { Name = addDialog.RowControl.Value }; return(new List <RoadType>() { created }); }, Value = _roadTypes.Values }; _roadTypesControl.AddColumns(RoadType.PropertyMatcher()); PropertiesPanel.Children.Add(_roadTypesControl.GetUiElement); }
public void TriggerCountdown() { ModExplosiveSave explosiveSave = ComponentUtils.GetComponent <ModExplosiveSave>(this); if (explosiveSave is null) { Logger.LogError("Could not trigger countdown. No ModExplosiveSave!"); return; } explosiveSave.TriggerCountdown(explosionDelay); }
private static void ChangeWeight(GameObject item, float newWeight) { GearItem gearItem = ComponentUtils.GetComponent <GearItem>(item); if (gearItem is null) { Logger.Log("Could not assign new weight. Item has no GearItem component."); return; } gearItem.m_WeightKG = newWeight; }
public void FullReport(AlgorithmResult res) { var fileName = EnterFileName("full-report", "Txt file (*.txt)|*.txt"); if (fileName == null) { return; } File.WriteAllText(fileName, ReportUtils.FullReport(res)); ComponentUtils.ShowMessage("Результат в файл успешно записан", MessageBoxImage.Information); }
internal static Animation AssignAnimationClip(GameObject go, AssetData data) { var animation = ComponentUtils.GetOrAddIf <Animation>(go, s_CreatePlayerForClips); if (animation != null) { AssignAnimationClip(animation, (AnimationClip)data.asset); } return(animation); }
public void MatrixReport(AlgorithmResult res) { var fileName = EnterFileName("matrix-report", "Csv file (*.csv)|*.csv"); if (fileName == null) { return; } File.WriteAllText(fileName, ReportUtils.MatrixReport(res)); ComponentUtils.ShowMessage("Результат в файл успешно записан", MessageBoxImage.Information); }
private void TriggerExplosion() { ModExplosiveComponent explosiveComponent = ComponentUtils.GetComponent <ModExplosiveComponent>(this); if (explosiveComponent is null) { Logger.LogError("Could not trigger explosion. No ModExplosiveComponent!"); return; } explosiveComponent.OnExplode(); }
private static void Postfix(GearItem __instance) { FixName(__instance); if (!IsInitialized() || ComponentUtils.GetModComponent(__instance) != null) { return; } else { ChangeGameObject(ComponentUtils.GetGameObject(__instance)); } }
protected override void OnAttached() { base.OnAttached(); _block.Text = KarveLocale.Properties.Resources.PlusMinusBehaviour_OnAttached_MoreItems; _image = new Image(); _image.Source = ComponentUtils.CreateImageSource(PlusPath, true); _panel.Children.Add(_image); _panel.Children.Add(_block); this.AssociatedObject.Content = _panel; this.AssociatedObject.Checked += AssociatedObject_Checked; this.AssociatedObject.Unchecked += AssociatedObject_Unchecked; }
private static GearItem GetTargetItem(string targetItemName, string reference) { GameObject targetItem = Resources.Load(targetItemName)?.Cast <GameObject>(); if (ComponentUtils.GetModComponent(targetItem) != null) { // if this a modded item, map it now (no harm if it was already mapped earlier) Mapper.Map(targetItem); } return(ModUtils.GetItem <GearItem>(targetItemName, reference)); }
private void AssociatedObject_DataSearchTextBoxChanged(object sender, RoutedEventArgs e) { var value = e; var brandValue = ComponentUtils.GetTextDo(DataObject, "Value.MAR", DataType.Any); if (!string.IsNullOrEmpty(brandValue)) { var brand = RelatedBrandPath; ExecuteRuleWithCode(brandValue); SetVariant(); } }
// USAGE of Access private void TextBlock_accessRecord_AppearanceAccToContent(object sender) { TextBlock tb = sender as TextBlock; if (tb == null) { return; } string date = ""; if (tb.Tag != null) { if (tb.Tag is ComponentManagerAndAccessFlagDateTimeTriple) { ComponentManagerAndAccessFlagDateTimeTriple info = (ComponentManagerAndAccessFlagDateTimeTriple)tb.Tag; DateTime recorded_time = info.AccessTimeStamp_Current; if (recorded_time > DateTime.MinValue) { date = recorded_time.ToString(DateTimeFormatInfo.CurrentInfo); } } } tb.ToolTip = ComponentUtils.ComponentAccessTypeStringToDescriptionDE(tb.Text, date); if (ComponentUtils.ACCESS_NOT_ALLOWED_SINGLE.IsMatch(tb.Text)) { tb.Effect = null; } else if (ComponentUtils.ACCESS_ALLOWED_SINGLE.IsMatch(tb.Text)) { tb.Effect = new DropShadowEffect() { Color = (Color)ColorConverter.ConvertFromString("#FF0000ff"), Direction = 315, ShadowDepth = 2, BlurRadius = 1, Opacity = 1 }; } else if (ComponentUtils.ACCESS_RECORDED_SINGLE.IsMatch(tb.Text)) { tb.Effect = new DropShadowEffect() { Color = (Color)ColorConverter.ConvertFromString("#FFff7e00"), Direction = 315, ShadowDepth = 2, BlurRadius = 1, Opacity = 1 }; } }
public void GetComponentInChildren() { var gameObject = new GameObject(); gameObject.AddComponent <MeshFilter>(); var child = new GameObject(); child.transform.SetParent(gameObject.transform); child.AddComponent <BoxCollider>(); child.AddComponent <MeshRenderer>(); child.AddComponent <BoxCollider>(); Assert.AreEqual(gameObject.GetComponentInChildren <BoxCollider>(), ComponentUtils <BoxCollider> .GetComponentInChildren(gameObject)); }
private static bool UpdateTransportSystem(TransportSystem selected) { if (!IsViable(null)) { return(false); } selected.Name = _nameControl.Value; App.DataBase.GetCollection <TransportSystem>().Update(selected); ComponentUtils.ShowMessage("Данная транспортная система была обновлена", MessageBoxImage.Information); return(true); }
internal static void Postfix(PlayerManager __instance, PlayerControlMode mode) { if (mode == lastMode) { return; } lastMode = mode; EquippableModComponent equippable = ComponentUtils.GetEquippableModComponent(__instance.m_ItemInHands); equippable?.OnControlModeChangedWhileEquipped?.Invoke(); }
public static void InitializeComponents(ref GameObject prefab) { if (ComponentUtils.GetModComponent(prefab) != null) { return; } string name = NameUtils.RemoveGearPrefix(prefab.name); string data = JsonHandler.GetJsonText(name); ProxyObject dict = JSON.Load(data) as ProxyObject; InitializeComponents(ref prefab, dict); }
internal static void Configure(GameObject prefab) { ModScentComponent modScentComponent = ComponentUtils.GetComponent <ModScentComponent>(prefab); if (modScentComponent is null) { return; } Scent scent = ComponentUtils.GetOrCreateComponent <Scent>(modScentComponent); scent.m_ScentCategory = EnumUtils.TranslateEnumValue <ScentRangeCategory, ScentCategory>(modScentComponent.scentCategory); }
private static void Postfix(GearItem gi, ref bool __result) { if (__result || gi is null) { return; } EquippableModComponent equippable = ComponentUtils.GetEquippableModComponent(gi); if (equippable != null) { __result = true; } }
public static void Map(GameObject prefab) { if (prefab is null) { throw new ArgumentException("The prefab was NULL."); } ModComponent modComponent = ComponentUtils.GetModComponent(prefab); if (modComponent is null) { throw new ArgumentException("Prefab " + prefab.name + " does not contain a ModComponent."); } bool hasModPlaceHolder = !(ComponentUtils.GetComponent <ModPlaceHolderComponent>(prefab) is null); if (prefab.GetComponent <GearItem>() is null || hasModPlaceHolder) { ConfigureBehaviours(modComponent); EquippableMapper.Configure(modComponent); LiquidMapper.Configure(modComponent); PowderMapper.Configure(modComponent); FoodMapper.Configure(modComponent); CookableMapper.Configure(modComponent); CookingPotMapper.Configure(modComponent); RifleMapper.Configure(modComponent); ClothingMapper.Configure(modComponent); CollectibleMapper.Configure(modComponent); CharcoalMapper.Configure(modComponent); PurificationMapper.Configure(modComponent); ResearchMapper.Configure(modComponent); FirstAidMapper.Configure(modComponent); ToolMapper.Configure(modComponent); GenericEquippableMapper.Configure(modComponent); BedMapper.Configure(modComponent); BodyHarvestMapper.Configure(modComponent); if (hasModPlaceHolder) { return; } InspectMapper.Configure(modComponent); ConfigureGearItem(modComponent); mappedItems.Add(modComponent); PostProcess(modComponent); } }
internal static VideoPlayer AttachVideoClip(GameObject go, AssetData data) { var player = ComponentUtils.GetOrAddIf <VideoPlayer>(go, s_CreatePlayerForClips); if (player != null) { #if UNITY_EDITOR UnityEditor.Undo.RecordObject(player, k_AssignVideoClipUndo); #endif player.clip = (VideoClip)data.asset; } return(player); }
internal static AudioSource AttachAudioClip(GameObject go, AssetData data) { var source = ComponentUtils.GetOrAddIf <AudioSource>(go, s_CreatePlayerForClips); if (source != null) { #if UNITY_EDITOR UnityEditor.Undo.RecordObject(source, k_AssignAudioClipUndo); #endif source.clip = (AudioClip)data.asset; } return(source); }
public void AddNavigationDrawerPanel() { #if UNITY_EDITOR if (NavigationDrawerPanel == null && !Application.isPlaying) { m_NavigationDrawerPanel = ComponentUtils.InstantiatePrefab("NavigationDrawerPanel_pfb")?.GetComponent<NavigationDrawerPanel>(); if (m_NavigationDrawerPanel != null) { m_NavigationDrawerPanel.transform.SetParent(GetComponent<RectTransform>(), false); } EditorUtility.DisplayDialog("Information", "Navigation Drawer panel has been successfully added!", "Ok"); return; } EditorUtility.DisplayDialog("Information", "You only need one drawer panel per application.\nAdding more is useless.", "Ok"); #endif }
private void SetVariant() { var box = this.RelatedVariantObject as DataField; if (box != null) { var variante = ComponentUtils.GetTextDo(DataObject, "Value.VARIANTE", DataType.Any); if (!string.IsNullOrEmpty(variante)) { box.TextContent = variante; } } }
public void AddActionBar() { #if UNITY_EDITOR if (ActionBar == null && !Application.isPlaying) { m_ActionBar = ComponentUtils.InstantiatePrefab("ActionBar_pfb")?.GetComponent<ActionBar>(); if (m_ActionBar != null) { m_ActionBar.transform.SetParent(GetComponent<RectTransform>(), false); } EditorUtility.DisplayDialog("Information", "ActionBar has been successfully added!", "Ok"); return; } EditorUtility.DisplayDialog("Information", "You only need one action bar per application.\nAdding more is useless.", "Ok"); #endif }
/// <summary> /// This is the method that actually does the work. /// </summary> /// <param name="DA">The DA object is used to retrieve from inputs and store in outputs.</param> protected override void SolveInstance(IGH_DataAccess DA) { string inputJson = null; var cpus = 4; var method = 0; var caseType = 0; var materials = new List <string>(); var epwFile = ""; string overrides = null; if (!DA.GetData(0, ref inputJson)) { return; } if (inputJson == "error") { return; } DA.GetData(1, ref cpus); DA.GetData(2, ref method); //DA.GetData(3, ref caseType); if (!DA.GetDataList(3, materials)) { return; } if (!DA.GetData(4, ref epwFile) && (method <= 1)) { return; } DA.GetData(5, ref overrides); try { var outputs = RadiationSolution.Setup( inputJson, ComponentUtils.ValidateCPUs(cpus), Methods[method], CaseTypes[caseType].ToLower(), materials, epwFile, overrides ); DA.SetData(0, outputs); } catch (Exception error) { AddRuntimeMessage(GH_RuntimeMessageLevel.Error, error.Message); } }
private void ExecuteRules(object newValue) { var newDataObject = newValue; var box = this.RelatedObject as DualFieldSearchBox; if (newDataObject != null) { var cpValue = ComponentUtils.GetTextDo(newDataObject, "CP", DataType.Any); if (!string.IsNullOrEmpty(cpValue)) { var provinceValue = cpValue.Substring(0, 2); if (newValue is BaseViewObject) { SetValues(provinceValue, "PROV", "PROVINCIA", newDataObject); } else { SetValues(provinceValue, "Value.PROV", "Value.PROVINCIA", newDataObject); } } } ExecuteRuleOnPobla(newValue); /* * Basically this does the same as above but with the related paths. */ if (!string.IsNullOrEmpty(RelatedPath)) { var relatedValue = ComponentUtils.GetTextDo(newDataObject, Path, DataType.Any); if (!string.IsNullOrEmpty(relatedValue)) { var provinceValue = relatedValue.Substring(0, 2); string pathStr; if (newDataObject is BaseViewObject) { pathStr = RelatedPath; } else { pathStr = "Value." + RelatedPath; } ComponentUtils.SetPropValue(newDataObject, pathStr, provinceValue); } } if (box != null) { box.DataView = newDataObject; } }
public void ShowDialog() { _dialog.Title = Title; ComponentUtils.InsertIconToPanel(_dialog.InfoPanel, AppResources.GetInfoIcon, "Для большей информации об атрибуте, наведите на название этого атрибута"); _entityList = new GenericEntityListControl <T>(ListTitle, _columnMatcher, DisplayUpdate); _dialog.ListPanel.Children.Add(_entityList.GetUiElement()); foreach (var p in _propertyRows) { _dialog.PropertiesPanel.Children.Add(p); } ComponentUtils.InsertIconToButton(_dialog.AddButton, AppResources.GetAddItemIcon, OpenAddNewItemWindowButtonTitle); _dialog.AddButton.Click += (sender, args) => DisplayNew(); _addButton.Click += (sender, args) => { if (!AddItemFunction.Invoke()) { return; } _entityList.SetSource(UpdateCollectionFunction.Invoke()); DisplayNew(); }; _updateButton.Click += (sender, args) => { var selected = _entityList.Selected; if (!UpdateItemFunction.Invoke(selected)) { return; } var updatedList = UpdateCollectionFunction.Invoke().ToList(); _entityList.SetSource(updatedList); _entityList.Selected = updatedList.First(t => t.Id == selected.Id); }; _removeButton.Click += (sender, args) => { if (!RemoveItemFunction.Invoke(_entityList.Selected)) { return; } _entityList.SetSource(UpdateCollectionFunction.Invoke()); DisplayNew(); }; _entityList.SetSource(UpdateCollectionFunction.Invoke()); _dialog.ShowDialog(); }
internal static void Postfix(Panel_Cooking __instance) { Il2CppSystem.Collections.Generic.List <GearItem> foodList = __instance.m_FoodList; if (foodList == null) { return; } foreach (GearItem eachGearItem in foodList) { CookingModifier cookingModifier = ComponentUtils.GetComponent <CookingModifier>(eachGearItem); cookingModifier?.Revert(); //if(cookingModifier) Implementation.Log("{0} reverted from Melt and Cook", eachGearItem.name); } }
private string GetPropertyValue(object dataObject, string name, DataType type) { if (dataObject == null) { return(string.Empty); } var tmp = ComponentUtils.GetTextDo(dataObject, name, type); if (type != DataType.Email) { return(tmp); } tmp = tmp.Replace("#", "@");; return(tmp); }
void OnRayEntered(GameObject gameObject, TrackedDeviceEventData eventData) { var dropReceiver = ComponentUtils <IDropReceiver> .GetComponent(gameObject); if (dropReceiver != null) { var rayOrigin = eventData.interactor; if (dropReceiver.CanDrop(GetCurrentDropObject(rayOrigin))) { dropReceiver.OnDropHoverStarted(); m_HoverObjects[rayOrigin] = gameObject; SetCurrentDropReceiver(rayOrigin, dropReceiver); } } }