-
Notifications
You must be signed in to change notification settings - Fork 259
/
GSGameplayEffectTypes.h
69 lines (57 loc) · 1.81 KB
/
GSGameplayEffectTypes.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
// Copyright 2020 Dan Kestranek.
#pragma once
#include "GameplayEffectTypes.h"
#include "Abilities/GameplayAbilityTargetTypes.h"
#include "GSGameplayEffectTypes.generated.h"
/**
* Data structure that stores an instigator and related data, such as positions and targets
* Games can subclass this structure and add game-specific information
* It is passed throughout effect execution so it is a great place to track transient information about an execution
*/
USTRUCT()
struct GASSHOOTER_API FGSGameplayEffectContext : public FGameplayEffectContext
{
GENERATED_USTRUCT_BODY()
public:
virtual FGameplayAbilityTargetDataHandle GetTargetData()
{
return TargetData;
}
virtual void AddTargetData(const FGameplayAbilityTargetDataHandle& TargetDataHandle)
{
TargetData.Append(TargetDataHandle);
}
/**
* Functions that subclasses of FGameplayEffectContext need to override
*/
virtual UScriptStruct* GetScriptStruct() const override
{
return FGSGameplayEffectContext::StaticStruct();
}
virtual FGSGameplayEffectContext* Duplicate() const override
{
FGSGameplayEffectContext* NewContext = new FGSGameplayEffectContext();
*NewContext = *this;
NewContext->AddActors(Actors);
if (GetHitResult())
{
// Does a deep copy of the hit result
NewContext->AddHitResult(*GetHitResult(), true);
}
// Shallow copy of TargetData, is this okay?
NewContext->TargetData.Append(TargetData);
return NewContext;
}
virtual bool NetSerialize(FArchive& Ar, class UPackageMap* Map, bool& bOutSuccess) override;
protected:
FGameplayAbilityTargetDataHandle TargetData;
};
template<>
struct TStructOpsTypeTraits<FGSGameplayEffectContext> : public TStructOpsTypeTraitsBase2<FGSGameplayEffectContext>
{
enum
{
WithNetSerializer = true,
WithCopy = true // Necessary so that TSharedPtr<FHitResult> Data is copied around
};
};