Skip to content

Commit

Permalink
rename NpcBase -> NPCDescriptor
Browse files Browse the repository at this point in the history
update migrations

RenameNPCDescriptor migration
  • Loading branch information
lodicolo committed Feb 27, 2025
1 parent 04ee4a7 commit ffefd3a
Show file tree
Hide file tree
Showing 32 changed files with 4,012 additions and 440 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using Intersect.Framework.Core.GameObjects.Events;
using Intersect.Framework.Core.GameObjects.Items;
using Intersect.Framework.Core.GameObjects.Maps;
using Intersect.Framework.Core.GameObjects.NPCs;
using Intersect.Framework.Core.GameObjects.Variables;
using Intersect.GameObjects;

Expand All @@ -19,7 +20,7 @@ public enum GameObjectType
[GameObjectInfo(typeof(ItemDescriptor), "items")]
Item,

[GameObjectInfo(typeof(NpcBase), "npcs")]
[GameObjectInfo(typeof(NPCDescriptor), "npcs")]
Npc,

[GameObjectInfo(typeof(ProjectileBase), "projectiles")]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@
using Intersect.Enums;
using Intersect.Framework.Core.GameObjects.Conditions;
using Intersect.Framework.Core.GameObjects.Events;
using Intersect.GameObjects;
using Intersect.Models;
using Intersect.Utilities;
using Newtonsoft.Json;

namespace Intersect.GameObjects;
namespace Intersect.Framework.Core.GameObjects.NPCs;

public partial class NpcBase : DatabaseObject<NpcBase>, IFolderable
public partial class NPCDescriptor : DatabaseObject<NPCDescriptor>, IFolderable
{
private long[] _maxVitals = new long[Enum.GetValues<Vital>().Length];
private int[] _stats = new int[Enum.GetValues<Stat>().Length];
Expand Down Expand Up @@ -110,13 +111,13 @@ public string ImmunitiesJson
}

[JsonConstructor]
public NpcBase(Guid id) : base(id)
public NPCDescriptor(Guid id) : base(id)
{
Name = "New Npc";
}

//Parameterless constructor for EF
public NpcBase()
public NPCDescriptor()
{
Name = "New Npc";
}
Expand Down
3 changes: 2 additions & 1 deletion Framework/Intersect.Framework.Core/GameObjects/QuestBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using Intersect.Framework.Core.GameObjects.Conditions;
using Intersect.Framework.Core.GameObjects.Events;
using Intersect.Framework.Core.GameObjects.Items;
using Intersect.Framework.Core.GameObjects.NPCs;
using Intersect.Framework.Core.Serialization;
using Intersect.Localization;
using Intersect.Models;
Expand Down Expand Up @@ -254,7 +255,7 @@ public string GetTaskString(Dictionary<int, LocalizedString> descriptions)
break;
case QuestObjective.KillNpcs: //Kill Npcs
taskString = descriptions[(int)Objective].ToString(
NpcBase.GetName(TargetId),
NPCDescriptor.GetName(TargetId),
Quantity,
Description
);
Expand Down
3 changes: 2 additions & 1 deletion Intersect.Client.Core/Interface/Game/QuestsWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
using Intersect.Client.Networking;
using Intersect.Enums;
using Intersect.Framework.Core.GameObjects.Items;
using Intersect.Framework.Core.GameObjects.NPCs;
using Intersect.GameObjects;
using Intersect.Utilities;

Expand Down Expand Up @@ -381,7 +382,7 @@ private void UpdateSelectedQuest()
Strings.QuestLog.TaskNpc.ToString(
Globals.Me.QuestProgress[mSelectedQuest.Id].TaskProgress,
mSelectedQuest.Tasks[i].Quantity,
NpcBase.GetName(mSelectedQuest.Tasks[i].TargetId)
NPCDescriptor.GetName(mSelectedQuest.Tasks[i].TargetId)
), mQuestDescTemplateLabel
);
}
Expand Down
19 changes: 10 additions & 9 deletions Intersect.Editor/Forms/DockingElements/frmMapLayers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
using Intersect.Framework.Core.GameObjects.Maps;
using Intersect.Framework.Core.GameObjects.Maps.Attributes;
using Intersect.Framework.Core.GameObjects.Maps.MapList;
using Intersect.Framework.Core.GameObjects.NPCs;
using Intersect.GameObjects;
using Intersect.Localization;
using Intersect.Utilities;
Expand Down Expand Up @@ -793,13 +794,13 @@ public void RefreshNpcList()
{
// Update the list incase npcs have been modified since form load.
cmbNpc.Items.Clear();
cmbNpc.Items.AddRange(NpcBase.Names);
cmbNpc.Items.AddRange(NPCDescriptor.Names);

// Add the map NPCs
lstMapNpcs.Items.Clear();
for (var i = 0; i < Globals.CurrentMap.Spawns.Count; i++)
{
lstMapNpcs.Items.Add(NpcBase.GetName(Globals.CurrentMap.Spawns[i].NpcId));
lstMapNpcs.Items.Add(NPCDescriptor.GetName(Globals.CurrentMap.Spawns[i].NpcId));
}

// Don't select if there are no NPCs, to avoid crashes.
Expand All @@ -816,7 +817,7 @@ public void RefreshNpcList()
if (lstMapNpcs.SelectedIndex < Globals.CurrentMap.Spawns.Count)
{
cmbDir.SelectedIndex = (int) Globals.CurrentMap.Spawns[lstMapNpcs.SelectedIndex].Direction;
cmbNpc.SelectedIndex = NpcBase.ListIndex(Globals.CurrentMap.Spawns[lstMapNpcs.SelectedIndex].NpcId);
cmbNpc.SelectedIndex = NPCDescriptor.ListIndex(Globals.CurrentMap.Spawns[lstMapNpcs.SelectedIndex].NpcId);
if (Globals.CurrentMap.Spawns[lstMapNpcs.SelectedIndex].X >= 0)
{
rbDeclared.Checked = true;
Expand All @@ -840,13 +841,13 @@ private void btnAddMapNpc_Click(object sender, EventArgs e)
//Don't add nothing
if (cmbNpc.SelectedIndex > -1)
{
n.NpcId = NpcBase.IdFromList(cmbNpc.SelectedIndex);
n.NpcId = NPCDescriptor.IdFromList(cmbNpc.SelectedIndex);
n.X = -1;
n.Y = -1;
n.Direction = NpcSpawnDirection.Random;

Globals.CurrentMap.Spawns.Add(n);
lstMapNpcs.Items.Add(NpcBase.GetName(n.NpcId));
lstMapNpcs.Items.Add(NPCDescriptor.GetName(n.NpcId));
lstMapNpcs.SelectedIndex = lstMapNpcs.Items.Count - 1;
}

Expand All @@ -864,7 +865,7 @@ private void btnRemoveMapNpc_Click(object sender, EventArgs e)
lstMapNpcs.Items.Clear();
for (var i = 0; i < Globals.CurrentMap.Spawns.Count; i++)
{
lstMapNpcs.Items.Add(NpcBase.GetName(Globals.CurrentMap.Spawns[i].NpcId));
lstMapNpcs.Items.Add(NPCDescriptor.GetName(Globals.CurrentMap.Spawns[i].NpcId));
}

if (lstMapNpcs.Items.Count > 0)
Expand Down Expand Up @@ -902,7 +903,7 @@ private void lstMapNpcs_Update()

var selectedSpawn = Globals.CurrentMap.Spawns[lstMapNpcs.SelectedIndex];

cmbNpc.SelectedIndex = NpcBase.ListIndex(selectedSpawn.NpcId);
cmbNpc.SelectedIndex = NPCDescriptor.ListIndex(selectedSpawn.NpcId);
cmbDir.SelectedIndex = (int)selectedSpawn.Direction;
rbDeclared.Checked = selectedSpawn.X >= 0;
rbRandom.Checked = !rbDeclared.Checked;
Expand Down Expand Up @@ -943,14 +944,14 @@ private void cmbNpc_SelectedIndexChanged(object sender, EventArgs e)

if (lstMapNpcs.SelectedIndex >= 0)
{
Globals.CurrentMap.Spawns[lstMapNpcs.SelectedIndex].NpcId = NpcBase.IdFromList(cmbNpc.SelectedIndex);
Globals.CurrentMap.Spawns[lstMapNpcs.SelectedIndex].NpcId = NPCDescriptor.IdFromList(cmbNpc.SelectedIndex);

// Refresh List
n = lstMapNpcs.SelectedIndex;
lstMapNpcs.Items.Clear();
for (var i = 0; i < Globals.CurrentMap.Spawns.Count; i++)
{
lstMapNpcs.Items.Add(NpcBase.GetName(Globals.CurrentMap.Spawns[i].NpcId));
lstMapNpcs.Items.Add(NPCDescriptor.GetName(Globals.CurrentMap.Spawns[i].NpcId));
}

lstMapNpcs.SelectedIndex = n;
Expand Down
11 changes: 6 additions & 5 deletions Intersect.Editor/Forms/Editors/Events/CommandPrinter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using Intersect.Framework.Core.GameObjects.Events.Commands;
using Intersect.Framework.Core.GameObjects.Items;
using Intersect.Framework.Core.GameObjects.Maps.MapList;
using Intersect.Framework.Core.GameObjects.NPCs;
using Intersect.Framework.Core.GameObjects.Variables;
using Intersect.GameObjects;
using Microsoft.Extensions.Logging;
Expand Down Expand Up @@ -1035,7 +1036,7 @@ private static string GetCommandText(SpawnNpcCommand command, MapInstance map)
if (orderedMap.MapId == command.MapId)
{
return Strings.EventCommandList.spawnnpc.ToString(
NpcBase.GetName(command.NpcId),
NPCDescriptor.GetName(command.NpcId),
Strings.EventCommandList.spawnonmap.ToString(
orderedMap.Name, command.X, command.Y, Strings.Direction.dir?[command.Dir]
)
Expand All @@ -1044,7 +1045,7 @@ private static string GetCommandText(SpawnNpcCommand command, MapInstance map)
}

return Strings.EventCommandList.spawnnpc.ToString(
NpcBase.GetName(command.NpcId),
NPCDescriptor.GetName(command.NpcId),
Strings.EventCommandList.spawnonmap.ToString(
Strings.EventCommandList.mapnotfound, command.X, command.Y, Strings.Direction.dir[command.Dir]
)
Expand All @@ -1062,21 +1063,21 @@ private static string GetCommandText(SpawnNpcCommand command, MapInstance map)
if (command.EntityId == Guid.Empty)
{
return Strings.EventCommandList.spawnnpc.ToString(
NpcBase.GetName(command.NpcId),
NPCDescriptor.GetName(command.NpcId),
Strings.EventCommandList.spawnonplayer.ToString(command.X, command.Y, retain)
);
}

if (map.LocalEvents.TryGetValue(command.EntityId, out var localEvent))
{
return Strings.EventCommandList.spawnnpc.ToString(
NpcBase.GetName(command.NpcId),
NPCDescriptor.GetName(command.NpcId),
Strings.EventCommandList.spawnonevent.ToString(localEvent.Name, command.X, command.Y, retain)
);
}

return Strings.EventCommandList.spawnnpc.ToString(
NpcBase.GetName(command.NpcId),
NPCDescriptor.GetName(command.NpcId),
Strings.EventCommandList.spawnonevent.ToString(
Strings.EventCommandList.deletedevent, command.X, command.Y, retain
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using Intersect.Framework.Core.GameObjects.Events.Commands;
using Intersect.Framework.Core.GameObjects.Items;
using Intersect.Framework.Core.GameObjects.Maps;
using Intersect.Framework.Core.GameObjects.NPCs;
using Intersect.Framework.Core.GameObjects.Variables;
using Intersect.GameObjects;
using Intersect.Utilities;
Expand Down Expand Up @@ -529,7 +530,7 @@ private void UpdateFormElements(ConditionType type)
case ConditionType.NoNpcsOnMap:
grpNpc.Show();
cmbNpcs.Items.Clear();
cmbNpcs.Items.AddRange(NpcBase.Names);
cmbNpcs.Items.AddRange(NPCDescriptor.Names);

chkNpc.Checked = false;
cmbNpcs.Hide();
Expand Down Expand Up @@ -1344,7 +1345,7 @@ private void SetupFormValues(NoNpcsOnMapCondition condition)
{
lblNpc.Show();
cmbNpcs.Show();
cmbNpcs.SelectedIndex = NpcBase.ListIndex(condition.NpcId);
cmbNpcs.SelectedIndex = NPCDescriptor.ListIndex(condition.NpcId);
}
else
{
Expand Down Expand Up @@ -1541,7 +1542,7 @@ private void SaveFormValues(QuestCompletedCondition condition)
private void SaveFormValues(NoNpcsOnMapCondition condition)
{
condition.SpecificNpc = chkNpc.Checked;
condition.NpcId = condition.SpecificNpc ? NpcBase.IdFromList(cmbNpcs.SelectedIndex) : default;
condition.NpcId = condition.SpecificNpc ? NPCDescriptor.IdFromList(cmbNpcs.SelectedIndex) : default;
}

private void SaveFormValues(GenderIsCondition condition)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using Intersect.Framework.Core.GameObjects.Events.Commands;
using Intersect.Framework.Core.GameObjects.Maps;
using Intersect.Framework.Core.GameObjects.Maps.MapList;
using Intersect.Framework.Core.GameObjects.NPCs;
using Intersect.GameObjects;

namespace Intersect.Editor.Forms.Editors.Events.Event_Commands;
Expand Down Expand Up @@ -41,8 +42,8 @@ SpawnNpcCommand editingCommand
mCurrentMap = currentMap;
InitLocalization();
cmbNpc.Items.Clear();
cmbNpc.Items.AddRange(NpcBase.Names);
cmbNpc.SelectedIndex = NpcBase.ListIndex(mMyCommand.NpcId);
cmbNpc.Items.AddRange(NPCDescriptor.Names);
cmbNpc.SelectedIndex = NPCDescriptor.ListIndex(mMyCommand.NpcId);
if (mMyCommand.MapId != Guid.Empty)
{
cmbConditionType.SelectedIndex = 0;
Expand Down Expand Up @@ -181,7 +182,7 @@ private void UpdateSpawnPreview()

private void btnSave_Click(object sender, EventArgs e)
{
mMyCommand.NpcId = NpcBase.IdFromList(cmbNpc.SelectedIndex);
mMyCommand.NpcId = NPCDescriptor.IdFromList(cmbNpc.SelectedIndex);
switch (cmbConditionType.SelectedIndex)
{
case 0: //Tile Spawn
Expand Down
7 changes: 4 additions & 3 deletions Intersect.Editor/Forms/Editors/Quest/Quest_TaskEditor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using Intersect.Editor.Localization;
using Intersect.Enums;
using Intersect.Framework.Core.GameObjects.Items;
using Intersect.Framework.Core.GameObjects.NPCs;
using Intersect.GameObjects;
using Microsoft.Extensions.Logging;

Expand Down Expand Up @@ -57,7 +58,7 @@ public QuestTaskEditor(QuestBase refQuest, QuestBase.QuestTask refTask)

break;
case 2: //Kill NPCS
cmbNpc.SelectedIndex = NpcBase.ListIndex(mMyTask?.TargetId ?? Guid.Empty);
cmbNpc.SelectedIndex = NPCDescriptor.ListIndex(mMyTask?.TargetId ?? Guid.Empty);
nudNpcQuantity.Value = mMyTask?.Quantity ?? 0;

break;
Expand Down Expand Up @@ -115,7 +116,7 @@ private void UpdateFormElements()
case 2: //Kill Npcs
grpKillNpcs.Show();
cmbNpc.Items.Clear();
cmbNpc.Items.AddRange(NpcBase.Names);
cmbNpc.Items.AddRange(NPCDescriptor.Names);
if (cmbNpc.Items.Count > 0)
{
cmbNpc.SelectedIndex = 0;
Expand Down Expand Up @@ -144,7 +145,7 @@ private void btnSave_Click(object sender, EventArgs e)

break;
case QuestObjective.KillNpcs: //Kill Npcs
mMyTask.TargetId = NpcBase.IdFromList(cmbNpc.SelectedIndex);
mMyTask.TargetId = NPCDescriptor.IdFromList(cmbNpc.SelectedIndex);
mMyTask.Quantity = (int) nudNpcQuantity.Value;

break;
Expand Down
Loading

0 comments on commit ffefd3a

Please sign in to comment.