Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Loot/Core: LootManager MVP implementation - WIP #364

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

kirmmin
Copy link
Member

@kirmmin kirmmin commented Aug 24, 2021

Replaces #280

Client Loot support (Vacuum and Item)
LootBag Support
VirtualItem support
WorldEntity Loot assignment

VirtualItem support
Client Loot support (Vacuum and Item)
WorldEntity Loot assignment
@@ -182,6 +186,66 @@ private void CacheRewardPropertiesByTier()
.ToImmutableList());
}

private void AddToTargets(TargetGroupEntry entry, ref List<uint> targetIds, ref List<TargetGroupType> unhandledTargetGroups)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would say ref isn't required here. You only add new elements and don't re assign the full list so it's not required.


private UpdateTimer updateTimer = new UpdateTimer(1d);

public GlobalLootManager()
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

singletons should not have public ctors

switch (type)
{
case LootEntityType.Creature:
if (!creatureLoot.ContainsKey(entityId))
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use TryGetValue in here instead of ContainsKey + this[]. That saves some checks. The out parameter is passed by ref since it's a list.

Same for all other similar cases in this PR

var entries = ImmutableDictionary.CreateBuilder<uint, List<uint>>();
foreach (QuestObjectiveEntry questObjectiveEntry in GameTableManager.Instance.QuestObjective.Entries
.Where(o => o.TargetGroupIdRewardPane > 0u ||
(QuestObjectiveType)o.Type == QuestObjectiveType.ActivateTargetGroup ||
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actual question: Why is QuestObjectiveType not used as field type?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Truthfully, I don't know if we're adjusting the GameTable Entry Field Types from "standard" types (like float, int, etc.). We've never discussed it, and we're commonly casting from int to enum, for example, so I tend to follow what's already been done.

What's your thoughts on this, @Rawaho ?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2 issues I can see if we wanted to do so.

  1. Does the current GameTable loading code handle enums?
  2. Since the GameTable models are stored in the shared project, all enums will have to moved out of the world project.


questObjectiveTargets = entries.ToImmutableDictionary(e => e.Key, e => e.Value.ToImmutableList());

string targetGroupTypes = "";

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minor: can simply to string targetGroupTypes = string.Join(" ", unhandledTargetGroups);

private void RemoveExpiredLootInstances()
{
foreach (LootInstance lootInstance in lootInstances.Where(i => i.HasExpired).ToList())
lootInstances.Remove(lootInstance);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To save you the iteration, you can rewrite this as lootInstances.RemoveAll(i => i.HasExpired);

@Rawaho Rawaho added this to the Pull Request Cleanup milestone Jan 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants