Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #pragma once
- /*
- * All RTSDK classes interact with 'units' via this interface, this is to allow the entire RTSUnit class to be swapped out!
- * There may be situations where you do not want to make every interactive object a full 'character' pawn, such as obstacles
- * By implementing this or an interface derived from this the unreal actor becomes a 'unit' as far as the framework is concerned
- * See RTSUnit class for a basic game agnostic implementation of this interface, Public/Units/RTSUnit.h
- *
- * Arguments are standard unreal game framework classes, you can pass around your derived classes this way with casting within implementations
- * For example stat modifiers take a responsible UObject to handle it long term (such as expiring, doing effects over time, etc)
- * in RTSDK's unit implementation this is done by RTSStatusEffect actor components, but it could be anything implementing RTSStatusEffectInterface!
- *
- * Derived interfaces can extend this with game specific accessors, setters, helpers, actions and events without breaking RTSDK
- *
- * Please note that ue4 blueprintable interfaces do not like having their functions called directly in c++. You have to use the static Execute_ function
- * if you call these functions directly in c++ it will throw an exception with a message that you should not do this.
- * This makes it a little harder to intellisense it and is a bit longer to type but results in a lot of power for blueprint classes,
- * which can override the function entirely, or call your native implementation via super and add functionality on top with visual scripts.
- *
- * For example getting a unit's icon is done like so,
- * UMaterialInterface* icon = IRTSUnitInterface::Execute_GetUnitIcon(PointerToAUnit);
- * rather than
- * UMaterialInterface* icon = GetUnitIcon();
- *
- * Implementing the function in c++ requires an override to the _Implementation auto generated virtual function
- * UMaterialInterface* GetUnitIcon();
- * is implemented by this, in the h file
- * virtual UMaterialInterface* GetUnitIcon_Implementation() override;
- * which would then be defined in the cpp file as
- * UMaterialInterface* ARTSUnit::GetUnitIcon_Implementation();
- *
- * Another thing to note is that a BlueprintNativeEvent with no return value can only be used on the blueprint event graph, it won't go inside functions!
- * As such, all functions in this interface at least return a bool, so they are all implemented in blueprint as a separate function graph.
- *
- * You can return void in derived interfaces to make events for the blueprint class' event graph, this is just a choice made for consistency.
- * In these cases the boolean returns true for success, you can therefore report failure (for whatever reason) with a return of false in your implementation.
- *
- * Finally, BlueprintNativeEvent functions need blueprint safe arguments and return types,
- * if you derive this interface class and your new methods and their native implementations are causing compile errors
- * look at the generated header and cpp files and see what arguments UnrealHeaderTool has given them.
- *
- * For example, FText arguments will become const FText& arguments when it generates the Execute_ and _Implementation functions
- */
- #include "Game/RTSDKMinimal.h"
- #include "RTSUnitInterface.generated.h"
- DECLARE_DYNAMIC_MULTICAST_DELEGATE(FRTSTestSignature);
- UINTERFACE(Blueprintable)
- class RTSDK_API URTSUnitInterface : public UInterface
- {
- GENERATED_UINTERFACE_BODY()
- };
- class RTSDK_API IRTSUnitInterface
- {
- GENERATED_IINTERFACE_BODY()
- public:
- /*Get this units display name*/
- UFUNCTION(BlueprintNativeEvent, BlueprintCallable, Category = "RTS Unit Interface")
- FText GetUnitDisplayName();
- UFUNCTION(BlueprintNativeEvent, BlueprintCallable, Category = "RTS Unit Interface")
- bool SetUnitDisplayName(const FText& NewName);
- /*Get this units command page*/
- UFUNCTION(BlueprintNativeEvent, BlueprintCallable, Category = "RTS Unit Interface")
- FRTSCommandPageInfo GetUnitCommandPage(APlayerState* InPlayer);
- /*
- * Whether the player should be able to target this at all, for context commands or mouseover for information
- * 3D picking will look for actors implementing this interface, then actors that return true when passed the player's state
- * the best target will become the player's target unit
- */
- UFUNCTION(BlueprintNativeEvent, BlueprintCallable, Category = "RTS Unit Interface")
- uint8 ShouldBeTargetedByPlayer(APlayerState* InPlayer);
- /*
- * Whether units should be able to target this unit when searching for targets.
- * The unit that is searching for targets is passed as argument. This makes it conditional on a case by case basis eg stealth mechanics
- */
- UFUNCTION(BlueprintNativeEvent, BlueprintCallable, Category = "RTS Unit Interface")
- uint8 ShouldUnitBeTargetedByUnit(AActor* InUnit);
- UFUNCTION(BlueprintNativeEvent, BlueprintCallable, Category = "RTS Unit Interface")
- uint8 ShouldUnitBeSelectedByPlayer(APlayerState* InPlayer);
- /*Get this units icon*/
- UFUNCTION(BlueprintNativeEvent, BlueprintCallable, Category = "RTS Unit Interface")
- UMaterialInterface* GetUnitIcon();
- UFUNCTION(BlueprintNativeEvent, BlueprintCallable, Category = "RTS Unit Interface")
- bool SetUnitIcon(UMaterialInterface* NewIcon);
- UFUNCTION(BlueprintNativeEvent, BlueprintCallable, Category = "RTS Unit Interface")
- int32 GetUnitTeamIndex();
- UFUNCTION(BlueprintNativeEvent, BlueprintCallable, Category = "RTS Unit Interface")
- int32 GetUnitForceIndex();
- UFUNCTION(BlueprintNativeEvent, BlueprintCallable, Category = "RTS Unit Interface")
- bool SetUnitTeamIndex(int NewIndex);
- UFUNCTION(BlueprintNativeEvent, BlueprintCallable, Category = "RTS Unit Interface")
- bool SetUnitForceIndex(int NewIndex);
- UFUNCTION(BlueprintNativeEvent, BlueprintCallable, Category = "RTS Unit Interface")
- float GetFinalUnitStat(FName StatName, bool ForceUpdate = false);
- UFUNCTION(BlueprintNativeEvent, BlueprintCallable, Category = "RTS Unit Interface")
- float GetBaseUnitStat(FName StatName);
- UFUNCTION(BlueprintNativeEvent, BlueprintCallable, Category = "RTS Unit Interface")
- bool SetBaseUnitStat(FName StatName, float NewBase);
- UFUNCTION(BlueprintNativeEvent, BlueprintCallable, Category = "RTS Unit Interface")
- FRTSStatInfo GetStatInfoForUnitStat(FName TargetStat);
- UFUNCTION(BlueprintNativeEvent, BlueprintCallable, Category = "RTS Unit Interface")
- bool AddUnitStat(FName TargetStat, const FText& DisplayName, const FText& TooltipText, UMaterialInterface* Icon, bool CanGoNegative, float BaseValue);
- UFUNCTION(BlueprintNativeEvent, BlueprintCallable, Category = "RTS Unit Interface")
- bool AddUnitStatModifier(FName TargetStat, UObject* TargetObject);
- /*removes any modifiers to sight radius done by the specified effect, returns the number of effects*/
- UFUNCTION(BlueprintNativeEvent, BlueprintCallable, Category = "RTS Unit Interface")
- bool RemoveUnitStatModifier(FName TargetStat, UObject* TargetObject);
- UFUNCTION(BlueprintNativeEvent, BlueprintCallable, Category = "RTS Unit Interface")
- bool UpdateUnitStat(FName TargetStat);
- UPROPERTY(BlueprintAssignable, Category = "RTS Unit Interface")
- static FRTSTestSignature ReceiveTestEvent;
- UFUNCTION(BlueprintNativeEvent, BlueprintCallable, Category = "RTS Unit Interface")
- uint8 GetFriendlyPlayerContextCommandUnitAbilityType(APlayerState* InPlayer);
- UFUNCTION(BlueprintNativeEvent, BlueprintCallable, Category = "RTS Unit Interface")
- uint8 GetEnemyPlayerContextCommandUnitAbilityType(APlayerState* InPlayer);
- UFUNCTION(BlueprintNativeEvent, BlueprintCallable, Category = "RTS Unit Interface")
- uint8 GetNeutralPlayerContextCommandUnitAbilityType(APlayerState* InPlayer);
- //add an on update stat event, investigate multicast delegates via interface and rig up move speed check to it, not on tick, same with sight radius
- //ASSUMING DIRECT CONTROL!
- //Pass a player controller into this to possess this RTSUnit using unreal game framework controller-pawn possession
- //Existing RTSUnitAIControllers will be retained in the pointer 'UnitAIController', but is ejected from control
- //Call UnpossessRTSUnit to return control to the unit AI.
- //only works on server!
- UFUNCTION(BlueprintNativeEvent, BlueprintCallable, Category = "RTS Unit Interface")
- bool PossessUnit(AController* NewController);
- UFUNCTION(BlueprintNativeEvent, BlueprintCallable, Category = "RTS Unit Interface")
- bool UnPossessUnit();
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement