Beispiel #1
0
            internal TriggerGroup CreateTriggerGroup(int _coordinate)
            {
                TriggerGroup _group = new TriggerGroup(_coordinate, GetNextGroupID(_coordinate));

                TriggerGroupList.Add(_group);
                return(_group);
            }
Beispiel #2
0
            internal TriggerGroup NewOrGetTriggerGroup(int _coordinate, int _kind)
            {
                TriggerGroup _group = GetTriggerGroup(_coordinate, _kind);

                if (_group == null)
                {
                    _group = new TriggerGroup(_coordinate, _kind);
                    TriggerGroupList.Add(_group);
                }
                return(_group);
            }
            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);
                    }
                }
            }