Ejemplo n.º 1
0
 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);
 }
Ejemplo n.º 2
0
        private void changePart(EquipmentModelDefinition.Part newPartDef, AvatarModel.Part newPart)
        {
            int slotIndex = newPartDef.SlotIndex;
            int partType  = (int)newPartDef.PartType;

            this.changePart(slotIndex, partType, newPart);
        }
Ejemplo n.º 3
0
        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)));
        }
Ejemplo n.º 4
0
 private void ejectRemainingParts(HashSet <AvatarModel.Part> partsToEject)
 {
     foreach (AvatarModel.Part current in partsToEject)
     {
         EquipmentModelDefinition.Part partDefinition = this.GetPartDefinition(current);
         AvatarModel.Part part = this.GetPart(partDefinition.SlotIndex, partDefinition.PartType);
         if (part == current)
         {
             this.changePart(partDefinition, null);
         }
     }
 }
Ejemplo n.º 5
0
 public static void CreateDecalContent(ViewPart partView, AvatarModel.Part modelPart, List <KeyValuePair <TypedAssetContentKey <Texture2D>, Action <Texture2D> > > decalContent)
 {
     partView.InitDecalProps(modelPart.Decals.Length);
     for (int i = 0; i < modelPart.Decals.Length; i++)
     {
         AvatarView.__c__DisplayClass4 __c__DisplayClass = new AvatarView.__c__DisplayClass4();
         DCustomEquipmentDecal         decal             = modelPart.Decals[i];
         __c__DisplayClass.decalMatProp = new DecalMaterialProperties(decal.Index);
         __c__DisplayClass.decalMatProp.Import(decal, null);
         partView.SetDecalProps(i, __c__DisplayClass.decalMatProp);
         TypedAssetContentKey <Texture2D> key = AvatarView.CreateDecalKey(decal);
         decalContent.Add(new KeyValuePair <TypedAssetContentKey <Texture2D>, Action <Texture2D> >(key, new Action <Texture2D>(__c__DisplayClass._CreateDecalContent_b__3)));
     }
 }
Ejemplo n.º 6
0
 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);
         }
     }
 }
Ejemplo n.º 7
0
 public static void CreateDecalContent(ViewPart partView, AvatarModel.Part modelPart, List <KeyValuePair <TypedAssetContentKey <Texture2D>, Action <Texture2D> > > decalContent)
 {
     partView.InitDecalProps(modelPart.Decals.Length);
     for (int i = 0; i < modelPart.Decals.Length; i++)
     {
         DCustomEquipmentDecal   decal        = modelPart.Decals[i];
         DecalMaterialProperties decalMatProp = new DecalMaterialProperties(decal.Index);
         decalMatProp.Import(decal);
         partView.SetDecalProps(i, decalMatProp);
         TypedAssetContentKey <Texture2D> key = CreateDecalKey(decal);
         decalContent.Add(new KeyValuePair <TypedAssetContentKey <Texture2D>, Action <Texture2D> >(key, delegate(Texture2D decalTex)
         {
             decalMatProp.Texture = decalTex;
         }));
     }
 }
Ejemplo n.º 8
0
 private void changePart(int slotIndex, int partIndex, AvatarModel.Part newPart)
 {
     AvatarModel.Part arg = this.setPart(slotIndex, (EquipmentPartType)partIndex, newPart ?? ((partIndex == 0) ? new AvatarModel.Part(null, slotIndex, null) : null));
     if (this.PartChanged != null)
     {
         try
         {
             this.PartChanged(slotIndex, partIndex, arg, this.GetPart(slotIndex, (EquipmentPartType)partIndex));
         }
         catch (Exception ex)
         {
             Log.LogException(this, ex);
             throw;
         }
     }
 }
Ejemplo n.º 9
0
 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 void Apply(AvatarModel.Part newPart)
 {
     base.startWork();
     if (newPart != null)
     {
         if (newPart.Equipment != null)
         {
             this.cleanupLoading();
             EquipmentModelDefinition.Part eqPart = newPart.Equipment.Parts[newPart.Index];
             KeyValuePair <TypedAssetContentKey <EquipmentViewDefinition>, Action <EquipmentViewDefinition> >[] content = new KeyValuePair <TypedAssetContentKey <EquipmentViewDefinition>, Action <EquipmentViewDefinition> >[]
             {
                 AvatarView.CreatePartContent(this.Model, this.partView, newPart, eqPart)
             };
             List <KeyValuePair <TypedAssetContentKey <Texture2D>, Action <Texture2D> > > list = new List <KeyValuePair <TypedAssetContentKey <Texture2D>, Action <Texture2D> > >();
             if (newPart.Decals != null)
             {
                 AvatarView.CreateDecalContent(this.partView, newPart, list);
             }
             this.loadingEquipmentRequest = this.outfitService.Load <EquipmentViewDefinition>(content, this.outfitService.EquipmentPartCache, null);
             this.loadingDecalRequest     = this.outfitService.Load <Texture2D>(list, this.outfitService.DecalCache, null);
         }
         else
         {
             this.cleanupCurrent();
             BodyViewDefinition bodyViewDefinition = this.Model.Definition.Slots[newPart.Index].LOD[this.Model.LodLevel];
             bodyViewDefinition.ApplyToViewPart(this.partView);
             this.setupRenderer();
             base.stopWork();
         }
         base.gameObject.SetActive(true);
     }
     else
     {
         base.gameObject.SetActive(false);
         this.cleanupCurrent();
         base.stopWork();
     }
 }
Ejemplo n.º 11
0
        private void applyPart(int slotIndex, int partIndex, AvatarModel.Part newPart)
        {
            AvatarViewDistinctChild avatarViewDistinctChild = children[slotIndex, partIndex];

            if (avatarViewDistinctChild == null && newPart != null)
            {
                string text = Model.Definition.Slots[slotIndex].Name;
                if (partIndex > 0)
                {
                    text = text + "_" + AvatarDefinition.PartTypeStrings[partIndex];
                }
                GameObject gameObject = new GameObject(text);
                gameObject.transform.SetParent(base.transform, worldPositionStays: false);
                gameObject.layer = base.gameObject.layer;
                gameObject.SetActive(value: false);
                avatarViewDistinctChild           = gameObject.AddComponent <AvatarViewDistinctChild>();
                avatarViewDistinctChild.SlotIndex = slotIndex;
                avatarViewDistinctChild.PartIndex = partIndex;
                avatarViewDistinctChild.Model     = Model;
                avatarViewDistinctChild.Rig       = rig;
                gameObject.SetActive(value: true);
                children[slotIndex, partIndex] = avatarViewDistinctChild;
                if (this.OnChildAdded != null)
                {
                    this.OnChildAdded(avatarViewDistinctChild);
                }
            }
            boundsIsDirty = true;
            if (avatarViewDistinctChild != null)
            {
                avatarViewDistinctChild.Apply(newPart);
                if (avatarViewDistinctChild.IsBusy && !base.IsBusy)
                {
                    startWork();
                }
            }
        }
Ejemplo n.º 12
0
 private AvatarModel.Part setPart(int slotIndex, EquipmentPartType partType, AvatarModel.Part newPart)
 {
     AvatarModel.Part part = this.GetPart(slotIndex, partType);
     this.parts[slotIndex, (int)partType] = newPart;
     return(part);
 }
Ejemplo n.º 13
0
        private void ejectPart(HashSet <AvatarModel.Part> ejectedParts, HashSet <EquipmentModelDefinition> ejectedEquipment, AvatarModel.Part modelPart)
        {
            ejectedParts.Add(modelPart);
            IEnumerable <AvatarModel.Part> connectedParts = this.GetConnectedParts(modelPart);

            if (this.IsRequiredPart(modelPart))
            {
                foreach (AvatarModel.Part current in connectedParts)
                {
                    ejectedParts.Add(current);
                }
            }
            if (AvatarModel.areAllPartsRemoved(connectedParts, ejectedParts))
            {
                ejectedEquipment.Add(modelPart.Equipment);
            }
        }
Ejemplo n.º 14
0
        public static KeyValuePair <TypedAssetContentKey <EquipmentViewDefinition>, Action <EquipmentViewDefinition> > CreatePartContent(AvatarModel model, ViewPart partView, AvatarModel.Part modelPart, EquipmentModelDefinition.Part eqPart)
        {
            TypedAssetContentKey <EquipmentViewDefinition> key = model.Definition.CreatePartKey(modelPart.Equipment, eqPart, model.LodLevel);

            return(new KeyValuePair <TypedAssetContentKey <EquipmentViewDefinition>, Action <EquipmentViewDefinition> >(key, delegate(EquipmentViewDefinition eq)
            {
                onPartDefinitionLoaded(partView, eq);
            }));
        }
Ejemplo n.º 15
0
 private void model_PartChanged(int arg1, int arg2, AvatarModel.Part arg3, AvatarModel.Part arg4)
 {
     modelDirty = true;
 }
Ejemplo n.º 16
0
 public bool IsRequiredPart(AvatarModel.Part part)
 {
     return(this.GetPartDefinition(part).Required);
 }
Ejemplo n.º 17
0
 public EquipmentModelDefinition.Part GetPartDefinition(AvatarModel.Part part)
 {
     return(part.Equipment.Parts[part.Index]);
 }
Ejemplo n.º 18
0
 private void model_PartChanged(int slotIndex, int partIndex, AvatarModel.Part oldPart, AvatarModel.Part newPart)
 {
     applyPart(slotIndex, partIndex, newPart);
 }
Ejemplo n.º 19
0
 public bool _GetConnectedParts_b__7(AvatarModel.Part p)
 {
     return(p.Equipment != null && p != this.modelPart);
 }
Ejemplo n.º 20
0
 public bool TryGetEquippedPart(int slotIndex, EquipmentPartType partType, out AvatarModel.Part outPart)
 {
     outPart = this.GetPart(slotIndex, partType);
     return(outPart != null && outPart.Equipment != null);
 }
Ejemplo n.º 21
0
        public static KeyValuePair <TypedAssetContentKey <EquipmentViewDefinition>, Action <EquipmentViewDefinition> > CreatePartContent(AvatarModel model, ViewPart partView, AvatarModel.Part modelPart, EquipmentModelDefinition.Part eqPart)
        {
            AvatarView.__c__DisplayClass1 __c__DisplayClass = new AvatarView.__c__DisplayClass1();
            __c__DisplayClass.partView = partView;
            TypedAssetContentKey <EquipmentViewDefinition> key = model.Definition.CreatePartKey(modelPart.Equipment, eqPart, model.LodLevel);

            return(new KeyValuePair <TypedAssetContentKey <EquipmentViewDefinition>, Action <EquipmentViewDefinition> >(key, new Action <EquipmentViewDefinition>(__c__DisplayClass._CreatePartContent_b__0)));
        }