Hi.
I was using the following HUDCustomOrderListComponent.
I upgraded ORK3.8 from around ORK3.6 to deal with other bugs, and I started getting compilation errors.
I think Gil changed the spawnedPrefabs in BaseHUDListContentComponent to KeyValuePair.

Before modification<< var orderStruct = (OrderStruct)x.User;
After modification>> var orderStruct = (OrderStruct)x.Value.User;


After this modification, x.Value.User becomes Null and Project fails at various points.
How can this be addressed?

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using GamingIsLove.Makinom.Components;
using GamingIsLove.Makinom;
using System.Linq;
using Cysharp.Threading.Tasks;

public class HUDCustomOrderListComponent : BaseHUDListContentComponent<TextContent>
{
//ReactiveCollection<OrderStruct> observableOrders;
//System.IDisposable updateSubscribe;
/*
============================================================================
Content functions
============================================================================
*/
public override void UpdateContent()
{
if (this.contentProvider == null)
{
if (this.gameObject.activeSelf)
{
this.gameObject.SetActive(false);
}
}
else
{
if (!this.gameObject.activeSelf)
{
this.gameObject.SetActive(true);
}

var orderStructListNoCast = Maki.Game.SelectedData.Get("OrderStruct");
if (orderStructListNoCast != null)
{
var orderStructList = orderStructListNoCast.Cast<OrderStruct>().ToArray();
for (int i = 0; i < orderStructList.Count(); i++)
{
// すでにCustomerがOrder済でない場合のみCreate
bool yetSpawned = !spawnedPrefabs.Any(x =>
{
var orderStruct = (OrderStruct)x.Value.User;
return !orderStructList.Any(y => y.orderedCombatant.GetName() == orderStruct.orderedCombatant.GetName());
});
if (yetSpawned)
{
var createdPrefab = CreatePrefab(i, settings.prefab, orderStructList[i]);
}
}

var deletedPrefab = spawnedPrefabs.Where(x =>
{
var orderStruct = (OrderStruct)x.Value.User;
return !orderStructList.ToArray().Any(y =>
{
return y.orderedCombatant.GetName() == orderStruct.orderedCombatant.GetName();
});
});
foreach (var item in deletedPrefab.ToArray())
{
spawnedPrefabs.Remove(item);
Destroy(item.Value.gameObject);
}
}

if (spawnedPrefabs.Count() > 0 && orderStructListNoCast == null)
{
foreach (var prefabHUDContentsProvider in spawnedPrefabs)
{
Destroy(prefabHUDContentsProvider.Value.gameObject,0.1f);
}
spawnedPrefabs.Clear();
}
}
}

/*
============================================================================
Register functions
============================================================================
*/
async public override void Register()
{
await UniTask.DelayFrame(3);
if (!this.isRegistered)
{
Maki.Game.SelectedData.DataChanged += this.MarkUpdateContent;
this.MarkUpdateContent();
base.Register();
}
}

public override void Unregister()
{
if (this.isRegistered)
{
Maki.Game.SelectedData.DataChanged -= this.MarkUpdateContent;
base.Unregister();
}
}
}
  • edited October 2022
    Yes, ORK 3.8 (or rather Makinom 2.9) changed a few things for the HUD list components. Probably best check the code of one of ORK's built-in HUD list components to see what changed.
    Also, there's now a HUD Selected Data List component available to use selected data as HUD content.

    As for your code - it's hard for me to tell what's wrong, since I don't know your OrderStruct data and how it's created.
    Post edited by gamingislove on
    Please consider rating/reviewing my products on the Asset Store (hopefully positively), as that helps tremendously with getting found.
    If you're enjoying my products, updates and support, please consider supporting me on patreon.com!
Sign In or Register to comment.