Added GOAPAction Stub

This commit is contained in:
Philip W 2023-03-20 04:03:23 +00:00
parent d02f832733
commit 2e03f7cf19
3 changed files with 57 additions and 0 deletions

View File

@ -1,4 +1,5 @@
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation"> <wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
<s:Boolean x:Key="/Default/UserDictionary/Words/=Azos/@EntryIndexedValue">True</s:Boolean> <s:Boolean x:Key="/Default/UserDictionary/Words/=Azos/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=GOAP/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Iroquoid/@EntryIndexedValue">True</s:Boolean> <s:Boolean x:Key="/Default/UserDictionary/Words/=Iroquoid/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Probertium/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary> <s:Boolean x:Key="/Default/UserDictionary/Words/=Probertium/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary>

View File

@ -0,0 +1,32 @@
// Fill out your copyright notice in the Description page of Project Settings.
#include "GOAPAction.h"
bool UGOAPAction::CheckPreConditions(TMap<FString, int32> WorldState)
{
for (TPair<FString, int32> PreCondition : PreConditions)
{
if (WorldState.Contains(PreCondition.Key))
{
if (WorldState[PreCondition.Key] != PreCondition.Value) return false;
}
}
return true;
}
TMap<FString, int32> UGOAPAction::ApplyEffects(TMap<FString, int32> WorldState)
{
for (TPair<FString, int32> Effect : Effects)
{
if (WorldState.Contains(Effect.Key))
{
WorldState[Effect.Key] = Effect.Value;
}
else
{
WorldState.Add(Effect.Key, Effect.Value);
}
}
return WorldState;
}

View File

@ -0,0 +1,24 @@
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "UObject/Object.h"
#include "GOAPAction.generated.h"
/**
*
*/
UCLASS()
class COMP250_1_2101327_AI_API UGOAPAction : public UObject
{
GENERATED_BODY()
public:
virtual bool CheckPreConditions(TMap<FString, int32> WorldState);
TMap<FString, int32> ApplyEffects(TMap<FString, int32> WorldState);
protected:
TMap<FString, int32> PreConditions;
TMap<FString, int32> Effects;
};