3 [
Attribute(
"{9F18C476AB860F3B}Prefabs/World/Game/ItemPreviewManager.et")]
4 protected ResourceName m_sPreviewManager;
7 protected string m_sPreviewWidgetName;
9 protected ItemPreviewManagerEntity m_PreviewManager;
12 protected bool m_bReloadLoadout;
15 override void HandlerAttached(Widget w)
18 m_bReloadLoadout =
true;
21 protected void DeleteChildrens(IEntity entity,
bool deleteRoot =
true)
26 IEntity child = entity.GetChildren();
29 IEntity sibling = child.GetSibling();
30 DeleteChildrens(child);
34 if (!entity.IsDeleted() && deleteRoot)
41 if (!m_bReloadLoadout)
49 Resource res = Resource.Load(m_sPreviewManager);
51 GetGame().SpawnEntityPrefabLocal(res, world);
60 ResourceName resName =
loadout.GetLoadoutResource();
63 IEntity previewedEntity =
m_PreviewManager.ResolvePreviewEntityForPrefab(resName);
65 return previewedEntity;
67 SCR_ArsenalManagerComponent arsenalManager;
68 if (!SCR_ArsenalManagerComponent.GetArsenalManager(arsenalManager))
69 return previewedEntity;
73 return previewedEntity;
75 DeleteChildrens(previewedEntity,
false);
77 EquipedLoadoutStorageComponent loadoutStorage = EquipedLoadoutStorageComponent.Cast(previewedEntity.FindComponent(EquipedLoadoutStorageComponent));
80 for (
int i = 0; i <
loadoutData.Clothings.Count(); ++i)
86 Resource resource = Resource.Load(
loadoutData.Clothings[i].ClothingPrefab);
90 IEntity cloth =
GetGame().SpawnEntityPrefabLocal(resource, previewedEntity.GetWorld());
94 slot.AttachEntity(cloth);
98 EquipedWeaponStorageComponent weaponStorage = EquipedWeaponStorageComponent.Cast(previewedEntity.FindComponent(EquipedWeaponStorageComponent));
101 for (
int i = 0; i <
loadoutData.Weapons.Count(); ++i)
107 Resource resource = Resource.Load(
loadoutData.Weapons[i].WeaponPrefab);
111 IEntity weapon =
GetGame().SpawnEntityPrefabLocal(resource, previewedEntity.GetWorld());
115 slot.AttachEntity(weapon);
119 BaseWeaponManagerComponent weaponManager = BaseWeaponManagerComponent.Cast(previewedEntity.FindComponent(BaseWeaponManagerComponent));
122 int weaponDefaultIndex = weaponManager.GetDefaultWeaponIndex();
123 if (weaponDefaultIndex > -1)
125 array<WeaponSlotComponent> outSlots = {};
126 weaponManager.GetWeaponsSlots(outSlots);
129 if (weaponSlot.GetWeaponSlotIndex() == weaponDefaultIndex)
131 weaponManager.SelectWeapon(weaponSlot);
138 m_PreviewManager.SetPreviewItem(m_wPreview, previewedEntity, attributes,
true);
139 return previewedEntity;
149 ItemPreviewManagerEntity GetPreviewManagerEntity()
155 void SetPreviewManagerEntity(ItemPreviewManagerEntity instance)
169 m_wPreview = instance;
173 void SetReloadLoadout(
bool flag)
175 m_bReloadLoadout = flag;