public void GetByIDOrDefault_OneItem_ReturnsPCOutfit() { // Arrange var id = Guid.NewGuid(); PCOutfit entity = new PCOutfit { PlayerID = id }; // Act MessageHub.Instance.Publish(new OnCacheObjectSet <PCOutfit>(entity)); // Assert Assert.AreNotSame(entity, _cache.GetByIDOrDefault(id)); }
private void ShowLoadOutfitOptions() { PCOutfit entity = GetPlayerOutfits(GetPC()) ?? new PCOutfit(); ClearPageResponses("LoadOutfitsPage"); if (entity.Outfit1 != null) { AddResponseToPage("LoadOutfitsPage", "Load from Slot 1", true, new Tuple <string, dynamic>(string.Empty, 1)); } if (entity.Outfit2 != null) { AddResponseToPage("LoadOutfitsPage", "Load from Slot 2", true, new Tuple <string, dynamic>(string.Empty, 2)); } if (entity.Outfit3 != null) { AddResponseToPage("LoadOutfitsPage", "Load from Slot 3", true, new Tuple <string, dynamic>(string.Empty, 3)); } if (entity.Outfit4 != null) { AddResponseToPage("LoadOutfitsPage", "Load from Slot 4", true, new Tuple <string, dynamic>(string.Empty, 4)); } if (entity.Outfit5 != null) { AddResponseToPage("LoadOutfitsPage", "Load from Slot 5", true, new Tuple <string, dynamic>(string.Empty, 5)); } if (entity.Outfit6 != null) { AddResponseToPage("LoadOutfitsPage", "Load from Slot 6", true, new Tuple <string, dynamic>(string.Empty, 6)); } if (entity.Outfit7 != null) { AddResponseToPage("LoadOutfitsPage", "Load from Slot 7", true, new Tuple <string, dynamic>(string.Empty, 7)); } if (entity.Outfit8 != null) { AddResponseToPage("LoadOutfitsPage", "Load from Slot 8", true, new Tuple <string, dynamic>(string.Empty, 8)); } if (entity.Outfit9 != null) { AddResponseToPage("LoadOutfitsPage", "Load from Slot 9", true, new Tuple <string, dynamic>(string.Empty, 9)); } if (entity.Outfit10 != null) { AddResponseToPage("LoadOutfitsPage", "Load from Slot 10", true, new Tuple <string, dynamic>(string.Empty, 10)); } AddResponseToPage("LoadOutfitsPage", "Back"); }
private void ShowSaveOutfitOptions() { PCOutfit entity = GetPlayerOutfits(GetPC()) ?? new PCOutfit(); ClearPageResponses("SaveOutfitPage"); string responseText = entity.Outfit1 == null?_color.Red("Save in Slot 1") : _color.Green("Save in Slot 1"); AddResponseToPage("SaveOutfitPage", responseText); responseText = entity.Outfit2 == null?_color.Red("Save in Slot 2") : _color.Green("Save in Slot 2"); AddResponseToPage("SaveOutfitPage", responseText); responseText = entity.Outfit3 == null?_color.Red("Save in Slot 3") : _color.Green("Save in Slot 3"); AddResponseToPage("SaveOutfitPage", responseText); responseText = entity.Outfit4 == null?_color.Red("Save in Slot 4") : _color.Green("Save in Slot 4"); AddResponseToPage("SaveOutfitPage", responseText); responseText = entity.Outfit5 == null?_color.Red("Save in Slot 5") : _color.Green("Save in Slot 5"); AddResponseToPage("SaveOutfitPage", responseText); responseText = entity.Outfit6 == null?_color.Red("Save in Slot 6") : _color.Green("Save in Slot 6"); AddResponseToPage("SaveOutfitPage", responseText); responseText = entity.Outfit7 == null?_color.Red("Save in Slot 7") : _color.Green("Save in Slot 7"); AddResponseToPage("SaveOutfitPage", responseText); responseText = entity.Outfit8 == null?_color.Red("Save in Slot 8") : _color.Green("Save in Slot 8"); AddResponseToPage("SaveOutfitPage", responseText); responseText = entity.Outfit9 == null?_color.Red("Save in Slot 9") : _color.Green("Save in Slot 9"); AddResponseToPage("SaveOutfitPage", responseText); responseText = entity.Outfit10 == null?_color.Red("Save in Slot 10") : _color.Green("Save in Slot 10"); AddResponseToPage("SaveOutfitPage", responseText); AddResponseToPage("SaveOutfitPage", "Back"); }
private void ShowLoadOutfitOptions() { PCOutfit entity = GetPlayerOutfits(GetPC()) ?? new PCOutfit(); ClearPageResponses("LoadOutfitPage"); if (entity.Outfit1 != null) { AddResponseToPage("LoadOutfitPage", "Load from Slot 1", true, 1); } if (entity.Outfit2 != null) { AddResponseToPage("LoadOutfitPage", "Load from Slot 2", true, 2); } if (entity.Outfit3 != null) { AddResponseToPage("LoadOutfitPage", "Load from Slot 3", true, 3); } if (entity.Outfit4 != null) { AddResponseToPage("LoadOutfitPage", "Load from Slot 4", true, 4); } if (entity.Outfit5 != null) { AddResponseToPage("LoadOutfitPage", "Load from Slot 5", true, 5); } if (entity.Outfit6 != null) { AddResponseToPage("LoadOutfitPage", "Load from Slot 6", true, 6); } if (entity.Outfit7 != null) { AddResponseToPage("LoadOutfitPage", "Load from Slot 7", true, 7); } if (entity.Outfit8 != null) { AddResponseToPage("LoadOutfitPage", "Load from Slot 8", true, 8); } if (entity.Outfit9 != null) { AddResponseToPage("LoadOutfitPage", "Load from Slot 9", true, 9); } if (entity.Outfit10 != null) { AddResponseToPage("LoadOutfitPage", "Load from Slot 10", true, 10); } }
public void GetByIDOrDefault_TwoItems_ReturnsCorrectObject() { // Arrange var id1 = Guid.NewGuid(); var id2 = Guid.NewGuid(); PCOutfit entity1 = new PCOutfit { PlayerID = id1 }; PCOutfit entity2 = new PCOutfit { PlayerID = id2 }; // Act MessageHub.Instance.Publish(new OnCacheObjectSet <PCOutfit>(entity1)); MessageHub.Instance.Publish(new OnCacheObjectSet <PCOutfit>(entity2)); // Assert Assert.AreNotSame(entity1, _cache.GetByIDOrDefault(id1)); Assert.AreNotSame(entity2, _cache.GetByIDOrDefault(id2)); }
public void GetByIDOrDefault_NoItems_ReturnsNull() { // Arrange var id1 = Guid.NewGuid(); var id2 = Guid.NewGuid(); PCOutfit entity1 = new PCOutfit { PlayerID = id1 }; PCOutfit entity2 = new PCOutfit { PlayerID = id2 }; // Act MessageHub.Instance.Publish(new OnCacheObjectSet <PCOutfit>(entity1)); MessageHub.Instance.Publish(new OnCacheObjectSet <PCOutfit>(entity2)); MessageHub.Instance.Publish(new OnCacheObjectDeleted <PCOutfit>(entity1)); MessageHub.Instance.Publish(new OnCacheObjectDeleted <PCOutfit>(entity2)); // Assert Assert.IsNull(_cache.GetByIDOrDefault(id1)); Assert.IsNull(_cache.GetByIDOrDefault(id2)); }
private void HandleLoadOutfit(int responseID) { DialogResponse response = GetResponseByID("LoadOutfitPage", responseID); NWPlayer oPC = GetPC(); if (!CanModifyClothes()) { oPC.FloatingText("You cannot modify your currently equipped clothes."); return; } int outfitID = (int)response.CustomData; PCOutfit entity = GetPlayerOutfits(GetPC()); NWPlaceable oTempStorage = (_.GetObjectByTag("OUTFIT_BARREL")); NWItem oClothes = oPC.Chest; NWItem storedClothes = null; oClothes.SetLocalString("TEMP_OUTFIT_UUID", oPC.GlobalID.ToString()); if (outfitID == 1) { storedClothes = SerializationService.DeserializeItem(entity.Outfit1, oTempStorage); } else if (outfitID == 2) { storedClothes = SerializationService.DeserializeItem(entity.Outfit2, oTempStorage); } else if (outfitID == 3) { storedClothes = SerializationService.DeserializeItem(entity.Outfit3, oTempStorage); } else if (outfitID == 4) { storedClothes = SerializationService.DeserializeItem(entity.Outfit4, oTempStorage); } else if (outfitID == 5) { storedClothes = SerializationService.DeserializeItem(entity.Outfit5, oTempStorage); } else if (outfitID == 6) { storedClothes = SerializationService.DeserializeItem(entity.Outfit6, oTempStorage); } else if (outfitID == 7) { storedClothes = SerializationService.DeserializeItem(entity.Outfit7, oTempStorage); } else if (outfitID == 8) { storedClothes = SerializationService.DeserializeItem(entity.Outfit8, oTempStorage); } else if (outfitID == 9) { storedClothes = SerializationService.DeserializeItem(entity.Outfit9, oTempStorage); } else if (outfitID == 10) { storedClothes = SerializationService.DeserializeItem(entity.Outfit10, oTempStorage); } if (storedClothes == null) { throw new Exception("Unable to locate stored clothes."); } NWGameObject oCopy = _.CopyItem(oClothes.Object, oTempStorage.Object, TRUE); oCopy = _.CopyItemAndModify(oCopy, ITEM_APPR_TYPE_ARMOR_MODEL, ITEM_APPR_ARMOR_MODEL_LBICEP, _.GetItemAppearance(storedClothes.Object, ITEM_APPR_TYPE_ARMOR_MODEL, ITEM_APPR_ARMOR_MODEL_LBICEP), TRUE); oCopy = _.CopyItemAndModify(oCopy, ITEM_APPR_TYPE_ARMOR_COLOR, ITEM_APPR_ARMOR_MODEL_LBICEP, _.GetItemAppearance(storedClothes.Object, ITEM_APPR_TYPE_ARMOR_COLOR, ITEM_APPR_ARMOR_MODEL_LBICEP), TRUE); oCopy = _.CopyItemAndModify(oCopy, ITEM_APPR_TYPE_ARMOR_MODEL, ITEM_APPR_ARMOR_MODEL_BELT, _.GetItemAppearance(storedClothes.Object, ITEM_APPR_TYPE_ARMOR_MODEL, ITEM_APPR_ARMOR_MODEL_BELT), TRUE); oCopy = _.CopyItemAndModify(oCopy, ITEM_APPR_TYPE_ARMOR_COLOR, ITEM_APPR_ARMOR_MODEL_BELT, _.GetItemAppearance(storedClothes.Object, ITEM_APPR_TYPE_ARMOR_COLOR, ITEM_APPR_ARMOR_MODEL_BELT), TRUE); oCopy = _.CopyItemAndModify(oCopy, ITEM_APPR_TYPE_ARMOR_MODEL, ITEM_APPR_ARMOR_MODEL_LFOOT, _.GetItemAppearance(storedClothes.Object, ITEM_APPR_TYPE_ARMOR_MODEL, ITEM_APPR_ARMOR_MODEL_LFOOT), TRUE); oCopy = _.CopyItemAndModify(oCopy, ITEM_APPR_TYPE_ARMOR_COLOR, ITEM_APPR_ARMOR_MODEL_LFOOT, _.GetItemAppearance(storedClothes.Object, ITEM_APPR_TYPE_ARMOR_COLOR, ITEM_APPR_ARMOR_MODEL_LFOOT), TRUE); oCopy = _.CopyItemAndModify(oCopy, ITEM_APPR_TYPE_ARMOR_MODEL, ITEM_APPR_ARMOR_MODEL_LFOREARM, _.GetItemAppearance(storedClothes.Object, ITEM_APPR_TYPE_ARMOR_MODEL, ITEM_APPR_ARMOR_MODEL_LFOREARM), TRUE); oCopy = _.CopyItemAndModify(oCopy, ITEM_APPR_TYPE_ARMOR_COLOR, ITEM_APPR_ARMOR_MODEL_LFOREARM, _.GetItemAppearance(storedClothes.Object, ITEM_APPR_TYPE_ARMOR_COLOR, ITEM_APPR_ARMOR_MODEL_LFOREARM), TRUE); oCopy = _.CopyItemAndModify(oCopy, ITEM_APPR_TYPE_ARMOR_MODEL, ITEM_APPR_ARMOR_MODEL_LHAND, _.GetItemAppearance(storedClothes.Object, ITEM_APPR_TYPE_ARMOR_MODEL, ITEM_APPR_ARMOR_MODEL_LHAND), TRUE); oCopy = _.CopyItemAndModify(oCopy, ITEM_APPR_TYPE_ARMOR_COLOR, ITEM_APPR_ARMOR_MODEL_LHAND, _.GetItemAppearance(storedClothes.Object, ITEM_APPR_TYPE_ARMOR_COLOR, ITEM_APPR_ARMOR_MODEL_LHAND), TRUE); oCopy = _.CopyItemAndModify(oCopy, ITEM_APPR_TYPE_ARMOR_MODEL, ITEM_APPR_ARMOR_MODEL_LSHIN, _.GetItemAppearance(storedClothes.Object, ITEM_APPR_TYPE_ARMOR_MODEL, ITEM_APPR_ARMOR_MODEL_LSHIN), TRUE); oCopy = _.CopyItemAndModify(oCopy, ITEM_APPR_TYPE_ARMOR_COLOR, ITEM_APPR_ARMOR_MODEL_LSHIN, _.GetItemAppearance(storedClothes.Object, ITEM_APPR_TYPE_ARMOR_COLOR, ITEM_APPR_ARMOR_MODEL_LSHIN), TRUE); oCopy = _.CopyItemAndModify(oCopy, ITEM_APPR_TYPE_ARMOR_MODEL, ITEM_APPR_ARMOR_MODEL_LSHOULDER, _.GetItemAppearance(storedClothes.Object, ITEM_APPR_TYPE_ARMOR_MODEL, ITEM_APPR_ARMOR_MODEL_LSHOULDER), TRUE); oCopy = _.CopyItemAndModify(oCopy, ITEM_APPR_TYPE_ARMOR_COLOR, ITEM_APPR_ARMOR_MODEL_LSHOULDER, _.GetItemAppearance(storedClothes.Object, ITEM_APPR_TYPE_ARMOR_COLOR, ITEM_APPR_ARMOR_MODEL_LSHOULDER), TRUE); oCopy = _.CopyItemAndModify(oCopy, ITEM_APPR_TYPE_ARMOR_MODEL, ITEM_APPR_ARMOR_MODEL_LTHIGH, _.GetItemAppearance(storedClothes.Object, ITEM_APPR_TYPE_ARMOR_MODEL, ITEM_APPR_ARMOR_MODEL_LTHIGH), TRUE); oCopy = _.CopyItemAndModify(oCopy, ITEM_APPR_TYPE_ARMOR_COLOR, ITEM_APPR_ARMOR_MODEL_LTHIGH, _.GetItemAppearance(storedClothes.Object, ITEM_APPR_TYPE_ARMOR_COLOR, ITEM_APPR_ARMOR_MODEL_LTHIGH), TRUE); oCopy = _.CopyItemAndModify(oCopy, ITEM_APPR_TYPE_ARMOR_MODEL, ITEM_APPR_ARMOR_MODEL_NECK, _.GetItemAppearance(storedClothes.Object, ITEM_APPR_TYPE_ARMOR_MODEL, ITEM_APPR_ARMOR_MODEL_NECK), TRUE); oCopy = _.CopyItemAndModify(oCopy, ITEM_APPR_TYPE_ARMOR_COLOR, ITEM_APPR_ARMOR_MODEL_NECK, _.GetItemAppearance(storedClothes.Object, ITEM_APPR_TYPE_ARMOR_COLOR, ITEM_APPR_ARMOR_MODEL_NECK), TRUE); oCopy = _.CopyItemAndModify(oCopy, ITEM_APPR_TYPE_ARMOR_MODEL, ITEM_APPR_ARMOR_MODEL_PELVIS, _.GetItemAppearance(storedClothes.Object, ITEM_APPR_TYPE_ARMOR_MODEL, ITEM_APPR_ARMOR_MODEL_PELVIS), TRUE); oCopy = _.CopyItemAndModify(oCopy, ITEM_APPR_TYPE_ARMOR_COLOR, ITEM_APPR_ARMOR_MODEL_PELVIS, _.GetItemAppearance(storedClothes.Object, ITEM_APPR_TYPE_ARMOR_COLOR, ITEM_APPR_ARMOR_MODEL_PELVIS), TRUE); oCopy = _.CopyItemAndModify(oCopy, ITEM_APPR_TYPE_ARMOR_MODEL, ITEM_APPR_ARMOR_MODEL_RBICEP, _.GetItemAppearance(storedClothes.Object, ITEM_APPR_TYPE_ARMOR_MODEL, ITEM_APPR_ARMOR_MODEL_RBICEP), TRUE); oCopy = _.CopyItemAndModify(oCopy, ITEM_APPR_TYPE_ARMOR_COLOR, ITEM_APPR_ARMOR_MODEL_RBICEP, _.GetItemAppearance(storedClothes.Object, ITEM_APPR_TYPE_ARMOR_COLOR, ITEM_APPR_ARMOR_MODEL_RBICEP), TRUE); oCopy = _.CopyItemAndModify(oCopy, ITEM_APPR_TYPE_ARMOR_MODEL, ITEM_APPR_ARMOR_MODEL_RFOOT, _.GetItemAppearance(storedClothes.Object, ITEM_APPR_TYPE_ARMOR_MODEL, ITEM_APPR_ARMOR_MODEL_RFOOT), TRUE); oCopy = _.CopyItemAndModify(oCopy, ITEM_APPR_TYPE_ARMOR_COLOR, ITEM_APPR_ARMOR_MODEL_RFOOT, _.GetItemAppearance(storedClothes.Object, ITEM_APPR_TYPE_ARMOR_COLOR, ITEM_APPR_ARMOR_MODEL_RFOOT), TRUE); oCopy = _.CopyItemAndModify(oCopy, ITEM_APPR_TYPE_ARMOR_MODEL, ITEM_APPR_ARMOR_MODEL_RFOREARM, _.GetItemAppearance(storedClothes.Object, ITEM_APPR_TYPE_ARMOR_MODEL, ITEM_APPR_ARMOR_MODEL_RFOREARM), TRUE); oCopy = _.CopyItemAndModify(oCopy, ITEM_APPR_TYPE_ARMOR_COLOR, ITEM_APPR_ARMOR_MODEL_RFOREARM, _.GetItemAppearance(storedClothes.Object, ITEM_APPR_TYPE_ARMOR_COLOR, ITEM_APPR_ARMOR_MODEL_RFOREARM), TRUE); oCopy = _.CopyItemAndModify(oCopy, ITEM_APPR_TYPE_ARMOR_MODEL, ITEM_APPR_ARMOR_MODEL_RHAND, _.GetItemAppearance(storedClothes.Object, ITEM_APPR_TYPE_ARMOR_MODEL, ITEM_APPR_ARMOR_MODEL_RHAND), TRUE); oCopy = _.CopyItemAndModify(oCopy, ITEM_APPR_TYPE_ARMOR_COLOR, ITEM_APPR_ARMOR_MODEL_RHAND, _.GetItemAppearance(storedClothes.Object, ITEM_APPR_TYPE_ARMOR_COLOR, ITEM_APPR_ARMOR_MODEL_RHAND), TRUE); oCopy = _.CopyItemAndModify(oCopy, ITEM_APPR_TYPE_ARMOR_MODEL, ITEM_APPR_ARMOR_MODEL_ROBE, _.GetItemAppearance(storedClothes.Object, ITEM_APPR_TYPE_ARMOR_MODEL, ITEM_APPR_ARMOR_MODEL_ROBE), TRUE); oCopy = _.CopyItemAndModify(oCopy, ITEM_APPR_TYPE_ARMOR_COLOR, ITEM_APPR_ARMOR_MODEL_ROBE, _.GetItemAppearance(storedClothes.Object, ITEM_APPR_TYPE_ARMOR_COLOR, ITEM_APPR_ARMOR_MODEL_ROBE), TRUE); oCopy = _.CopyItemAndModify(oCopy, ITEM_APPR_TYPE_ARMOR_MODEL, ITEM_APPR_ARMOR_MODEL_RSHIN, _.GetItemAppearance(storedClothes.Object, ITEM_APPR_TYPE_ARMOR_MODEL, ITEM_APPR_ARMOR_MODEL_RSHIN), TRUE); oCopy = _.CopyItemAndModify(oCopy, ITEM_APPR_TYPE_ARMOR_COLOR, ITEM_APPR_ARMOR_MODEL_RSHIN, _.GetItemAppearance(storedClothes.Object, ITEM_APPR_TYPE_ARMOR_COLOR, ITEM_APPR_ARMOR_MODEL_RSHIN), TRUE); oCopy = _.CopyItemAndModify(oCopy, ITEM_APPR_TYPE_ARMOR_MODEL, ITEM_APPR_ARMOR_MODEL_RSHOULDER, _.GetItemAppearance(storedClothes.Object, ITEM_APPR_TYPE_ARMOR_MODEL, ITEM_APPR_ARMOR_MODEL_RSHOULDER), TRUE); oCopy = _.CopyItemAndModify(oCopy, ITEM_APPR_TYPE_ARMOR_COLOR, ITEM_APPR_ARMOR_MODEL_RSHOULDER, _.GetItemAppearance(storedClothes.Object, ITEM_APPR_TYPE_ARMOR_COLOR, ITEM_APPR_ARMOR_MODEL_RSHOULDER), TRUE); oCopy = _.CopyItemAndModify(oCopy, ITEM_APPR_TYPE_ARMOR_MODEL, ITEM_APPR_ARMOR_MODEL_RTHIGH, _.GetItemAppearance(storedClothes.Object, ITEM_APPR_TYPE_ARMOR_MODEL, ITEM_APPR_ARMOR_MODEL_RTHIGH), TRUE); oCopy = _.CopyItemAndModify(oCopy, ITEM_APPR_TYPE_ARMOR_COLOR, ITEM_APPR_ARMOR_MODEL_RTHIGH, _.GetItemAppearance(storedClothes.Object, ITEM_APPR_TYPE_ARMOR_COLOR, ITEM_APPR_ARMOR_MODEL_RTHIGH), TRUE); oCopy = _.CopyItemAndModify(oCopy, ITEM_APPR_TYPE_ARMOR_MODEL, ITEM_APPR_ARMOR_MODEL_TORSO, _.GetItemAppearance(storedClothes.Object, ITEM_APPR_TYPE_ARMOR_MODEL, ITEM_APPR_ARMOR_MODEL_TORSO), TRUE); oCopy = _.CopyItemAndModify(oCopy, ITEM_APPR_TYPE_ARMOR_COLOR, ITEM_APPR_ARMOR_MODEL_TORSO, _.GetItemAppearance(storedClothes.Object, ITEM_APPR_TYPE_ARMOR_COLOR, ITEM_APPR_ARMOR_MODEL_TORSO), TRUE); NWItem oFinal = (_.CopyItem(oCopy, oPC.Object, TRUE)); oFinal.DeleteLocalString("TEMP_OUTFIT_UUID"); _.DestroyObject(oCopy); oClothes.Destroy(); storedClothes.Destroy(); oPC.AssignCommand(() => _.ActionEquipItem(oFinal.Object, INVENTORY_SLOT_CHEST)); foreach (NWItem item in oTempStorage.InventoryItems) { if (item.GetLocalString("TEMP_OUTFIT_UUID") == oPC.GlobalID.ToString()) { item.Destroy(); } } ShowLoadOutfitOptions(); }
private void HandleSaveOutfit(int responseID) { NWPlayer oPC = GetPC(); NWItem oClothes = (_.GetItemInSlot(INVENTORY_SLOT_CHEST, oPC.Object)); if (!CanModifyClothes()) { oPC.FloatingText("You cannot save your currently equipped clothes."); return; } PCOutfit entity = GetPlayerOutfits(oPC); var action = DatabaseActionType.Update; if (entity == null) { entity = new PCOutfit { PlayerID = oPC.GlobalID }; action = DatabaseActionType.Insert; } if (!oClothes.IsValid) { oPC.FloatingText(ColorTokenService.Red("You do not have clothes equipped")); return; } string clothesData = SerializationService.Serialize(oClothes); if (responseID == 1) { entity.Outfit1 = clothesData; } else if (responseID == 2) { entity.Outfit2 = clothesData; } else if (responseID == 3) { entity.Outfit3 = clothesData; } else if (responseID == 4) { entity.Outfit4 = clothesData; } else if (responseID == 5) { entity.Outfit5 = clothesData; } else if (responseID == 6) { entity.Outfit6 = clothesData; } else if (responseID == 7) { entity.Outfit7 = clothesData; } else if (responseID == 8) { entity.Outfit8 = clothesData; } else if (responseID == 9) { entity.Outfit9 = clothesData; } else if (responseID == 10) { entity.Outfit10 = clothesData; } DataService.SubmitDataChange(entity, action); ShowSaveOutfitOptions(); }
private void HandleLoadOutfit(int responseID) { DialogResponse response = GetResponseByID("LoadOutfitPage", responseID); NWPlayer oPC = GetPC(); if (!CanModifyClothes()) { oPC.FloatingText("You cannot modify your currently equipped clothes."); return; } int outfitID = (int)response.CustomData; PCOutfit entity = GetPlayerOutfits(GetPC()); if (entity == null) { return; } NWPlaceable oTempStorage = (GetObjectByTag("OUTFIT_BARREL")); NWItem oClothes = oPC.Chest; NWItem storedClothes = null; oClothes.SetLocalString("TEMP_OUTFIT_UUID", oPC.GlobalID.ToString()); if (outfitID == 1) { storedClothes = SerializationService.DeserializeItem(entity.Outfit1, oTempStorage); } else if (outfitID == 2) { storedClothes = SerializationService.DeserializeItem(entity.Outfit2, oTempStorage); } else if (outfitID == 3) { storedClothes = SerializationService.DeserializeItem(entity.Outfit3, oTempStorage); } else if (outfitID == 4) { storedClothes = SerializationService.DeserializeItem(entity.Outfit4, oTempStorage); } else if (outfitID == 5) { storedClothes = SerializationService.DeserializeItem(entity.Outfit5, oTempStorage); } else if (outfitID == 6) { storedClothes = SerializationService.DeserializeItem(entity.Outfit6, oTempStorage); } else if (outfitID == 7) { storedClothes = SerializationService.DeserializeItem(entity.Outfit7, oTempStorage); } else if (outfitID == 8) { storedClothes = SerializationService.DeserializeItem(entity.Outfit8, oTempStorage); } else if (outfitID == 9) { storedClothes = SerializationService.DeserializeItem(entity.Outfit9, oTempStorage); } else if (outfitID == 10) { storedClothes = SerializationService.DeserializeItem(entity.Outfit10, oTempStorage); } if (storedClothes == null) { throw new Exception("Unable to locate stored clothes."); } uint oCopy = CopyItem(oClothes.Object, oTempStorage.Object, true); oCopy = CopyItemAndModify(oCopy, ItemAppearanceType.ArmorModel, (int)AppearanceArmor.LeftBicep, (int)GetItemAppearance(storedClothes.Object, ItemAppearanceType.ArmorModel, (int)AppearanceArmor.LeftBicep), true); oCopy = CopyItemAndModify(oCopy, ItemAppearanceType.ArmorColor, (int)AppearanceArmor.LeftBicep, (int)GetItemAppearance(storedClothes.Object, ItemAppearanceType.ArmorColor, (int)AppearanceArmor.LeftBicep), true); oCopy = CopyItemAndModify(oCopy, ItemAppearanceType.ArmorModel, (int)AppearanceArmor.Belt, (int)GetItemAppearance(storedClothes.Object, ItemAppearanceType.ArmorModel, (int)AppearanceArmor.Belt), true); oCopy = CopyItemAndModify(oCopy, ItemAppearanceType.ArmorColor, (int)AppearanceArmor.Belt, (int)GetItemAppearance(storedClothes.Object, ItemAppearanceType.ArmorColor, (int)AppearanceArmor.Belt), true); oCopy = _.CopyItemAndModify(oCopy, ItemAppearanceType.ArmorModel, (int)AppearanceArmor.LeftFoot, (int)GetItemAppearance(storedClothes.Object, ItemAppearanceType.ArmorModel, (int)AppearanceArmor.LeftFoot), true); oCopy = _.CopyItemAndModify(oCopy, ItemAppearanceType.ArmorColor, (int)AppearanceArmor.LeftFoot, (int)GetItemAppearance(storedClothes.Object, ItemAppearanceType.ArmorColor, (int)AppearanceArmor.LeftFoot), true); oCopy = _.CopyItemAndModify(oCopy, ItemAppearanceType.ArmorModel, (int)AppearanceArmor.LeftForearm, (int)GetItemAppearance(storedClothes.Object, ItemAppearanceType.ArmorModel, (int)AppearanceArmor.LeftForearm), true); oCopy = _.CopyItemAndModify(oCopy, ItemAppearanceType.ArmorColor, (int)AppearanceArmor.LeftForearm, (int)GetItemAppearance(storedClothes.Object, ItemAppearanceType.ArmorColor, (int)AppearanceArmor.LeftForearm), true); oCopy = _.CopyItemAndModify(oCopy, ItemAppearanceType.ArmorModel, (int)AppearanceArmor.LeftHand, (int)GetItemAppearance(storedClothes.Object, ItemAppearanceType.ArmorModel, (int)AppearanceArmor.LeftHand), true); oCopy = _.CopyItemAndModify(oCopy, ItemAppearanceType.ArmorColor, (int)AppearanceArmor.LeftHand, (int)GetItemAppearance(storedClothes.Object, ItemAppearanceType.ArmorColor, (int)AppearanceArmor.LeftHand), true); oCopy = _.CopyItemAndModify(oCopy, ItemAppearanceType.ArmorModel, (int)AppearanceArmor.LeftShin, (int)GetItemAppearance(storedClothes.Object, ItemAppearanceType.ArmorModel, (int)AppearanceArmor.LeftShin), true); oCopy = _.CopyItemAndModify(oCopy, ItemAppearanceType.ArmorColor, (int)AppearanceArmor.LeftShin, (int)GetItemAppearance(storedClothes.Object, ItemAppearanceType.ArmorColor, (int)AppearanceArmor.LeftShin), true); oCopy = _.CopyItemAndModify(oCopy, ItemAppearanceType.ArmorModel, (int)AppearanceArmor.LeftShoulder, (int)GetItemAppearance(storedClothes.Object, ItemAppearanceType.ArmorModel, (int)AppearanceArmor.LeftShoulder), true); oCopy = _.CopyItemAndModify(oCopy, ItemAppearanceType.ArmorColor, (int)AppearanceArmor.LeftShoulder, (int)GetItemAppearance(storedClothes.Object, ItemAppearanceType.ArmorColor, (int)AppearanceArmor.LeftShoulder), true); oCopy = _.CopyItemAndModify(oCopy, ItemAppearanceType.ArmorModel, (int)AppearanceArmor.LeftThigh, (int)GetItemAppearance(storedClothes.Object, ItemAppearanceType.ArmorModel, (int)AppearanceArmor.LeftThigh), true); oCopy = _.CopyItemAndModify(oCopy, ItemAppearanceType.ArmorColor, (int)AppearanceArmor.LeftThigh, (int)GetItemAppearance(storedClothes.Object, ItemAppearanceType.ArmorColor, (int)AppearanceArmor.LeftThigh), true); oCopy = _.CopyItemAndModify(oCopy, ItemAppearanceType.ArmorModel, (int)AppearanceArmor.Neck, (int)GetItemAppearance(storedClothes.Object, ItemAppearanceType.ArmorModel, (int)AppearanceArmor.Neck), true); oCopy = _.CopyItemAndModify(oCopy, ItemAppearanceType.ArmorColor, (int)AppearanceArmor.Neck, (int)GetItemAppearance(storedClothes.Object, ItemAppearanceType.ArmorColor, (int)AppearanceArmor.Neck), true); oCopy = _.CopyItemAndModify(oCopy, ItemAppearanceType.ArmorModel, (int)AppearanceArmor.Pelvis, (int)GetItemAppearance(storedClothes.Object, ItemAppearanceType.ArmorModel, (int)AppearanceArmor.Pelvis), true); oCopy = _.CopyItemAndModify(oCopy, ItemAppearanceType.ArmorColor, (int)AppearanceArmor.Pelvis, (int)GetItemAppearance(storedClothes.Object, ItemAppearanceType.ArmorColor, (int)AppearanceArmor.Pelvis), true); oCopy = _.CopyItemAndModify(oCopy, ItemAppearanceType.ArmorModel, (int)AppearanceArmor.RightBicep, (int)GetItemAppearance(storedClothes.Object, ItemAppearanceType.ArmorModel, (int)AppearanceArmor.RightBicep), true); oCopy = _.CopyItemAndModify(oCopy, ItemAppearanceType.ArmorColor, (int)AppearanceArmor.RightBicep, (int)GetItemAppearance(storedClothes.Object, ItemAppearanceType.ArmorColor, (int)AppearanceArmor.RightBicep), true); oCopy = _.CopyItemAndModify(oCopy, ItemAppearanceType.ArmorModel, (int)AppearanceArmor.RightFoot, (int)GetItemAppearance(storedClothes.Object, ItemAppearanceType.ArmorModel, (int)AppearanceArmor.RightFoot), true); oCopy = _.CopyItemAndModify(oCopy, ItemAppearanceType.ArmorColor, (int)AppearanceArmor.RightFoot, (int)GetItemAppearance(storedClothes.Object, ItemAppearanceType.ArmorColor, (int)AppearanceArmor.RightFoot), true); oCopy = _.CopyItemAndModify(oCopy, ItemAppearanceType.ArmorModel, (int)AppearanceArmor.RightForearm, (int)GetItemAppearance(storedClothes.Object, ItemAppearanceType.ArmorModel, (int)AppearanceArmor.RightForearm), true); oCopy = _.CopyItemAndModify(oCopy, ItemAppearanceType.ArmorColor, (int)AppearanceArmor.RightForearm, (int)GetItemAppearance(storedClothes.Object, ItemAppearanceType.ArmorColor, (int)AppearanceArmor.RightForearm), true); oCopy = _.CopyItemAndModify(oCopy, ItemAppearanceType.ArmorModel, (int)AppearanceArmor.RightHand, (int)GetItemAppearance(storedClothes.Object, ItemAppearanceType.ArmorModel, (int)AppearanceArmor.RightHand), true); oCopy = _.CopyItemAndModify(oCopy, ItemAppearanceType.ArmorColor, (int)AppearanceArmor.RightHand, (int)GetItemAppearance(storedClothes.Object, ItemAppearanceType.ArmorColor, (int)AppearanceArmor.RightHand), true); oCopy = _.CopyItemAndModify(oCopy, ItemAppearanceType.ArmorModel, (int)AppearanceArmor.Robe, (int)GetItemAppearance(storedClothes.Object, ItemAppearanceType.ArmorModel, (int)AppearanceArmor.Robe), true); oCopy = _.CopyItemAndModify(oCopy, ItemAppearanceType.ArmorColor, (int)AppearanceArmor.Robe, (int)GetItemAppearance(storedClothes.Object, ItemAppearanceType.ArmorColor, (int)AppearanceArmor.Robe), true); oCopy = _.CopyItemAndModify(oCopy, ItemAppearanceType.ArmorModel, (int)AppearanceArmor.RightShin, (int)GetItemAppearance(storedClothes.Object, ItemAppearanceType.ArmorModel, (int)AppearanceArmor.RightShin), true); oCopy = _.CopyItemAndModify(oCopy, ItemAppearanceType.ArmorColor, (int)AppearanceArmor.RightShin, (int)GetItemAppearance(storedClothes.Object, ItemAppearanceType.ArmorColor, (int)AppearanceArmor.RightShin), true); oCopy = _.CopyItemAndModify(oCopy, ItemAppearanceType.ArmorModel, (int)AppearanceArmor.RightShoulder, (int)GetItemAppearance(storedClothes.Object, ItemAppearanceType.ArmorModel, (int)AppearanceArmor.RightShoulder), true); oCopy = _.CopyItemAndModify(oCopy, ItemAppearanceType.ArmorColor, (int)AppearanceArmor.RightShoulder, (int)GetItemAppearance(storedClothes.Object, ItemAppearanceType.ArmorColor, (int)AppearanceArmor.RightShoulder), true); oCopy = _.CopyItemAndModify(oCopy, ItemAppearanceType.ArmorModel, (int)AppearanceArmor.RightThigh, (int)GetItemAppearance(storedClothes.Object, ItemAppearanceType.ArmorModel, (int)AppearanceArmor.RightThigh), true); oCopy = _.CopyItemAndModify(oCopy, ItemAppearanceType.ArmorColor, (int)AppearanceArmor.RightThigh, (int)GetItemAppearance(storedClothes.Object, ItemAppearanceType.ArmorColor, (int)AppearanceArmor.RightThigh), true); oCopy = _.CopyItemAndModify(oCopy, ItemAppearanceType.ArmorModel, (int)AppearanceArmor.Torso, (int)GetItemAppearance(storedClothes.Object, ItemAppearanceType.ArmorModel, (int)AppearanceArmor.Torso), true); oCopy = _.CopyItemAndModify(oCopy, ItemAppearanceType.ArmorColor, (int)AppearanceArmor.Torso, (int)GetItemAppearance(storedClothes.Object, ItemAppearanceType.ArmorColor, (int)AppearanceArmor.Torso), true); NWItem oFinal = (CopyItem(oCopy, oPC.Object, true)); oFinal.DeleteLocalString("TEMP_OUTFIT_UUID"); DestroyObject(oCopy); oClothes.Destroy(); storedClothes.Destroy(); oPC.AssignCommand(() => ActionEquipItem(oFinal.Object, InventorySlot.Chest)); foreach (NWItem item in oTempStorage.InventoryItems) { if (item.GetLocalString("TEMP_OUTFIT_UUID") == oPC.GlobalID.ToString()) { item.Destroy(); } } ShowLoadOutfitOptions(); }
private void HandleSaveOutfit(int responseID) { DialogResponse response = GetResponseByID("SaveOutfitPage", responseID); if (response.Text == "Back") { ChangePage("MainPage"); return; } NWPlayer oPC = GetPC(); NWItem oClothes = NWItem.Wrap(_.GetItemInSlot(INVENTORY_SLOT_CHEST, oPC.Object)); PCOutfit entity = GetPlayerOutfits(oPC); if (entity == null) { entity = new PCOutfit { PlayerID = oPC.GlobalID }; } if (!oClothes.IsValid) { oPC.FloatingText(_color.Red("You do not have clothes equipped")); return; } string clothesData = _serialization.Serialize(oClothes); if (responseID == 1) { entity.Outfit1 = clothesData; } else if (responseID == 2) { entity.Outfit2 = clothesData; } else if (responseID == 3) { entity.Outfit3 = clothesData; } else if (responseID == 4) { entity.Outfit4 = clothesData; } else if (responseID == 5) { entity.Outfit5 = clothesData; } else if (responseID == 6) { entity.Outfit6 = clothesData; } else if (responseID == 7) { entity.Outfit7 = clothesData; } else if (responseID == 8) { entity.Outfit8 = clothesData; } else if (responseID == 9) { entity.Outfit9 = clothesData; } else if (responseID == 10) { entity.Outfit10 = clothesData; } _db.SaveChanges(); ShowSaveOutfitOptions(); }