internal int GetNextGroupID(int _coordinate) { if (!TriggerGroupList.Any(x => x.Coordinate == _coordinate)) { return(9); } return(TriggerGroupList.Where(x => x.Coordinate == _coordinate).OrderByDescending(x => x.Kind).First().Kind + 1); }
internal void RefreshCache() { ClearCache(); _cachedCoordinatePropertyList = TriggerPropertyList.Where(x => x.Coordinate == _currentCoordinateIndex).OrderBy(x => x.Slot).ToList(); _cachedSlotIndex = new HashSet <int>(_cachedCoordinatePropertyList.Select(x => x.Slot)); _cachedCoordinateGroupPropertyList = _cachedCoordinatePropertyList.Where(x => x.RefKind >= 9).ToList(); _cachedCoordinateGroupList = TriggerGroupList.Where(x => x.Coordinate == _currentCoordinateIndex).OrderBy(x => x.Kind).ToList(); _cachedGroupKind = new HashSet <int>(_cachedCoordinateGroupList.Select(x => x.Kind)); }
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); } } }
internal TriggerGroup GetTriggerGroupByGUID(int _coordinate, string _guid) { return(TriggerGroupList.Where(x => x.Coordinate == _coordinate && x.GUID == _guid).FirstOrDefault()); }
internal TriggerGroup GetTriggerGroup(int _coordinate, int _kind) { return(TriggerGroupList.Where(x => x.Coordinate == _coordinate && x.Kind == _kind).FirstOrDefault()); }