private void executeSpawedAction(SpawnedAction spawnedAction) { if (spawnedAction.Reward != null) { Service.Get <EventDispatcher>().DispatchEvent(new RewardServiceEvents.MyRewardEarned(RewardSource.QUICK_NOTIFICATION, "", spawnedAction.Reward)); } switch (spawnedAction.Action) { case SpawnedAction.SPAWNED_ACTION.StartQuest: if (spawnedAction.Quest != null) { Service.Get <TutorialManager>().EndTutorial(); Service.Get <EventDispatcher>().DispatchEvent(new QuestEvents.StartQuest(spawnedAction.Quest)); } break; case SpawnedAction.SPAWNED_ACTION.ReplayQuest: if (spawnedAction.Quest != null) { Service.Get <TutorialManager>().EndTutorial(); Service.Get <EventDispatcher>().DispatchEvent(new QuestEvents.ReplayQuest(spawnedAction.Quest)); } break; } }
private SpawnPlayerParams(Vector3 position, Quaternion rotation, ZoneDefinition zone, string sceneName, SpawnedAction spawnedAction, bool nudgePlayer, bool getOutOfSwimming, Reward pendingReward) { Position = position; Rotation = rotation; Zone = zone; SceneName = sceneName; SpawnedAction = spawnedAction; NudgePlayer = nudgePlayer; GetOutOfSwimming = getOutOfSwimming; PendingReward = pendingReward; }
public SpawnPlayerParamsBuilder SpawnedAction(SpawnedAction spawnedAction) { this.spawnedAction = spawnedAction; return(this); }
public void SpawnPlayer(SpawnPlayerParams spawnPlayerParams) { if (spawnPlayerParams.Zone != null || !string.IsNullOrEmpty(spawnPlayerParams.SceneName)) { bool flag = false; PresenceData component = dataEntityCollection.GetComponent <PresenceData>(dataEntityCollection.LocalPlayerHandle); ZoneTransitionService zoneTransitionService = Service.Get <ZoneTransitionService>(); if (spawnPlayerParams.Zone != null) { ZoneDefinition zoneBySceneName = zoneTransitionService.GetZoneBySceneName(component.Room); flag = zoneBySceneName != null && string.Equals(spawnPlayerParams.Zone.ZoneName, zoneBySceneName.ZoneName); } else if (!string.IsNullOrEmpty(spawnPlayerParams.SceneName)) { flag = ((!zoneTransitionService.IsInIgloo) ? string.Equals(component.Room, spawnPlayerParams.SceneName) : string.Equals(zoneTransitionService.CurrentZone.SceneName, spawnPlayerParams.SceneName)); } if (!flag) { if (!dataEntityCollection.TryGetComponent <SpawnData>(dataEntityCollection.LocalPlayerHandle, out var component2)) { component2 = dataEntityCollection.AddComponent <SpawnData>(dataEntityCollection.LocalPlayerHandle); } if (spawnPlayerParams.SpawnedAction != null) { component2.SpawnedAction = spawnPlayerParams.SpawnedAction; } component2.Position = spawnPlayerParams.Position; component2.Rotation = spawnPlayerParams.Rotation; component2.PendingReward = spawnPlayerParams.PendingReward; if (spawnPlayerParams.Zone != null) { zoneTransitionService.LoadZone(spawnPlayerParams.Zone, "Loading"); } else { zoneTransitionService.LoadZone(spawnPlayerParams.SceneName, "Loading"); } return; } } if (spawnPlayerParams.PendingReward != null) { Service.Get <EventDispatcher>().DispatchEvent(new RewardServiceEvents.MyRewardEarned(RewardSource.QUICK_NOTIFICATION, "", spawnPlayerParams.PendingReward)); } if (Vector3.Distance(base.transform.position, spawnPlayerParams.Position) <= 3f) { if (spawnPlayerParams.SpawnedAction != null) { executeSpawedAction(spawnPlayerParams.SpawnedAction); } return; } LocomotionTracker component3 = base.gameObject.GetComponent <LocomotionTracker>(); if (component3.IsCurrentControllerOfType <SlideController>()) { component3.SetCurrentController <RunController>(); } else if (spawnPlayerParams.GetOutOfSwimming && component3.IsCurrentControllerOfType <SwimController>()) { Animator component4 = base.gameObject.GetComponent <Animator>(); component4.SetTrigger(AnimationHashes.Params.SwimToWalk); component3.SetCurrentController <RunController>(); } Vector3 zero = Vector3.zero; if (spawnPlayerParams.NudgePlayer && component3.IsCurrentControllerOfType <RunController>()) { zero.y = 0.5f; } base.transform.position = spawnPlayerParams.Position + zero; ClubPenguin.Core.SceneRefs.Get <BaseCamera>().Snap(); if (spawnPlayerParams.NudgePlayer) { actionOnSpawned = spawnPlayerParams.SpawnedAction; CoroutineRunner.Start(LocomotionUtils.nudgePlayer(component3, onNudgePlayerDone), component3.gameObject, "MoveAfterJump"); } else if (spawnPlayerParams.SpawnedAction != null) { executeSpawedAction(spawnPlayerParams.SpawnedAction); } }
private void spawnLocalPlayerInZone() { if (Service.Get <ZoneTransitionService>().CurrentZone.AlwaysSpawnPlayerAtDefaultLocation) { spawnNearDefaultLocation(); return; } actionOnSpawned = null; Quaternion rotation = Quaternion.identity; PositionData component3; if (playerDataHandle.Handle == dataEntityCollection.LocalPlayerHandle) { Vector3 vector = Vector3.zero; bool flag = false; SpawnData component2; if (dataEntityCollection.TryGetComponent <PausedStateData>(dataEntityCollection.LocalPlayerHandle, out var component)) { if (component.ShouldSkipResume) { component.ShouldSkipResume = false; } else { vector = component.Position; flag = true; } } else if (dataEntityCollection.TryGetComponent <SpawnData>(dataEntityCollection.LocalPlayerHandle, out component2)) { vector = component2.Position; rotation = component2.Rotation; actionOnSpawned = component2.SpawnedAction; actionOnSpawned.Reward = component2.PendingReward; flag = true; dataEntityCollection.RemoveComponent <SpawnData>(dataEntityCollection.LocalPlayerHandle); } if (flag && dataEntityCollection.TryGetComponent <PositionData>(dataEntityCollection.LocalPlayerHandle, out component3)) { component3.Position = vector; localPlayerSpawnPostion = vector; base.transform.SetPositionAndRotation(vector, rotation); if (actionOnSpawned != null && (actionOnSpawned.Action != 0 || actionOnSpawned.Reward != null)) { eventDispatcher.AddListener <HudEvents.HudInitComplete>(onHudInitCompleted); } return; } } if (isSpawnNearPlayer()) { Service.Get <EventDispatcher>().AddListener <FriendsServiceEvents.FriendLocationInRoomReceived>(onFriendLocationReceived); Service.Get <EventDispatcher>().AddListener <FriendsServiceEvents.FriendNotInRoom>(onFriendNotInRoom); Service.Get <INetworkServicesManager>().FriendsService.GetFriendLocationInRoom(dataEntityCollection.GetComponent <SpawnAtPlayerData>(playerDataHandle.Handle).PlayerSWID); return; } bool flag2 = false; component3 = dataEntityCollection.GetComponent <PositionData>(playerDataHandle.Handle); if (!flag2 && component3 != null && component3.Position != Vector3.zero) { LocomotionActionEvent action = default(LocomotionActionEvent); action.Type = LocomotionAction.Move; action.Position = component3.Position; action.Direction = Vector3.zero; Service.Get <INetworkServicesManager>().PlayerActionService.LocomotionAction(action); flag2 = true; } if (!flag2) { spawnAtSceneLocation(); } }