Skip to main content

PlayerEffectController

A class in Root.Township, Alta.Alchemy.

The player's EffectHandler. Adds networked teleporting: it moves the local player and shows the teleport effect for everyone nearby. Both sides; a component on the player prefab.

Constructors​

MemberWhat it is
PlayerEffectController()Unity makes components itself; use AddComponent or spawn a prefab instead of new.

Fields​

3 private and internal fields
MemberWhat it is
private PlayerCharacter playerBacking field for Player.
private MethodSyncStruct<PlayerEffectController.PlayerEffectTeleportInformation> remoteTeleportEffectMethod sync for teleport messages (EntityMessageType.TeleportRequest).
private PooledObjectDefinition teleportEffectPooled visual effect spawned where a teleport happens. Not spawned on headless builds.

Properties​

MemberWhat it is
PlayerCharacter Player { get; }The PlayerCharacter this controller belongs to.

Events​

MemberWhat it is
event Action<EffectHandler.TeleportType> PlayerRepositionedRaised on the local player after the server teleports them, with the teleport type.

Methods​

MemberWhat it is
override void Teleport(Vector3 position, float strength, EffectHandler.TeleportType teleportType = 0)Local player: teleports to the position (with a cooldown) and tells others. Server on a remote player: tells that player to teleport.
3 private and internal methods
MemberWhat it is
private void Awake()Finds the PlayerCharacter on the entity and waits for entity initialization.
private void Initialize(NetworkEntity entity)Creates the method sync used to send teleport messages once the entity is set up.
private void NetworkTeleport(IPlayer player, Stream stream, PlayerEffectController.PlayerEffectTeleportInformation teleportInformation)Handles a teleport message: moves the local player if told to, spawns the visual effect, and on the server relays the owner's message to nearby chunks.