Example #1
0
        public static string GetSceneNameFromZoneName(string zoneName)
        {
            Dictionary <string, ZoneDefinition> dictionary = Service.Get <IGameData>().Get <Dictionary <string, ZoneDefinition> >();
            ZoneDefinition zoneDefinition = dictionary[zoneName];

            if (zoneDefinition != null)
            {
                return(zoneDefinition.SceneName);
            }
            return(null);
        }
Example #2
0
 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;
 }
Example #3
0
        public void SetWaypoint(DWaypoint waypointData)
        {
            currentWaypointData = waypointData;
            GameObject gameObject = (string.IsNullOrEmpty(waypointData.WaypointName) ? waypointData.WaypointObject : GameObject.Find(waypointData.WaypointName.Trim()));

            CustomZonePathingTrigger[] array = Object.FindObjectsOfType <CustomZonePathingTrigger>();
            for (int i = 0; i < array.Length; i++)
            {
                if (array[i].IsInTrigger && array[i].IsOverrideActive())
                {
                    if (gameObject == null)
                    {
                        gameObject = array[i].OverrideWaypointTarget.gameObject;
                        break;
                    }
                    CustomZonePathingTarget component = gameObject.GetComponent <CustomZonePathingTarget>();
                    if (component == null || component.IsCustomWaypointActive())
                    {
                        gameObject = array[i].OverrideWaypointTarget.gameObject;
                        break;
                    }
                }
            }
            EventDispatcher eventDispatcher         = Service.Get <EventDispatcher>();
            bool            flag                    = true;
            Vector3         onScreenIndicatorOffset = waypointData.OnScreenIndicatorOffset;

            if (gameObject != null)
            {
                flag = false;
                CustomZonePathingTarget component = gameObject.GetComponent <CustomZonePathingTarget>();
                if (component != null && component.IsCustomWaypointActive())
                {
                    gameObject = component.WaypointPosition;
                }
                eventDispatcher.DispatchEvent(new HudEvents.SetNavigationTarget(gameObject.transform, waypointData.ShowOnScreenIndicator, onScreenIndicatorOffset));
            }
            else if (waypointData.WaypointZone != null)
            {
                ZoneDefinition currentZone    = Service.Get <ZoneTransitionService>().CurrentZone;
                string         nextZoneInPath = GetNextZoneInPath(currentZone.ZoneName, waypointData.WaypointZone);
                GameObject     gameObject2    = GameObject.Find(nextZoneInPath + "Transition");
                if (gameObject2 != null)
                {
                    flag = false;
                    eventDispatcher.DispatchEvent(new HudEvents.SetNavigationTarget(gameObject2.transform));
                }
            }
            if (flag)
            {
                eventDispatcher.DispatchEvent(default(HudEvents.SetNavigationTarget));
            }
        }
 public void LoadZone(ZoneDefinition zone, string transitionScene = null, string worldName = null)
 {
     if (zone.Type == ZoneDefinition.ZoneType.Igloo)
     {
         ZoneId zoneId = new ZoneId();
         zoneId.name       = zone.ZoneName;
         zoneId.instanceId = CurrentInstanceId;
         LoadIgloo(zoneId, Service.Get <Localizer>().Language, SceneStateData.SceneState.Play, transitionScene);
     }
     else
     {
         LoadZone(zone.SceneName, transitionScene, worldName);
     }
 }
        private bool connectToIgloo(ZoneId zoneId, ZoneDefinition zoneToJoin, Language language, string onJoinNotificationTag)
        {
            if (!startZoneTransition(zoneToJoin.SceneName, onJoinNotificationTag))
            {
                return(false);
            }
            ContentIdentifier contentIdentifier = generateContentIdentifier();

            targetWorldToJoin = null;
            Service.Get <INetworkServicesManager>().WorldService.JoinIgloo(zoneId, LocalizationLanguage.GetLanguageString(language), this);
            PreviousZone      = CurrentZone;
            CurrentZone       = zoneToJoin;
            CurrentInstanceId = zoneId.instanceId;
            return(IsConnecting);
        }
Example #6
0
        private bool spawnNearTransition(ZoneDefinition previousZone)
        {
            bool       result     = false;
            GameObject gameObject = null;

            ZoneTransition[] array = Object.FindObjectsOfType <ZoneTransition>();
            foreach (ZoneTransition zoneTransition in array)
            {
                if (zoneTransition.Zone == null)
                {
                    Log.LogErrorFormatted(this, "Invalid zone transition found while attempting to spawn player. No zone definition assigned to transition '{0}'", zoneTransition.GetPath());
                }
                else if (zoneTransition.Zone.ZoneName == previousZone.ZoneName)
                {
                    gameObject = zoneTransition.gameObject;
                    break;
                }
            }
            if (gameObject != null)
            {
                SpawnPointSelector component = gameObject.GetComponent <SpawnPointSelector>();
                if (component != null)
                {
                    result = true;
                    setPositionToSpawnPoint(component);
                }
                else
                {
                    result = false;
                }
            }
            else
            {
                MapTransition mapTransition = Object.FindObjectOfType <MapTransition>();
                if (mapTransition != null)
                {
                    SpawnPointSelector component = mapTransition.GetComponent <SpawnPointSelector>();
                    if (component != null)
                    {
                        result = true;
                        setPositionToSpawnPoint(component);
                    }
                }
            }
            return(result);
        }
Example #7
0
        public bool spawnAtSceneLocation()
        {
            bool           flag         = false;
            ZoneDefinition previousZone = Service.Get <ZoneTransitionService>().PreviousZone;

            if (previousZone != null)
            {
                flag = spawnNearTransition(previousZone);
            }
            if (!flag)
            {
                flag = spawnNearDefaultLocation();
            }
            if (ClubPenguin.Core.SceneRefs.IsSet <BaseCamera>())
            {
                ClubPenguin.Core.SceneRefs.Get <BaseCamera>().Snap();
            }
            return(flag);
        }
Example #8
0
        private void Awake()
        {
            if (string.IsNullOrEmpty(ZoneDefinitionKey.Id))
            {
                return;
            }
            Dictionary <string, ZoneDefinition> dictionary = Service.Get <IGameData>().Get <Dictionary <string, ZoneDefinition> >();

            if (dictionary.TryGetValue(ZoneDefinitionKey.Id, out var value))
            {
                if (Zone != null)
                {
                }
                Zone = value;
            }
            else
            {
                Log.LogErrorFormatted(this, "Value for key {0} not found", ZoneDefinitionKey.Id);
            }
        }
        public void SetZonesFromManifest(Manifest manifest)
        {
            Zones.Clear();
            ScriptableObject[] assets = manifest.Assets;
            for (int i = 0; i < assets.Length; i++)
            {
                ZoneDefinition item = (ZoneDefinition)assets[i];
                Zones.Add(item);
            }
            string text = SceneManager.GetActiveScene().name;

            foreach (ZoneDefinition zone in Zones)
            {
                if (zone.SceneName == text)
                {
                    CurrentZone = zone;
                    break;
                }
            }
        }
        public bool ConnectToZone(string sceneName, string worldName = null, string onJoinNotificationTag = null)
        {
            ZoneDefinition zoneBySceneName = GetZoneBySceneName(sceneName);

            if (zoneBySceneName == null)
            {
                Log.LogError(this, "Attempting to join a zone that doesn't exist");
                return(false);
            }
            if (!startZoneTransition(sceneName, onJoinNotificationTag))
            {
                return(false);
            }
            PresenceData      component         = dataEntityCollection.GetComponent <PresenceData>(dataEntityCollection.LocalPlayerHandle);
            ContentIdentifier contentIdentifier = generateContentIdentifier();

            if (!string.IsNullOrEmpty(worldName))
            {
                targetWorldToJoin = worldName;
                ZoneId zoneId = new ZoneId();
                zoneId.name = zoneBySceneName.ZoneName;
                Service.Get <INetworkServicesManager>().WorldService.JoinRoomInWorld(new RoomIdentifier(worldName, Service.Get <Localizer>().Language, zoneId, contentIdentifier.ToString()), this);
            }
            else if (component != null && !string.IsNullOrEmpty(component.World))
            {
                targetWorldToJoin = component.World;
                ZoneId zoneId = new ZoneId();
                zoneId.name = zoneBySceneName.ZoneName;
                Service.Get <INetworkServicesManager>().WorldService.JoinRoomInWorld(new RoomIdentifier(component.World, Service.Get <Localizer>().Language, zoneId, contentIdentifier.ToString()), this);
            }
            else
            {
                targetWorldToJoin = null;
                Service.Get <INetworkServicesManager>().WorldService.JoinRoom(zoneBySceneName.ZoneName, contentIdentifier.ToString(), Service.Get <Localizer>().LanguageString, this);
            }
            PreviousZone      = CurrentZone;
            CurrentZone       = zoneBySceneName;
            CurrentInstanceId = "";
            return(IsConnecting);
        }
        private bool onSelfJoinedRoom(WorldServiceEvents.SelfRoomJoinedEvent evt)
        {
            IsConnecting = false;
            dispatcher.RemoveListener <WorldServiceEvents.SelfRoomJoinedEvent>(onSelfJoinedRoom);
            ZoneDefinition zone = GetZone(evt.Room.zoneId.name);

            if (zone != null && !zone.IsQuestOnly && zone.Type != ZoneDefinition.ZoneType.Igloo)
            {
                Service.Get <GameSettings>().LastZone.SetValue(evt.Room.zoneId.name);
                IsInIgloo = false;
            }
            else if (zone != null)
            {
                IsInIgloo = zone.Type == ZoneDefinition.ZoneType.Igloo;
            }
            checkIfZoneTransitionComplete();
            checkForLocalizationChange(GetWorld(evt.Room.world));
            if (targetWorldToJoin != null && targetWorldToJoin != evt.Room.world)
            {
                onJoinNotificationTag = "GlobalUI.Notification.WorldBump";
            }
            if (!string.IsNullOrEmpty(onJoinNotificationTag))
            {
                DNotification dNotification = new DNotification();
                dNotification.Message              = string.Format(Service.Get <Localizer>().GetTokenTranslation(onJoinNotificationTag), evt.Room.world);
                dNotification.PopUpDelayTime       = 6f;
                dNotification.WaitForLoading       = true;
                dNotification.PersistBetweenScenes = false;
                Service.Get <TrayNotificationManager>().ShowNotification(dNotification);
                onJoinNotificationTag = string.Empty;
            }
            Service.Get <ICPSwrveService>().EndTimer("igloo");
            if (zone.Type == ZoneDefinition.ZoneType.Igloo)
            {
                startBIVisitIglooTimer(evt);
            }
            return(false);
        }
        public void LoadIgloo(ZoneId zoneId, Language language, SceneStateData.SceneState sceneState, string transitionScene = null, string onJoinNotificationTag = null)
        {
            ZoneDefinition zone = GetZone(zoneId.name);

            if (isSceneTransitionValid(zone.SceneName))
            {
                Dictionary <string, object> dictionary = new Dictionary <string, object>();
                dictionary.Add(SceneTransitionService.SceneArgs.LoadingScreenOverride.ToString(), IglooSplashScreen.Key);
                sceneTransition(zone.SceneName, transitionScene, dictionary);
                connectToIgloo(zoneId, zone, language, onJoinNotificationTag);
            }
            DataEntityHandle dataEntityHandle = dataEntityCollection.FindEntityByName("ActiveSceneData");

            if (dataEntityHandle.IsNull)
            {
                dataEntityHandle = dataEntityCollection.AddEntity("ActiveSceneData");
            }
            if (!dataEntityCollection.TryGetComponent <SceneStateData>(dataEntityHandle, out var component))
            {
                component = dataEntityCollection.AddComponent <SceneStateData>(dataEntityHandle);
            }
            component.State = sceneState;
        }
Example #13
0
 public SpawnPlayerParamsBuilder Zone(ZoneDefinition zone)
 {
     this.zone = zone;
     return(this);
 }
Example #14
0
        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);
            }
        }