ace/Source/ACE.Server/Entity/CreateList.cs
Mag-nus 75fc1ce23c
Step 3. Convert ShardDatabase/WorldObjects biota from the ACE.Database model to the new ACE.Entity model (#2731)
* Step 1. Add new adapter classes and models

All classes and objects added are in new namespaces.

This add has 0 interraction on existing ACE code.

This sets the groundwork for Step 2. Moving World DB caching to the new models

* first part of the world entity usage

* almost there

* final part

* update WeenieExtensions

* fix

* merge fixes and improvements

* ACE.Database new code

* it compiles

* InitializePropertyDictionaries

* WOrldDatabaseWithEntityCache cleanup

* ShardDatabaseWithCaching

* ShardDatabase Cleanup

* todo

* cache counts reported in serverstatus

* House InitializePropertyDictionaries

* improve ServerStatus

* BiotaModel change HousePermissions to Dictionary<uint, bool>

* PropertiesAllegiance to dictionary

* BiotaUpdater improvements

* Shard Database Cache Reporting

* More code ported from Step 3

* Remove stub CharacterCache

* Update WorldDatabaseWithEntityCache.cs

* build fixes

* code audit

* Remove non-callback functions from SerializedShardDatabase

* BiotaUpdater progress.. only emote left

* Emotes done... now need to test

* fix

* Burden/Value fix for containers

* fat fingered EncumbranceVal

* add some safety

* Don't cache player biotas for initial PlayerManager load

* fix null spellbook

* Add another null check

This is redundant as the check is also upstream.

This is to prevent an exception in the future if this function is called from another source.
2020-04-02 22:40:27 -05:00

71 lines
2 KiB
C#

using System.Collections.Generic;
using ACE.Entity.Enum;
using ACE.Entity.Models;
namespace ACE.Server.Entity
{
public class CreateList
{
public List<PropertiesCreateList> Items;
public List<CreateListSet> Sets; // only for items w/ Treasure flag and probability
public List<int> ItemSets; // item index -> set index
public CreateList(List<PropertiesCreateList> createList)
{
Items = createList;
BuildSets(createList);
}
public void BuildSets(List<PropertiesCreateList> createList)
{
Sets = new List<CreateListSet>();
ItemSets = new List<int>();
var setIdx = -1;
var totalProbability = 0.0f;
CreateListSet currentSet = null;
for (var i = 0; i < createList.Count; i++)
{
var item = createList[i];
var destinationType = (DestinationType)item.DestinationType;
var useRNG = destinationType.HasFlag(DestinationType.Treasure) && item.Shade != 0;
var shadeOrProbability = item.Shade;
if (useRNG)
{
// handle sets in 0-1 chunks
if (totalProbability == 0.0f || totalProbability >= 1.0f)
{
totalProbability = 0.0f;
currentSet = new CreateListSet();
Sets.Add(currentSet);
setIdx++;
}
var probability = shadeOrProbability;
totalProbability += probability;
currentSet.Add(item);
ItemSets.Add(setIdx);
}
else
ItemSets.Add(-1);
}
}
public CreateListSetModifier GetSetModifier(int idx, float modifier)
{
var set = Sets[ItemSets[idx]];
return new CreateListSetModifier(set, modifier);
}
}
}