1[
EntityEditorProps(
category:
"GameScripted/FastTravel", description:
"Handles client > server communication for Fast travel. Should be attached to PlayerController.")]
19 [
Attribute(
"300",
desc:
"Minimum delay between fast travels (seconds).",
params:
"0 inf 1")];
22 [
Attribute(
"250",
desc:
"How far away from the target destination will player get teleported.",
params:
"0 inf 1")];
25 [
Attribute(
"IEntity",
desc:
"Allowed class name of destination entity (inherited classes are also allowed).")];
31 static const int SPAWNING_RADIUS = 10;
33 static const float FADE_DURATION = 1.5;
34 static const float BLACKSCREEN_DURATION = 1.0;
35 static const float CLOSE_MAP_DELAY = 0.75;
39 static SCR_FastTravelComponent GetLocalInstance()
41 PlayerController pc =
GetGame().GetPlayerController();
46 return SCR_FastTravelComponent.Cast(pc.FindComponent(SCR_FastTravelComponent));
83 static void ToggleMapDestinationSelection(
bool enable,
bool disableAfterUse =
true)
85 SCR_FastTravelComponent comp = GetLocalInstance();
91 SCR_NotificationsComponent.SendLocal(
ENotification.FASTTRAVEL_AVAILABLE);
93 SCR_NotificationsComponent.SendLocal(
ENotification.FASTTRAVEL_UNAVAILABLE);
95 SCR_MapEntity.GetOnSelectionChanged().Remove(comp.OnSelectionChanged);
101 comp.DisableAfterUse();
103 SCR_MapEntity.GetOnSelectionChanged().Insert(comp.OnSelectionChanged);
123 IEntity entity = selectedItem.Entity();
135 if (player && mapEntity.
IsOpen())
158 RplComponent rpl = RplComponent.Cast(entity.
FindComponent(RplComponent));
161 return RplId.Invalid();
216 if (destination.IsInherited(
IEntity))
217 target =
IEntity.Cast(destination);
220 else if (destination.IsInherited(BaseRplComponent))
221 target = BaseRplComponent.Cast(destination).GetEntity();
255 ToggleMapDestinationSelection(
false);
260 GetGame().GetCallqueue().CallLater(
FadeOut, CLOSE_MAP_DELAY * 1000);
271 fade.FadeOutEffect(
true, FADE_DURATION);
275 GetGame().GetCallqueue().CallLater(
Teleport, (FADE_DURATION + BLACKSCREEN_DURATION) * 1000);
281 SCR_ChimeraCharacter player = SCR_ChimeraCharacter.Cast(
m_PlayerController.GetControlledEntity());
283 if (player && !player.IsInVehicle() && !player.GetCharacterController().IsDead())
286 SCR_NotificationsComponent.SendLocal(
ENotification.FASTTRAVEL_DONE);
294 fade.FadeOutEffect(
false, FADE_DURATION);
317 newPlayerOrigin[1] = playerOrigin[1];
319 float angle =
Math.Atan2(playerOrigin[2] - targetOrigin[2], playerOrigin[0] - targetOrigin[0]);
324 SCR_WorldTools.FindEmptyTerrainPosition(newPlayerOrigin, newPlayerOrigin, SPAWNING_RADIUS);
326 return newPlayerOrigin;
332 super.OnPostInit(owner);
342 Print(
"SCR_FastTravelComponent must be attached to PlayerController!",
LogLevel.ERROR);
ArmaReforgerScripted GetGame()
SCR_CacheNoteComponentClass ScriptComponentClass RplProp()] protected ref array< string > m_aLines
int GetCooldown()
Reads the cooldown value from player's rank.
bool ServerSanityCheck(notnull IEntity target)
enum SCR_ECompassType EntityEditorProps(category:"GameScripted/Gadgets", description:"Compass", color:"0 0 255 255")
Prefab data class for compass component.
void SetDestination(RplId id, string name)
Destination must be a replicated item with valid RplId.
void RpcAsk_FastTravel(RplId destinationId)
vector CalculateDestinationVector(notnull IEntity destination)
RplId FindDestinationId(IEntity entity)
string GetDestinationName()
string m_sDestinationName
string m_sDestinationType
SCR_FastTravelComponentClass m_PlayerController
bool m_bIsDestinationValid
void SetNextTransportTimestamp(WorldTimestamp timestamp)
IEntity GetEntityByDestinationId(RplId id)
vector m_vTeleportCoordinates
WorldTimestamp GetNextTransportTimestamp()
void RpcDo_FastTravel(vector position)
WorldTimestamp m_fNextTravelAvailableAt
void ~SCR_FastTravelComponent()
void OnSelectionChanged(MapItem item)
SCR_EPlayerTeleportedReason
UI Textures DeployMenu Briefing conflict_HintBanner_1_UI desc
proto external Managed FindComponent(typename typeName)
Replication item identifier.
static SCR_GadgetManagerComponent GetGadgetManager(IEntity entity)
void RemoveHeldGadget()
Remove gadget held in hand.
static bool TeleportLocalPlayer(vector worldPosition, SCR_EPlayerTeleportedReason teleportReason=SCR_EPlayerTeleportedReason.DEFAULT)
MapItem GetHoveredItem()
Get hovered item.
bool IsOpen()
Check if the map is opened.
static ScriptInvokerBase< MapItemInvoker > GetOnSelectionChanged()
Get on selection changed invoker.
static SCR_MapEntity GetMapInstance()
Get map entity instance.
BaseInfoDisplay GetEffect(typename effectType)
Return the effect is it exist.
static SCR_ScreenEffectsManager GetScreenEffectsDisplay()
Static GetScreenEffectsDisplay will return this regardless of whether SCR_ScreenEffectsManager is run...
static float GetTerrainY(vector pos, BaseWorld world=null, bool noUnderwater=false, TraceParam trace=null)
proto external GenericEntity GetOwner()
Get owner entity.
override void EOnInit(IEntity owner)
proto void Print(void var, LogLevel level=LogLevel.NORMAL)
Prints content of variable to console/log.
LogLevel
Enum with severity of the logging message.
SCR_FieldOfViewSettings Attribute
EntityEvent
Various entity events.
void RplRpc(RplChannel channel, RplRcver rcver, RplCondition condition=RplCondition.None, string customConditionName="")
RplCondition
Conditional replication rule. Fine grained selection of receivers.
RplChannel
Communication channel. Reliable is guaranteed to be delivered. Unreliable not.