Hi,
I would like to override the value of an attribute when another item is assigned in its place in the shortcut bar.
1. When I am in inventory and click on Assign. My holster attribute changes
2. When I replace an assigned item. My case attribute changes or reverts to its default value.
I tried adding the following code to the AssignHotbarItemAction script but it failed:
[CODE = csharp] protected override void InvokeActionInternal (ItemInfo itemInfo, ItemUser itemUser)
{
var item = itemInfo.Item;
var holsterAttribute = item.GetAttribute <Attribut <Transform>> ("Holster");
if (holsterAttribute! = null)
{
holsterAttribute.SetOverrideValue (m_HolsterDefault);
}
if (m_AsyncFuncActions.Count <m_ItemHotbar.SlotCount) {
for (int i = m_AsyncFuncActions.Count; i <m_ItemHotbar.SlotCount; i ++) {
var localIndex = i;
m_AsyncFuncActions.Add (new AsyncFuncAction <int> ((localIndex + 1) .ToString (), () => localIndex));
}
} else if (m_AsyncFuncActions.Count> m_ItemHotbar.SlotCount) {
m_AsyncFuncActions.Trim (m_ItemHotbar.SlotCount);
}
base.InvokeActionInternal (itemInfo, itemUser);
}[/CODE]
and
Thanks in advance for the help
I would like to override the value of an attribute when another item is assigned in its place in the shortcut bar.
1. When I am in inventory and click on Assign. My holster attribute changes
2. When I replace an assigned item. My case attribute changes or reverts to its default value.
I tried adding the following code to the AssignHotbarItemAction script but it failed:
[CODE = csharp] protected override void InvokeActionInternal (ItemInfo itemInfo, ItemUser itemUser)
{
var item = itemInfo.Item;
var holsterAttribute = item.GetAttribute <Attribut <Transform>> ("Holster");
if (holsterAttribute! = null)
{
holsterAttribute.SetOverrideValue (m_HolsterDefault);
}
if (m_AsyncFuncActions.Count <m_ItemHotbar.SlotCount) {
for (int i = m_AsyncFuncActions.Count; i <m_ItemHotbar.SlotCount; i ++) {
var localIndex = i;
m_AsyncFuncActions.Add (new AsyncFuncAction <int> ((localIndex + 1) .ToString (), () => localIndex));
}
} else if (m_AsyncFuncActions.Count> m_ItemHotbar.SlotCount) {
m_AsyncFuncActions.Trim (m_ItemHotbar.SlotCount);
}
base.InvokeActionInternal (itemInfo, itemUser);
}[/CODE]
and
C#:
protected override bool CanInvokeInternal(ItemInfo itemInfo, ItemUser itemUser)
{
if (itemUser is IItemHotbarOwner itemHotbarOwner) {
m_ItemHotbar = itemHotbarOwner.ItemHotbar;
} else {
m_ItemHotbar = itemUser.gameObject.GetComponent<IItemHotbarOwner>()?.ItemHotbar;
}
var item = itemInfo.Item;
var holsterAttribute = item.GetAttribute <Attribut <Transform>> ("Holster");
if (holsterAttribute! = null)
{
holsterAttribute.SetOverrideValue (m_Holster);
}
return m_ItemHotbar! = null
&& itemInfo.ItemCollection.HasItem ((1, élément));
}
Thanks in advance for the help