diff --git a/src/TechObject/ObjectsTree/UniversalObject/AttachedObjects.cs b/src/TechObject/ObjectsTree/UniversalObject/AttachedObjects.cs index 93a1b4eb..3ca82f79 100644 --- a/src/TechObject/ObjectsTree/UniversalObject/AttachedObjects.cs +++ b/src/TechObject/ObjectsTree/UniversalObject/AttachedObjects.cs @@ -29,8 +29,7 @@ public override bool SetNewValue(string newValue) string oldValue = Value; var thisObjNum = owner?.GlobalNum ?? 0; var isGeneric = owner is GenericTechObject; - List newNumbers = strategy.GetValidTechObjNums(newValue, - thisObjNum, isGeneric); + List newNumbers = strategy.GetValidTechObjNums(newValue, thisObjNum); newValue = string.Join(" ", newNumbers); string sortedValue = MoveNewValuesInTheEndOfString(newValue, @@ -295,7 +294,7 @@ public string Check() { var res = ""; var objNum = TechObjectManager.GetInstance().GetTechObjectN(Owner); - List numbers = strategy.GetValidTechObjNums(Value, objNum, Owner is GenericTechObject); + List numbers = strategy.GetValidTechObjNums(Value, objNum); string checkedValue = string.Join(" ", numbers); if (checkedValue != Value) { @@ -631,8 +630,9 @@ public interface IAttachedObjectsStrategy /// /// Входная строка /// Номер редактируемого объекта + /// Редактируемый объект - типовой /// - List GetValidTechObjNums(string value, int objNum, bool isGeneric); + List GetValidTechObjNums(string value, int objNum, bool isGeneric = false); /// /// Нужно ли инициализировать привязанные объекты @@ -708,7 +708,7 @@ public BaseStrategy(string name, string luaName, /// Номер редактируемого объекта /// - типовой объект public List GetValidTechObjNums(string value, - int selectedObjNum, bool isGeneric) + int selectedObjNum, bool isGeneric = false) { var validNumbers = new List(); List numbers = value.Split(' ') diff --git a/src/TechObject/ObjectsTree/UniversalObject/GenericTechObject.cs b/src/TechObject/ObjectsTree/UniversalObject/GenericTechObject.cs index 2ccc5312..6c6fd343 100644 --- a/src/TechObject/ObjectsTree/UniversalObject/GenericTechObject.cs +++ b/src/TechObject/ObjectsTree/UniversalObject/GenericTechObject.cs @@ -69,6 +69,7 @@ public void SetUpEventsHandlers() paramsManager.ValueChanged += UpdateParamsManager; ModesManager.ValueChanged += UpdateModesManager; AttachedObjects.ValueChanged += UpdateAttachedObjects; + BaseTechObject.ObjectGroupsList.ForEach(gr => gr.ValueChanged += UpdateObjectGroups); } /// @@ -83,6 +84,7 @@ public void Update() UpdateEquipment(null); UpdateParamsManager(null); UpdateTechObjectsData(null); + UpdateObjectGroups(null); } /// @@ -99,6 +101,24 @@ private void UpdateAttachedObjects(object sender) InheritedTechObjects.ForEach(to => to.AttachedObjects.UpdateOnGenericTechObject(AttachedObjects)); } + /// + /// Обновить поля групп танков: Группа танков, Источники/Приемники + /// + private void UpdateObjectGroups(object sender) + { + inheritedTechObjects.ForEach(to => + { + var genericObjGrList = BaseTechObject.ObjectGroupsList; + var inheritedObjGrList = to.BaseTechObject.ObjectGroupsList; + + var objectsGroups = genericObjGrList.Zip(inheritedObjGrList, (g, i) => new { Generic = g, Inherited = i }); + foreach (var og in objectsGroups) + { + og.Inherited.UpdateOnGenericTechObject(og.Generic); + } + }); + } + /// /// Обновить поле "Операции" /// diff --git a/src/TechObject/ObjectsTree/UniversalObject/ModesManager.cs b/src/TechObject/ObjectsTree/UniversalObject/ModesManager.cs index 0c1c56cf..defba7c4 100644 --- a/src/TechObject/ObjectsTree/UniversalObject/ModesManager.cs +++ b/src/TechObject/ObjectsTree/UniversalObject/ModesManager.cs @@ -603,6 +603,7 @@ public void UpdateOnGenericTechObject(ModesManager genericModesManager) if (mode is null) { mode = AddMode(genericMode.Name, genericMode.BaseOperation.LuaName); + mode.AddParent(this); } else {