Here are the examples of the csharp api System.Collections.Generic.List.Add(uint) taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
678 Examples
19
Source : JobBars.Party.cs
with GNU Affero General Public License v3.0
from 0ceal0t
with GNU Affero General Public License v3.0
from 0ceal0t
private static List<uint> GetPartyMemberOrder() {
var ret = new List<uint>();
var partyUI = UIHelper.GetPartyUI();
if (partyUI == null || partyUI->PartyMemberCount == 0) { // fallback
ret.Add(ClientState.LocalPlayer.ObjectId);
return ret;
}
for (int i = 0; i < partyUI->PartyMemberCount; i++) {
var member = partyUI->PartyMember[i];
var objectId = (uint)member.ObjectID;
ret.Add((objectId == 0xE0000000 || objectId == 0xFFFFFFFF) ? 0 : objectId);
}
return ret;
}
19
Source : JobBars.Party.cs
with GNU Affero General Public License v3.0
from 0ceal0t
with GNU Affero General Public License v3.0
from 0ceal0t
private static List<uint> GetPartyMemberOrder() {
var ret = new List<uint>();
var partyUI = UIHelper.GetPartyUI();
if (partyUI == null || partyUI->PartyMemberCount == 0) { // fallback
ret.Add(ClientState.LocalPlayer.ObjectId);
return ret;
}
for (int i = 0; i < partyUI->PartyMemberCount; i++) {
var member = partyUI->PartyMember[i];
var objectId = (uint)member.ObjectID;
ret.Add((objectId == 0xE0000000 || objectId == 0xFFFFFFFF) ? 0 : objectId);
}
return ret;
}
19
Source : AvifWriter.AvifWriterState.cs
with MIT License
from 0xC0000054
with MIT License
from 0xC0000054
private ImageStateInfo InitializeFromImageGrid(IReadOnlyList<CompressedAV1Image> colorImages,
IReadOnlyList<CompressedAV1Image> alphaImages,
bool premultipliedAlpha,
ImageGridMetadata imageGridMetadata)
{
ulong mediaDataBoxContentSize = 0;
uint itemId = FirsreplacedemId;
List<uint> colorImageIds = new List<uint>(colorImages.Count);
List<uint> alphaImageIds = alphaImages != null ? new List<uint>(alphaImages.Count) : null;
List<int> mediaDataBoxColorItemIndexes = new List<int>(colorImages.Count);
List<int> mediaBoxAlphaItemIndexes = new List<int>(alphaImages != null ? alphaImages.Count : 0);
for (int i = 0; i < colorImages.Count; i++)
{
int duplicateImageIndex;
int duplicateColorImageIndex = -1;
if (this.duplicateColorTiles.TryGetValue(i, out duplicateImageIndex))
{
duplicateColorImageIndex = mediaDataBoxColorItemIndexes[duplicateImageIndex];
}
CompressedAV1Image color = colorImages[i];
AvifWriterItem colorItem = AvifWriterItem.CreateFromImage(itemId, null, color, false, duplicateColorImageIndex);
itemId++;
colorImageIds.Add(colorItem.Id);
mediaDataBoxColorItemIndexes.Add(this.items.Count);
this.items.Add(colorItem);
if (duplicateColorImageIndex == -1)
{
mediaDataBoxContentSize += color.Data.ByteLength;
}
if (alphaImages != null)
{
int duplicateAlphaImageIndex = -1;
if (this.duplicateAlphaTiles.TryGetValue(i, out duplicateImageIndex))
{
duplicateAlphaImageIndex = mediaBoxAlphaItemIndexes[duplicateImageIndex];
}
CompressedAV1Image alpha = alphaImages[i];
AvifWriterItem alphaItem = AvifWriterItem.CreateFromImage(itemId, null, alpha, true, duplicateAlphaImageIndex);
itemId++;
alphaItem.ItemReferences.Add(new ItemReferenceEntryBox(alphaItem.Id, ReferenceTypes.AuxiliaryImage, colorItem.Id));
if (premultipliedAlpha)
{
alphaItem.ItemReferences.Add(new ItemReferenceEntryBox(colorItem.Id,
ReferenceTypes.PremultipliedAlphaImage,
alphaItem.Id));
}
alphaImageIds.Add(alphaItem.Id);
mediaBoxAlphaItemIndexes.Add(this.items.Count);
this.items.Add(alphaItem);
if (duplicateAlphaImageIndex == -1)
{
mediaDataBoxContentSize += alpha.Data.ByteLength;
}
}
}
ulong gridDescriptorLength;
if (imageGridMetadata.OutputHeight > ushort.MaxValue || imageGridMetadata.OutputWidth > ushort.MaxValue)
{
gridDescriptorLength = ImageGridDescriptor.LargeDescriptorLength;
}
else
{
gridDescriptorLength = ImageGridDescriptor.SmallDescriptorLength;
}
// The grid items do not have any data to write in the media data box.
AvifWriterItem colorGridItem = AvifWriterItem.CreateFromImageGrid(itemId, "Color", 0, gridDescriptorLength);
itemId++;
colorGridItem.ItemReferences.Add(new ItemReferenceEntryBox(colorGridItem.Id, ReferenceTypes.DerivedImage, colorImageIds));
this.PrimaryItemId = colorGridItem.Id;
this.items.Add(colorGridItem);
if (alphaImages != null)
{
// The ImageGridDescriptor is shared between the color and alpha image.
AvifWriterItem alphaGridItem = AvifWriterItem.CreateFromImageGrid(itemId, "Alpha", 0, gridDescriptorLength);
itemId++;
alphaGridItem.ItemReferences.Add(new ItemReferenceEntryBox(alphaGridItem.Id, ReferenceTypes.AuxiliaryImage, colorGridItem.Id));
alphaGridItem.ItemReferences.Add(new ItemReferenceEntryBox(alphaGridItem.Id, ReferenceTypes.DerivedImage, alphaImageIds));
if (premultipliedAlpha)
{
alphaGridItem.ItemReferences.Add(new ItemReferenceEntryBox(colorGridItem.Id,
ReferenceTypes.PremultipliedAlphaImage,
alphaGridItem.Id));
}
this.AlphaItemId = alphaGridItem.Id;
this.items.Add(alphaGridItem);
}
this.MediaDataBoxAlphaItemIndexes = mediaBoxAlphaItemIndexes;
this.MediaDataBoxColorItemIndexes = mediaDataBoxColorItemIndexes;
return new ImageStateInfo(mediaDataBoxContentSize, itemId);
}
19
Source : Formatter.Array1.List.cs
with MIT License
from 1996v
with MIT License
from 1996v
public List<UInt32> Deserialize(ref BssomReader reader, ref BssomDeserializeContext context)
{
if (reader.TryReadNullWithEnsureArray1BuildInType(BssomType.UInt32Code))
{
return default;
}
context.Option.Security.DepthStep(ref context);
reader.SkipVariableNumber();
int len = reader.ReadVariableNumber();
List<uint> val = new List<UInt32>(len);
for (int i = 0; i < len; i++)
{
val.Add(reader.ReadUInt32WithOutTypeHead());
}
context.Depth--;
return val;
}
19
Source : Builder.cs
with MIT License
from a3geek
with MIT License
from a3geek
private void AddSeeds(int count)
{
for(var i = 0; i < count; i++)
{
this.Seeds.Add((uint)(Random.value * uint.MaxValue));
}
}
19
Source : BaseCursor.cs
with Apache License 2.0
from abist-co-ltd
with Apache License 2.0
from abist-co-ltd
public virtual void OnPointerDown(MixedRealityPointerEventData eventData)
{
if (IsPointerValid)
{
foreach (var sourcePointer in eventData.InputSource.Pointers)
{
if (sourcePointer.PointerId == Pointer.PointerId)
{
SourceDownIds.Add(eventData.SourceId);
return;
}
}
}
}
19
Source : SpellBase.cs
with GNU Affero General Public License v3.0
from ACEmulator
with GNU Affero General Public License v3.0
from ACEmulator
public void Unpack(BinaryReader reader)
{
Name = reader.ReadObfuscatedString();
reader.AlignBoundary();
Desc = reader.ReadObfuscatedString();
reader.AlignBoundary();
School = (MagicSchool)reader.ReadUInt32();
Icon = reader.ReadUInt32();
Category = (SpellCategory)reader.ReadUInt32();
Bitfield = reader.ReadUInt32();
BaseMana = reader.ReadUInt32();
BaseRangeConstant = reader.ReadSingle();
BaseRangeMod = reader.ReadSingle();
Power = reader.ReadUInt32();
SpellEconomyMod = reader.ReadSingle();
FormulaVersion = reader.ReadUInt32();
ComponentLoss = reader.ReadSingle();
MetaSpellType = (SpellType)reader.ReadUInt32();
MetaSpellId = reader.ReadUInt32();
switch (MetaSpellType)
{
case SpellType.Enchantment:
case SpellType.FellowEnchantment:
Duration = reader.ReadDouble();
DegradeModifier = reader.ReadSingle();
DegradeLimit = reader.ReadSingle();
break;
case SpellType.PortalSummon:
PortalLifetime = reader.ReadDouble();
break;
}
// Components : Load them first, then decrypt them. More efficient to hash all at once.
List<uint> rawComps = new List<uint>();
for (uint j = 0; j < 8; j++)
{
uint comp = reader.ReadUInt32();
// We will only add the comp if it is valid
if (comp > 0)
rawComps.Add(comp);
}
// Get the decryped component values
Formula = DecryptFormula(rawComps, Name, Desc);
CasterEffect = reader.ReadUInt32();
TargetEffect = reader.ReadUInt32();
FizzleEffect = reader.ReadUInt32();
RecoveryInterval = reader.ReadDouble();
RecoveryAmount = reader.ReadSingle();
DisplayOrder = reader.ReadUInt32();
NonComponentTargetType = reader.ReadUInt32();
ManaMod = reader.ReadUInt32();
}
19
Source : SpellBase.cs
with GNU Affero General Public License v3.0
from ACEmulator
with GNU Affero General Public License v3.0
from ACEmulator
private static List<uint> DecryptFormula(List<uint> rawComps, string name, string desc)
{
List<uint> comps = new List<uint>();
// uint testDescHash = ComputeHash(" – 200");
uint nameHash = SpellTable.ComputeHash(name);
uint descHash = SpellTable.ComputeHash(desc);
uint key = (nameHash % 0x12107680) + (descHash % 0xBEADCF45);
for (int i = 0; i < rawComps.Count; i++)
{
uint comp = (rawComps[i] - key);
// This seems to correct issues with certain spells with extended characters.
if (comp > HIGHEST_COMP_ID) // highest comp ID is 198 - "Essence of Kemeroi", for Void Spells
comp = comp & 0xFF;
comps.Add(comp);
}
return comps;
}
19
Source : StringTableData.cs
with GNU Affero General Public License v3.0
from ACEmulator
with GNU Affero General Public License v3.0
from ACEmulator
public void Unpack(BinaryReader reader)
{
Id = reader.ReadUInt32();
var num_varnames = reader.ReadUInt16();
for (uint i = 0; i < num_varnames; i++)
VarNames.Add(reader.ReadUnicodeString());
var num_vars = reader.ReadUInt16();
for (uint i = 0; i < num_vars; i++)
Vars.Add(reader.ReadUnicodeString());
var num_strings = reader.ReadUInt32();
for (uint i = 0; i < num_strings; i++)
Strings.Add(reader.ReadUnicodeString());
var num_comments = reader.ReadUInt32();
for (uint i = 0; i < num_comments; i++)
Comments.Add(reader.ReadUInt32());
Unknown = reader.ReadByte();
}
19
Source : EnvCell.cs
with GNU Affero General Public License v3.0
from ACEmulator
with GNU Affero General Public License v3.0
from ACEmulator
public override void Unpack(BinaryReader reader)
{
Id = reader.ReadUInt32();
Flags = (EnvCellFlags)reader.ReadUInt32();
reader.BaseStream.Position += 4; // Skip ahead 4 bytes, because this is the CellId. Again. Twice.
byte numSurfaces = reader.ReadByte();
byte numPortals = reader.ReadByte(); // Note that "portal" in this context does not refer to the swirly pink/purple thing, its basically connecting cells
ushort numStabs = reader.ReadUInt16(); // I believe this is what cells can be seen from this one. So the engine knows what else it needs to load/draw.
// Read what surfaces are used in this cell
for (uint i = 0; i < numSurfaces; i++)
Surfaces.Add(0x08000000u | reader.ReadUInt16()); // these are stored in the dat as short values, so we'll make them a full dword
EnvironmentId = (0x0D000000u | reader.ReadUInt16());
CellStructure = reader.ReadUInt16();
Position.Unpack(reader);
CellPortals.Unpack(reader, numPortals);
for (uint i = 0; i < numStabs; i++)
VisibleCells.Add(reader.ReadUInt16());
if ((Flags & EnvCellFlags.HreplacedtaticObjs) != 0)
StaticObjects.Unpack(reader);
if ((Flags & EnvCellFlags.HasRestrictionObj) != 0)
RestrictionObj = reader.ReadUInt32();
}
19
Source : XpTable.cs
with GNU Affero General Public License v3.0
from ACEmulator
with GNU Affero General Public License v3.0
from ACEmulator
public override void Unpack(BinaryReader reader)
{
Id = reader.ReadUInt32();
// The counts for each "Table" are at the top of the file.
int attributeCount = reader.ReadInt32();
int vitalCount = reader.ReadInt32();
int trainedSkillCount = reader.ReadInt32();
int specializedSkillCount = reader.ReadInt32();
uint levelCount = reader.ReadUInt32();
for (int i = 0; i <= attributeCount; i++)
AttributeXpList.Add(reader.ReadUInt32());
for (int i = 0; i <= vitalCount; i++)
VitalXpList.Add(reader.ReadUInt32());
for (int i = 0; i <= trainedSkillCount; i++)
TrainedSkillXpList.Add(reader.ReadUInt32());
for (int i = 0; i <= specializedSkillCount; i++)
SpecializedSkillXpList.Add(reader.ReadUInt32());
for (int i = 0; i <= levelCount; i++)
CharacterLevelXPList.Add(reader.ReadUInt64());
for (int i = 0; i <= levelCount; i++)
CharacterLevelSkillCreditList.Add(reader.ReadUInt32());
}
19
Source : UnpackableExtensions.cs
with GNU Affero General Public License v3.0
from ACEmulator
with GNU Affero General Public License v3.0
from ACEmulator
public static void Unpack(this List<uint> value, BinaryReader reader)
{
var totalObjects = reader.ReadInt32();
for (int i = 0; i < totalObjects; i++)
{
var item = reader.ReadUInt32();
value.Add(item);
}
}
19
Source : QualityFilter.cs
with GNU Affero General Public License v3.0
from ACEmulator
with GNU Affero General Public License v3.0
from ACEmulator
public override void Unpack(BinaryReader reader)
{
Id = reader.ReadUInt32();
uint numInt = reader.ReadUInt32();
uint numInt64 = reader.ReadUInt32();
uint numBool = reader.ReadUInt32();
uint numFloat = reader.ReadUInt32();
uint numDid = reader.ReadUInt32();
uint numIid = reader.ReadUInt32();
uint numString = reader.ReadUInt32();
uint numPosition = reader.ReadUInt32();
for (var i = 0; i < numInt; i++)
IntStatFilter.Add(reader.ReadUInt32());
for (var i = 0; i < numInt64; i++)
Int64StatFilter.Add(reader.ReadUInt32());
for (var i = 0; i < numBool; i++)
BoolStatFilter.Add(reader.ReadUInt32());
for (var i = 0; i < numFloat; i++)
FloatStatFilter.Add(reader.ReadUInt32());
for (var i = 0; i < numDid; i++)
DidStatFilter.Add(reader.ReadUInt32());
for (var i = 0; i < numIid; i++)
IidStatFilter.Add(reader.ReadUInt32());
for (var i = 0; i < numString; i++)
StringStatFilter.Add(reader.ReadUInt32());
for (var i = 0; i < numPosition; i++)
PositionStatFilter.Add(reader.ReadUInt32());
uint numAttribute = reader.ReadUInt32();
uint numAttribute2nd = reader.ReadUInt32();
uint numSkill = reader.ReadUInt32();
for (var i = 0; i < numAttribute; i++)
AttributeStatFilter.Add(reader.ReadUInt32());
for (var i = 0; i < numAttribute2nd; i++)
Attribute2ndStatFilter.Add(reader.ReadUInt32());
for (var i = 0; i < numSkill; i++)
SkillStatFilter.Add(reader.ReadUInt32());
}
19
Source : SetupModel.cs
with GNU Affero General Public License v3.0
from ACEmulator
with GNU Affero General Public License v3.0
from ACEmulator
public override void Unpack(BinaryReader reader)
{
Id = reader.ReadUInt32();
Flags = (SetupFlags)reader.ReadUInt32();
AllowFreeHeading = (Flags & SetupFlags.AllowFreeHeading) != 0;
HasPhysicsBSP = (Flags & SetupFlags.HasPhysicsBSP) != 0;
// Get all the GraphicsObjects in this SetupModel. These are all the 01-types.
uint numParts = reader.ReadUInt32();
for (int i = 0; i < numParts; i++)
Parts.Add(reader.ReadUInt32());
if ((Flags & SetupFlags.HasParent) != 0)
{
for (int i = 0; i < numParts; i++)
ParentIndex.Add(reader.ReadUInt32());
}
if ((Flags & SetupFlags.HasDefaultScale) != 0)
{
for (int i = 0; i < numParts; i++)
DefaultScale.Add(reader.ReadVector3());
}
HoldingLocations.Unpack(reader);
ConnectionPoints.Unpack(reader);
int placementsCount = reader.ReadInt32();
for (int i = 0; i < placementsCount; i++)
{
int key = reader.ReadInt32();
// there is a frame for each Part
var placementType = new PlacementType();
placementType.Unpack(reader, (uint)Parts.Count);
PlacementFrames.Add(key, placementType);
}
CylSpheres.Unpack(reader);
Spheres.Unpack(reader);
Height = reader.ReadSingle();
Radius = reader.ReadSingle();
StepUpHeight = reader.ReadSingle();
StepDownHeight = reader.ReadSingle();
SortingSphere.Unpack(reader);
SelectionSphere.Unpack(reader);
Lights.Unpack(reader);
DefaultAnimation = reader.ReadUInt32();
DefaultScript = reader.ReadUInt32();
DefaultMotionTable = reader.ReadUInt32();
DefaultSoundTable = reader.ReadUInt32();
DefaultScriptTable = reader.ReadUInt32();
}
19
Source : UnpackableExtensions.cs
with GNU Affero General Public License v3.0
from ACEmulator
with GNU Affero General Public License v3.0
from ACEmulator
public static void UnpackSmartArray(this List<uint> value, BinaryReader reader)
{
var totalObjects = reader.ReadCompressedUInt32();
for (int i = 0; i < totalObjects; i++)
{
var item = reader.ReadUInt32();
value.Add(item);
}
}
19
Source : Spell.cs
with GNU Affero General Public License v3.0
from ACEmulator
with GNU Affero General Public License v3.0
from ACEmulator
public List<uint> TryBurnComponents(Player player)
{
var consumed = new List<uint>();
// the base rate for each component is defined per-spell
var baseRate = ComponentLoss;
// get magic skill mod
var magicSkill = GetMagicSkill();
var playerSkill = player.GetCreatureSkill(magicSkill);
var skillMod = Math.Min(1.0f, (float)Power / playerSkill.Current);
//Console.WriteLine($"TryBurnComponents.SkillMod: {skillMod}");
//DebugComponents();
foreach (var component in Formula.CurrentFormula)
{
if (!SpellFormula.SpellComponentsTable.SpellComponents.TryGetValue(component, out var spellComponent))
{
Console.WriteLine($"Spell.TryBurnComponents(): Couldn't find SpellComponent {component}");
continue;
}
// component burn rate = spell base rate * component destruction modifier * skillMod?
var burnRate = baseRate * spellComponent.CDM * skillMod;
// TODO: curve?
var rng = ThreadSafeRandom.Next(0.0f, 1.0f);
if (rng < burnRate)
consumed.Add(component);
}
return consumed;
}
19
Source : SpellFormula.cs
with GNU Affero General Public License v3.0
from ACEmulator
with GNU Affero General Public License v3.0
from ACEmulator
public List<uint> GetFociFormula()
{
FociFormula = new List<uint>();
// Add all the scarabs (remember, some spells have multiple scarabs, like Ring spells)
for (var i = 0; i < Components.Count; i++)
{
var component = Components[i];
if (IsScarab(component) || component == 111) // added: chorizite, as per client
FociFormula.Add(component);
}
// Number of Prismatic Tapers is based on the spell "power"
// See client CSpellBase::InqScarabOnlyFormula
var numTapers = 0;
switch (Power)
{
case 1:
numTapers = 1;
break;
case 2:
numTapers = 2;
break;
case 3:
case 4:
case 7:
numTapers = 3;
break;
case 5:
case 6:
case 8:
case 9:
case 10:
numTapers = 4;
break;
}
for (var i = 0; i < numTapers; i++)
FociFormula.Add(188); // prismatic taper
return FociFormula;
}
19
Source : PlayerFactory.cs
with GNU Affero General Public License v3.0
from ACEmulator
with GNU Affero General Public License v3.0
from ACEmulator
public static CreateResult Create(CharacterCreateInfo characterCreateInfo, Weenie weenie, ObjectGuid guid, uint accountId, WeenieType weenieType, out Player player)
{
var heritageGroup = DatManager.PortalDat.CharGen.HeritageGroups[(uint)characterCreateInfo.Heritage];
if (weenieType == WeenieType.Admin)
player = new Admin(weenie, guid, accountId);
else if (weenieType == WeenieType.Sentinel)
player = new Sentinel(weenie, guid, accountId);
else
player = new Player(weenie, guid, accountId);
player.SetProperty(PropertyInt.HeritageGroup, (int)characterCreateInfo.Heritage);
player.SetProperty(PropertyString.HeritageGroup, heritageGroup.Name);
player.SetProperty(PropertyInt.Gender, (int)characterCreateInfo.Gender);
player.SetProperty(PropertyString.Sex, characterCreateInfo.Gender == 1 ? "Male" : "Female");
//player.SetProperty(PropertyDataId.Icon, cgh.IconImage); // I don't believe this is used anywhere in the client, but it might be used by a future custom launcher
// pull character data from the dat file
var sex = heritageGroup.Genders[(int)characterCreateInfo.Gender];
player.SetProperty(PropertyDataId.MotionTable, sex.MotionTable);
player.SetProperty(PropertyDataId.SoundTable, sex.SoundTable);
player.SetProperty(PropertyDataId.PhysicsEffectTable, sex.PhysicsTable);
player.SetProperty(PropertyDataId.Setup, sex.SetupID);
player.SetProperty(PropertyDataId.PaletteBase, sex.BasePalette);
player.SetProperty(PropertyDataId.CombatTable, sex.CombatTable);
// Check the character scale
if (sex.Scale != 100)
player.SetProperty(PropertyFloat.DefaultScale, sex.Scale / 100.0f); // Scale is stored as a percentage
// Get the hair first, because we need to know if you're bald, and that's the name of that tune!
var hairstyle = sex.HairStyleList[(int)characterCreateInfo.Appearance.HairStyle];
// Olthoi and Gear Knights have a "Body Style" instead of a hair style. These styles have multiple model/texture changes, instead of a single head/hairstyle.
// Storing this value allows us to send the proper appearance ObjDesc
if (hairstyle.ObjDesc.AnimPartChanges.Count > 1)
player.SetProperty(PropertyInt.Hairstyle, (int)characterCreateInfo.Appearance.HairStyle);
// Certain races (Undead, Tumeroks, Others?) have multiple body styles available. This is controlled via the "hair style".
if (hairstyle.AlternateSetup > 0)
player.SetProperty(PropertyDataId.Setup, hairstyle.AlternateSetup);
player.SetProperty(PropertyDataId.EyesTexture, sex.GetEyeTexture(characterCreateInfo.Appearance.Eyes, hairstyle.Bald));
player.SetProperty(PropertyDataId.DefaultEyesTexture, sex.GetDefaultEyeTexture(characterCreateInfo.Appearance.Eyes, hairstyle.Bald));
player.SetProperty(PropertyDataId.NoseTexture, sex.GetNoseTexture(characterCreateInfo.Appearance.Nose));
player.SetProperty(PropertyDataId.DefaultNoseTexture, sex.GetDefaultNoseTexture(characterCreateInfo.Appearance.Nose));
player.SetProperty(PropertyDataId.MouthTexture, sex.GetMouthTexture(characterCreateInfo.Appearance.Mouth));
player.SetProperty(PropertyDataId.DefaultMouthTexture, sex.GetDefaultMouthTexture(characterCreateInfo.Appearance.Mouth));
player.Character.HairTexture = sex.GetHairTexture(characterCreateInfo.Appearance.HairStyle) ?? 0;
player.Character.DefaultHairTexture = sex.GetDefaultHairTexture(characterCreateInfo.Appearance.HairStyle) ?? 0;
// HeadObject can be null if we're dealing with GearKnight or Olthoi
var headObject = sex.GetHeadObject(characterCreateInfo.Appearance.HairStyle);
if (headObject != null)
player.SetProperty(PropertyDataId.HeadObject, (uint)headObject);
// Skin is stored as PaletteSet (list of Palettes), so we need to read in the set to get the specific palette
var skinPalSet = DatManager.PortalDat.ReadFromDat<PaletteSet>(sex.SkinPalSet);
player.SetProperty(PropertyDataId.SkinPalette, skinPalSet.GetPaletteID(characterCreateInfo.Appearance.SkinHue));
player.SetProperty(PropertyFloat.Shade, characterCreateInfo.Appearance.SkinHue);
// Hair is stored as PaletteSet (list of Palettes), so we need to read in the set to get the specific palette
var hairPalSet = DatManager.PortalDat.ReadFromDat<PaletteSet>(sex.HairColorList[(int)characterCreateInfo.Appearance.HairColor]);
player.SetProperty(PropertyDataId.HairPalette, hairPalSet.GetPaletteID(characterCreateInfo.Appearance.HairHue));
// Eye Color
player.SetProperty(PropertyDataId.EyesPalette, sex.EyeColorList[(int)characterCreateInfo.Appearance.EyeColor]);
// skip over this for olthoi, use the weenie defaults
if (!player.IsOlthoiPlayer)
{
if (characterCreateInfo.Appearance.HeadgearStyle < uint.MaxValue) // No headgear is max UINT
{
var hat = GetClothingObject(sex.GetHeadgearWeenie(characterCreateInfo.Appearance.HeadgearStyle), characterCreateInfo.Appearance.HeadgearColor, characterCreateInfo.Appearance.HeadgearHue);
if (hat != null)
player.TryEquipObject(hat, hat.ValidLocations ?? 0);
else
player.TryAddToInventory(CreateIOU(sex.GetHeadgearWeenie(characterCreateInfo.Appearance.HeadgearStyle)));
}
var shirt = GetClothingObject(sex.GetShirtWeenie(characterCreateInfo.Appearance.ShirtStyle), characterCreateInfo.Appearance.ShirtColor, characterCreateInfo.Appearance.ShirtHue);
if (shirt != null)
player.TryEquipObject(shirt, shirt.ValidLocations ?? 0);
else
player.TryAddToInventory(CreateIOU(sex.GetShirtWeenie(characterCreateInfo.Appearance.ShirtStyle)));
var pants = GetClothingObject(sex.GetPantsWeenie(characterCreateInfo.Appearance.PantsStyle), characterCreateInfo.Appearance.PantsColor, characterCreateInfo.Appearance.PantsHue);
if (pants != null)
player.TryEquipObject(pants, pants.ValidLocations ?? 0);
else
player.TryAddToInventory(CreateIOU(sex.GetPantsWeenie(characterCreateInfo.Appearance.PantsStyle)));
var shoes = GetClothingObject(sex.GetFootwearWeenie(characterCreateInfo.Appearance.FootwearStyle), characterCreateInfo.Appearance.FootwearColor, characterCreateInfo.Appearance.FootwearHue);
if (shoes != null)
player.TryEquipObject(shoes, shoes.ValidLocations ?? 0);
else
player.TryAddToInventory(CreateIOU(sex.GetFootwearWeenie(characterCreateInfo.Appearance.FootwearStyle)));
string templateName = heritageGroup.Templates[characterCreateInfo.TemplateOption].Name;
player.SetProperty(PropertyString.Template, templateName);
player.Addreplacedle(heritageGroup.Templates[characterCreateInfo.TemplateOption].replacedle, true);
// attributes
var result = ValidateAttributeCredits(characterCreateInfo, heritageGroup.AttributeCredits);
if (result != CreateResult.Success)
return result;
player.Strength.StartingValue = characterCreateInfo.StrengthAbility;
player.Endurance.StartingValue = characterCreateInfo.EnduranceAbility;
player.Coordination.StartingValue = characterCreateInfo.CoordinationAbility;
player.Quickness.StartingValue = characterCreateInfo.QuicknessAbility;
player.Focus.StartingValue = characterCreateInfo.FocusAbility;
player.Self.StartingValue = characterCreateInfo.SelfAbility;
// data we don't care about
//characterCreateInfo.CharacterSlot;
//characterCreateInfo.ClreplacedId;
// characters start with max vitals
player.Health.Current = player.Health.Base;
player.Stamina.Current = player.Stamina.Base;
player.Mana.Current = player.Mana.Base;
// set initial skill credit amount. 52 for all but "Olthoi", which have 68
player.SetProperty(PropertyInt.AvailableSkillCredits, (int)heritageGroup.SkillCredits);
player.SetProperty(PropertyInt.TotalSkillCredits, (int)heritageGroup.SkillCredits);
if (characterCreateInfo.SkillAdvancementClreplacedes.Count != 55)
return CreateResult.ClientServerSkillsMismatch;
for (int i = 0; i < characterCreateInfo.SkillAdvancementClreplacedes.Count; i++)
{
var sac = characterCreateInfo.SkillAdvancementClreplacedes[i];
if (sac == SkillAdvancementClreplaced.Inactive)
continue;
if (!DatManager.PortalDat.SkillTable.SkillBaseHash.ContainsKey((uint)i))
{
log.ErrorFormat("Character {0} tried to create with skill {1} that was not found in Portal dat.", characterCreateInfo.Name, i);
return CreateResult.InvalidSkillRequested;
}
var skill = DatManager.PortalDat.SkillTable.SkillBaseHash[(uint)i];
var trainedCost = skill.TrainedCost;
var specializedCost = skill.UpgradeCostFromTrainedToSpecialized;
foreach (var skillGroup in heritageGroup.Skills)
{
if (skillGroup.SkillNum == i)
{
trainedCost = skillGroup.NormalCost;
specializedCost = skillGroup.PrimaryCost;
break;
}
}
if (sac == SkillAdvancementClreplaced.Specialized)
{
if (!player.TrainSkill((Skill)i, trainedCost))
return CreateResult.FailedToTrainSkill;
if (!player.SpecializeSkill((Skill)i, specializedCost))
return CreateResult.FailedToSpecializeSkill;
}
else if (sac == SkillAdvancementClreplaced.Trained)
{
if (!player.TrainSkill((Skill)i, trainedCost, true))
return CreateResult.FailedToTrainSkill;
}
else if (sac == SkillAdvancementClreplaced.Untrained)
player.UntrainSkill((Skill)i, 0);
}
// Set Heritage based Melee and Ranged Masteries
GetMasteries(player.HeritageGroup, out WeaponType meleeMastery, out WeaponType rangedMastery);
player.SetProperty(PropertyInt.MeleeMastery, (int)meleeMastery);
player.SetProperty(PropertyInt.RangedMastery, (int)rangedMastery);
// Set innate augs
SetInnateAugmentations(player);
var isDualWieldTrainedOrSpecialized = player.Skills.TryGetValue(Skill.DualWield, out var dualWield) && dualWield.AdvancementClreplaced > SkillAdvancementClreplaced.Untrained;
// grant starter items based on skills
var starterGearConfig = StarterGearFactory.GetStarterGearConfiguration();
var grantedWeenies = new List<uint>();
foreach (var skillGear in starterGearConfig.Skills)
{
//var charSkill = player.Skills[(Skill)skillGear.SkillId];
if (!player.Skills.TryGetValue((Skill)skillGear.SkillId, out var charSkill))
continue;
if (charSkill.AdvancementClreplaced == SkillAdvancementClreplaced.Trained || charSkill.AdvancementClreplaced == SkillAdvancementClreplaced.Specialized)
{
foreach (var item in skillGear.Gear)
{
if (grantedWeenies.Contains(item.WeenieId))
{
var existingItem = player.Inventory.Values.FirstOrDefault(i => i.WeenieClreplacedId == item.WeenieId);
if (existingItem == null || (existingItem.MaxStackSize ?? 1) <= 1)
continue;
existingItem.SetStackSize(existingItem.StackSize + item.StackSize);
continue;
}
var loot = WorldObjectFactory.CreateNewWorldObject(item.WeenieId);
if (loot != null)
{
if (loot.StackSize.HasValue && loot.MaxStackSize.HasValue)
loot.SetStackSize((item.StackSize <= loot.MaxStackSize) ? item.StackSize : loot.MaxStackSize);
}
else
{
player.TryAddToInventory(CreateIOU(item.WeenieId));
}
if (loot != null && player.TryAddToInventory(loot))
grantedWeenies.Add(item.WeenieId);
if (isDualWieldTrainedOrSpecialized && loot != null)
{
if (loot.WeenieType == WeenieType.MeleeWeapon)
{
var dualloot = WorldObjectFactory.CreateNewWorldObject(item.WeenieId);
if (dualloot != null)
{
player.TryAddToInventory(dualloot);
}
else
{
player.TryAddToInventory(CreateIOU(item.WeenieId));
}
}
}
}
var heritageLoot = skillGear.Heritage.FirstOrDefault(i => i.HeritageId == (ushort)characterCreateInfo.Heritage);
if (heritageLoot != null)
{
foreach (var item in heritageLoot.Gear)
{
if (grantedWeenies.Contains(item.WeenieId))
{
var existingItem = player.Inventory.Values.FirstOrDefault(i => i.WeenieClreplacedId == item.WeenieId);
if (existingItem == null || (existingItem.MaxStackSize ?? 1) <= 1)
continue;
existingItem.SetStackSize(existingItem.StackSize + item.StackSize);
continue;
}
var loot = WorldObjectFactory.CreateNewWorldObject(item.WeenieId);
if (loot != null)
{
if (loot.StackSize.HasValue && loot.MaxStackSize.HasValue)
loot.SetStackSize((item.StackSize <= loot.MaxStackSize) ? item.StackSize : loot.MaxStackSize);
}
else
{
player.TryAddToInventory(CreateIOU(item.WeenieId));
}
if (loot != null && player.TryAddToInventory(loot))
grantedWeenies.Add(item.WeenieId);
if (isDualWieldTrainedOrSpecialized && loot != null)
{
if (loot.WeenieType == WeenieType.MeleeWeapon)
{
var dualloot = WorldObjectFactory.CreateNewWorldObject(item.WeenieId);
if (dualloot != null)
{
player.TryAddToInventory(dualloot);
}
else
{
player.TryAddToInventory(CreateIOU(item.WeenieId));
}
}
}
}
}
foreach (var spell in skillGear.Spells)
{
if (charSkill.AdvancementClreplaced == SkillAdvancementClreplaced.Trained && spell.SpecializedOnly == false)
player.AddKnownSpell(spell.SpellId);
else if (charSkill.AdvancementClreplaced == SkillAdvancementClreplaced.Specialized)
player.AddKnownSpell(spell.SpellId);
}
}
}
}
else
{
if (player.CharacterreplacedleId > 0)
player.Addreplacedle((uint)player.CharacterreplacedleId.Value, true);
if (player.Biota.PropertiesSpellBook?.Count > 0)
{
var i = 0u;
foreach (var spell in player.Biota.PropertiesSpellBook)
{
player.HandleActionAddSpellFavorite((uint)spell.Key, i++, 0);
}
}
}
player.Name = characterCreateInfo.Name;
player.Character.Name = characterCreateInfo.Name;
// Index used to determine the starting location
var startArea = characterCreateInfo.StartArea;
var starterArea = DatManager.PortalDat.CharGen.StarterAreas[(int)startArea];
player.Location = new Position(starterArea.Locations[0].ObjCellID,
starterArea.Locations[0].Frame.Origin.X, starterArea.Locations[0].Frame.Origin.Y, starterArea.Locations[0].Frame.Origin.Z,
starterArea.Locations[0].Frame.Orientation.X, starterArea.Locations[0].Frame.Orientation.Y, starterArea.Locations[0].Frame.Orientation.Z, starterArea.Locations[0].Frame.Orientation.W);
var instantiation = new Position(0xA9B40019, 84, 7.1f, 94, 0, 0, -0.0784591f, 0.996917f); // ultimate fallback.
var spellFreeRide = new Database.Models.World.Spell();
switch (starterArea.Name)
{
case "OlthoiLair": //todo: check this when olthoi play is allowed in ace
spellFreeRide = null; // no training area for olthoi, so they start and fall back to same place.
instantiation = new Position(player.Location);
break;
case "Shoushi":
spellFreeRide = DatabaseManager.World.GetCachedSpell(3813); // Free Ride to Shoushi
break;
case "Yaraq":
spellFreeRide = DatabaseManager.World.GetCachedSpell(3814); // Free Ride to Yaraq
break;
case "Sanamar":
spellFreeRide = DatabaseManager.World.GetCachedSpell(3535); // Free Ride to Sanamar
break;
case "Holtburg":
default:
spellFreeRide = DatabaseManager.World.GetCachedSpell(3815); // Free Ride to Holtburg
break;
}
if (spellFreeRide != null && spellFreeRide.Name != "")
instantiation = new Position(spellFreeRide.PositionObjCellId.Value, spellFreeRide.PositionOriginX.Value, spellFreeRide.PositionOriginY.Value, spellFreeRide.PositionOriginZ.Value, spellFreeRide.PositionAnglesX.Value, spellFreeRide.PositionAnglesY.Value, spellFreeRide.PositionAnglesZ.Value, spellFreeRide.PositionAnglesW.Value);
player.Instantiation = new Position(instantiation);
if (!player.IsOlthoiPlayer)
{
player.Sanctuary = new Position(player.Location);
player.SetProperty(PropertyBool.RecallsDisabled, true);
if (PropertyManager.GetBool("pk_server").Item)
player.SetProperty(PropertyInt.PlayerKillerStatus, (int)PlayerKillerStatus.PK);
else if (PropertyManager.GetBool("pkl_server").Item)
player.SetProperty(PropertyInt.PlayerKillerStatus, (int)PlayerKillerStatus.NPK);
if ((PropertyManager.GetBool("pk_server").Item || PropertyManager.GetBool("pkl_server").Item) && PropertyManager.GetBool("pk_server_safe_training_academy").Item)
{
player.SetProperty(PropertyFloat.MinimumTimeSincePk, -PropertyManager.GetDouble("pk_new_character_grace_period").Item);
player.SetProperty(PropertyInt.PlayerKillerStatus, (int)PlayerKillerStatus.NPK);
}
}
if (player is Sentinel || player is Admin)
{
player.Character.IsPlussed = true;
player.CloakStatus = CloakStatus.Off;
player.ChannelsAllowed = player.ChannelsActive;
}
CharacterCreateSetDefaultCharacterOptions(player);
return CreateResult.Success;
}
19
Source : HouseManager.cs
with GNU Affero General Public License v3.0
from ACEmulator
with GNU Affero General Public License v3.0
from ACEmulator
private static void BuildHouseIdToGuid()
{
using (var ctx = new WorldDbContext())
{
var query = from weenie in ctx.Weenie
join inst in ctx.LandblockInstance on weenie.ClreplacedId equals inst.WeenieClreplacedId
where weenie.Type == (int)WeenieType.House
select new
{
Weenie = weenie,
Instance = inst
};
var results = query.ToList();
HouseIdToGuid = new Dictionary<uint, List<uint>>();
foreach (var result in results)
{
var clreplacedname = result.Weenie.ClreplacedName;
var guid = result.Instance.Guid;
if (!uint.TryParse(Regex.Match(clreplacedname, @"\d+").Value, out var houseId))
{
log.Error($"[HOUSE] HouseManager.BuildHouseIdToGuid(): couldn't parse {clreplacedname}");
continue;
}
if (!HouseIdToGuid.TryGetValue(houseId, out var houseGuids))
{
houseGuids = new List<uint>();
HouseIdToGuid.Add(houseId, houseGuids);
}
houseGuids.Add(guid);
}
//log.Info($"BuildHouseIdToGuid: {HouseIdToGuid.Count}");
}
}
19
Source : GameActionCreateTinkeringTool.cs
with GNU Affero General Public License v3.0
from ACEmulator
with GNU Affero General Public License v3.0
from ACEmulator
[GameAction(GameActionType.CreateTinkeringTool)]
public static void Handle(ClientMessage message, Session session)
{
var vendorGuid = message.Payload.ReadUInt32();
uint itemcount = message.Payload.ReadUInt32();
var items = new List<uint>();
while (itemcount > 0)
{
itemcount--;
items.Add(message.Payload.ReadUInt32());
}
session.Player.HandleSalvaging(items);
}
19
Source : NetworkSession.cs
with GNU Affero General Public License v3.0
from ACEmulator
with GNU Affero General Public License v3.0
from ACEmulator
public void ProcessPacket(ClientPacket packet)
{
if (isReleased) // Session has been removed
return;
packetLog.DebugFormat("[{0}] Processing packet {1}", session.LoggingIdentifier, packet.Header.Sequence);
NetworkStatistics.C2S_Packets_Aggregate_Increment();
if (!packet.VerifyCRC(ConnectionData.CryptoClient))
{
return;
}
// If the client sent a NAK with a cleartext CRC then process it
if ((packet.Header.Flags & PacketHeaderFlags.RequestRetransmit) == PacketHeaderFlags.RequestRetransmit
&& !((packet.Header.Flags & PacketHeaderFlags.EncryptedChecksum) == PacketHeaderFlags.EncryptedChecksum))
{
List<uint> uncached = null;
foreach (uint sequence in packet.HeaderOptional.RetransmitData)
{
if (!Retransmit(sequence))
{
if (uncached == null)
uncached = new List<uint>();
uncached.Add(sequence);
}
}
if (uncached != null)
{
// Sends a response packet w/ PacketHeader.RejectRetransmit
var packetRejectRetransmit = new PacketRejectRetransmit(uncached);
EnqueueSend(packetRejectRetransmit);
}
NetworkStatistics.C2S_RequestsForRetransmit_Aggregate_Increment();
return; //cleartext crc NAK is never accompanied by additional data needed by the rest of the pipeline
}
#region order-insensitive "half-processing"
if (packet.Header.HasFlag(PacketHeaderFlags.Disconnect))
{
session.Terminate(SessionTerminationReason.PacketHeaderDisconnect);
return;
}
if (packet.Header.HasFlag(PacketHeaderFlags.NetErrorDisconnect))
{
session.Terminate(SessionTerminationReason.ClientSentNetworkErrorDisconnect);
return;
}
// depending on the current session state:
// Set the next timeout tick value, to compare against in the WorldManager
// Sessions that have gone past the AuthLoginRequest step will stay active for a longer period of time (exposed via configuration)
// Sessions that in the AuthLoginRequest will have a short timeout, as set in the AuthenticationHandler.DefaultAuthTimeout.
// Example: Applications that check uptime will stay in the AuthLoginRequest state.
session.Network.TimeoutTick = (session.State == SessionState.AuthLoginRequest) ?
DateTime.UtcNow.AddSeconds(AuthenticationHandler.DefaultAuthTimeout).Ticks : // Default is 15s
DateTime.UtcNow.AddSeconds(NetworkManager.DefaultSessionTimeout).Ticks; // Default is 60s
#endregion
#region Reordering stage
// Reordering stage
// Check if this packet's sequence is a sequence which we have already processed.
// There are some exceptions:
// Sequence 0 as we have several Seq 0 packets during connect. This also cathes a case where it seems CICMDCommand arrives at any point with 0 sequence value too.
// If the only header on the packet is AckSequence. It seems AckSequence can come in with the same sequence value sometimes.
if (packet.Header.Sequence <= lastReceivedPacketSequence && packet.Header.Sequence != 0 &&
!(packet.Header.Flags == PacketHeaderFlags.AckSequence && packet.Header.Sequence == lastReceivedPacketSequence))
{
packetLog.WarnFormat("[{0}] Packet {1} received again", session.LoggingIdentifier, packet.Header.Sequence);
return;
}
// Check if this packet's sequence is greater then the next one we should be getting.
// If true we must store it to replay once we have caught up.
var desiredSeq = lastReceivedPacketSequence + 1;
if (packet.Header.Sequence > desiredSeq)
{
packetLog.DebugFormat("[{0}] Packet {1} received out of order", session.LoggingIdentifier, packet.Header.Sequence);
if (!outOfOrderPackets.ContainsKey(packet.Header.Sequence))
outOfOrderPackets.TryAdd(packet.Header.Sequence, packet);
if (desiredSeq + 2 <= packet.Header.Sequence && DateTime.UtcNow - LastRequestForRetransmitTime > new TimeSpan(0, 0, 1))
DoRequestForRetransmission(packet.Header.Sequence);
return;
}
#endregion
#region Final processing stage
// Processing stage
// If we reach here, this is a packet we should proceed with processing.
HandleOrderedPacket(packet);
// Process data now in sequence
// Finally check if we have any out of order packets or fragments we need to process;
CheckOutOfOrderPackets();
CheckOutOfOrderFragments();
#endregion
}
19
Source : NetworkSession.cs
with GNU Affero General Public License v3.0
from ACEmulator
with GNU Affero General Public License v3.0
from ACEmulator
private void DoRequestForRetransmission(uint rcvdSeq)
{
var desiredSeq = lastReceivedPacketSequence + 1;
List<uint> needSeq = new List<uint>();
needSeq.Add(desiredSeq);
uint bottom = desiredSeq + 1;
if (rcvdSeq < bottom || rcvdSeq - bottom > CryptoSystem.MaximumEffortLevel)
{
session.Terminate(SessionTerminationReason.AbnormalSequenceReceived);
return;
}
uint seqIdCount = 1;
for (uint a = bottom; a < rcvdSeq; a++)
{
if (!outOfOrderPackets.ContainsKey(a))
{
needSeq.Add(a);
seqIdCount++;
if (seqIdCount >= MaxNumNakSeqIds)
{
break;
}
}
}
ServerPacket reqPacket = new ServerPacket();
byte[] reqData = new byte[4 + (needSeq.Count * 4)];
MemoryStream msReqData = new MemoryStream(reqData, 0, reqData.Length, true, true);
msReqData.Write(BitConverter.GetBytes((uint)needSeq.Count), 0, 4);
needSeq.ForEach(k => msReqData.Write(BitConverter.GetBytes(k), 0, 4));
reqPacket.Data = msReqData;
reqPacket.Header.Flags = PacketHeaderFlags.RequestRetransmit;
EnqueueSend(reqPacket);
LastRequestForRetransmitTime = DateTime.UtcNow;
packetLog.DebugFormat("[{0}] Requested retransmit of {1}", session.LoggingIdentifier, needSeq.Select(k => k.ToString()).Aggregate((a, b) => a + ", " + b));
NetworkStatistics.S2C_RequestsForRetransmit_Aggregate_Increment();
}
19
Source : AppraiseInfo.cs
with GNU Affero General Public License v3.0
from ACEmulator
with GNU Affero General Public License v3.0
from ACEmulator
private void AddEnchantments(WorldObject wo)
{
if (wo == null) return;
// get all currently active item enchantments on the item
var woEnchantments = wo.EnchantmentManager.GetEnchantments(MagicSchool.ItemEnchantment);
foreach (var enchantment in woEnchantments)
SpellBook.Add((uint)enchantment.SpellId | EnchantmentMask);
// show auras from wielder, if applicable
// this technically wasn't a feature in retail
if (wo.Wielder != null && wo.IsEnchantable && wo.WeenieType != WeenieType.Clothing && !wo.IsShield && PropertyManager.GetBool("show_aura_buff").Item)
{
// get all currently active item enchantment auras on the player
var wielderEnchantments = wo.Wielder.EnchantmentManager.GetEnchantments(MagicSchool.ItemEnchantment);
// Only show reflected Auras from player appropriate for wielded weapons
foreach (var enchantment in wielderEnchantments)
{
if (wo is Caster)
{
// Caster weapon only item Auras
if ((enchantment.SpellCategory == SpellCategory.DefenseModRaising)
|| (enchantment.SpellCategory == SpellCategory.DefenseModRaisingRare)
|| (enchantment.SpellCategory == SpellCategory.ManaConversionModRaising)
|| (enchantment.SpellCategory == SpellCategory.SpellDamageRaising))
{
SpellBook.Add((uint)enchantment.SpellId | EnchantmentMask);
}
}
else if (wo is Missile || wo is Ammunition)
{
if ((enchantment.SpellCategory == SpellCategory.DamageRaising)
|| (enchantment.SpellCategory == SpellCategory.DamageRaisingRare))
{
SpellBook.Add((uint)enchantment.SpellId | EnchantmentMask);
}
}
else
{
// Other weapon type Auras
if ((enchantment.SpellCategory == SpellCategory.AttackModRaising)
|| (enchantment.SpellCategory == SpellCategory.AttackModRaisingRare)
|| (enchantment.SpellCategory == SpellCategory.DamageRaising)
|| (enchantment.SpellCategory == SpellCategory.DamageRaisingRare)
|| (enchantment.SpellCategory == SpellCategory.DefenseModRaising)
|| (enchantment.SpellCategory == SpellCategory.DefenseModRaisingRare)
|| (enchantment.SpellCategory == SpellCategory.WeaponTimeRaising)
|| (enchantment.SpellCategory == SpellCategory.WeaponTimeRaisingRare))
{
SpellBook.Add((uint)enchantment.SpellId | EnchantmentMask);
}
}
}
}
}
19
Source : LandblockStruct.cs
with GNU Affero General Public License v3.0
from ACEmulator
with GNU Affero General Public License v3.0
from ACEmulator
public void GetCellRotation(uint landblockID, uint x, uint y, ref bool singleTextureCell, ref uint surfNum, ref LandDefs.Rotation rotation)
{
var lcoord = LandDefs.blockid_to_lcoord(landblockID);
var globalCellX = (int)(lcoord.Value.X + x);
var globalCellY = (int)(lcoord.Value.Y + y);
// no palette shift
// SW / SE / NE / NW
var i = (int)(LandDefs.VertexDim * x + y);
var terrain = Terrain[i];
var t1 = (terrain & 0x7F) >> 2;
var r1 = terrain & 3;
var j = (int)(LandDefs.VertexDim * (x + 1) + y);
var terrain2 = Terrain[j];
var t2 = (terrain2 & 0x7F) >> 2;
var r2 = terrain2 & 3;
var terrain3 = Terrain[j + 1];
var t3 = (terrain3 & 0x7F) >> 2;
var r3 = terrain3 & 3;
var terrain4 = Terrain[i + 1];
var t4 = (terrain4 & 0x7F) >> 2;
var r4 = terrain4 & 3;
/*Console.WriteLine($"LandblockStruct.GetCellRotation({landblockID:X8}, x:{x}, y:{y})");
Console.WriteLine($"I1: {i}, I2: {j}, I3: {j+1}, I4: {i+1}");
if (r1 != 0 || r2 != 0 || r3 != 0 || r4 != 0)
Console.WriteLine($"R1: {r1}, R2: {r2}, R3: {r3}, R4: {r4}");
Console.WriteLine($"T1: {(LandDefs.TerrainType)t1}, T2: {(LandDefs.TerrainType)t2}, T3: {(LandDefs.TerrainType)t3}, T4: {(LandDefs.TerrainType)t4}");*/
var palCodes = new List<uint>();
palCodes.Add(GetPalCode(r1, r2, r3, r4, t1, t2, t3, t4)); // 0
//palCodes.Add(GetPalCode(r2, r3, r4, r1, t2, t3, t4, t1)); // 270
//palCodes.Add(GetPalCode(r3, r4, r1, r2, t3, t4, t1, t2)); // 180
//palCodes.Add(GetPalCode(r4, r1, r2, r3, t4, t1, t2, t3)); // 90
var singleRoadCell = r1 == r2 && r1 == r3 && r1 == r4;
var singleTypeCell = t1 == t2 && t1 == t3 && t1 == t4;
singleTextureCell = r1 != 0 ? singleRoadCell : singleRoadCell && singleTypeCell;
var regionDesc = DatManager.PortalDat.RegionDesc;
var minimizePal = true;
LandSurf.Instance.SelectTerrain(globalCellX, globalCellY, ref surfNum, ref rotation, palCodes, 1, minimizePal);
}
19
Source : PackableList.cs
with GNU Affero General Public License v3.0
from ACEmulator
with GNU Affero General Public License v3.0
from ACEmulator
public static List<uint> ReadListUInt32(this BinaryReader reader)
{
var size = reader.ReadUInt32();
var list = new List<uint>();
for (var i = 0; i < size; i++)
list.Add(reader.ReadUInt32());
return list;
}
19
Source : AppraiseInfo.cs
with GNU Affero General Public License v3.0
from ACEmulator
with GNU Affero General Public License v3.0
from ACEmulator
private void BuildSpells(WorldObject wo)
{
SpellBook = new List<uint>();
if (wo is Creature)
return;
// add primary spell, if exists
if (wo.SpellDID.HasValue)
SpellBook.Add(wo.SpellDID.Value);
// add proc spell, if exists
if (wo.ProcSpell.HasValue)
SpellBook.Add(wo.ProcSpell.Value);
var woSpellDID = wo.SpellDID; // prevent recursive lock
var woProcSpell = wo.ProcSpell;
foreach (var spellId in wo.Biota.GetKnownSpellsIdsWhere(i => i != woSpellDID && i != woProcSpell, wo.BiotaDatabaseLock))
SpellBook.Add((uint)spellId);
}
19
Source : AppraiseInfo.cs
with GNU Affero General Public License v3.0
from ACEmulator
with GNU Affero General Public License v3.0
from ACEmulator
private void BuildSpells(WorldObject wo)
{
SpellBook = new List<uint>();
if (wo is Creature)
return;
// add primary spell, if exists
if (wo.SpellDID.HasValue)
SpellBook.Add(wo.SpellDID.Value);
// add proc spell, if exists
if (wo.ProcSpell.HasValue)
SpellBook.Add(wo.ProcSpell.Value);
var woSpellDID = wo.SpellDID; // prevent recursive lock
var woProcSpell = wo.ProcSpell;
foreach (var spellId in wo.Biota.GetKnownSpellsIdsWhere(i => i != woSpellDID && i != woProcSpell, wo.BiotaDatabaseLock))
SpellBook.Add((uint)spellId);
}
19
Source : PacketHeaderOptional.cs
with GNU Affero General Public License v3.0
from ACEmulator
with GNU Affero General Public License v3.0
from ACEmulator
public void Unpack(BinaryReader reader, PacketHeader header)
{
Header = header;
Size = (uint)reader.BaseStream.Position;
BinaryWriter writer = new BinaryWriter(headerBytes);
if (header.HasFlag(PacketHeaderFlags.ServerSwitch)) // 0x100
{
writer.Write(reader.ReadBytes(8));
}
if (header.HasFlag(PacketHeaderFlags.RequestRetransmit)) // 0x1000
{
if (reader.BaseStream.Length < reader.BaseStream.Position + 4) { IsValid = false; return; }
uint retransmitCount = reader.ReadUInt32();
writer.Write(retransmitCount);
RetransmitData = new List<uint>();
for (uint i = 0u; i < retransmitCount; i++)
{
if (reader.BaseStream.Length < reader.BaseStream.Position + 4) { IsValid = false; return; }
uint sequence = reader.ReadUInt32();
writer.Write(sequence);
RetransmitData.Add(sequence);
}
}
if (header.HasFlag(PacketHeaderFlags.RejectRetransmit)) // 0x2000
{
if (reader.BaseStream.Length < reader.BaseStream.Position + 4) { IsValid = false; return; }
uint count = reader.ReadUInt32();
writer.Write(count);
for (int i = 0; i < count; i++)
{
if (reader.BaseStream.Length < reader.BaseStream.Position + 4) { IsValid = false; return; }
writer.Write(reader.ReadBytes(4));
}
}
if (header.HasFlag(PacketHeaderFlags.AckSequence)) // 0x4000
{
if (reader.BaseStream.Length < reader.BaseStream.Position + 4) { IsValid = false; return; }
AckSequence = reader.ReadUInt32();
writer.Write(AckSequence);
}
if (header.HasFlag(PacketHeaderFlags.LoginRequest)) // 0x10000
{
long position = reader.BaseStream.Position;
long length = reader.BaseStream.Length - position;
if (length < 1) { IsValid = false; return; }
byte[] loginBytes = new byte[length];
reader.BaseStream.Read(loginBytes, (int)position, (int)length);
writer.Write(loginBytes);
reader.BaseStream.Position = position;
}
if (header.HasFlag(PacketHeaderFlags.WorldLoginRequest)) // 0x20000
{
if (reader.BaseStream.Length < reader.BaseStream.Position + 8) { IsValid = false; return; }
long position = reader.BaseStream.Position;
writer.Write(reader.ReadBytes(8));
reader.BaseStream.Position = position;
}
if (header.HasFlag(PacketHeaderFlags.ConnectResponse)) // 0x80000
{
long position = reader.BaseStream.Position;
if (reader.BaseStream.Length < reader.BaseStream.Position + 8) { IsValid = false; return; }
writer.Write(reader.ReadBytes(8));
reader.BaseStream.Position = position;
}
if (header.HasFlag(PacketHeaderFlags.CICMDCommand)) // 0x400000
{
if (reader.BaseStream.Length < reader.BaseStream.Position + 8) { IsValid = false; return; }
writer.Write(reader.ReadBytes(8));
}
if (header.HasFlag(PacketHeaderFlags.TimeSync)) // 0x1000000
{
if (reader.BaseStream.Length < reader.BaseStream.Position + 8) { IsValid = false; return; }
TimeSynch = reader.ReadDouble();
writer.Write(TimeSynch);
}
if (header.HasFlag(PacketHeaderFlags.Ecreplacedquest)) // 0x2000000
{
if (reader.BaseStream.Length < reader.BaseStream.Position + 4) { IsValid = false; return; }
EcreplacedquestClientTime = reader.ReadSingle();
writer.Write(EcreplacedquestClientTime);
}
if (header.HasFlag(PacketHeaderFlags.Flow)) // 0x8000000
{
if (reader.BaseStream.Length < reader.BaseStream.Position + 6) { IsValid = false; return; }
FlowBytes = reader.ReadUInt32();
FlowInterval = reader.ReadUInt16();
writer.Write(FlowBytes);
writer.Write(FlowInterval);
}
Size = (uint)reader.BaseStream.Position - Size;
}
19
Source : Creature_Networking.cs
with GNU Affero General Public License v3.0
from ACEmulator
with GNU Affero General Public License v3.0
from ACEmulator
public override ACE.Enreplacedy.ObjDesc CalculateObjDesc()
{
ACE.Enreplacedy.ObjDesc objDesc = new ACE.Enreplacedy.ObjDesc();
ClothingTable item;
AddBaseModelData(objDesc);
var coverage = new List<uint>();
uint thisSetupId = SetupTableId;
bool showHelm = true;
bool showCloak = true;
if (this is Player player)
{
showHelm = player.GetCharacterOption(CharacterOption.ShowYourHelmOrHeadGear);
showCloak = player.GetCharacterOption(CharacterOption.ShowYourCloak);
}
// Some player races use an AlternateSetupDid, either at creation or via Barber options.
// BUT -- those values do not correspond with entries in the Clothing Table.
// So, we need to make some adjustments to look up something that DOES exist and is appropriate for the AlternateSetup model.
switch (thisSetupId)
{
//case (uint)SetupConst.UmbraenMaleCrown:
case (uint)SetupConst.UmbraenMaleCrownGen:
case (uint)SetupConst.UmbraenMaleNoCrown:
case (uint)SetupConst.UmbraenMaleVoid:
thisSetupId = (uint)SetupConst.UmbraenMaleCrown;
break;
//case (uint)SetupConst.UmbraenFemaleCrown:
//case (uint)SetupConst.UmbraenFemaleCrownGen:
case (uint)SetupConst.UmbraenFemaleNoCrown:
case (uint)SetupConst.UmbraenFemaleVoid:
thisSetupId = (uint)SetupConst.UmbraenFemaleCrown;
break;
//case (uint)SetupConst.PenumbraenMaleCrown:
case (uint)SetupConst.PenumbraenMaleCrownGen:
case (uint)SetupConst.PenumbraenMaleNoCrown:
case (uint)SetupConst.PenumbraenMaleVoid:
thisSetupId = (uint)SetupConst.PenumbraenMaleCrown;
break;
//case (uint)SetupConst.PenumbraenFemaleCrown:
//case (uint)SetupConst.PenumbraenFemaleCrownGen:
case (uint)SetupConst.PenumbraenFemaleNoCrown:
case (uint)SetupConst.PenumbraenFemaleVoid:
thisSetupId = (uint)SetupConst.PenumbraenFemaleCrown;
break;
case (uint)SetupConst.UndeadMaleUndeadGen:
case (uint)SetupConst.UndeadMaleSkeleton:
case (uint)SetupConst.UndeadMaleSkeletonNoFlame:
case (uint)SetupConst.UndeadMaleZombie:
case (uint)SetupConst.UndeadMaleZombieNoFlame:
thisSetupId = (uint)SetupConst.UndeadMaleUndead;
break;
case (uint)SetupConst.UndeadFemaleUndeadGen:
case (uint)SetupConst.UndeadFemaleSkeleton:
case (uint)SetupConst.UndeadFemaleSkeletonNoFlame:
case (uint)SetupConst.UndeadFemaleZombie:
case (uint)SetupConst.UndeadFemaleZombieNoFlame:
thisSetupId = (uint)SetupConst.UndeadFemaleUndead;
break;
case (uint)SetupConst.AnakshayMale:
thisSetupId = (uint)SetupConst.HumanMale;
break;
case (uint)SetupConst.AnakshayFemale:
thisSetupId = (uint)SetupConst.HumanFemale;
break;
}
// get all the Armor Items so we can calculate their priority
var armorItems = EquippedObjects.Values.Where(x => (x.ItemType == ItemType.Armor)).ToList();
foreach (var w in armorItems)
w.setVisualClothingPriority();
// sort the armor into the proper order... TopLayerPriority first, then no priority, then TopLayerPriority=false.
// Secondary sort field is the calculated "VisualClothingPriority"
var top = armorItems.Where(x => x.TopLayerPriority == true).OrderBy(x => x.VisualClothingPriority);
var noLayer = armorItems.Where(x => x.TopLayerPriority == null).OrderBy(x => x.VisualClothingPriority);
var bottom = armorItems.Where(x => x.TopLayerPriority == false).OrderBy(x => x.VisualClothingPriority);
var sortedArmorItems = bottom.Concat(noLayer).Concat(top).ToList();
var clothesAndCloaks = EquippedObjects.Values
.Where(x => (x.ItemType == ItemType.Clothing)) // FootWear & HandWear is included in the ArmorItems above
.OrderBy(x => x.ClothingPriority);
var eo = clothesAndCloaks.Concat(sortedArmorItems).ToList();
if (eo.Count == 0)
{
// Check if there is any defined ObjDesc in the Biota and, if so, apply them
if (Biota.PropertiesAnimPart.GetCount(BiotaDatabaseLock) > 0 || Biota.PropertiesPalette.GetCount(BiotaDatabaseLock) > 0 || Biota.PropertiesTextureMap.GetCount(BiotaDatabaseLock) > 0)
{
Biota.PropertiesAnimPart.CopyTo(objDesc.AnimPartChanges, BiotaDatabaseLock);
Biota.PropertiesPalette.CopyTo(objDesc.SubPalettes, BiotaDatabaseLock);
Biota.PropertiesTextureMap.CopyTo(objDesc.TextureChanges, BiotaDatabaseLock);
return objDesc;
}
}
foreach (var w in eo)
{
if ((w.CurrentWieldedLocation == EquipMask.HeadWear) && !showHelm && (this is Player))
continue;
if ((w.CurrentWieldedLocation == EquipMask.Cloak) && !showCloak && (this is Player))
continue;
// We can wield things that are not part of our model, only use those items that can cover our model.
if ((w.CurrentWieldedLocation & (EquipMask.Clothing | EquipMask.Armor | EquipMask.Cloak)) != 0)
{
if (w.ClothingBase.HasValue)
item = DatManager.PortalDat.ReadFromDat<ClothingTable>((uint)w.ClothingBase);
else
{
objDesc = AddSetupAsClothingBase(objDesc, w);
// Add any potentially added parts back into the coverage list
foreach(var a in objDesc.AnimPartChanges)
if (!coverage.Contains(a.Index))
coverage.Add(a.Index);
continue;
}
if (item.ClothingBaseEffects.ContainsKey(thisSetupId))
// Check if the player model has data. Gear Knights, this is usually you.
{
// Add the model and texture(s)
ClothingBaseEffect clothingBaseEffect = item.ClothingBaseEffects[thisSetupId];
foreach (CloObjectEffect t in clothingBaseEffect.CloObjectEffects)
{
byte partNum = (byte)t.Index;
coverage.Add(partNum);
objDesc.AddAnimPartChange(new PropertiesAnimPart { Index = (byte)t.Index, AnimationId = t.ModelId });
foreach (CloTextureEffect t1 in t.CloTextureEffects)
objDesc.AddTextureChange(new PropertiesTextureMap { PartIndex = (byte)t.Index, OldTexture = t1.OldTexture, NewTexture = t1.NewTexture });
}
if (item.ClothingSubPalEffects.Count > 0)
{
int size = item.ClothingSubPalEffects.Count;
int palCount = size;
CloSubPalEffect itemSubPal;
int palOption = 0;
if (w.PaletteTemplate.HasValue)
palOption = (int)w.PaletteTemplate;
if (item.ClothingSubPalEffects.ContainsKey((uint)palOption))
{
itemSubPal = item.ClothingSubPalEffects[(uint)palOption];
}
else
{
itemSubPal = item.ClothingSubPalEffects[item.ClothingSubPalEffects.Keys.ElementAt(0)];
}
float shade = 0;
if (w.Shade.HasValue)
shade = (float)w.Shade;
for (int i = 0; i < itemSubPal.CloSubPalettes.Count; i++)
{
var itemPalSet = DatManager.PortalDat.ReadFromDat<PaletteSet>(itemSubPal.CloSubPalettes[i].PaletteSet);
ushort itemPal = (ushort)itemPalSet.GetPaletteID(shade);
for (int j = 0; j < itemSubPal.CloSubPalettes[i].Ranges.Count; j++)
{
ushort palOffset = (ushort)(itemSubPal.CloSubPalettes[i].Ranges[j].Offset / 8);
ushort numColors = (ushort)(itemSubPal.CloSubPalettes[i].Ranges[j].NumColors / 8);
objDesc.SubPalettes.Add(new PropertiesPalette { SubPaletteId = itemPal, Offset = palOffset, Length = numColors });
}
}
}
}
}
}
// Add the "naked" body parts. These are the ones not already covered.
// Note that this is the original SetupTableId, not thisSetupId.
if (SetupTableId > 0)
{
var baseSetup = DatManager.PortalDat.ReadFromDat<SetupModel>(SetupTableId);
for (byte i = 0; i < baseSetup.Parts.Count; i++)
{
if (!coverage.Contains(i) && i != 0x10) // Don't add body parts for those that are already covered. Also don't add the head, that was already covered by AddCharacterBaseModelData()
objDesc.AnimPartChanges.Add(new PropertiesAnimPart { Index = i, AnimationId = baseSetup.Parts[i] });
//AddModel(i, baseSetup.Parts[i]);
}
}
if (coverage.Count == 0 && ClothingBase.HasValue)
return base.CalculateObjDesc();
return objDesc;
}
19
Source : Creature_Networking.cs
with GNU Affero General Public License v3.0
from ACEmulator
with GNU Affero General Public License v3.0
from ACEmulator
public override ACE.Enreplacedy.ObjDesc CalculateObjDesc()
{
ACE.Enreplacedy.ObjDesc objDesc = new ACE.Enreplacedy.ObjDesc();
ClothingTable item;
AddBaseModelData(objDesc);
var coverage = new List<uint>();
uint thisSetupId = SetupTableId;
bool showHelm = true;
bool showCloak = true;
if (this is Player player)
{
showHelm = player.GetCharacterOption(CharacterOption.ShowYourHelmOrHeadGear);
showCloak = player.GetCharacterOption(CharacterOption.ShowYourCloak);
}
// Some player races use an AlternateSetupDid, either at creation or via Barber options.
// BUT -- those values do not correspond with entries in the Clothing Table.
// So, we need to make some adjustments to look up something that DOES exist and is appropriate for the AlternateSetup model.
switch (thisSetupId)
{
//case (uint)SetupConst.UmbraenMaleCrown:
case (uint)SetupConst.UmbraenMaleCrownGen:
case (uint)SetupConst.UmbraenMaleNoCrown:
case (uint)SetupConst.UmbraenMaleVoid:
thisSetupId = (uint)SetupConst.UmbraenMaleCrown;
break;
//case (uint)SetupConst.UmbraenFemaleCrown:
//case (uint)SetupConst.UmbraenFemaleCrownGen:
case (uint)SetupConst.UmbraenFemaleNoCrown:
case (uint)SetupConst.UmbraenFemaleVoid:
thisSetupId = (uint)SetupConst.UmbraenFemaleCrown;
break;
//case (uint)SetupConst.PenumbraenMaleCrown:
case (uint)SetupConst.PenumbraenMaleCrownGen:
case (uint)SetupConst.PenumbraenMaleNoCrown:
case (uint)SetupConst.PenumbraenMaleVoid:
thisSetupId = (uint)SetupConst.PenumbraenMaleCrown;
break;
//case (uint)SetupConst.PenumbraenFemaleCrown:
//case (uint)SetupConst.PenumbraenFemaleCrownGen:
case (uint)SetupConst.PenumbraenFemaleNoCrown:
case (uint)SetupConst.PenumbraenFemaleVoid:
thisSetupId = (uint)SetupConst.PenumbraenFemaleCrown;
break;
case (uint)SetupConst.UndeadMaleUndeadGen:
case (uint)SetupConst.UndeadMaleSkeleton:
case (uint)SetupConst.UndeadMaleSkeletonNoFlame:
case (uint)SetupConst.UndeadMaleZombie:
case (uint)SetupConst.UndeadMaleZombieNoFlame:
thisSetupId = (uint)SetupConst.UndeadMaleUndead;
break;
case (uint)SetupConst.UndeadFemaleUndeadGen:
case (uint)SetupConst.UndeadFemaleSkeleton:
case (uint)SetupConst.UndeadFemaleSkeletonNoFlame:
case (uint)SetupConst.UndeadFemaleZombie:
case (uint)SetupConst.UndeadFemaleZombieNoFlame:
thisSetupId = (uint)SetupConst.UndeadFemaleUndead;
break;
case (uint)SetupConst.AnakshayMale:
thisSetupId = (uint)SetupConst.HumanMale;
break;
case (uint)SetupConst.AnakshayFemale:
thisSetupId = (uint)SetupConst.HumanFemale;
break;
}
// get all the Armor Items so we can calculate their priority
var armorItems = EquippedObjects.Values.Where(x => (x.ItemType == ItemType.Armor)).ToList();
foreach (var w in armorItems)
w.setVisualClothingPriority();
// sort the armor into the proper order... TopLayerPriority first, then no priority, then TopLayerPriority=false.
// Secondary sort field is the calculated "VisualClothingPriority"
var top = armorItems.Where(x => x.TopLayerPriority == true).OrderBy(x => x.VisualClothingPriority);
var noLayer = armorItems.Where(x => x.TopLayerPriority == null).OrderBy(x => x.VisualClothingPriority);
var bottom = armorItems.Where(x => x.TopLayerPriority == false).OrderBy(x => x.VisualClothingPriority);
var sortedArmorItems = bottom.Concat(noLayer).Concat(top).ToList();
var clothesAndCloaks = EquippedObjects.Values
.Where(x => (x.ItemType == ItemType.Clothing)) // FootWear & HandWear is included in the ArmorItems above
.OrderBy(x => x.ClothingPriority);
var eo = clothesAndCloaks.Concat(sortedArmorItems).ToList();
if (eo.Count == 0)
{
// Check if there is any defined ObjDesc in the Biota and, if so, apply them
if (Biota.PropertiesAnimPart.GetCount(BiotaDatabaseLock) > 0 || Biota.PropertiesPalette.GetCount(BiotaDatabaseLock) > 0 || Biota.PropertiesTextureMap.GetCount(BiotaDatabaseLock) > 0)
{
Biota.PropertiesAnimPart.CopyTo(objDesc.AnimPartChanges, BiotaDatabaseLock);
Biota.PropertiesPalette.CopyTo(objDesc.SubPalettes, BiotaDatabaseLock);
Biota.PropertiesTextureMap.CopyTo(objDesc.TextureChanges, BiotaDatabaseLock);
return objDesc;
}
}
foreach (var w in eo)
{
if ((w.CurrentWieldedLocation == EquipMask.HeadWear) && !showHelm && (this is Player))
continue;
if ((w.CurrentWieldedLocation == EquipMask.Cloak) && !showCloak && (this is Player))
continue;
// We can wield things that are not part of our model, only use those items that can cover our model.
if ((w.CurrentWieldedLocation & (EquipMask.Clothing | EquipMask.Armor | EquipMask.Cloak)) != 0)
{
if (w.ClothingBase.HasValue)
item = DatManager.PortalDat.ReadFromDat<ClothingTable>((uint)w.ClothingBase);
else
{
objDesc = AddSetupAsClothingBase(objDesc, w);
// Add any potentially added parts back into the coverage list
foreach(var a in objDesc.AnimPartChanges)
if (!coverage.Contains(a.Index))
coverage.Add(a.Index);
continue;
}
if (item.ClothingBaseEffects.ContainsKey(thisSetupId))
// Check if the player model has data. Gear Knights, this is usually you.
{
// Add the model and texture(s)
ClothingBaseEffect clothingBaseEffect = item.ClothingBaseEffects[thisSetupId];
foreach (CloObjectEffect t in clothingBaseEffect.CloObjectEffects)
{
byte partNum = (byte)t.Index;
coverage.Add(partNum);
objDesc.AddAnimPartChange(new PropertiesAnimPart { Index = (byte)t.Index, AnimationId = t.ModelId });
foreach (CloTextureEffect t1 in t.CloTextureEffects)
objDesc.AddTextureChange(new PropertiesTextureMap { PartIndex = (byte)t.Index, OldTexture = t1.OldTexture, NewTexture = t1.NewTexture });
}
if (item.ClothingSubPalEffects.Count > 0)
{
int size = item.ClothingSubPalEffects.Count;
int palCount = size;
CloSubPalEffect itemSubPal;
int palOption = 0;
if (w.PaletteTemplate.HasValue)
palOption = (int)w.PaletteTemplate;
if (item.ClothingSubPalEffects.ContainsKey((uint)palOption))
{
itemSubPal = item.ClothingSubPalEffects[(uint)palOption];
}
else
{
itemSubPal = item.ClothingSubPalEffects[item.ClothingSubPalEffects.Keys.ElementAt(0)];
}
float shade = 0;
if (w.Shade.HasValue)
shade = (float)w.Shade;
for (int i = 0; i < itemSubPal.CloSubPalettes.Count; i++)
{
var itemPalSet = DatManager.PortalDat.ReadFromDat<PaletteSet>(itemSubPal.CloSubPalettes[i].PaletteSet);
ushort itemPal = (ushort)itemPalSet.GetPaletteID(shade);
for (int j = 0; j < itemSubPal.CloSubPalettes[i].Ranges.Count; j++)
{
ushort palOffset = (ushort)(itemSubPal.CloSubPalettes[i].Ranges[j].Offset / 8);
ushort numColors = (ushort)(itemSubPal.CloSubPalettes[i].Ranges[j].NumColors / 8);
objDesc.SubPalettes.Add(new PropertiesPalette { SubPaletteId = itemPal, Offset = palOffset, Length = numColors });
}
}
}
}
}
}
// Add the "naked" body parts. These are the ones not already covered.
// Note that this is the original SetupTableId, not thisSetupId.
if (SetupTableId > 0)
{
var baseSetup = DatManager.PortalDat.ReadFromDat<SetupModel>(SetupTableId);
for (byte i = 0; i < baseSetup.Parts.Count; i++)
{
if (!coverage.Contains(i) && i != 0x10) // Don't add body parts for those that are already covered. Also don't add the head, that was already covered by AddCharacterBaseModelData()
objDesc.AnimPartChanges.Add(new PropertiesAnimPart { Index = i, AnimationId = baseSetup.Parts[i] });
//AddModel(i, baseSetup.Parts[i]);
}
}
if (coverage.Count == 0 && ClothingBase.HasValue)
return base.CalculateObjDesc();
return objDesc;
}
19
Source : House.cs
with GNU Affero General Public License v3.0
from ACEmulator
with GNU Affero General Public License v3.0
from ACEmulator
public void BuildGuests()
{
Guests = new Dictionary<ObjectGuid, bool>();
var housePermissions = Biota.CloneHousePermissions(BiotaDatabaseLock);
var deleted = new List<uint>();
foreach (var kvp in housePermissions)
{
var player = PlayerManager.FindByGuid(kvp.Key);
if (player == null)
{
//Console.WriteLine($"{Name}.BuildGuests(): couldn't find guest {kvp.Key:X8}");
log.Warn($"[HOUSE] {Name}.BuildGuests(): couldn't find guest {kvp.Key:X8}");
// character has been deleted -- automatically remove?
deleted.Add(kvp.Key);
continue;
}
Guests.Add(player.Guid, kvp.Value);
}
if (deleted.Count > 0)
{
foreach (var guid in deleted)
Biota.RemoveHouseGuest(guid, BiotaDatabaseLock);
ChangesDetected = true;
SaveBiotaToDatabase();
}
}
19
Source : Buffer.cs
with GNU General Public License v3.0
from ACEmulator
with GNU General Public License v3.0
from ACEmulator
public Dictionary<uint, List<uint>> TextureToSetup(Dictionary<uint, InstanceBatch> objects)
{
var table = new Dictionary<uint, List<uint>>();
foreach (var obj in objects.Values)
{
var setupID = obj.R_PhysicsObj.PhysicsObj.PartArray.Setup._dat.Id;
if (setupID == 0)
setupID = obj.R_PhysicsObj.PhysicsObj.PartArray.Parts[0].GfxObj.ID;
foreach (var part in obj.R_PhysicsObj.PhysicsObj.PartArray.Parts)
{
foreach (var surfaceID in part.GfxObj._dat.Surfaces)
{
if (!table.TryGetValue(surfaceID, out var setup))
table.Add(surfaceID, new List<uint>() { setupID });
else if (!setup.Contains(setupID))
setup.Add(setupID);
}
}
}
return table;
}
19
Source : Buffer.cs
with GNU General Public License v3.0
from ACEmulator
with GNU General Public License v3.0
from ACEmulator
public Dictionary<uint, List<uint>> SetupToTexture(Dictionary<uint, InstanceBatch> objects)
{
var table = new Dictionary<uint, List<uint>>();
foreach (var obj in objects.Values)
{
var setupID = obj.R_PhysicsObj.PhysicsObj.PartArray.Setup._dat.Id;
if (setupID == 0)
setupID = obj.R_PhysicsObj.PhysicsObj.PartArray.Parts[0].GfxObj.ID;
table.TryGetValue(setupID, out var textureIDs);
if (textureIDs != null) continue;
textureIDs = new List<uint>();
foreach (var part in obj.R_PhysicsObj.PhysicsObj.PartArray.Parts)
{
foreach (var textureID in part.GfxObj._dat.Surfaces)
{
if (!textureIDs.Contains(textureID))
textureIDs.Add(textureID);
}
}
table.Add(setupID, textureIDs);
}
return table;
}
19
Source : Buffer.cs
with GNU General Public License v3.0
from ACEmulator
with GNU General Public License v3.0
from ACEmulator
public Dictionary<uint, List<uint>> GfxObjToSetup(Dictionary<uint, InstanceBatch> objects)
{
var table = new Dictionary<uint, List<uint>>();
foreach (var obj in objects.Values)
{
var setupID = obj.R_PhysicsObj.PhysicsObj.PartArray.Setup._dat.Id;
if (setupID == 0)
setupID = obj.R_PhysicsObj.PhysicsObj.PartArray.Parts[0].GfxObj.ID;
foreach (var part in obj.R_PhysicsObj.PhysicsObj.PartArray.Parts)
{
var gfxObjID = part.GfxObj.ID;
if (!table.TryGetValue(gfxObjID, out var gfxObj))
table.Add(gfxObjID, new List<uint>() { setupID });
else if (!gfxObj.Contains(setupID))
gfxObj.Add(setupID);
}
}
return table;
}
19
Source : ParticleExplorer.xaml.cs
with GNU General Public License v3.0
from ACEmulator
with GNU General Public License v3.0
from ACEmulator
public void ReadScripts()
{
var scriptIDs = DatManager.PortalDat.AllFiles.Keys.Where(i => i >> 24 == 0x33).ToList();
var particleScripts = new List<uint>();
foreach (var scriptID in scriptIDs)
{
var script = DatManager.PortalDat.ReadFromDat<PhysicsScript>(scriptID);
foreach (var scriptData in script.ScriptData)
{
if (scriptData.Hook is CreateParticleHook)
{
particleScripts.Add(scriptID);
break;
}
}
}
MainWindow.Status.WriteLine($"Found {particleScripts.Count} particle scripts");
PopulateTable(Scripts, particleScripts);
}
19
Source : Buffer.cs
with GNU General Public License v3.0
from ACEmulator
with GNU General Public License v3.0
from ACEmulator
public Dictionary<uint, List<uint>> SetupToGfxObj(Dictionary<uint, InstanceBatch> objects)
{
var table = new Dictionary<uint, List<uint>>();
foreach (var obj in objects.Values)
{
var setupID = obj.R_PhysicsObj.PhysicsObj.PartArray.Setup._dat.Id;
if (setupID == 0)
setupID = obj.R_PhysicsObj.PhysicsObj.PartArray.Parts[0].GfxObj.ID;
table.TryGetValue(setupID, out var gfxObjIDs);
if (gfxObjIDs != null) continue;
gfxObjIDs = new List<uint>();
foreach (var part in obj.R_PhysicsObj.PhysicsObj.PartArray.Parts)
{
var gfxObjID = part.GfxObj.ID;
if (!gfxObjIDs.Contains(gfxObjID))
gfxObjIDs.Add(gfxObjID);
}
table.Add(setupID, gfxObjIDs);
}
return table;
}
19
Source : SubKeyHashedListCell.cs
with MIT License
from ADeltaX
with MIT License
from ADeltaX
public override int ReadFrom(byte[] buffer, int offset)
{
_hashType = EndianUtilities.BytesToString(buffer, offset, 2);
_numElements = EndianUtilities.ToInt16LittleEndian(buffer, offset + 2);
_subKeyIndexes = new List<int>(_numElements);
_nameHashes = new List<uint>(_numElements);
for (int i = 0; i < _numElements; ++i)
{
_subKeyIndexes.Add(EndianUtilities.ToInt32LittleEndian(buffer, offset + 0x4 + i * 0x8));
_nameHashes.Add(EndianUtilities.ToUInt32LittleEndian(buffer, offset + 0x4 + i * 0x8 + 0x4));
}
return 0x4 + _numElements * 0x8;
}
19
Source : SubKeyHashedListCell.cs
with MIT License
from ADeltaX
with MIT License
from ADeltaX
internal int Add(string name, int cellIndex)
{
for (int i = 0; i < _numElements; ++i)
{
KeyNodeCell cell = _hive.GetCell<KeyNodeCell>(_subKeyIndexes[i]);
if (string.Compare(cell.Name, name, StringComparison.OrdinalIgnoreCase) > 0)
{
_subKeyIndexes.Insert(i, cellIndex);
_nameHashes.Insert(i, CalcHash(name));
_numElements++;
return i;
}
}
_subKeyIndexes.Add(cellIndex);
_nameHashes.Add(CalcHash(name));
return _numElements++;
}
19
Source : ParticleMesh.cs
with The Unlicense
from aeroson
with The Unlicense
from aeroson
uint GLGenBuffer()
{
uint handle = (uint)GL.GenBuffer();
allBufferHandles.Add(handle);
return handle;
}
19
Source : Volume.cs
with MIT License
from aerosoul94
with MIT License
from aerosoul94
public List<uint> GetClusterChain(DirectoryEntry dirent)
{
var firstCluster = dirent.FirstCluster;
List<uint> clusterChain = new List<uint>();
if (firstCluster == 0 || firstCluster > this.MaxClusters)
{
Console.WriteLine($" {dirent.GetFullPath()}: First cluster is invalid (FirstCluster={firstCluster} MaxClusters={this.MaxClusters})");
return clusterChain;
}
clusterChain.Add(firstCluster);
if (dirent.IsDeleted())
{
return clusterChain;
}
uint fatEntry = firstCluster;
uint reservedIndexes = (_isFat16) ? Constants.Cluster16Reserved : Constants.ClusterReserved;
while (true)
{
fatEntry = _fileAllocationTable[fatEntry];
if (fatEntry >= reservedIndexes)
{
break;
}
if (fatEntry == 0 || fatEntry > _fileAllocationTable.Length)
{
// TODO: Warn user.
Console.WriteLine($"File {dirent.FileName} has a corrupt cluster chain!");
clusterChain = new List<uint>(1);
clusterChain.Add(firstCluster);
return clusterChain;
}
// Get next cluster.
clusterChain.Add(fatEntry);
}
return clusterChain;
}
19
Source : Volume.cs
with MIT License
from aerosoul94
with MIT License
from aerosoul94
public List<uint> GetClusterChain(DirectoryEntry dirent)
{
var firstCluster = dirent.FirstCluster;
List<uint> clusterChain = new List<uint>();
if (firstCluster == 0 || firstCluster > this.MaxClusters)
{
Console.WriteLine($" {dirent.GetFullPath()}: First cluster is invalid (FirstCluster={firstCluster} MaxClusters={this.MaxClusters})");
return clusterChain;
}
clusterChain.Add(firstCluster);
if (dirent.IsDeleted())
{
return clusterChain;
}
uint fatEntry = firstCluster;
uint reservedIndexes = (_isFat16) ? Constants.Cluster16Reserved : Constants.ClusterReserved;
while (true)
{
fatEntry = _fileAllocationTable[fatEntry];
if (fatEntry >= reservedIndexes)
{
break;
}
if (fatEntry == 0 || fatEntry > _fileAllocationTable.Length)
{
// TODO: Warn user.
Console.WriteLine($"File {dirent.FileName} has a corrupt cluster chain!");
clusterChain = new List<uint>(1);
clusterChain.Add(firstCluster);
return clusterChain;
}
// Get next cluster.
clusterChain.Add(fatEntry);
}
return clusterChain;
}
19
Source : IntegrityAnalyzer.cs
with MIT License
from aerosoul94
with MIT License
from aerosoul94
private List<uint> FindCollidingClusters(DatabaseFile databaseFile)
{
// Get a list of cluster who are possibly corrupted
List<uint> collidingClusters = new List<uint>();
// for each cluster used by this dirent, check if other dirents are
// also claiming it.
foreach (var cluster in databaseFile.ClusterChain)
{
if (clusterMap[(uint)cluster].Count > 1)
{
collidingClusters.Add((uint)cluster);
}
}
return collidingClusters;
}
19
Source : PartitionDatabase.cs
with MIT License
from aerosoul94
with MIT License
from aerosoul94
public DatabaseFile LoadDirectoryEntryFromDatabase(JsonElement directoryEntryObject)
{
// Make sure that the offset property was stored for this file
JsonElement offsetElement;
if (!directoryEntryObject.TryGetProperty("Offset", out offsetElement))
{
Console.WriteLine("Failed to load metadata object from database: Missing offset field");
return null;
}
// Make sure that the cluster property was stored for this file
JsonElement clusterElement;
if (!directoryEntryObject.TryGetProperty("Cluster", out clusterElement))
{
Console.WriteLine("Failed to load metadata object from database: Missing cluster field");
return null;
}
long offset = offsetElement.GetInt64();
uint cluster = clusterElement.GetUInt32();
// Ensure that the offset is within the bounds of the parreplacedion.
if (offset < this.volume.Offset || offset > this.volume.Offset + this.volume.Length)
{
Console.WriteLine($"Failed to load metadata object from database: Invalid offset {offset}");
return null;
}
// Ensure that the cluster index is valid
if (cluster < 0 || cluster > this.volume.MaxClusters)
{
Console.WriteLine($"Failed to load metadata object from database: Invalid cluster {cluster}");
return null;
}
// Read the DirectoryEntry data
byte[] data = new byte[0x40];
this.volume.GetReader().Seek(offset);
this.volume.GetReader().Read(data, 0x40);
// Create a DirectoryEntry
var directoryEntry = new DirectoryEntry(this.volume.Platform, data, 0);
directoryEntry.Cluster = cluster;
directoryEntry.Offset = offset;
// Add this file to the FileDatabase
var databaseFile = fileDatabase.AddFile(directoryEntry, true);
/*
* Here we begin replacedigning our user-configurable modifications
*/
if (directoryEntryObject.TryGetProperty("Children", out var childrenElement))
{
foreach (var childElement in childrenElement.EnumerateArray())
{
LoadDirectoryEntryFromDatabase(childElement);
}
}
if (directoryEntryObject.TryGetProperty("Clusters", out var clustersElement))
{
List<uint> clusterChain = new List<uint>();
//if (databaseFile.FileName == "ears_godfather")
// System.Diagnostics.Debugger.Break();
foreach (var clusterIndex in clustersElement.EnumerateArray())
{
clusterChain.Add(clusterIndex.GetUInt32());
}
databaseFile.ClusterChain = clusterChain;
}
return databaseFile;
}
19
Source : ClusterChainDialog.cs
with MIT License
from aerosoul94
with MIT License
from aerosoul94
private void button1_Click(object sender, EventArgs e)
{
NewClusterChain = new List<uint>();
foreach (ListViewItem item in listView1.Items)
{
NewClusterChain.Add((uint)item.Tag);
}
}
19
Source : AgoraServiceImplementation.cs
with MIT License
from AgoraIO-Community
with MIT License
from AgoraIO-Community
public void StartSession(string sessionId, string agoraAPI, string token, VideoAgoraProfile profile = VideoAgoraProfile.Portrait360P, bool swapWidthAndHeight = false, bool webSdkInteroperability = false)
{
_knownStreams.Add(_myId);
_agoraHandler = new AgoraRtcEngineEventHandler(this);
_agoraEngine = RtcEngine.Create(global::Android.App.Application.Context, agoraAPI, _agoraHandler);
_agoraEngine.EnableWebSdkInteroperability(webSdkInteroperability);
_agoraEngine.SetChannelProfile(Constants.ChannelProfileCommunication);
//_agoraEngine.SetVideoProfile(Constants.VideoProfile360p, false); <2.3.0
_agoraEngine.SetVideoEncoderConfiguration(GetVideoConfig(profile));
_agoraEngine.EnableLocalVideo(true);
_agoraEngine.EnableVideo();
_agoraEngine.SwitchCamera();
_agoraEngine.SetEnableSpeakerphone(true);
// if you do not specify the uid, we will generate the uid for you
_agoraEngine.JoinChannel(token, sessionId, string.Empty, 0);
}
19
Source : AgoraServiceImplementation.cs
with MIT License
from AgoraIO-Community
with MIT License
from AgoraIO-Community
public virtual void OnFirstRemoteVideoDecoded(int uid, int width, int height, int elapsed)
{
var id = (uint)uid;
_knownStreams.Add(id);
if (!_containers.Any(a => a.StreamUID == id))
{
if (_containers.Any(a => a.StreamUID == AgoraService.UnknownRemoteStreamId))
{
var viewHolder = _containers.First(a => a.StreamUID == AgoraService.UnknownRemoteStreamId);
viewHolder.StreamUID = id;
viewHolder.VideoView.IsOffline = false;
}
else
{
OnNewStream((uint)uid, width, height);
}
}
}
19
Source : RoadSigns.cs
with GNU General Public License v3.0
from Albo1125
with GNU General Public License v3.0
from Albo1125
public static void dropSign(string selectedSign, bool swapHeading, Vector3 Location, float HeadingModifier)
{
GameFiber.StartNew(delegate
{
try
{
//string selectedCone = barriersToChooseFrom[EntryPoint.rnd.Next(barriersToChooseFrom.Length)];
//string selectedCone = "PROP_MP_ARROW_BARRIER_01";
if (TrafficPolicerHandler.IsLSPDFRPlusRunning)
{
API.LSPDFRPlusFunctions.AddCountToStatistic(Main.PluginName, "Road signs placed");
}
Rage.Object trafficCone = new Rage.Object(selectedSign, Location);
trafficCone.IsPersistent = true;
trafficCone.IsInvincible = true;
trafficCone.Rotation = RotationToPlaceAt;
if (swapHeading)
{
trafficCone.Heading = Game.LocalPlayer.Character.Heading + 180f;
}
trafficCone.Heading += HeadingModifier;
trafficCone.IsPositionFrozen = false;
if (TrafficSignPreview.Exists())
{
TrafficSignPreview.SetPositionZ(TrafficSignPreview.Position.Z + 3f);
}
int waitCount = 0;
while (trafficCone.HeightAboveGround > 0.01f)
{
trafficCone.SetPositionZ(trafficCone.Position.Z - (trafficCone.HeightAboveGround * 0.75f));
waitCount++;
if (waitCount >= 1000)
{
break;
}
}
if (trafficCone.Exists())
{
trafficCone.IsPositionFrozen = true;
roadSignsDropped.Add(trafficCone);
UInt32 handle = World.AddSpeedZone(trafficCone.Position, 5f, 5f);
speedZones.Add(handle);
Rage.Object invWall = new Rage.Object("p_ice_box_01_s", trafficCone.Position);
invWall.IsPersistent = true;
Ped invPed = new Ped(trafficCone.Position);
invPed.MakeMissionPed();
invPed.IsVisible = false;
invPed.IsPositionFrozen = true;
invWall.Heading = Game.LocalPlayer.Character.Heading;
invWall.IsVisible = false;
RoadSignsWithInvisWallsAndPeds.Add(trafficCone, invWall, invPed);
}
}
catch (Exception e)
{
Game.LogTrivial(e.ToString());
}
});
}
19
Source : OctoMap.cs
with MIT License
from Alexander-Scott
with MIT License
from Alexander-Scott
private void BuildOctoMapFromBitStreamRecursive(BitStream bitStream, uint currentNodeId)
{
// Create child nodes of this current node
uint[] childIdArray = new uint[8];
for (int i = 0; i < 8; i++)
{
uint childNodeId = _nodeHighestIndex++;
_nodes.Add(childNodeId, new OctoMapNode());
childIdArray[i] = childNodeId;
}
// Add child ids to dictionary
uint childArrayId = _nodeChildrenHighestIndex++;
_nodeChildren.Add(childArrayId, childIdArray);
// Create node and add child array linkage
OctoMapNode currentNode = _nodes[currentNodeId];
currentNode.ChildArrayId = childArrayId;
_nodes[currentNodeId] = currentNode;
// Correctly set the state of each of the children created
List<uint> innerNodeChildren = new List<uint>();
for (int i = 0; i < 8; i++)
{
int firstBit = bitStream.ReadBit().AsInt();
int secondBit = bitStream.ReadBit().AsInt();
OctoMapNode childNode;
if (firstBit == 1 && secondBit == 1) // INNER NODE
{
innerNodeChildren.Add(childIdArray[i]);
}
else if (firstBit == 0 && secondBit == 1) // OCCUPIED
{
childNode = _nodes[childIdArray[i]];
_nodes[childIdArray[i]] = IncreaseNodeOccupation(childNode);
}
else if (firstBit == 1 && secondBit == 0) // FREE
{
childNode = _nodes[childIdArray[i]];
_nodes[childIdArray[i]] = DecreaseNodeOccupation(childNode);
}
// else UNKNOWN
}
// Now loop through each child that is an inner node
for (int i = 0; i < innerNodeChildren.Count; i++)
{
BuildOctoMapFromBitStreamRecursive(bitStream, innerNodeChildren[i]);
}
}
19
Source : TMP_SpriteAssetMenu.cs
with MIT License
from Alword
with MIT License
from Alword
[MenuItem("CONTEXT/TMP_Spritereplacedet/Update Sprite replacedet", false, 2100)]
static void UpdateSpritereplacedet(MenuCommand command)
{
TMP_Spritereplacedet spritereplacedet = (TMP_Spritereplacedet)command.context;
if (spritereplacedet == null)
return;
// Get a list of all the sprites contained in the texture referenced by the sprite replacedet.
// This only works if the texture is set to sprite mode.
string filePath = replacedetDatabase.GetreplacedetPath(spritereplacedet.spriteSheet);
if (string.IsNullOrEmpty(filePath))
return;
// Get all the Sprites sorted Left to Right / Top to Bottom
Sprite[] sprites = replacedetDatabase.LoadAllreplacedetsAtPath(filePath).Select(x => x as Sprite).Where(x => x != null).OrderByDescending(x => x.rect.y).ThenBy(x => x.rect.x).ToArray();
List<TMP_SpriteGlyph> spriteGlyphTable = spritereplacedet.spriteGlyphTable;
// Finding available glyph indexes to insert new glyphs into.
var tempGlyphTable = spriteGlyphTable.OrderBy(glyph => glyph.index).ToList();
List<uint> availableGlyphIndexes = new List<uint>();
int elementIndex = 0;
for (uint i = 0; i < tempGlyphTable[tempGlyphTable.Count - 1].index; i++)
{
uint currentElementIndex = tempGlyphTable[elementIndex].index;
if (i == currentElementIndex)
elementIndex += 1;
else
availableGlyphIndexes.Add(i);
}
// Iterate over each of the sprites in the texture to try to match them to existing sprites in the sprite replacedet.
for (int i = 0; i < sprites.Length; i++)
{
int id = sprites[i].GetInstanceID();
int glyphIndex = spriteGlyphTable.FindIndex(item => item.sprite.GetInstanceID() == id);
if (glyphIndex == -1)
{
// Add new Sprite Glyph to the table
Sprite sprite = sprites[i];
TMP_SpriteGlyph spriteGlyph = new TMP_SpriteGlyph();
// Get available glyph index
if (availableGlyphIndexes.Count > 0)
{
spriteGlyph.index = availableGlyphIndexes[0];
availableGlyphIndexes.RemoveAt(0);
}
else
spriteGlyph.index = (uint)spriteGlyphTable.Count;
spriteGlyph.metrics = new GlyphMetrics(sprite.rect.width, sprite.rect.height, -sprite.pivot.x, sprite.rect.height - sprite.pivot.y, sprite.rect.width);
spriteGlyph.glyphRect = new GlyphRect(sprite.rect);
spriteGlyph.scale = 1.0f;
spriteGlyph.sprite = sprite;
spriteGlyphTable.Add(spriteGlyph);
TMP_SpriteCharacter spriteCharacter = new TMP_SpriteCharacter(0, spriteGlyph);
spriteCharacter.name = sprite.name;
spriteCharacter.scale = 1.0f;
spritereplacedet.spriteCharacterTable.Add(spriteCharacter);
}
else
{
// Look for changes in existing Sprite Glyph
Sprite sprite = sprites[i];
TMP_SpriteGlyph spriteGlyph = spriteGlyphTable[glyphIndex];
// We only update changes to the sprite position / glyph rect.
if (spriteGlyph.glyphRect.x != sprite.rect.x || spriteGlyph.glyphRect.y != sprite.rect.y || spriteGlyph.glyphRect.width != sprite.rect.width || spriteGlyph.glyphRect.height != sprite.rect.height)
spriteGlyph.glyphRect = new GlyphRect(sprite.rect);
}
}
// Sort glyph table by glyph index
spritereplacedet.SortGlyphTable();
spritereplacedet.UpdateLookupTables();
TMPro_EventManager.ON_SPRITE_replacedET_PROPERTY_CHANGED(true, spritereplacedet);
}
19
Source : ParticleState.cs
with MIT License
from AmplifyCreations
with MIT License
from AmplifyCreations
void RemoveDeadParticles()
{
m_listToRemove.Clear();
var enumerator = m_particleDict.GetEnumerator();
while ( enumerator.MoveNext() )
{
KeyValuePair<uint, Particle> pair = enumerator.Current;
if ( pair.Value.refCount <= 0 )
{
m_particleStack.Push( pair.Value );
if(!m_listToRemove.Contains(pair.Key))
m_listToRemove.Add( pair.Key );
}
else
pair.Value.refCount = 0;
}
for ( int i = 0; i < m_listToRemove.Count; i++ )
m_particleDict.Remove( m_listToRemove[ i ] );
}
See More Examples