public static void RefreshWeaponPartModels(ICharacterAppearance appearance, int weaponId, WeaponPartsStruct oldParts, WeaponPartsStruct parts, EWeaponSlotType slot) { var weaponConfig = SingletonManager.Get <WeaponResourceConfigManager>().GetConfigById(weaponId); if (null == weaponConfig) { return; } if (!((EWeaponType_Config)weaponConfig.Type).MayHasPart()) { Logger.WarnFormat("weapon type {0} has no attachment by default ", weaponConfig.Type); return; } var pos = slot.ToWeaponInPackage(); // var oldArr = oldParts.ToAniLocation(); var newArr = parts.ToAniLocation(); for (WeaponPartLocation tmp = WeaponPartLocation.None + 1; tmp < WeaponPartLocation.EndOfTheWorld; tmp++) { if (newArr[(int)tmp] > 0) { appearance.MountAttachment(pos, tmp, newArr[(int)tmp]); } else { appearance.UnmountAttachment(pos, tmp); } } }
/// <summary> /// 刷新武器的配件显示 /// </summary> /// <param name="appearance"></param> /// <param name="weaponId">武器的Id</param> /// <param name="attachments">武器的配件信息</param> /// <param name="slot">武器的位置</param> public static void RefreshWeaponPartModels(ICharacterAppearance appearance, int weaponId, WeaponPartsStruct oldAttachment, WeaponPartsStruct attachments, EWeaponSlotType slot) { Logger.DebugFormat("RefreshAttachmnetModels {0}, old {1}, new {2}, slot {3}", weaponId, oldAttachment, attachments, slot); var weaponConfig = SingletonManager.Get <WeaponConfigManager>().GetConfigById(weaponId); if (null == weaponConfig) { return; } if (!((EWeaponType)weaponConfig.Type).MayHasPart()) { Logger.WarnFormat("weapon type {0} has no attachment by default ", weaponConfig.Type); return; } PrepareDicsForAttach(oldAttachment, attachments); var pos = slot.ToWeaponInPackage(); foreach (var pair in _attachmentsDic) { if (pair.Value > 0) { if (!_oldAttachmentsDic.ContainsKey(pair.Key) || _oldAttachmentsDic[pair.Key] != pair.Value) { appearance.MountAttachment(pos, pair.Key, pair.Value); } } else { if (_oldAttachmentsDic.ContainsKey(pair.Key) && _oldAttachmentsDic[pair.Key] > 0) { appearance.UnmountAttachment(pos, pair.Key); } } } }