public void Prepare(int weaponId) { if (_cache.ContainsKey(weaponId)) { _current = _cache[weaponId]; return; } var weaponCfg = SingletonManager.Get <WeaponConfigManager>().GetConfigById(weaponId); if (null == weaponCfg) { return; } _current = new WeaponAssembly(); if (weaponCfg.Type == (int)EWeaponType.TacticWeapon) { _current.Sound = null; _current.Effect = null; _current.BaseLogic = new TacticWeaponLogic(weaponId, _freeArgs); } else { _current.Sound = _weaponLogicFactory.CreateWeaponSoundLogic(weaponId, _playerWeaponState); _current.Effect = _weaponLogicFactory.CreateWeaponEffectLogic(weaponId); _current.BaseLogic = _weaponLogicFactory.CreateWeaponLogic(weaponId, _current.Sound, _current.Effect, _bulletInfoProviderDispatcher); } _cache[weaponId] = _current; }
//singleton void Awake() { if (weaponAssembly == null) { weaponAssembly = this; } else if (weaponAssembly != this) { Destroy(this); } }