public bool GetEquipmentToEject(EquipmentModelDefinition eqToApply, out HashSet <AvatarModel.Part> ejectedParts, out HashSet <EquipmentModelDefinition> ejectedEquipment)
 {
     ejectedParts     = new HashSet <AvatarModel.Part>();
     ejectedEquipment = new HashSet <EquipmentModelDefinition>();
     EquipmentModelDefinition.Part[] array = eqToApply.Parts;
     for (int i = 0; i < array.Length; i++)
     {
         EquipmentModelDefinition.Part part = array[i];
         AvatarModel.Part modelPart         = null;
         bool             flag = this.TryGetEquippedPart(part.SlotIndex, part.PartType, out modelPart);
         if (!flag)
         {
             flag = (part.PartType == EquipmentPartType.BaseMeshAddition && this.TryGetEquippedPart(part.SlotIndex, EquipmentPartType.BaseMeshReplacement, out modelPart));
         }
         if (!flag)
         {
             flag = (part.PartType == EquipmentPartType.BaseMeshReplacement && this.TryGetEquippedPart(part.SlotIndex, EquipmentPartType.BaseMeshAddition, out modelPart));
         }
         if (flag)
         {
             this.ejectPart(ejectedParts, ejectedEquipment, modelPart);
         }
     }
     return(ejectedParts.Count > 0);
 }
        private void ejectReplacedEquipment(EquipmentModelDefinition eqDefToApply, AvatarModel.ApplyResult result)
        {
            HashSet <AvatarModel.Part>         partsEjected = null;
            HashSet <EquipmentModelDefinition> hashSet      = null;

            if (this.GetEquipmentToEject(eqDefToApply, out partsEjected, out hashSet))
            {
                foreach (EquipmentModelDefinition current in hashSet)
                {
                    this.equipmentList.Remove(current);
                    if (this.EquipmentEjected != null)
                    {
                        try
                        {
                            this.EquipmentEjected(current);
                        }
                        catch (Exception ex)
                        {
                            Log.LogException(this, ex);
                        }
                    }
                }
            }
            result.PartsEjected     = partsEjected;
            result.EquipmentEjected = hashSet;
        }
Exemple #3
0
        private void ejectReplacedEquipment(EquipmentModelDefinition eqDefToApply, ApplyResult result)
        {
            HashSet <Part> ejectedParts = null;
            HashSet <EquipmentModelDefinition> ejectedEquipment = null;

            if (GetEquipmentToEject(eqDefToApply, out ejectedParts, out ejectedEquipment))
            {
                foreach (EquipmentModelDefinition item in ejectedEquipment)
                {
                    equipmentList.Remove(item);
                    if (this.EquipmentEjected != null)
                    {
                        try
                        {
                            this.EquipmentEjected(item);
                        }
                        catch (Exception ex)
                        {
                            Log.LogException(this, ex);
                        }
                    }
                }
            }
            result.PartsEjected     = ejectedParts;
            result.EquipmentEjected = ejectedEquipment;
        }
        public IEnumerable <AvatarModel.Part> GetConnectedParts(AvatarModel.Part modelPart)
        {
            AvatarModel.__c__DisplayClass8 __c__DisplayClass = new AvatarModel.__c__DisplayClass8();
            __c__DisplayClass.modelPart = modelPart;
            __c__DisplayClass.__4__this = this;
            EquipmentModelDefinition equipment = __c__DisplayClass.modelPart.Equipment;

            EquipmentModelDefinition.Part[] source = equipment.Parts;
            return(source.Select(new Func <EquipmentModelDefinition.Part, AvatarModel.Part>(this._GetConnectedParts_b__6)).Where(new Func <AvatarModel.Part, bool>(__c__DisplayClass._GetConnectedParts_b__7)));
        }
Exemple #5
0
        public IEnumerable <Part> GetConnectedParts(Part modelPart)
        {
            EquipmentModelDefinition equipment = modelPart.Equipment;

            EquipmentModelDefinition.Part[] source = equipment.Parts;
            return(from p in source
                   select GetPart(p.SlotIndex, p.PartType) into p
                       where p.Equipment != null && p != modelPart
                   select p);
        }
 private void removeEquipment(EquipmentModelDefinition eq)
 {
     this.equipmentList.Remove(eq);
     for (int i = 0; i < eq.Parts.Length; i++)
     {
         int slotIndex         = eq.Parts[i].SlotIndex;
         int partType          = (int)eq.Parts[i].PartType;
         AvatarModel.Part part = this.parts[slotIndex, partType];
         if (part != null && part.Equipment == eq)
         {
             this.changePart(slotIndex, partType, null);
         }
     }
 }
        public TypedAssetContentKey <EquipmentViewDefinition> CreatePartKey(EquipmentModelDefinition equipment, EquipmentModelDefinition.Part eqPart, int lodLevel)
        {
            string text = string.Format("{0}_{1}_{2}_{3}LOD", new object[]
            {
                equipment.Name,
                AvatarDefinition.PartTypeStrings[(int)eqPart.PartType],
                this.Slots[eqPart.SlotIndex].Name,
                lodLevel
            });

            return(new TypedAssetContentKey <EquipmentViewDefinition>(AvatarDefinition.DEFINITION_KEYPATTERN, new string[]
            {
                text
            }));
        }
        public AvatarModel.ApplyResult ApplyEquipment(DCustomEquipment customEqToApply)
        {
            EquipmentModelDefinition equipmentDefinition = this.Definition.GetEquipmentDefinition(customEqToApply);

            AvatarModel.ApplyResult applyResult = new AvatarModel.ApplyResult();
            applyResult.CustomEquipmentApplied     = customEqToApply;
            applyResult.EquipmentDefinitionApplied = equipmentDefinition;
            applyResult.PartsAdded = new HashSet <AvatarModel.Part>();
            if (equipmentDefinition != null)
            {
                this.ejectReplacedEquipment(equipmentDefinition, applyResult);
                this.applyParts(equipmentDefinition, customEqToApply, applyResult.PartsAdded);
                this.ejectRemainingParts(applyResult.PartsEjected);
                this.equipmentList.Add(equipmentDefinition);
            }
            return(applyResult);
        }
Exemple #9
0
        public bool RemoveEquipment(string equipmentName)
        {
            bool result = false;
            EquipmentModelDefinition equipmentDefinition = Definition.GetEquipmentDefinition(equipmentName);

            if (equipmentDefinition != null)
            {
                if (equipmentList.Contains(equipmentDefinition))
                {
                    removeEquipment(equipmentDefinition);
                    result = true;
                }
            }
            else
            {
                Log.LogErrorFormatted(this, "Trying to remove unknown equipment '{0}' from avatar model {1}", equipmentName, base.name);
            }
            return(result);
        }
 private void applyParts(EquipmentModelDefinition eqDefToApply, DCustomEquipment customEqToApply, HashSet <AvatarModel.Part> partsAdded)
 {
     for (int i = 0; i < eqDefToApply.Parts.Length; i++)
     {
         DCustomEquipmentDecal[]       decals     = null;
         EquipmentModelDefinition.Part newPartDef = eqDefToApply.Parts[i];
         if (customEqToApply.Parts != null)
         {
             for (int j = 0; j < customEqToApply.Parts.Length; j++)
             {
                 if (customEqToApply.Parts[j].SlotIndex == newPartDef.SlotIndex)
                 {
                     decals = customEqToApply.Parts[j].Decals;
                     break;
                 }
             }
         }
         AvatarModel.Part part = new AvatarModel.Part(eqDefToApply, i, decals);
         this.changePart(newPartDef, part);
         partsAdded.Add(part);
     }
 }
        public TypedAssetContentKey <EquipmentViewDefinition> CreatePartKey(EquipmentModelDefinition equipment, EquipmentModelDefinition.Part eqPart, int lodLevel)
        {
            string text = $"{equipment.Name}_{PartTypeStrings[(int)eqPart.PartType]}_{Slots[eqPart.SlotIndex].Name}_{lodLevel}LOD";

            return(new TypedAssetContentKey <EquipmentViewDefinition>(DEFINITION_KEYPATTERN, text));
        }
 public Part(EquipmentModelDefinition equipment, int index, DCustomEquipmentDecal[] decals)
 {
     this.Equipment = equipment;
     this.Index     = index;
     this.Decals    = decals;
 }