-
-
Notifications
You must be signed in to change notification settings - Fork 78
feat(instances): time-space and raid entrances, from the capture to w… #2282
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
Open
denislauri1999
wants to merge
4
commits into
NosCoreIO:master
Choose a base branch
from
denislauri1999:pr/scripted-instances
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
c43595e
feat(instances): the runtime, stacked on the import instead of repeat…
denislauri1999 ccf80e6
style: drop the comments, upstream keeps only what a reader would get…
denislauri1999 0d4a1fd
fix(instances): a built definition no longer grows when the builder i…
denislauri1999 829f460
chore(instances): drop the UTF-8 BOM from the files this branch adds
denislauri1999 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
src/NosCore.GameObject/Services/ScriptedInstanceService/IScriptedInstanceService.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| // __ _ __ __ ___ __ ___ ___ | ||
| // | \| |/__\ /' _/ / _//__\| _ \ __| | ||
| // | | ' | \/ |`._`.| \_| \/ | v / _| | ||
| // |_|\__|\__/ |___/ \__/\__/|_|_\___| | ||
| // | ||
|
|
||
| using NosCore.Packets.ServerPackets.MiniMap; | ||
| using System; | ||
| using System.Collections.Generic; | ||
| using System.Threading.Tasks; | ||
|
|
||
| namespace NosCore.GameObject.Services.ScriptedInstanceService | ||
| { | ||
| public interface IScriptedInstanceService | ||
| { | ||
| IReadOnlyList<ScriptedInstance> GetByMap(short mapId); | ||
|
|
||
| ScriptedInstance? GetAt(short mapId, short positionX, short positionY); | ||
|
|
||
| IEnumerable<WpPacket> GenerateWp(short mapId); | ||
|
|
||
| Task<ScriptedInstanceRun?> InstantiateAsync(ScriptedInstance entrance); | ||
|
|
||
| ScriptedInstanceRun? GetRun(Guid mapInstanceId); | ||
|
|
||
| Task<bool> DisposeIfEmptyAsync(ScriptedInstanceRun run); | ||
| } | ||
| } |
118 changes: 118 additions & 0 deletions
118
src/NosCore.GameObject/Services/ScriptedInstanceService/InstanceDefinitionBuilder.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,118 @@ | ||
| // __ _ __ __ ___ __ ___ ___ | ||
| // | \| |/__\ /' _/ / _//__\| _ \ __| | ||
| // | | ' | \/ |`._`.| \_| \/ | v / _| | ||
| // |_|\__|\__/ |___/ \__/\__/|_|_\___| | ||
| // | ||
|
|
||
| using System.Collections.Generic; | ||
|
|
||
| namespace NosCore.GameObject.Services.ScriptedInstanceService | ||
| { | ||
| public sealed class InstanceDefinitionBuilder | ||
| { | ||
| private readonly List<InstanceRoom> _rooms = []; | ||
| private readonly List<InstanceGift> _required = []; | ||
| private readonly List<InstanceGift> _draw = []; | ||
| private readonly List<InstanceGift> _special = []; | ||
| private readonly List<InstanceGift> _gift = []; | ||
|
|
||
| private byte _id; | ||
| private string? _label; | ||
| private string? _title; | ||
| private byte _levelMinimum; | ||
| private byte _levelMaximum; | ||
| private byte _lives; | ||
| private short _startX; | ||
| private short _startY; | ||
| private long _gold; | ||
| private int _reputation; | ||
| private int _familyExperience; | ||
|
|
||
| public static InstanceDefinitionBuilder Named(byte id, string label, string title) | ||
| { | ||
| return new InstanceDefinitionBuilder { _id = id, _label = label, _title = title }; | ||
| } | ||
|
|
||
| public InstanceDefinitionBuilder ForLevels(byte minimum, byte maximum) | ||
| { | ||
| _levelMinimum = minimum; | ||
| _levelMaximum = maximum; | ||
| return this; | ||
| } | ||
|
|
||
| public InstanceDefinitionBuilder WithLives(byte lives) | ||
| { | ||
| _lives = lives; | ||
| return this; | ||
| } | ||
|
|
||
| public InstanceDefinitionBuilder StartingAt(short x, short y) | ||
| { | ||
| _startX = x; | ||
| _startY = y; | ||
| return this; | ||
| } | ||
|
|
||
| public InstanceDefinitionBuilder Rewarding(long gold = 0, int reputation = 0, int familyExperience = 0) | ||
| { | ||
| _gold = gold; | ||
| _reputation = reputation; | ||
| _familyExperience = familyExperience; | ||
| return this; | ||
| } | ||
|
|
||
| public InstanceDefinitionBuilder WithRoom(short mapVNum, out int key, byte indexX = 0, byte indexY = 0) | ||
| { | ||
| key = _rooms.Count + 1; | ||
| _rooms.Add(new InstanceRoom(key, mapVNum, indexX, indexY)); | ||
| return this; | ||
| } | ||
|
|
||
| public InstanceDefinitionBuilder Requiring(short vNum, short amount) | ||
| { | ||
| _required.Add(new InstanceGift(vNum, amount)); | ||
| return this; | ||
| } | ||
|
|
||
| public InstanceDefinitionBuilder Drawing(short vNum, short amount, short design = 0, bool randomRare = false) | ||
| { | ||
| _draw.Add(new InstanceGift(vNum, amount, design, randomRare)); | ||
| return this; | ||
| } | ||
|
|
||
| public InstanceDefinitionBuilder WithSpecialReward(short vNum, short amount, bool heroic = false) | ||
| { | ||
| _special.Add(new InstanceGift(vNum, amount, 0, false, heroic)); | ||
| return this; | ||
| } | ||
|
|
||
| public InstanceDefinitionBuilder WithReward(short vNum, short amount) | ||
| { | ||
| _gift.Add(new InstanceGift(vNum, amount)); | ||
| return this; | ||
| } | ||
|
|
||
| public ScriptedInstanceDefinition Build() | ||
| { | ||
| return new ScriptedInstanceDefinition | ||
| { | ||
| Id = _id, | ||
| Label = _label, | ||
| Title = _title, | ||
| LevelMinimum = _levelMinimum, | ||
| LevelMaximum = _levelMaximum, | ||
| Lives = _lives, | ||
| StartX = _startX, | ||
| StartY = _startY, | ||
| Gold = _gold, | ||
| Reputation = _reputation, | ||
| FamilyExperience = _familyExperience, | ||
| RequiredItems = [.. _required], | ||
| DrawItems = [.. _draw], | ||
| SpecialItems = [.. _special], | ||
| GiftItems = [.. _gift], | ||
| Rooms = [.. _rooms] | ||
| }; | ||
| } | ||
| } | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🩺 Stability & Availability | 🟠 Major | ⚡ Quick win
Register the destination session before cleanup.
DisposeIfEmptyAsyncchecksMapInstance.Sessions. At Line 175, the destination channel is not added until Lines 250-252. If the final player moves between rooms in the same run, every room appears empty and cleanup removes the destination room.Move this cleanup after the destination
Sessions.Add, or register the destination session before cleanup.🤖 Prompt for AI Agents