Use typed item keys in server item decisions

This commit is contained in:
Meta Vens 2026-06-15 01:12:22 +01:00
commit c245538793
5 changed files with 6 additions and 7 deletions

View file

@ -2,8 +2,6 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
using System;
public class HaulingTask : AgentTask
{
public override TaskType Type => TaskType.Haul;
@ -12,7 +10,7 @@ public class HaulingTask : AgentTask
public Entity Target;
public Guid ItemType;
public string ItemKey;
public int Quantity;
}

View file

@ -404,7 +404,7 @@ public abstract class Entity
public void GenerateWeaponGroups()
{
foreach (var group in Weapons
.GroupBy(w => w.Item.EquippableItem.ItemId)
.GroupBy(w => w.Item.EquippableItem.ItemKey)
.OrderBy(wg=>wg.Average(w=>w.Range))
.Select((weapons, index) => (weapons, index)))
{

View file

@ -336,9 +336,7 @@ public class LoadoutGenerator
var itemRow = previousItems.FirstOrDefault(i => FitsHardpoint(i, hardpoint));
var previousItem = itemRow == null
? null
: Guid.TryParse(itemRow.LegacyId, out var previousItemId)
? entity.Equipment.FirstOrDefault(item => item.EquippableItem.ItemId == previousItemId)
: null;
: entity.Equipment.FirstOrDefault(item => item.EquippableItem.ItemKey == itemRow.ItemKey);
itemRow ??= RandomCatalogItem(RuntimeItemCandidateKind.Gear, hardpoint, 2);
if (itemRow == null) ItemManager.Log($"No compatible item found for entity {hardpoint.Type} hardpoint!");
else