-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #253 from sebastian-heinz/feature/drops
Enemy drops and random item gathering amounts
- Loading branch information
Showing
43 changed files
with
213,582 additions
and
11,231 deletions.
There are no files selected for viewing
This file contains 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 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 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 was deleted.
Oops, something went wrong.
This file contains 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
14 changes: 0 additions & 14 deletions
14
Arrowgene.Ddon.GameServer/GatheringItems/GatheringItemManager.cs
This file was deleted.
Oops, something went wrong.
30 changes: 30 additions & 0 deletions
30
Arrowgene.Ddon.GameServer/GatheringItems/InstanceDropItemManager.cs
This file contains 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,30 @@ | ||
using System.Collections.Generic; | ||
using Arrowgene.Ddon.Shared; | ||
using Arrowgene.Ddon.Shared.Model; | ||
|
||
namespace Arrowgene.Ddon.GameServer.GatheringItems | ||
{ | ||
public class InstanceDropItemManager : InstanceItemManager<uint> | ||
{ | ||
public InstanceDropItemManager(AssetRepository assetRepository) : base() | ||
{ | ||
this.assetRepository = assetRepository; | ||
} | ||
|
||
private readonly AssetRepository assetRepository; | ||
|
||
protected override List<GatheringItem> FetchItemsFromRepository(StageId stage, uint setId) | ||
{ | ||
List<Enemy> enemiesInSet = assetRepository.EnemySpawnAsset.Enemies.GetValueOrDefault((stage, (byte) 0)); | ||
if(enemiesInSet != null && setId < enemiesInSet.Count) | ||
{ | ||
Enemy enemy = enemiesInSet[(int) setId]; | ||
if(enemy.DropsTable != null) | ||
{ | ||
return enemy.DropsTable.Items; | ||
} | ||
} | ||
return new List<GatheringItem>(); | ||
} | ||
} | ||
} |
34 changes: 6 additions & 28 deletions
34
Arrowgene.Ddon.GameServer/GatheringItems/InstanceGatheringItemManager.cs
This file contains 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 |
---|---|---|
@@ -1,43 +1,21 @@ | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using Arrowgene.Ddon.Shared; | ||
using Arrowgene.Ddon.Shared.Entity.Structure; | ||
using Arrowgene.Ddon.Shared.Model; | ||
|
||
namespace Arrowgene.Ddon.GameServer.GatheringItems | ||
{ | ||
public class InstanceGatheringItemManager | ||
public class InstanceGatheringItemManager : InstanceItemManager<uint> | ||
{ | ||
public InstanceGatheringItemManager(GatheringItemManager gatheringItemManager) | ||
public InstanceGatheringItemManager(AssetRepository assetRepository) : base() | ||
{ | ||
this._gatheringItemManager = gatheringItemManager; | ||
this._gatheringItemsDictionary = new MultiKeyMultiValueDictionary<StageId, uint, GatheringItem>(); | ||
this.assetRepository = assetRepository; | ||
} | ||
|
||
private readonly GatheringItemManager _gatheringItemManager; | ||
private readonly MultiKeyMultiValueDictionary<StageId, uint, GatheringItem> _gatheringItemsDictionary; | ||
private readonly AssetRepository assetRepository; | ||
|
||
public List<GatheringItem> GetAssets(CDataStageLayoutId stageLayoutId, uint subGroupId) | ||
protected override List<GatheringItem> FetchItemsFromRepository(StageId stage, uint subGroupId) | ||
{ | ||
return GetAssets(StageId.FromStageLayoutId(stageLayoutId), subGroupId); | ||
} | ||
|
||
public List<GatheringItem> GetAssets(StageId stageId, uint subGroupId) | ||
{ | ||
if(!_gatheringItemsDictionary.Has(stageId, subGroupId)) | ||
{ | ||
List<GatheringItem> items = _gatheringItemManager.GetAssets(stageId, subGroupId); | ||
List<GatheringItem> itemsClone = items.Select(item => (GatheringItem) item.Clone()).ToList(); | ||
_gatheringItemsDictionary.AddRange(stageId, subGroupId, itemsClone); | ||
return items; | ||
} | ||
|
||
return _gatheringItemsDictionary.Get(stageId, subGroupId); | ||
} | ||
|
||
public void Clear() | ||
{ | ||
_gatheringItemsDictionary.Clear(); | ||
return assetRepository.GatheringItems.GetValueOrDefault((stage, subGroupId)) ?? new List<GatheringItem>(); | ||
} | ||
} | ||
} |
41 changes: 41 additions & 0 deletions
41
Arrowgene.Ddon.GameServer/GatheringItems/InstanceItemManager.cs
This file contains 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,41 @@ | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using Arrowgene.Ddon.Shared.Entity.Structure; | ||
using Arrowgene.Ddon.Shared.Model; | ||
|
||
namespace Arrowgene.Ddon.GameServer.GatheringItems | ||
{ | ||
public abstract class InstanceItemManager<T> | ||
{ | ||
public InstanceItemManager() | ||
{ | ||
this._gatheringItemsDictionary = new Dictionary<(StageId, T), List<InstancedGatheringItem>>(); | ||
} | ||
|
||
private readonly Dictionary<(StageId, T), List<InstancedGatheringItem>> _gatheringItemsDictionary; | ||
|
||
public List<InstancedGatheringItem> GetAssets(CDataStageLayoutId stageLayoutId, T subGroupId) | ||
{ | ||
return GetAssets(StageId.FromStageLayoutId(stageLayoutId), subGroupId); | ||
} | ||
|
||
public List<InstancedGatheringItem> GetAssets(StageId stageId, T subGroupId) | ||
{ | ||
if(!_gatheringItemsDictionary.ContainsKey((stageId, subGroupId))) | ||
{ | ||
List<GatheringItem> items = FetchItemsFromRepository(stageId, subGroupId); | ||
List<InstancedGatheringItem> instancedItems = items.Select(item => new InstancedGatheringItem(item)).ToList(); | ||
_gatheringItemsDictionary.Add((stageId, subGroupId), instancedItems); | ||
return instancedItems; | ||
} | ||
return _gatheringItemsDictionary[(stageId, subGroupId)]; | ||
} | ||
|
||
public void Clear() | ||
{ | ||
_gatheringItemsDictionary.Clear(); | ||
} | ||
|
||
protected abstract List<GatheringItem> FetchItemsFromRepository(StageId stage, T subGroupId); | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
Arrowgene.Ddon.GameServer/GatheringItems/InstancedGatheringItem.cs
This file contains 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,22 @@ | ||
using System; | ||
using Arrowgene.Ddon.Shared.Model; | ||
|
||
public class InstancedGatheringItem | ||
{ | ||
public InstancedGatheringItem() | ||
{ | ||
} | ||
|
||
public InstancedGatheringItem(GatheringItem gatheringItem) | ||
{ | ||
ItemId = gatheringItem.ItemId; | ||
ItemNum = (uint) Random.Shared.Next((int) gatheringItem.ItemNum, (int) gatheringItem.MaxItemNum+1); | ||
Quality = gatheringItem.Quality; | ||
IsHidden = gatheringItem.IsHidden; | ||
} | ||
|
||
public uint ItemId { get; set; } | ||
public uint ItemNum { get; set; } | ||
public uint Quality { get; set; } | ||
public bool IsHidden { get; set; } | ||
} |
Oops, something went wrong.