Пример #1
0
        public void RandomizeClothing()
        {
            PlayerOutfitDetails outfit = default(PlayerOutfitDetails);

            outfit.sessionId = SessionId;
            outfit.parts     = randomizeOutfitParts();
            eventDispatcher.DispatchEvent(new PlayerStateServiceEvents.PlayerOutfitChanged(outfit));
        }
Пример #2
0
        private void onRoomJoin(GameServerEvent evt, object data)
        {
            removeSFSListeners();
            PlayerOutfitDetails outfit = signedJoinRoomData.Data.playerRoomData.outfit;

            outfit.sessionId = clubPenguinClient.PlayerSessionId;
            Service.Get <EventDispatcher>().DispatchEvent(new WorldServiceEvents.SelfRoomJoinedEvent(clubPenguinClient.PlayerSessionId, clubPenguinClient.PlayerName, new RoomIdentifier((string)data), signedJoinRoomData.Data.extraLayoutData, signedJoinRoomData.Data.roomOwnerName, signedJoinRoomData.Data.roomOwner));
            Service.Get <EventDispatcher>().DispatchEvent(new PlayerStateServiceEvents.PlayerMembershipStatusChanged(signedJoinRoomData.Data.membershipRights.member));
            Service.Get <EventDispatcher>().DispatchEvent(new PlayerStateServiceEvents.PlayerOutfitChanged(outfit));
            Service.Get <EventDispatcher>().DispatchEvent(new PlayerStateServiceEvents.PlayerProfileChanged(clubPenguinClient.PlayerSessionId, signedJoinRoomData.Data.playerRoomData.profile));
            Service.Get <EventDispatcher>().DispatchEvent(new PlayerStateServiceEvents.TubeSelected(clubPenguinClient.PlayerSessionId, signedJoinRoomData.Data.selectedTubeId));
            Service.Get <EventDispatcher>().DispatchEvent(new RewardServiceEvents.MyAssetsReceived(signedJoinRoomData.Data.playerRoomData.assets));
            Service.Get <EventDispatcher>().DispatchEvent(new ConsumableServiceEvents.InventoryRecieved(signedJoinRoomData.Data.playerRoomData.consumableInventory));
            Service.Get <EventDispatcher>().DispatchEvent(new TaskNetworkServiceEvents.DailyTaskProgressRecieved(signedJoinRoomData.Data.playerRoomData.dailyTaskProgress));
            Service.Get <EventDispatcher>().DispatchEvent(new RewardServiceEvents.RoomRewardsReceived(iglooToJoin.name, signedJoinRoomData.Data.earnedRewards));
            Service.Get <EventDispatcher>().DispatchEvent(new QuestServiceEvents.QuestStatesRecieved(signedJoinRoomData.Data.playerRoomData.quests));
            signedJoinRoomData = null;
        }
Пример #3
0
 public PlayerOutfitChanged(PlayerOutfitDetails outfit)
 {
     Outfit = outfit;
 }
Пример #4
0
        private void broadcastUserVariables(User user, ArrayList changedVars = null)
        {
            bool flag = getSessionId(user) == mt.ClubPenguinClient.PlayerSessionId;

            if (!flag && (changedVars == null || changedVars.Contains(SocketUserVars.PROTOTYPE.GetKey())) && user.ContainsVariable(SocketUserVars.PROTOTYPE.GetKey()))
            {
                PrototypeState prototypeState = default(PrototypeState);
                prototypeState.id   = getSessionId(user);
                prototypeState.data = JsonMapper.ToObject(user.GetVariable(SocketUserVars.PROTOTYPE.GetKey()).GetStringValue());
                mt.triggerEvent(GameServerEvent.PROTOTYPE_STATE, prototypeState);
            }
            if (changedVars == null || changedVars.Contains(SocketUserVars.EQUIPPED_OBJECT.GetKey()))
            {
                UserVariable variable  = user.GetVariable(SocketUserVars.EQUIPPED_OBJECT.GetKey());
                UserVariable variable2 = user.GetVariable(SocketUserVars.EQUIPPED_OBJECT_PROPERTIES.GetKey());
                if (variable == null)
                {
                    if (changedVars != null && changedVars.Contains(SocketUserVars.EQUIPPED_OBJECT_PROPERTIES.GetKey()) && variable2 == null)
                    {
                        mt.triggerEvent(GameServerEvent.SERVER_ITEM_REMOVED, new CPMMOItemId(getSessionId(user), CPMMOItemId.CPMMOItemParent.PLAYER));
                    }
                    else
                    {
                        mt.triggerEvent(GameServerEvent.HELD_OBJECT_DEQUIPPED, getSessionId(user));
                    }
                }
                else
                {
                    EquippedObject equippedObject = EquippedObject.FromSFSData(variable.GetSFSObjectValue());
                    if (variable2 != null)
                    {
                        PlayerHeldItem playerHeldItem = new PlayerHeldItem();
                        playerHeldItem.Id         = new CPMMOItemId(getSessionId(user), CPMMOItemId.CPMMOItemParent.PLAYER);
                        playerHeldItem.CreatorId  = playerHeldItem.Id.Id;
                        playerHeldItem.Type       = equippedObject.EquippedObjectId;
                        playerHeldItem.Properties = variable2.GetStringValue();
                        mt.triggerEvent(GameServerEvent.SERVER_ITEM_ADDED, playerHeldItem);
                    }
                    else if (!flag || (flag && equippedObject.isPartyGame()))
                    {
                        HeldObjectEvent heldObjectEvent = default(HeldObjectEvent);
                        heldObjectEvent.SessionId = getSessionId(user);
                        heldObjectEvent.Type      = equippedObject.EquippedObjectId;
                        if (equippedObject.IsConsumable())
                        {
                            mt.triggerEvent(GameServerEvent.CONSUMABLE_EQUIPPED, heldObjectEvent);
                        }
                        else if (equippedObject.IsDispensable())
                        {
                            mt.triggerEvent(GameServerEvent.DISPENSABLE_EQUIPPED, heldObjectEvent);
                        }
                        else if (equippedObject.IsDurable())
                        {
                            mt.triggerEvent(GameServerEvent.DURABLE_EQUIPPED, heldObjectEvent);
                        }
                        else if (equippedObject.isPartyGame())
                        {
                            mt.triggerEvent(GameServerEvent.PARTYGAME_EQUIPPED, heldObjectEvent);
                        }
                    }
                }
            }
            else if (changedVars.Contains(SocketUserVars.EQUIPPED_OBJECT_PROPERTIES.GetKey()))
            {
                UserVariable variable3 = user.GetVariable(SocketUserVars.EQUIPPED_OBJECT.GetKey());
                if (variable3 != null && variable3.Type == VariableType.OBJECT)
                {
                    PlayerHeldItem playerHeldItem = new PlayerHeldItem();
                    playerHeldItem.Id         = new CPMMOItemId(getSessionId(user), CPMMOItemId.CPMMOItemParent.PLAYER);
                    playerHeldItem.CreatorId  = playerHeldItem.Id.Id;
                    playerHeldItem.Type       = EquippedObject.FromSFSData(variable3.GetSFSObjectValue()).EquippedObjectId;
                    playerHeldItem.Properties = user.GetVariable(SocketUserVars.EQUIPPED_OBJECT_PROPERTIES.GetKey()).GetStringValue();
                    mt.triggerEvent(GameServerEvent.SERVER_ITEM_CHANGED, playerHeldItem);
                }
            }
            if (!flag && (changedVars == null || changedVars.Contains(SocketUserVars.LOCOMOTION_STATE.GetKey())))
            {
                UserVariable variable4 = user.GetVariable(SocketUserVars.LOCOMOTION_STATE.GetKey());
                PlayerLocomotionStateEvent playerLocomotionStateEvent = default(PlayerLocomotionStateEvent);
                playerLocomotionStateEvent.SessionId = getSessionId(user);
                if (variable4 == null || variable4.IsNull())
                {
                    playerLocomotionStateEvent.State = LocomotionState.Default;
                }
                else
                {
                    playerLocomotionStateEvent.State = (LocomotionState)variable4.GetIntValue();
                }
                mt.triggerEvent(GameServerEvent.USER_LOCO_STATE_CHANGED, playerLocomotionStateEvent);
            }
            if (!flag && (changedVars == null || changedVars.Contains(SocketUserVars.OUTFIT.GetKey())) && user.ContainsVariable(SocketUserVars.OUTFIT.GetKey()))
            {
                PlayerOutfitDetails playerOutfitDetails = mt.JsonService.Deserialize <PlayerOutfitDetails>(user.GetVariable(SocketUserVars.OUTFIT.GetKey()).GetStringValue());
                playerOutfitDetails.sessionId = getSessionId(user);
                mt.triggerEvent(GameServerEvent.USER_OUTFIT_CHANGED, playerOutfitDetails);
            }
            if (!flag && (changedVars == null || changedVars.Contains(SocketUserVars.PROFILE.GetKey())) && user.ContainsVariable(SocketUserVars.PROFILE.GetKey()))
            {
                ProfileEvent profileEvent = default(ProfileEvent);
                profileEvent.SessionId      = getSessionId(user);
                profileEvent.Profile        = new Profile();
                profileEvent.Profile.colour = user.GetVariable(SocketUserVars.PROFILE.GetKey()).GetIntValue();
                mt.triggerEvent(GameServerEvent.USER_PROFILE_CHANGED, profileEvent);
            }
            if (!flag && (changedVars == null || changedVars.Contains(SocketUserVars.AIR_BUBBLE.GetKey())))
            {
                UserVariable         variable5            = user.GetVariable(SocketUserVars.AIR_BUBBLE.GetKey());
                PlayerAirBubbleEvent playerAirBubbleEvent = default(PlayerAirBubbleEvent);
                playerAirBubbleEvent.SessionId = getSessionId(user);
                if (variable5 == null || variable5.IsNull())
                {
                    playerAirBubbleEvent.AirBubble = new AirBubble();
                }
                else
                {
                    playerAirBubbleEvent.AirBubble = AirBubble.FromSFSData(variable5.GetSFSObjectValue());
                }
                mt.triggerEvent(GameServerEvent.AIR_BUBBLE_UPDATE, playerAirBubbleEvent);
            }
            if (!flag && (changedVars == null || changedVars.Contains(SocketUserVars.ON_QUEST.GetKey())))
            {
                UserVariable variable4    = user.GetVariable(SocketUserVars.ON_QUEST.GetKey());
                OnQuestState onQuestState = default(OnQuestState);
                onQuestState.SessionId = getSessionId(user);
                if (!(variable4?.IsNull() ?? true))
                {
                    onQuestState.MascotName = variable4.GetStringValue();
                }
                mt.triggerEvent(GameServerEvent.ON_QUEST, onQuestState);
            }
            if (!flag && (changedVars == null || changedVars.Contains(SocketUserVars.SELECTED_TUBE.GetKey())) && user.ContainsVariable(SocketUserVars.SELECTED_TUBE.GetKey()))
            {
                SelectedTubeEvent selectedTubeEvent = default(SelectedTubeEvent);
                selectedTubeEvent.SessionId = getSessionId(user);
                selectedTubeEvent.TubeId    = user.GetVariable(SocketUserVars.SELECTED_TUBE.GetKey()).GetIntValue();
                mt.triggerEvent(GameServerEvent.SELECTED_TUBE_CHANGED, selectedTubeEvent);
            }
            if (!flag && (changedVars == null || changedVars.Contains(SocketUserVars.TEMPORARY_HEAD_STATUS.GetKey())) && user.ContainsVariable(SocketUserVars.TEMPORARY_HEAD_STATUS.GetKey()))
            {
                TemporaryHeadStatusEvent temporaryHeadStatusEvent = default(TemporaryHeadStatusEvent);
                temporaryHeadStatusEvent.SessionId = getSessionId(user);
                temporaryHeadStatusEvent.Type      = user.GetVariable(SocketUserVars.TEMPORARY_HEAD_STATUS.GetKey()).GetIntValue();
                mt.triggerEvent(GameServerEvent.TEMPORARY_HEAD_STATUS_CHANGED, temporaryHeadStatusEvent);
            }
            if (flag || (changedVars != null && !changedVars.Contains(SocketUserVars.AWAY_FROM_KEYBOARD.GetKey())))
            {
                return;
            }
            UserVariable variable6 = user.GetVariable(SocketUserVars.AWAY_FROM_KEYBOARD.GetKey());

            if (variable6 == null || variable6.IsNull())
            {
                EquippedObject equippedObject2 = null;
                UserVariable   variable7       = user.GetVariable(SocketUserVars.EQUIPPED_OBJECT.GetKey());
                if (variable7 != null)
                {
                    equippedObject2 = EquippedObject.FromSFSData(variable7.GetSFSObjectValue());
                }
                mt.triggerEvent(GameServerEvent.AWAY_FROM_KEYBOARD_STATE_CHANGED, new AFKEvent(getSessionId(user), 0, equippedObject2));
            }
            else
            {
                mt.triggerEvent(GameServerEvent.AWAY_FROM_KEYBOARD_STATE_CHANGED, new AFKEvent(getSessionId(user), variable6.GetIntValue(), null));
            }
        }
    private void onPlayerOutfitChanged(GameServerEvent evt, object data)
    {
        PlayerOutfitDetails outfit = (PlayerOutfitDetails)data;

        Service.Get <EventDispatcher>().DispatchEvent(new PlayerStateServiceEvents.PlayerOutfitChanged(outfit));
    }