class UMagesNetwork

Overview

#include <MagesNetwork.h>

class UMagesNetwork: public UObject
{
public:
    // fields

    float NetworkedActorDestructionTimeout = 0.5f;
    FRandomStream RandomStream;
    bool IsClient = false;
    static const int MAX_VIEW_IDS = 100;

    // methods

    UPROPERTY(BlueprintAssignable, Category = "Mages|Networking");
    UPROPERTY(BlueprintAssignable, Category = "Mages|Networking");
    UPROPERTY(BlueprintAssignable, Category = "Mages|Networking");
    UPROPERTY(BlueprintReadOnly, Category = "Mages|Networking");
    UPROPERTY(BlueprintReadOnly, Category = "Mages|Networking");
    void Initialize();
    void OnInit(LoadBalancingListener* CurrentListener);
    void Tick(float DeltaTime);
    UMagesView* GetView(int ID);
    int GetLocalPlayerNumber();
    AActor* Instantiate(TSubclassOf<AActor> Blueprint, AActor* Parent = nullptr);
    int GetNumPlayersInRoom();
    void RegisterUserEvent(FString EventName, FOnMagesUserEvent Callback);
    void RaiseUserEvent(FString EventName, UObject* EventData);
    bool RegisterView(UMagesView* View, int ViewID);
    void DeregisterView(UMagesView* View, int ViewID);
    void ReplicateActor(AActor* ActorInstance, AActor* ParentActor);
    void RaiseTransferAuthorityEvent(int viewID, int newPlayerID);
    void RaiseDestroyEvent(int viewID, int creatorID);
    void RaiseEvent(NetMessageClass msg, bool SentToAll = false);
    int GetServerTimestamp();
    int AllocateViewID(int OwnerID);

    void RemoveInstantiatedActor(
        AActor* actorToRemove,
        bool LocalOnly,
        int viewID,
        int CreatorID
        );
};

Detailed Documentation

Fields

float NetworkedActorDestructionTimeout = 0.5f

Sets the time to wait until an actor can be safely destroyed

FRandomStream RandomStream

A Synchronized RNG

static const int MAX_VIEW_IDS = 100

Internal

Methods

UPROPERTY(BlueprintAssignable, Category = "Mages|Networking")

Events Called when a player (including the local one) has entered the room

UPROPERTY(BlueprintAssignable, Category = "Mages|Networking")

Called on any event

UPROPERTY(BlueprintAssignable, Category = "Mages|Networking")

Called when the local player has created a room

UPROPERTY(BlueprintReadOnly, Category = "Mages|Networking")

Flags True if the local player is the host (or server)

UPROPERTY(BlueprintReadOnly, Category = "Mages|Networking")

True if the local player is in a Coop session

void Initialize()

Initialization

UMagesView* GetView(int ID)

Networking Returns the Mages View Component associated with this ID

int GetLocalPlayerNumber()

Returns the local player’s actor number

AActor* Instantiate(TSubclassOf<AActor> Blueprint, AActor* Parent = nullptr)

Instantiate a blueprint for all connected players

int GetNumPlayersInRoom()

Returns the total amount of players in the current room (including the local player) or -1 otherwise

void RegisterUserEvent(FString EventName, FOnMagesUserEvent Callback)

Create a custom event type with a callback

void RaiseUserEvent(FString EventName, UObject* EventData)

Call a custom event on the network

int AllocateViewID(int OwnerID)

Returns 0 on failure, as it is an invalid ViewID (since no player can have 0 as their actor number)