Advertisement
Guest User

Untitled

a guest
Jul 26th, 2015
47
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 22.07 KB | None | 0 0
  1. // Fill out your copyright notice in the Description page of Project Settings.
  2.  
  3. #include "GAMEPROJECT.h"
  4. #include "EquipmentComponent.h"
  5.  
  6. //TODO:
  7. #pragma message("EquipmentComponent: Needs more solid check for compatible appearance component")
  8.  
  9.  
  10. // Sets default values for this component's properties
  11. UEquipmentComponent::UEquipmentComponent()
  12. {
  13.     // Set this component to be initialized when the game starts, and to be ticked every frame.  You can turn these features
  14.     // off to improve performance if you don't need them.
  15.     bWantsBeginPlay = false;
  16.     bWantsInitializeComponent = true;
  17.     PrimaryComponentTick.bCanEverTick = true;
  18.  
  19.     bReplicates = true;
  20.     bAutoActivate = true;
  21.  
  22.     // ...
  23.     //Get empty textures
  24.     static ConstructorHelpers::FObjectFinder<UTexture2D> TorsoUpperObj(TEXT("Texture2D'/Game/Textures/Characters/Clothing/Defaults/Clothing_TU_None.Clothing_TU_None'"));
  25.     TorsoUpperEmpty = TorsoUpperObj.Object;
  26.     static ConstructorHelpers::FObjectFinder<UTexture2D> TorsoLowerObj(TEXT("Texture2D'/Game/Textures/Characters/Clothing/Defaults/Clothing_TL_None.Clothing_TL_None'"));
  27.     TorsoLowerEmpty = TorsoUpperObj.Object;
  28.     static ConstructorHelpers::FObjectFinder<UTexture2D> ArmUpperObj(TEXT("Texture2D'/Game/Textures/Characters/Clothing/Defaults/Clothing_AU_None.Clothing_AU_None'"));
  29.     ArmUpperEmpty = TorsoUpperObj.Object;
  30.     static ConstructorHelpers::FObjectFinder<UTexture2D> ArmLowerrObj(TEXT("Texture2D'/Game/Textures/Characters/Clothing/Defaults/Clothing_AL_None.Clothing_AL_None'"));
  31.     ArmLowerEmpty = TorsoUpperObj.Object;
  32.     static ConstructorHelpers::FObjectFinder<UTexture2D> LegUpperObj(TEXT("Texture2D'/Game/Textures/Characters/Clothing/Defaults/Clothing_LU_None.Clothing_LU_None'"));
  33.     LegUpperEmpty = TorsoUpperObj.Object;
  34.     static ConstructorHelpers::FObjectFinder<UTexture2D> LegLowerObj(TEXT("Texture2D'/Game/Textures/Characters/Clothing/Defaults/Clothing_LL_None.Clothing_LL_None'"));
  35.     LegLowerEmpty = TorsoUpperObj.Object;
  36.     static ConstructorHelpers::FObjectFinder<UTexture2D> HandEmptyObj(TEXT("Texture2D'/Game/Textures/Characters/Clothing/Defaults/Clothing_HA_None.Clothing_HA_None'"));
  37.     HandEmpty = TorsoUpperObj.Object;
  38.     static ConstructorHelpers::FObjectFinder<UTexture2D> FootEmptyObj(TEXT("Texture2D'/Game/Textures/Characters/Clothing/Defaults/Clothing_FO_None.Clothing_FO_None'"));
  39.     FootEmpty = TorsoUpperObj.Object;
  40. }
  41.  
  42.  
  43. void UEquipmentComponent::InitializeComponent()
  44. {
  45.     Super::InitializeComponent();
  46.  
  47.     // ...
  48.     OwningCharacter = Cast<AGameCharacter>(GetOwner());
  49.     ParentCustomizationComponent = Cast<UCharacterCustomizationComponent>(OwningCharacter->GetComponentByClass(UCharacterCustomizationComponent::StaticClass()));
  50.  
  51.     if (OwningCharacter && ParentCustomizationComponent)
  52.     {
  53.         if (EquippedHeadwear != Headwear.GetDefaultObject())
  54.         {
  55.             //clear the slot for the new item
  56.             Unequip(EGameEquipmentSlot::EQT_Head);
  57.             Equip(Headwear.GetDefaultObject());
  58.         }
  59.        
  60.         if (EquippedNecklace != Necklace.GetDefaultObject())
  61.         {
  62.             //clear the slot for the new item
  63.             Unequip(EGameEquipmentSlot::EQT_Necklace);
  64.             Equip(Necklace.GetDefaultObject());
  65.         }
  66.  
  67.         if (EquippedShoulders != Shoulders.GetDefaultObject())
  68.         {
  69.             //clear the slot for the new item
  70.             Unequip(EGameEquipmentSlot::EQT_Shoulders);
  71.             Equip(Shoulders.GetDefaultObject());
  72.         }
  73.  
  74.         if (EquippedShirt != Shirt.GetDefaultObject())
  75.         {
  76.             //clear the slot for the new item
  77.             Unequip(EGameEquipmentSlot::EQT_Shirt);
  78.             Equip(Shirt.GetDefaultObject());
  79.         }
  80.        
  81.         if (EquippedChestpiece->StaticClass() != Chestpiece)
  82.         {
  83.             //clear the slot for the new item
  84.             Unequip(EGameEquipmentSlot::EQT_Chestpiece);
  85.             Equip(Chestpiece.GetDefaultObject());
  86.         }
  87.  
  88.         if (EquippedBelt != Belt.GetDefaultObject())
  89.         {
  90.             //clear the slot for the new item
  91.             Unequip(EGameEquipmentSlot::EQT_Belt);
  92.             Equip(Belt.GetDefaultObject());
  93.         }
  94.  
  95.         if (EquippedBracers != Bracers.GetDefaultObject())
  96.         {
  97.             //clear the slot for the new item
  98.             Unequip(EGameEquipmentSlot::EQT_Bracers);
  99.             Equip(Bracers.GetDefaultObject());
  100.         }
  101.  
  102.         if (EquippedHands != Hands.GetDefaultObject())
  103.         {
  104.             //clear the slot for the new item
  105.             Unequip(EGameEquipmentSlot::EQT_Hands);
  106.             Equip(Hands.GetDefaultObject());
  107.         }
  108.  
  109.         //TODO: Implement Rings
  110.  
  111.         if (EquippedLegs != Legs.GetDefaultObject())
  112.         {
  113.             //clear the slot for the new item
  114.             Unequip(EGameEquipmentSlot::EQT_Legs);
  115.             Equip(Legs.GetDefaultObject());
  116.         }
  117.  
  118.         if (EquippedFeet != Feet.GetDefaultObject())
  119.         {
  120.             //clear the slot for the new item
  121.             Unequip(EGameEquipmentSlot::EQT_Feet);
  122.             Equip(Feet.GetDefaultObject());
  123.         }
  124.  
  125.         if (EquippedCape != Cape.GetDefaultObject())
  126.         {
  127.             //clear the slot for the new item
  128.             Unequip(EGameEquipmentSlot::EQT_Cape);
  129.             Equip(Cape.GetDefaultObject());
  130.         }
  131.  
  132.         if (EquippedTabard != Tabard.GetDefaultObject())
  133.         {
  134.             //clear the slot for the new item
  135.             Unequip(EGameEquipmentSlot::EQT_Tabard);
  136.             Equip(Tabard.GetDefaultObject());
  137.         }
  138.     }
  139. }
  140.  
  141. // Called every frame
  142. void UEquipmentComponent::TickComponent( float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction )
  143. {
  144.     Super::TickComponent( DeltaTime, TickType, ThisTickFunction );
  145.  
  146.     // ...
  147. }
  148.  
  149. bool UEquipmentComponent::Equip(UEquipment* Item)
  150. {
  151.     if (OwningCharacter&& ParentCustomizationComponent && Item)
  152.     {
  153.         UArmor* Armor = Cast<UArmor>(Item);
  154.         UWeapon* Weapon = Cast<UWeapon>(Item);
  155.  
  156.         if (Armor)
  157.         {
  158.             EGameEquipmentSlot Slot = Armor->EquipmentSlot;
  159.  
  160.             //render the larger mesh elements (if any)
  161.             TArray<TEnumAsByte< EGameEquipmentDisplayType > > Types = Armor->DisplayTypes;
  162.             //BREAKING: access violation crash here
  163.             ParentCustomizationComponent->RenderArmorElements(Types, true);
  164.  
  165.             switch (Slot)
  166.             {
  167.                 case EGameEquipmentSlot::EQT_Head:
  168.                 {
  169.                     //TODO: Implement meshes & socket handling
  170.                     return true;
  171.                 }
  172.                 case EGameEquipmentSlot::EQT_Necklace:
  173.                 {
  174.                     //TODO: Implement necklace texture
  175.                     UNeckArmor* Necklace = Cast<UNeckArmor>(Armor);
  176.                     SetUpperTorsoTexture(Necklace->GetUpperTorsoTexture(OwningCharacter->Gender), Slot);
  177.                     EquippedNecklace = Necklace;
  178.                     return true;
  179.                 }
  180.                 case EGameEquipmentSlot::EQT_Shoulders:
  181.                 {
  182.                     //TODO: Implement meshes & socket handling
  183.                     return true;
  184.                 }
  185.                 case EGameEquipmentSlot::EQT_Cape:
  186.                 {
  187.                     //TODO: Implement capes
  188.                     return true;
  189.                 }
  190.                 case EGameEquipmentSlot::EQT_Shirt:
  191.                 {
  192.                     UShirtArmor* Shirt = Cast<UShirtArmor>(Armor);
  193.                     SetUpperTorsoTexture(Shirt->GetUpperTorsoTexture(OwningCharacter->Gender), Slot);
  194.                     SetLowerTorsoTexture(Shirt->GetLowerTorsoTexture(OwningCharacter->Gender), Slot);
  195.                     SetUpperArmTexture(Shirt->GetUpperArmTexture(OwningCharacter->Gender), Slot);
  196.                     SetLowerArmTexture(Shirt->GetLowerArmTexture(OwningCharacter->Gender), Slot);
  197.                     EquippedShirt = Shirt;
  198.                     return true;
  199.                 }
  200.                 case EGameEquipmentSlot::EQT_Chestpiece:
  201.                 {
  202.                     UChestArmor* Chest = Cast<UChestArmor>(Armor);
  203.                     SetUpperTorsoTexture(Chest->GetUpperTorsoTexture(OwningCharacter->Gender), Slot);
  204.                     SetLowerTorsoTexture(Chest->GetLowerTorsoTexture(OwningCharacter->Gender), Slot);
  205.                     SetUpperArmTexture(Chest->GetUpperArmTexture(OwningCharacter->Gender), Slot);
  206.                     SetLowerArmTexture(Chest->GetLowerArmTexture(OwningCharacter->Gender), Slot);
  207.                     SetUpperLegTexture(Chest->GetUpperLegTexture(OwningCharacter->Gender), Slot);
  208.                     SetLowerLegTexture(Chest->GetLowerLegTexture(OwningCharacter->Gender), Slot);
  209.                     EquippedChestpiece = Chest;
  210.                     return true;
  211.                 }
  212.                 case EGameEquipmentSlot::EQT_Belt:
  213.                 {
  214.                     UBeltArmor* Belt = Cast<UBeltArmor>(Armor);
  215.                     SetUpperLegTexture(Belt->GetUpperLegTexture(OwningCharacter->Gender), Slot);
  216.                     EquippedBelt = Belt;
  217.                     return true;
  218.                 }
  219.                 case EGameEquipmentSlot::EQT_Bracers:
  220.                 {
  221.                     UBracerArmor* Bracer = Cast<UBracerArmor>(Armor);
  222.                     SetLowerArmTexture(Bracer->GetLowerArmTexture(OwningCharacter->Gender), Slot);
  223.                     EquippedBracers = Bracer;
  224.                     return true;
  225.                 }
  226.                 case EGameEquipmentSlot::EQT_Hands:
  227.                 {
  228.                     UHandsArmor* Hands = Cast<UHandsArmor>(Armor);
  229.                     SetLowerArmTexture(Hands->GetLowerArmTexture(OwningCharacter->Gender), Slot);
  230.                     SetHandTexture(Hands->GetHandTexture(OwningCharacter->Gender), Slot);
  231.                     EquippedHands = Hands;
  232.                     return true;
  233.                 }
  234.                 case EGameEquipmentSlot::EQT_Ring:
  235.                 {
  236.                     URingArmor* Ring = Cast<URingArmor>(Armor);
  237.                     //TODO: Implement meshes & socket handling
  238.                     return true;
  239.                 }
  240.                 case EGameEquipmentSlot::EQT_Legs:
  241.                 {
  242.                     ULegsArmor* Legs = Cast<ULegsArmor>(Armor);
  243.                     SetUpperLegTexture(Legs->GetUpperLegTexture(OwningCharacter->Gender), Slot);
  244.                     SetLowerLegTexture(Legs->GetLowerLegTexture(OwningCharacter->Gender), Slot);
  245.                     EquippedLegs = Legs;
  246.                     return true;
  247.                 }
  248.                 case EGameEquipmentSlot::EQT_Feet:
  249.                 {
  250.                     UFeetArmor* Feet = Cast<UFeetArmor>(Armor);
  251.                     SetLowerLegTexture(Feet->GetLowerLegTexture(OwningCharacter->Gender), Slot);
  252.                     SetFootTexture(Feet->GetFootTexture(OwningCharacter->Gender), Slot);
  253.                     EquippedFeet = Feet;
  254.                     return true;
  255.                 }
  256.                 case EGameEquipmentSlot::EQT_Tabard:
  257.                 {
  258.                     UTabardArmor* Tabard = Cast<UTabardArmor>(Armor);
  259.                     SetUpperTorsoTexture(Tabard->GetUpperTorsoTexture(OwningCharacter->Gender), Slot);
  260.                     SetLowerTorsoTexture(Tabard->GetLowerTorsoTexture(OwningCharacter->Gender), Slot);
  261.                     EquippedTabard = Tabard;
  262.                     return true;
  263.                 }
  264.                 default:
  265.                 {
  266.                     return false;
  267.                 }
  268.             }
  269.         }
  270.         else if (Weapon)
  271.         {
  272.             //TODO: Implement weapon handling
  273.             EGameEquipmentSlot Slot = Weapon->EquipmentSlot;
  274.  
  275.             //clear the slot for the new item
  276.             Unequip(Slot);
  277.  
  278.             switch (Slot)
  279.             {
  280.                 case EGameEquipmentSlot::EQT_RightHand:
  281.                 {
  282.                     return true;
  283.                 }
  284.                 case EGameEquipmentSlot::EQT_LeftHand:
  285.                 {
  286.                     return true;
  287.                 }
  288.                 case EGameEquipmentSlot::EQT_TwoHand:
  289.                 {
  290.                     return true;
  291.                 }
  292.                 case EGameEquipmentSlot::EQT_OffHand:
  293.                 {
  294.                     return true;
  295.                 }
  296.                 case EGameEquipmentSlot::EQT_Special:
  297.                 {
  298.                     return true;
  299.                 }
  300.                 default:
  301.                 {
  302.                     return false;
  303.                 }
  304.             }
  305.         }
  306.         else
  307.         {
  308.             return false;
  309.         }
  310.     }
  311.     else
  312.     {
  313.         return false;
  314.     }      
  315. }
  316.  
  317. bool UEquipmentComponent::Unequip(EGameEquipmentSlot Slot)
  318. {
  319.     if (ParentCustomizationComponent)
  320.     {
  321.         switch (Slot)
  322.         {
  323.             case EGameEquipmentSlot::EQT_Head:
  324.             {
  325.                 //TODO: Implement headwear mesh & sockets
  326.                 return false;
  327.             }
  328.             case EGameEquipmentSlot::EQT_Necklace:
  329.             {
  330.                 //TODO: Implement necklace textures
  331.                 if (EquippedNecklace)
  332.                 {
  333.                     SetUpperTorsoTexture(TorsoUpperEmpty, Slot);
  334.                     return true;
  335.                 }
  336.             }
  337.             case EGameEquipmentSlot::EQT_Shoulders:
  338.             {
  339.                 //TODO: Implement shoulder meshes & sockets
  340.                 return false;
  341.             }
  342.             case EGameEquipmentSlot::EQT_Cape:
  343.             {
  344.                 //TODO: Implement capes
  345.                 return false;
  346.             }
  347.             case EGameEquipmentSlot::EQT_Shirt:
  348.             {
  349.                 if (EquippedShirt)
  350.                 {
  351.                     //render the larger mesh elements (if any)
  352.                     ParentCustomizationComponent->RenderArmorElements(EquippedShirt->DisplayTypes, false);
  353.                     SetUpperTorsoTexture(TorsoUpperEmpty, Slot);
  354.                     SetLowerTorsoTexture(TorsoLowerEmpty, Slot);
  355.                     SetUpperArmTexture(ArmUpperEmpty, Slot);
  356.                     SetLowerArmTexture(ArmLowerEmpty, Slot);
  357.                 }
  358.                 return true;
  359.             }
  360.             case EGameEquipmentSlot::EQT_Chestpiece:
  361.             {
  362.                 if (EquippedChestpiece)
  363.                 {
  364.                     //render the larger mesh elements (if any)
  365.                     ParentCustomizationComponent->RenderArmorElements(EquippedChestpiece->DisplayTypes, false);
  366.                     SetUpperTorsoTexture(TorsoUpperEmpty, Slot);
  367.                     SetLowerTorsoTexture(TorsoLowerEmpty, Slot);
  368.                     SetUpperArmTexture(ArmUpperEmpty, Slot);
  369.                     SetLowerArmTexture(ArmLowerEmpty, Slot);
  370.                     SetUpperLegTexture(LegUpperEmpty, Slot);
  371.                     SetLowerLegTexture(LegLowerEmpty, Slot);
  372.                 }
  373.                 return true;
  374.             }
  375.             case EGameEquipmentSlot::EQT_Belt:
  376.             {
  377.                 if (EquippedBelt)
  378.                 {
  379.                     ParentCustomizationComponent->RenderArmorElements(EquippedBelt->DisplayTypes, false);
  380.                     SetUpperLegTexture(LegUpperEmpty, Slot);
  381.                 }
  382.                 return true;
  383.             }
  384.             case EGameEquipmentSlot::EQT_Bracers:
  385.             {
  386.                 if (EquippedBracers)
  387.                 {
  388.                     ParentCustomizationComponent->RenderArmorElements(EquippedBracers->DisplayTypes, false);
  389.                     SetLowerArmTexture(ArmLowerEmpty, Slot);
  390.                 }
  391.                 return true;
  392.             }
  393.             case EGameEquipmentSlot::EQT_Hands:
  394.             {
  395.                 if (EquippedHands)
  396.                 {
  397.                     ParentCustomizationComponent->RenderArmorElements(EquippedHands->DisplayTypes, false);
  398.                     SetLowerArmTexture(ArmLowerEmpty, Slot);
  399.                     SetHandTexture(HandEmpty, Slot);
  400.                 }
  401.                 return true;
  402.             }
  403.             case EGameEquipmentSlot::EQT_Ring:
  404.             {
  405.                 //TODO: Implement ring meshes & sockets
  406.                 return false;
  407.             }
  408.             case EGameEquipmentSlot::EQT_Legs:
  409.             {
  410.                 if (EquippedLegs)
  411.                 {
  412.                     ParentCustomizationComponent->RenderArmorElements(EquippedLegs->DisplayTypes, false);
  413.                     SetUpperLegTexture(LegUpperEmpty, Slot);
  414.                     SetLowerLegTexture(LegLowerEmpty, Slot);
  415.                 }
  416.                 return true;
  417.             }
  418.             case EGameEquipmentSlot::EQT_Feet:
  419.             {
  420.                 if (EquippedFeet)
  421.                 {
  422.                     ParentCustomizationComponent->RenderArmorElements(EquippedFeet->DisplayTypes, false);
  423.                     SetLowerLegTexture(LegLowerEmpty, Slot);
  424.                     SetFootTexture(FootEmpty, Slot);
  425.                 }
  426.                 return true;
  427.             }
  428.             case EGameEquipmentSlot::EQT_Tabard:
  429.             {
  430.                 if (EquippedTabard)
  431.                 {
  432.                     ParentCustomizationComponent->RenderArmorElements(EquippedTabard->DisplayTypes, false);
  433.                     SetUpperTorsoTexture(TorsoUpperEmpty, Slot);
  434.                     SetLowerTorsoTexture(TorsoLowerEmpty, Slot);
  435.                 }
  436.                 return true;
  437.             }
  438.             case EGameEquipmentSlot::EQT_RightHand:
  439.             {
  440.                 //TODO: Implement weapon handling
  441.                 return false;
  442.             }
  443.             case EGameEquipmentSlot::EQT_LeftHand:
  444.             {
  445.                 //TODO: Implement weapon handling
  446.                 return false;
  447.             }
  448.             case EGameEquipmentSlot::EQT_TwoHand:
  449.             {
  450.                 //TODO: Implement weapon handling
  451.                 return false;
  452.             }
  453.             case EGameEquipmentSlot::EQT_OffHand:
  454.             {
  455.                 //TODO: Implement weapon handling
  456.                 return false;
  457.             }
  458.             case EGameEquipmentSlot::EQT_Special:
  459.             {
  460.                 //TODO: Implement weapon handling
  461.                 return false;
  462.             }
  463.             default:
  464.             {
  465.                 return false;
  466.             }
  467.         }
  468.     }  
  469.     return false;
  470. }
  471.  
  472. void UEquipmentComponent::SetUpperTorsoTexture(UTexture2D* Texture, EGameEquipmentSlot Slot)
  473. {      
  474.     switch (Slot)
  475.     {
  476.         case EGameEquipmentSlot::EQT_Necklace:
  477.         {
  478.             if (Texture)
  479.             {
  480.                 ParentCustomizationComponent->GetSkinInstance()->SetTextureParameterValue("Neck_TU", Texture);
  481.             }
  482.             else
  483.             {
  484.                 ParentCustomizationComponent->GetSkinInstance()->SetTextureParameterValue("Neck_TU", TorsoUpperEmpty);
  485.             }      
  486.             break;
  487.         }
  488.         case EGameEquipmentSlot::EQT_Shirt:
  489.         {
  490.             if (Texture)
  491.             {
  492.                 ParentCustomizationComponent->GetSkinInstance()->SetTextureParameterValue("Shirt_TU", Texture);
  493.             }
  494.             else
  495.             {
  496.                 ParentCustomizationComponent->GetSkinInstance()->SetTextureParameterValue("Shirt_TU", TorsoUpperEmpty);
  497.             }  
  498.             break;
  499.         }
  500.         case EGameEquipmentSlot::EQT_Chestpiece:
  501.         {
  502.             if (Texture)
  503.             {
  504.                 ParentCustomizationComponent->GetSkinInstance()->SetTextureParameterValue("Chest_TU", Texture);
  505.             }
  506.             else
  507.             {
  508.                 ParentCustomizationComponent->GetSkinInstance()->SetTextureParameterValue("Chest_TU", TorsoUpperEmpty);
  509.             }  
  510.             break;
  511.         }
  512.         case EGameEquipmentSlot::EQT_Tabard:
  513.         {
  514.             if (Texture)
  515.             {
  516.                 ParentCustomizationComponent->GetSkinInstance()->SetTextureParameterValue("Tabard_TU", Texture);
  517.             }
  518.             else
  519.             {
  520.                 ParentCustomizationComponent->GetSkinInstance()->SetTextureParameterValue("Tabard_TU", TorsoUpperEmpty);
  521.             }  
  522.             break;
  523.         }
  524.         default:
  525.         {
  526.             break;
  527.         }
  528.     }
  529. }
  530.  
  531. void UEquipmentComponent::SetLowerTorsoTexture(UTexture2D* Texture, EGameEquipmentSlot Slot)
  532. {
  533.     switch (Slot)
  534.     {
  535.         case EGameEquipmentSlot::EQT_Shirt:
  536.         {
  537.             if (Texture)
  538.             {
  539.                 ParentCustomizationComponent->GetSkinInstance()->SetTextureParameterValue("Shirt_TL", Texture);
  540.             }
  541.             else
  542.             {
  543.                 ParentCustomizationComponent->GetSkinInstance()->SetTextureParameterValue("Shirt_TL", TorsoLowerEmpty);
  544.             }
  545.             break;
  546.         }
  547.         case EGameEquipmentSlot::EQT_Chestpiece:
  548.         {
  549.             if (Texture)
  550.             {
  551.                 ParentCustomizationComponent->GetSkinInstance()->SetTextureParameterValue("Chest_TL", Texture);
  552.             }
  553.             else
  554.             {
  555.                 ParentCustomizationComponent->GetSkinInstance()->SetTextureParameterValue("Chest_TL", TorsoLowerEmpty);
  556.             }
  557.             break;
  558.         }
  559.         case EGameEquipmentSlot::EQT_Tabard:
  560.         {
  561.             if (Texture)
  562.             {
  563.                 ParentCustomizationComponent->GetSkinInstance()->SetTextureParameterValue("Tabard_TL", Texture);
  564.             }
  565.             else
  566.             {
  567.                 ParentCustomizationComponent->GetSkinInstance()->SetTextureParameterValue("Tabard_TL", TorsoLowerEmpty);
  568.             }
  569.             break;
  570.         }
  571.         default:
  572.         {
  573.             break;
  574.         }
  575.     }
  576. }
  577.  
  578. void UEquipmentComponent::SetUpperArmTexture(UTexture2D* Texture, EGameEquipmentSlot Slot)
  579. {
  580.     switch (Slot)
  581.     {
  582.         case EGameEquipmentSlot::EQT_Shirt:
  583.         {
  584.             if (Texture)
  585.             {
  586.                 ParentCustomizationComponent->GetSkinInstance()->SetTextureParameterValue("Shirt_AU", Texture);
  587.             }
  588.             else
  589.             {
  590.                 ParentCustomizationComponent->GetSkinInstance()->SetTextureParameterValue("Shirt_AU", ArmUpperEmpty);
  591.             }
  592.             break;
  593.         }
  594.         case EGameEquipmentSlot::EQT_Chestpiece:
  595.         {
  596.             if (Texture)
  597.             {
  598.                 ParentCustomizationComponent->GetSkinInstance()->SetTextureParameterValue("Chest_AU", Texture);
  599.             }
  600.             else
  601.             {
  602.                 ParentCustomizationComponent->GetSkinInstance()->SetTextureParameterValue("Chest_AU", ArmUpperEmpty);
  603.             }
  604.             break;
  605.         }
  606.         default:
  607.         {
  608.             break;
  609.         }
  610.     }
  611. }
  612.  
  613. void UEquipmentComponent::SetLowerArmTexture(UTexture2D* Texture, EGameEquipmentSlot Slot)
  614. {
  615.     switch (Slot)
  616.     {
  617.         case EGameEquipmentSlot::EQT_Shirt:
  618.         {
  619.             if (Texture)
  620.             {
  621.                 ParentCustomizationComponent->GetSkinInstance()->SetTextureParameterValue("Shirt_AL", Texture);
  622.             }
  623.             else
  624.             {
  625.                 ParentCustomizationComponent->GetSkinInstance()->SetTextureParameterValue("Shirt_AL", ArmLowerEmpty);
  626.             }
  627.             break;
  628.         }
  629.         case EGameEquipmentSlot::EQT_Chestpiece:
  630.         {
  631.             if (Texture)
  632.             {
  633.                 ParentCustomizationComponent->GetSkinInstance()->SetTextureParameterValue("Chest_AL", Texture);
  634.             }
  635.             else
  636.             {
  637.                 ParentCustomizationComponent->GetSkinInstance()->SetTextureParameterValue("Chest_AL", ArmLowerEmpty);
  638.             }
  639.             break;
  640.         }
  641.         case EGameEquipmentSlot::EQT_Hands:
  642.         {
  643.             if (Texture)
  644.             {
  645.                 ParentCustomizationComponent->GetSkinInstance()->SetTextureParameterValue("Hands_AL", Texture);
  646.             }
  647.             else
  648.             {
  649.                 ParentCustomizationComponent->GetSkinInstance()->SetTextureParameterValue("Hands_AL", ArmLowerEmpty);
  650.             }
  651.             break;
  652.         }
  653.         default:
  654.         {
  655.             break;
  656.         }
  657.     }
  658. }
  659.  
  660. void UEquipmentComponent::SetUpperLegTexture(UTexture2D* Texture, EGameEquipmentSlot Slot)
  661. {
  662.     switch (Slot)
  663.     {
  664.         case EGameEquipmentSlot::EQT_Chestpiece:
  665.         {
  666.             if (Texture)
  667.             {
  668.                 ParentCustomizationComponent->GetSkinInstance()->SetTextureParameterValue("Chest_LU", Texture);
  669.             }
  670.             else
  671.             {
  672.                 ParentCustomizationComponent->GetSkinInstance()->SetTextureParameterValue("Chest_LU", LegUpperEmpty);
  673.             }
  674.             break;
  675.         }
  676.         case EGameEquipmentSlot::EQT_Legs:
  677.         {
  678.             if (Texture)
  679.             {
  680.                 ParentCustomizationComponent->GetSkinInstance()->SetTextureParameterValue("Legs_LU", Texture);
  681.             }
  682.             else
  683.             {
  684.                 ParentCustomizationComponent->GetSkinInstance()->SetTextureParameterValue("Legs_LU", LegUpperEmpty);
  685.             }
  686.             break;
  687.         }
  688.         case EGameEquipmentSlot::EQT_Belt:
  689.         {
  690.             if (Texture)
  691.             {
  692.                 ParentCustomizationComponent->GetSkinInstance()->SetTextureParameterValue("Belt_LU", Texture);
  693.             }
  694.             else
  695.             {
  696.                 ParentCustomizationComponent->GetSkinInstance()->SetTextureParameterValue("Belt_LU", LegUpperEmpty);
  697.             }
  698.             break;
  699.         }
  700.         default:
  701.         {
  702.             break;
  703.         }
  704.     }
  705. }
  706.  
  707. void UEquipmentComponent::SetLowerLegTexture(UTexture2D* Texture, EGameEquipmentSlot Slot)
  708. {
  709.     switch (Slot)
  710.     {
  711.         case EGameEquipmentSlot::EQT_Chestpiece:
  712.         {
  713.             if (Texture)
  714.             {
  715.                 ParentCustomizationComponent->GetSkinInstance()->SetTextureParameterValue("Chest_LL", Texture);
  716.             }
  717.             else
  718.             {
  719.                 ParentCustomizationComponent->GetSkinInstance()->SetTextureParameterValue("Chest_LL", LegLowerEmpty);
  720.             }
  721.             break;
  722.         }
  723.         case EGameEquipmentSlot::EQT_Legs:
  724.         {
  725.             if (Texture)
  726.             {
  727.                 ParentCustomizationComponent->GetSkinInstance()->SetTextureParameterValue("Legs_LL", Texture);
  728.             }
  729.             else
  730.             {
  731.                 ParentCustomizationComponent->GetSkinInstance()->SetTextureParameterValue("Legs_LL", LegLowerEmpty);
  732.             }
  733.             break;
  734.         }
  735.         case EGameEquipmentSlot::EQT_Feet:
  736.         {
  737.             if (Texture)
  738.             {
  739.                 ParentCustomizationComponent->GetSkinInstance()->SetTextureParameterValue("Feet_LL", Texture);
  740.             }
  741.             else
  742.             {
  743.                 ParentCustomizationComponent->GetSkinInstance()->SetTextureParameterValue("Feet_LL", LegLowerEmpty);
  744.             }
  745.             break;
  746.         }
  747.         default:
  748.         {
  749.             break;
  750.         }
  751.     }
  752. }
  753.  
  754. void UEquipmentComponent::SetHandTexture(UTexture2D* Texture, EGameEquipmentSlot Slot)
  755. {
  756.     switch (Slot)
  757.     {
  758.         case EGameEquipmentSlot::EQT_Hands:
  759.         {
  760.             if (Texture)
  761.             {
  762.                 ParentCustomizationComponent->GetSkinInstance()->SetTextureParameterValue("Hands_HA", Texture);
  763.             }
  764.             else
  765.             {
  766.                 ParentCustomizationComponent->GetSkinInstance()->SetTextureParameterValue("Hands_HA", HandEmpty);
  767.             }
  768.             break;
  769.         }
  770.         case EGameEquipmentSlot::EQT_Ring:
  771.         {
  772.             if (Texture)
  773.             {
  774.                 ParentCustomizationComponent->GetSkinInstance()->SetTextureParameterValue("Ring_HA", Texture);
  775.             }
  776.             else
  777.             {
  778.                 ParentCustomizationComponent->GetSkinInstance()->SetTextureParameterValue("Ring_HA", HandEmpty);
  779.             }
  780.             break;
  781.         }
  782.         default:
  783.         {
  784.             break;
  785.         }
  786.     }
  787. }
  788.  
  789. void UEquipmentComponent::SetFootTexture(UTexture2D* Texture, EGameEquipmentSlot Slot)
  790. {
  791.     //special case: Cowmen never use the foot texture.
  792.     //Add spacemen here as well when we get there
  793.     if (OwningCharacter && !(OwningCharacter->CreatureRace == ECreatureRace::CR_Cowman))
  794.     {
  795.         switch (Slot)
  796.         {
  797.             case EGameEquipmentSlot::EQT_Feet:
  798.             {
  799.                 if (Texture)
  800.                 {
  801.                     ParentCustomizationComponent->GetSkinInstance()->SetTextureParameterValue("Feet_FO", Texture);
  802.                 }
  803.                 else
  804.                 {
  805.                     ParentCustomizationComponent->GetSkinInstance()->SetTextureParameterValue("Feet_FO", FootEmpty);
  806.                 }
  807.                 break;
  808.             }
  809.             default:
  810.             {
  811.                 break;
  812.             }
  813.         }
  814.     }  
  815. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement