Help to refactor my code in Unreal Engine c++, find and resolve mistakes if they are…
- User
Help to refactor my code in Unreal Engine c++, find and resolve mistakes if they are present. USV_InteractControllerComponent class: private: TMap<FPathToScenarioObject, TArray<FSV_HandlerBindFunction> > FuncClientNeedToBind; void USV_InteractControllerComponent::OnRep_ReplicatedHandlers() { USV_HandlerForBindingComponent* ReceivedHandler = ReplicatedHandlers.Last(); AddHandler(ReceivedHandler);
TArray<FSV_HandlerBindFunction> BindFunctions; FuncClientNeedToBind.RemoveAndCopyValue(ReceivedHandler->Execute_GetTargetScenarioName(ReceivedHandler), BindFunctions); if (&BindFunctions) { for (FSV_HandlerBindFunction BindFunction : BindFunctions) { BindFunction.Call(ReceivedHandler); } }} void USV_InteractControllerComponent::BindReceived( USV_HandlerForBindingComponent::FunctionPtr BindFunction, const FPathToScenarioObject TargetSlot, const FSV_SimpleStorageInteractEventDelegate& Event, const FSV_NetExecutionType NetType ) { if (USV_HandlerForBindingComponent* Handler = GetOrSpawnBindingHandler(TargetSlot)) { (Handler->*(BindFunction))(Event, NetType); //Handler->BindOnStartInteractive(Event, NetType); return; }
FuncClientNeedToBind.FindOrAdd(TargetSlot).Add(FSV_HandlerBindFunction(BindFunction, Event, NetType));}
void USV_InteractControllerComponent::ReceiveBindOnStartInteractive(FPathToScenarioObject TargetSlot, const FSV_SimpleStorageInteractEventDelegate& Event, FSV_NetExecutionType NetType) { BindReceived(&USV_HandlerForBindingComponent::BindOnStartInteractive, TargetSlot, Event, NetType);
} USTRUCT() struct FSV_HandlerBindFunction { GENERATED_USTRUCT_BODY()
public: FSV_HandlerBindFunction( const USV_HandlerForBindingComponent::FunctionPtr InFunction, const FSV_SimpleStorageInteractEventDelegate Event, const FSV_NetExecutionType NetExecutionType ) : BindFunction(InFunction), EventDelegate(Event), NetType(NetExecutionType) { } FSV_HandlerBindFunction() {}
/*FSV_HandlerBindFunction( const TFunction<void(USV_HandlerForBindingComponent*, const FSV_SimpleStorageInteractEventDelegate&, FSV_NetExecutionType)> , const FSV_SimpleStorageInteractEventDelegate Event, const FSV_NetExecutionType NetExecutionType ) : BindFunction(InFunction), EventDelegate(Event), NetType(NetExecutionType) { }*/ void Call(USV_HandlerForBindingComponent* Handler) const { if ( Handler && BindFunction ) { (Handler->*(BindFunction))(EventDelegate, NetType); } }private: USV_HandlerForBindingComponent::FunctionPtr BindFunction; /UPROPERTY() const TFunction<void(USV_HandlerForBindingComponent, const FSV_SimpleStorageInteractEventDelegate&, FSV_NetExecutionType)> BindFunction;*/ FSV_SimpleStorageInteractEventDelegate EventDelegate; FSV_NetExecutionType NetType; };
- Assistant