internal TriggerProperty NewOrGetTriggerProperty(int _coordinate, int _slot, int _refKind, int _refState) { TriggerProperty _trigger = GetTriggerProperty(_coordinate, _slot, _refKind, _refState); if (_trigger == null) { _trigger = new TriggerProperty(_coordinate, _slot, _refKind, _refState); TriggerPropertyList.Add(_trigger); } return(_trigger); }
internal void MissingPropertyCheck(int _coordinate) { string _name = _cordNames[_coordinate]; HashSet <int> _kinds = new HashSet <int>(TriggerPropertyList.Where(x => x.Coordinate == _coordinate).OrderBy(x => x.RefKind).Select(x => x.RefKind)); foreach (int _kind in _kinds) { HashSet <int> _slots = new HashSet <int>(TriggerPropertyList.Where(x => x.Coordinate == _coordinate && x.RefKind == _kind).OrderBy(x => x.Slot).Select(x => x.Slot)); foreach (int _slot in _slots) { List <TriggerProperty> _list = TriggerPropertyList.Where(x => x.Coordinate == _coordinate && x.RefKind == _kind && x.Slot == _slot).OrderBy(x => x.RefState).ToList(); if (_kind < 9 && _list.Count < 4) { for (int _state = 0; _state <= 3; _state++) { if (_list.Any(x => x.RefState == _state)) { continue; } TriggerPropertyList.Add(new TriggerProperty(_coordinate, _slot, _kind, _state)); _logger.LogMessage($"Triggers on {_name} slot {_slot + 1:00} for group {_clothesNames[_kind]} state {_statesNames[_state]} added because of absent"); } } else if (_kind >= 9) { TriggerGroup _group = GetTriggerGroup(_coordinate, _kind); foreach (int _state in _group.States.Keys) { if (_list.Any(x => x.RefState == _state)) { continue; } TriggerPropertyList.Add(new TriggerProperty(_coordinate, _slot, _kind, _state)); _logger.LogMessage($"Triggers on {_name} slot {_slot + 1:00} for group {_group.Label} state {_group.States[_state]} added because of absent"); } } } } }
public void CloneSlotTriggerProperty(int _srcSlotIndex, int _dstSlotIndex, int _srcCoordinateIndex, int _dstCoordinateIndex) { RemoveSlotTriggerProperty(_dstCoordinateIndex, _dstSlotIndex); List <TriggerProperty> _triggers = TriggerPropertyList.Where(x => x.Coordinate == _srcCoordinateIndex && x.Slot == _srcSlotIndex).ToList(); if (_triggers?.Count > 0) { foreach (TriggerProperty _trigger in _triggers) { TriggerProperty _copy = _trigger.JsonClone() as TriggerProperty; _copy.Coordinate = _dstCoordinateIndex; _copy.Slot = _dstSlotIndex; if (_srcCoordinateIndex != _dstCoordinateIndex && _copy.RefKind >= 9) { string _guid = TriggerGroupList.Where(x => x.Coordinate == _srcCoordinateIndex && x.Kind == _copy.RefKind).FirstOrDefault()?.GUID; if (_guid.IsNullOrEmpty()) { _logger.LogMessage($"Something seriously f****d up, don't save your card"); continue; } TriggerGroup _dstGroup = TriggerGroupList.Where(x => x.Coordinate == _dstCoordinateIndex && x.GUID == _guid).FirstOrDefault(); if (_dstGroup == null) { TriggerGroup _clone = GetTriggerGroup(_srcCoordinateIndex, _trigger.RefKind).JsonClone() as TriggerGroup; _clone.Coordinate = _dstCoordinateIndex; if (TriggerGroupList.Any(x => x.Coordinate == _dstCoordinateIndex && x.Kind == _copy.RefKind)) { int _kind = GetNextGroupID(_dstCoordinateIndex); _clone.Kind = _kind; _copy.RefKind = _kind; TriggerPropertyList.RemoveAll(x => x.Coordinate == _dstCoordinateIndex && x.RefKind == _kind); } TriggerGroupList.Add(_clone); } else { int _kind = _dstGroup.Kind; _copy.RefKind = _kind; int _state = _trigger.RefState; TriggerGroup _srcGroup = GetTriggerGroup(_srcCoordinateIndex, _kind); if (!_dstGroup.States.ContainsKey(_state)) { _dstGroup.States.Add(_state, _srcGroup.States[_state]); TriggerPropertyList.RemoveAll(x => x.Coordinate == _dstCoordinateIndex && x.RefKind == _kind && x.RefState == _state); HashSet <int> _slots = new HashSet <int>(TriggerPropertyList.Where(x => x.Coordinate == _dstCoordinateIndex && x.RefKind == _kind && x.Slot != _dstSlotIndex).Select(x => x.Slot)); if (_slots.Count > 0) { List <TriggerProperty> _tempTriggerProperty = new List <TriggerProperty>(); foreach (int _slot in _slots) { _tempTriggerProperty.Add(new TriggerProperty(_dstCoordinateIndex, _slot, _kind, _state)); } TriggerPropertyList.AddRange(_tempTriggerProperty); } } } } TriggerPropertyList.Add(_copy); } } }