(Feat) Add Cooking and Workbench
This commit is contained in:
@@ -0,0 +1,76 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
|
||||
#include "ItemDataAsset.h"
|
||||
|
||||
#include "Components/StaticMeshComponent.h"
|
||||
|
||||
#if WITH_EDITOR
|
||||
#include "Misc/DataValidation.h"
|
||||
#endif
|
||||
|
||||
#define LOCTEXT_NAMESPACE "ItemData"
|
||||
|
||||
void UItemDataAsset::ApplyWorldVisualsTo(UStaticMeshComponent* Component) const
|
||||
{
|
||||
if (!Component)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Component->SetStaticMesh(WorldMesh);
|
||||
|
||||
// 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)
|
||||
{
|
||||
Component->SetMaterial(0, WorldMeshMaterial);
|
||||
}
|
||||
}
|
||||
|
||||
#if WITH_EDITOR
|
||||
EDataValidationResult UItemDataAsset::IsDataValid(FDataValidationContext& Context) const
|
||||
{
|
||||
EDataValidationResult Result = Super::IsDataValid(Context);
|
||||
|
||||
if (bCanBeCooked && !CookedResult)
|
||||
{
|
||||
Context.AddError(LOCTEXT("CookNoResult", "'Can Be Cooked' is checked but no 'Cooked Result' is assigned: this item would sit on the fire forever without ever changing."));
|
||||
Result = EDataValidationResult::Invalid;
|
||||
}
|
||||
|
||||
if (bCanBurn && !BurntResult)
|
||||
{
|
||||
Context.AddError(LOCTEXT("BurnNoResult", "'Can Burn' is checked but no 'Burnt Result' is assigned."));
|
||||
Result = EDataValidationResult::Invalid;
|
||||
}
|
||||
|
||||
// Une chaine qui reboucle sur elle-meme ne plante pas, elle tourne : la
|
||||
// station re-arme un timer identique a chaque etape et le joueur voit un
|
||||
// objet qui ne finit jamais de cuire. Impossible a diagnostiquer en jeu.
|
||||
if (CookedResult == this)
|
||||
{
|
||||
Context.AddError(LOCTEXT("CookSelfResult", "'Cooked Result' points back to this asset: the item would cook into itself, endlessly."));
|
||||
Result = EDataValidationResult::Invalid;
|
||||
}
|
||||
|
||||
if (BurntResult == this)
|
||||
{
|
||||
Context.AddError(LOCTEXT("BurnSelfResult", "'Burnt Result' points back to this asset: the item would burn into itself, endlessly."));
|
||||
Result = EDataValidationResult::Invalid;
|
||||
}
|
||||
|
||||
// Un objet a charges ne s'empile pas (voir GetEffectiveMaxStack). Le poser
|
||||
// sur le feu reste possible, mais la charge entamee suit l'exemplaire et le
|
||||
// resultat en herite : autant que ce soit un choix, pas une surprise.
|
||||
if (MaxUses > 1 && bCanBeCooked)
|
||||
{
|
||||
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."));
|
||||
}
|
||||
|
||||
return Result;
|
||||
}
|
||||
#endif
|
||||
|
||||
#undef LOCTEXT_NAMESPACE
|
||||
Reference in New Issue
Block a user