(Feat) Add footsteps
This commit is contained in:
@@ -11,6 +11,36 @@
|
||||
|
||||
#define LOCTEXT_NAMESPACE "ItemData"
|
||||
|
||||
namespace
|
||||
{
|
||||
/**
|
||||
* Pose un mesh et son eventuel materiau de surcharge sur un composant.
|
||||
*
|
||||
* Prefixe du fichier oblige : le build unity concatene les .cpp du module,
|
||||
* un namespace anonyme n'isole rien.
|
||||
*/
|
||||
void ItemDataApplyMeshAndMaterial(UStaticMeshComponent* Component, UStaticMesh* Mesh, UMaterialInterface* Material)
|
||||
{
|
||||
// OverrideMaterials appartient au COMPOSANT, pas au mesh : il survit donc
|
||||
// a un changement d'asset. Sans ce vidage, un objet sans surcharge monte
|
||||
// apres un objet qui en avait une garderait le materiau du precedent --
|
||||
// le meme piege que les meshes de corps de la customisation. Il ne se
|
||||
// voit que sur un composant REUTILISE, donc jamais sur un pickup fraichement
|
||||
// engendre, et systematiquement sur l'objet en main ou sur un grill.
|
||||
Component->EmptyOverrideMaterials();
|
||||
|
||||
Component->SetStaticMesh(Mesh);
|
||||
|
||||
// SetMaterial(0, nullptr) ne "retire" pas le materiau, il pose un slot vide
|
||||
// et le mesh devient gris damier. Sans override, on ne touche a rien et le
|
||||
// mesh garde le sien.
|
||||
if (Material)
|
||||
{
|
||||
Component->SetMaterial(0, Material);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void UItemDataAsset::ApplyWorldVisualsTo(UStaticMeshComponent* Component) const
|
||||
{
|
||||
if (!Component)
|
||||
@@ -18,15 +48,20 @@ void UItemDataAsset::ApplyWorldVisualsTo(UStaticMeshComponent* Component) const
|
||||
return;
|
||||
}
|
||||
|
||||
Component->SetStaticMesh(WorldMesh);
|
||||
ItemDataApplyMeshAndMaterial(Component, WorldMesh, WorldMeshMaterial);
|
||||
}
|
||||
|
||||
// SetMaterial(0, nullptr) ne "retire" pas le materiau, il pose un slot vide
|
||||
// et le mesh devient gris damier. Sans override, on ne touche a rien et le
|
||||
// mesh garde le sien.
|
||||
if (WorldMeshMaterial)
|
||||
void UItemDataAsset::ApplyHeldVisualsTo(UStaticMeshComponent* Component) const
|
||||
{
|
||||
if (!Component)
|
||||
{
|
||||
Component->SetMaterial(0, WorldMeshMaterial);
|
||||
return;
|
||||
}
|
||||
|
||||
// Le materiau de surcharge est celui du monde, sans equivalent "en main" :
|
||||
// il sert a distinguer un cru d'un cuit, et cette distinction vaut aussi
|
||||
// dans la main. Un second champ n'aurait fait que se desynchroniser.
|
||||
ItemDataApplyMeshAndMaterial(Component, GetHeldMesh(), WorldMeshMaterial);
|
||||
}
|
||||
|
||||
#if WITH_EDITOR
|
||||
@@ -69,6 +104,22 @@ EDataValidationResult UItemDataAsset::IsDataValid(FDataValidationContext& Contex
|
||||
Context.AddWarning(LOCTEXT("CookableWithCharges", "This item has multiple uses AND can be cooked. The remaining charges follow the item through cooking, which is rarely what you want for food."));
|
||||
}
|
||||
|
||||
// Le symptome serait une main vide sans le moindre message : le composant
|
||||
// aurait bien monte son mesh, avec un asset nul.
|
||||
if (bShowInHand && !GetHeldMesh())
|
||||
{
|
||||
Context.AddError(LOCTEXT("HeldNoMesh", "'Show In Hand' is checked but neither 'Held Mesh' nor 'World Mesh' is assigned: nothing would appear in the player's hand."));
|
||||
Result = EDataValidationResult::Invalid;
|
||||
}
|
||||
|
||||
// Un outil invisible se remarque tout de suite en jeu, mais on cherche la
|
||||
// cause du mauvais cote -- dans le composant, dans le socket, dans le rig --
|
||||
// avant de penser a une case a cocher.
|
||||
if (IsTool() && !bShowInHand)
|
||||
{
|
||||
Context.AddWarning(LOCTEXT("ToolNotShownInHand", "This item is a tool but 'Show In Hand' is unchecked: the player will harvest with an empty hand."));
|
||||
}
|
||||
|
||||
return Result;
|
||||
}
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user