private void onExperienceStarted(string instanceId, long ownerId, bool isOwnerLocalPlayer, PropDefinition propDef)
 {
     try
     {
         invitationExperienceInstanceId = instanceId;
         invitingPlayerId        = ownerId;
         isInvitationLocalPlayer = isOwnerLocalPlayer;
         invitingPlayerObject    = getInvitingPlayerObject();
         if (invitingPlayerObject != null)
         {
             invitingPlayerAvatarView = invitingPlayerObject.GetComponent <AvatarView>();
         }
         CPMMOItemId identifier = new CPMMOItemId(long.Parse(invitationExperienceInstanceId), CPMMOItemId.CPMMOItemParent.PLAYER);
         serverObjectHandle = dataEntityCollection.FindEntity <ServerObjectItemData, CPMMOItemId>(identifier);
         if (serverObjectHandle.IsNull)
         {
             onItemRemoved();
             return;
         }
         serverObjectData      = dataEntityCollection.GetComponent <ServerObjectItemData>(serverObjectHandle);
         AvailableItemQuantity = propDef.TotalItemQuantity;
         totalItemQuantity     = propDef.TotalItemQuantity;
         setupNetworkServiceListeners();
         if (isOwnerLocalPlayer)
         {
             GameObject target = dataEntityCollection.GetComponent <GameObjectReferenceData>(dataEntityCollection.LocalPlayerHandle).GameObject;
             InputButtonGroupContentKey inputButtonGroupContentKey = (LocomotionHelper.IsCurrentControllerOfType <SwimController>(target) ? ((!(LocomotionHelper.GetCurrentController(target) as SwimController).IsInShallowWater) ? DivingControlLayout : SwimControlLayout) : ((!LocomotionHelper.IsCurrentControllerOfType <SitController>(target)) ? ControlLayout : ((!(LocomotionHelper.GetCurrentController(target) as SitController).IsUnderwater) ? SitControlLayout : SitSwimControlLayout)));
             if (inputButtonGroupContentKey != null && !string.IsNullOrEmpty(inputButtonGroupContentKey.Key))
             {
                 Service.Get <EventDispatcher>().DispatchEvent(new ControlsScreenEvents.SetRightOption(inputButtonGroupContentKey));
             }
             else
             {
                 Log.LogError(this, "Did not find a valid controls content key for this state");
             }
             ParticipationData component = dataEntityCollection.GetComponent <ParticipationData>(dataEntityCollection.LocalPlayerHandle);
             if (component != null)
             {
                 component.CurrentParticipationState = ParticipationState.Participating;
                 component.IsInteractButtonAvailable = false;
             }
         }
         Service.Get <EventDispatcher>().AddListener <PenguinInteraction.InteractionStartedEvent>(onInteractionStarted);
         if (invitingPlayerAvatarView != null)
         {
             if (invitingPlayerAvatarView.IsReady)
             {
                 onAvatarReady();
             }
             invitingPlayerAvatarView.OnReady += onAvatarViewReady;
         }
         switchToCamera();
     }
     catch (FormatException ex)
     {
         Log.LogException(this, ex);
     }
 }
 private void setupNetworkServiceListeners()
 {
     cpMMOItemId = new CPMMOItemId(long.Parse(partyBlasterId), CPMMOItemId.CPMMOItemParent.WORLD);
     if (dataEntityCollection.TryFindEntity <ServerObjectItemData, CPMMOItemId>(cpMMOItemId, out serverObjectHandle) && dataEntityCollection.TryGetComponent <ServerObjectPositionData>(serverObjectHandle, out serverObjectPositionData))
     {
         serverObjectPositionData.PositionChanged += onItemMoved;
         dataEntityCollection.EventDispatcher.AddListener <DataEntityEvents.EntityRemovedEvent>(onItemRemoved);
     }
     Service.Get <EventDispatcher>().AddListener <RewardServiceEvents.RewardsEarned>(onRewardsReceived);
 }
Esempio n. 3
0
    private void setupNetworkServiceListeners(long id)
    {
        CPMMOItemId cPMMOItemId = new CPMMOItemId(id, CPMMOItemId.CPMMOItemParent.WORLD);

        if (dataEntityCollection.TryFindEntity <ServerObjectItemData, CPMMOItemId>(cPMMOItemId, out serverObjectHandle))
        {
            serverObjectItemData = dataEntityCollection.GetComponent <ServerObjectItemData>(serverObjectHandle);
            GetComponent <NetworkObjectController>().ItemId = cPMMOItemId;
            serverObjectItemData.ItemChanged += onItemChanged;
            dataEntityCollection.EventDispatcher.AddListener <DataEntityEvents.EntityRemovedEvent>(onItemRemoved);
            parseCPMMOItem(serverObjectItemData.Item);
        }
        Service.Get <EventDispatcher>().AddListener <RewardServiceEvents.RewardsEarned>(onRewardsReceived);
    }
Esempio n. 4
0
 public ItemMoved(CPMMOItemId itemId, Vector3 position)
 {
     ItemId   = itemId;
     Position = position;
 }
Esempio n. 5
0
 public ItemDestroyed(CPMMOItemId itemId)
 {
     ItemId = itemId;
 }
Esempio n. 6
0
    private void sendInteractionEvent(GameObject trigger)
    {
        ForceInteractionAction component = trigger.GetComponent <ForceInteractionAction>();

        if (component != null && !component.IsInteractionBroadcasted)
        {
            sendLocomotionUpdate(newSteerDirection, LocomotionAction.Move);
            return;
        }
        LocomotionActionEvent action = default(LocomotionActionEvent);

        action.Type     = LocomotionAction.Interact;
        action.Position = getCurrentPosition();
        ObjectType type = ObjectType.LOCAL;
        string     id   = trigger.GetPath();
        string     tag  = "";

        if (trigger.GetComponent <AvatarDataHandle>() != null)
        {
            type = ObjectType.PLAYER;
            id   = Service.Get <CPDataEntityCollection>().GetComponent <SessionIdData>(trigger.GetComponent <AvatarDataHandle>().Handle).SessionId.ToString();
            tag  = trigger.tag;
        }
        else if (trigger.GetComponent <NetworkObjectController>() != null)
        {
            CPMMOItemId itemId = trigger.GetComponent <NetworkObjectController>().ItemId;
            if (itemId.Parent == CPMMOItemId.CPMMOItemParent.WORLD)
            {
                type = ObjectType.SERVER;
            }
            id  = itemId.Id.ToString();
            tag = trigger.tag;
        }
        else
        {
            Transform parent = trigger.transform.parent;
            while (parent != null && parent.GetComponent <AvatarDataHandle>() == null)
            {
                parent = parent.transform.parent;
            }
            if (parent != null)
            {
                type = ObjectType.PLAYER;
                id   = Service.Get <CPDataEntityCollection>().GetComponent <SessionIdData>(parent.GetComponent <AvatarDataHandle>().Handle).SessionId.ToString();
                tag  = trigger.tag;
            }
            else if (trigger.transform.parent != null)
            {
                Collectible componentInChildren = trigger.transform.parent.gameObject.GetComponentInChildren <Collectible>();
                bool        flag = false;
                if (componentInChildren != null && componentInChildren.RewardDef != null)
                {
                    List <CollectibleRewardDefinition> definitions = componentInChildren.RewardDef.GetDefinitions <CollectibleRewardDefinition>();
                    if (definitions.Count > 0 && definitions[0].Collectible != null)
                    {
                        tag  = definitions[0].Collectible.CollectibleType;
                        flag = true;
                    }
                }
                if (!flag)
                {
                    tag = trigger.tag;
                }
            }
            else
            {
                tag = trigger.tag;
            }
        }
        action.Object = new ActionedObject(type, id, tag);
        if (broadcastingDisabledEvents == 0)
        {
            networkService.PlayerActionService.LocomotionAction(action);
        }
    }
Esempio n. 7
0
    private void onServerItemRemoved(GameServerEvent gameServerEvent, object data)
    {
        CPMMOItemId itemId = (CPMMOItemId)data;

        Service.Get <EventDispatcher>().DispatchEvent(new WorldServiceEvents.ItemDestroyed(itemId));
    }