Ejemplo n.º 1
0
            internal void CloneAsNewTriggerGroupState(int _coordinate, int _kind, int _state)
            {
                TriggerGroup _group = GetTriggerGroup(_coordinate, _kind);

                if (_group == null)
                {
                    return;
                }
                if (!_group.States.ContainsKey(_state))
                {
                    return;
                }

                int _newState = _group.AddNewState();

                TriggerPropertyList.RemoveAll(x => x.Coordinate == _coordinate && x.RefKind == _kind && x.RefState == _newState);
                List <TriggerProperty> _tempTriggerProperty = TriggerPropertyList.Where(x => x.Coordinate == _coordinate && x.RefKind == _kind && x.RefState == _state).ToList().JsonClone() as List <TriggerProperty>;

                if (_tempTriggerProperty?.Count == 0)
                {
                    return;
                }
                foreach (TriggerProperty x in _tempTriggerProperty)
                {
                    x.RefState = _newState;
                }
                TriggerPropertyList.AddRange(_tempTriggerProperty);
            }
Ejemplo n.º 2
0
            internal void MissingGroupCheck(int _coordinate)
            {
                string        _name  = _cordNames[_coordinate];
                HashSet <int> _kinds = new HashSet <int>(TriggerPropertyList.Where(x => x.Coordinate == _coordinate && x.RefKind >= 9).OrderBy(x => x.RefKind).Select(x => x.RefKind));

                foreach (int _kind in _kinds)
                {
                    HashSet <int> _states = new HashSet <int>(TriggerPropertyList.Where(x => x.Coordinate == _coordinate && x.RefKind == _kind).OrderBy(x => x.RefState).Select(x => x.RefState));
                    TriggerGroup  _group  = GetTriggerGroup(_coordinate, _kind);
                    if (_group == null)
                    {
                        _logger.LogMessage($"Group info on {_name} for group {_group.Label} added because of absent");
                        _group = new TriggerGroup(_coordinate, _kind);
                    }
                    foreach (int _state in _states)
                    {
                        if (_group.States.ContainsKey(_state))
                        {
                            continue;
                        }
                        _group.AddNewState(_state);
                        _logger.LogMessage($"State info on {_name} for group {_group.Label} state {_group.States[_state]} added because of absent");
                    }
                }
            }
Ejemplo n.º 3
0
            internal void RemoveTriggerGroupState(int _coordinate, int _kind, int _state)
            {
                TriggerGroup _group = GetTriggerGroup(_coordinate, _kind);

                if (_group == null)
                {
                    return;
                }
                if (!_group.States.ContainsKey(_state))
                {
                    return;
                }

                if (_state == 0 || _state == 1)
                {
                    _logger.LogMessage($"Removing the first two states is restricted");
                    return;
                }

                TriggerPropertyList.RemoveAll(x => x.Coordinate == _coordinate && x.RefKind == _kind && x.RefState == _state);
                _group.States.Remove(_state);

                if (_group.Startup == _state)
                {
                    _group.Startup = 0;
                }

                if (_group.State == _state)
                {
                    _group.State = _group.Startup;
                }
            }
Ejemplo n.º 4
0
            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));
            }
Ejemplo n.º 5
0
            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);
            }
Ejemplo n.º 6
0
            internal void MissingKindCheck(int _coordinate)
            {
                List <TriggerProperty> _list = TriggerPropertyList.Where(x => x.Coordinate == _coordinate && x.RefKind < 9).OrderBy(x => x.RefKind).ToList();

                for (int i = 0; i <= 8; i++)
                {
                    if (ChaControl.GetClothesStateKind(i) == null && _list.Where(x => x.RefKind == i).ToList().Count > 0)
                    {
                        RemoveKindTriggerProperty(_coordinate, i);
                        _logger.LogMessage($"Triggers removed because no clothes assigned for {_clothesNames[i]}");
                    }
                }
            }
Ejemplo n.º 7
0
            internal void MissingPartCheck(int _coordinate)
            {
                List <ChaFileAccessory.PartsInfo> _partsInfo = ChaControl.ListPartsInfo(_coordinate);
                HashSet <int> _slots = new HashSet <int>(TriggerPropertyList.Where(x => x.Coordinate == _coordinate).OrderBy(x => x.Slot).Select(x => x.Slot));
                string        _name  = Enum.GetNames(typeof(ChaFileDefine.CoordinateType)).ElementAtOrDefault(_coordinate);

                foreach (int _slot in _slots)
                {
                    if (_slot >= _partsInfo.Count || _partsInfo[_slot].type == 120)
                    {
                        TriggerPropertyList.RemoveAll(x => x.Coordinate == _coordinate && x.Slot == _slot);
                        _logger.LogMessage($"Triggers on {_name} slot {_slot + 1:00} removed because no accessory assigned for that slot");
                    }
                }
            }
Ejemplo n.º 8
0
            internal void PackGroupID(int _coordinate)
            {
                Dictionary <int, int>  _mapping             = new Dictionary <int, int>();
                List <TriggerProperty> _tempTriggerProperty = TriggerPropertyList.Where(x => x.Coordinate == _coordinate && x.RefKind >= 9).OrderBy(x => x.RefKind).ToList();
                List <int>             _tempGroupKind       = new HashSet <int>(_tempTriggerProperty.Select(x => x.RefKind)).ToList();

                for (int i = 9; i < _tempGroupKind.Count; i++)
                {
                    if (_tempGroupKind[i] != i)
                    {
                        _mapping[i] = _tempGroupKind[i];
                    }
                }

                if (_mapping.Count == 0)
                {
                    return;
                }

                foreach (TriggerProperty x in TriggerPropertyList)
                {
                    if (x.Coordinate != _coordinate)
                    {
                        continue;
                    }
                    if (x.RefKind < 9 || !_mapping.ContainsKey(x.RefKind))
                    {
                        continue;
                    }
                    x.RefKind = _mapping[x.RefKind];
                }

                foreach (TriggerGroup x in TriggerGroupList)
                {
                    if (x.Coordinate != _coordinate)
                    {
                        continue;
                    }
                    if (!_mapping.ContainsKey(x.Kind))
                    {
                        continue;
                    }
                    x.Kind = _mapping[x.Kind];
                }
            }
Ejemplo n.º 9
0
            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");
                            }
                        }
                    }
                }
            }
Ejemplo n.º 10
0
            internal void AccSlotChangedHandler()
            {
                if (!JetPack.CharaMaker.Loaded)
                {
                    return;
                }
                int _slotIndex = CharaMaker._currentSlotIndex;

                _cachedSlotPropertyList.Clear();

                DebugMsg(LogLevel.Info, $"[AccSlotChangedHandler][{CharaFullName}] Fired!!");

                DebugMsg(LogLevel.Info, $"[AccSlotChangedHandler][{CharaFullName}][SlotIndex]: {_slotIndex}");
                if (_slotIndex < 0)
                {
#if DEBUG
                    _logger.LogError($"[AccSlotChangedHandler][{CharaFullName}] calling when SlotIndex = -1");
#endif
                    RefreshPreview("AccSlotChangedHandler");
                    return;
                }
                _curPartsInfo = ChaControl.GetPartsInfo(_slotIndex);
                if (_curPartsInfo == null)
                {
                    DebugMsg(LogLevel.Warning, $"[AccSlotChangedHandler][{CharaFullName}] Cannot retrive info for Slot{_slotIndex + 1:00}");
                    _accWinCtrlEnable.Visible.OnNext(false);
                    RefreshPreview("AccSlotChangedHandler");
                    return;
                }

                _accWinCtrlEnable.Visible.OnNext(_curPartsInfo.type > 120);

                _cachedSlotPropertyList = TriggerPropertyList.Where(x => x.Coordinate == _currentCoordinateIndex && x.Slot == _slotIndex).OrderBy(x => x.RefKind).ThenBy(x => x.RefState).ToList();

                RefreshPreview("AccSlotChangedHandler");
            }
Ejemplo n.º 11
0
            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);
                    }
                }
            }
Ejemplo n.º 12
0
 internal void RemoveSlotTriggerProperty(int _coordinate, int _slot)
 {
     TriggerPropertyList.RemoveAll(x => x.Coordinate == _coordinate && x.Slot == _slot);
 }
Ejemplo n.º 13
0
 internal void RemoveKindTriggerProperty(int _coordinate, int _refKind)
 {
     TriggerPropertyList.RemoveAll(x => x.Coordinate == _coordinate && x.RefKind == _refKind);
 }
Ejemplo n.º 14
0
 internal TriggerProperty GetTriggerProperty(int _coordinate, int _slot, int _refKind, int _refState)
 {
     return(TriggerPropertyList.Where(x => x.Coordinate == _coordinate && x.Slot == _slot && x.RefKind == _refKind && x.RefState == _refState).FirstOrDefault());
 }
Ejemplo n.º 15
0
 internal void RemoveTriggerGroup(int _coordinate, int _kind)
 {
     TriggerPropertyList.RemoveAll(x => x.Coordinate == _coordinate && x.RefKind == _kind);
     TriggerGroupList.RemoveAll(x => x.Coordinate == _coordinate && x.Kind == _kind);
 }