示例#1
0
 private void onPropUsed()
 {
     SpawnedInstance = (IsInstance ? PrefabToSpawn : Object.Instantiate(PrefabToSpawn));
     if (ParentToUser)
     {
         SpawnedInstance.transform.SetParent(prop.PropUserRef.transform, worldPositionStays: false);
     }
     else
     {
         SpawnedInstance.transform.position = prop.OnUseDestination;
         CameraCullingMaskHelper.SetLayerRecursive(SpawnedInstance.transform, "AllPlayerInteractibles");
     }
     SpawnedInstance.InstanceId         = prop.ExperienceInstanceId;
     SpawnedInstance.OwnerId            = prop.OwnerId;
     SpawnedInstance.IsOwnerLocalPlayer = prop.IsOwnerLocalPlayer;
     SpawnedInstance.PropDef            = prop.PropDef;
     if (HideInitially)
     {
         SpawnedInstance.gameObject.SetActive(value: false);
     }
     else
     {
         SpawnedInstance.StartExperience();
     }
     if (ApplyUserForwardVect)
     {
         SpawnedInstance.transform.forward = prop.PropUserRef.transform.forward;
     }
 }
示例#2
0
        public void LocalPlayerRetrieveProp(string propId)
        {
            if (LocalPlayerPropUser == null)
            {
                Log.LogError(this, "The local player was asked to retrieve a prop before the spawn event was raised");
            }
            else if (LocalPlayerPropUser.gameObject == null || LocalPlayerPropUser.gameObject.Equals(null))
            {
                Log.LogError(this, "The local player game object is not set");
            }
            else
            {
                if (dataEntityCollection.LocalPlayerSessionId == 0)
                {
                    return;
                }
                if (!Props.ContainsKey(propId))
                {
                    throw new InvalidOperationException("There is no prop definition for " + propId);
                }
                PropDefinition             propDefinition      = Props[propId];
                InvitationalItemExperience componentInChildren = LocalPlayerPropUser.GetComponentInChildren <InvitationalItemExperience>();
                if (componentInChildren != null)
                {
                    PropExperience componentInChildren2 = LocalPlayerPropUser.GetComponentInChildren <PropExperience>();
                    if (componentInChildren2 != null && componentInChildren2.PropDef != null && componentInChildren2.PropDef.Id.ToString() != propId)
                    {
                        Service.Get <EventDispatcher>().DispatchEvent(new InputEvents.ActionEvent(InputEvents.Actions.Cancel));
                    }
                }
                DHeldObject dHeldObject = new DHeldObject();
                dHeldObject.ObjectId = propId;
                switch (propDefinition.PropType)
                {
                case PropDefinition.PropTypes.Consumable:
                    dHeldObject.ObjectType = HeldObjectType.CONSUMABLE;
                    Service.Get <INetworkServicesManager>().ConsumableService.EquipItem(propId);
                    break;

                case PropDefinition.PropTypes.InteractiveObject:
                    dHeldObject.ObjectType = HeldObjectType.DISPENSABLE;
                    if (LocalPlayerPropUser.GetComponent <LocomotionBroadcaster>() != null)
                    {
                        Service.Get <INetworkServicesManager>().PlayerStateService.EquipDispensable(propDefinition.Id);
                    }
                    break;

                case PropDefinition.PropTypes.Durable:
                    dHeldObject.ObjectType = HeldObjectType.DURABLE;
                    Service.Get <INetworkServicesManager>().PlayerStateService.EquipDurable(propDefinition.Id);
                    break;
                }
                dataEntityCollection.GetComponent <HeldObjectsData>(dataEntityCollection.LocalPlayerHandle).HeldObject = dHeldObject;
            }
        }
示例#3
0
        private IEnumerator loadWorldExperience(ConsumableItem worldItem, Vector3 position)
        {
            AssetRequest <GameObject> assetRequest = Content.LoadAsync(getPropExperiencePathFromPropId(worldItem.Type));

            yield return(assetRequest);

            GameObject     experience        = UnityEngine.Object.Instantiate(assetRequest.Asset);
            PropExperience spawnedExperience = experience.GetComponent <PropExperience>();

            spawnedExperience.InstanceId         = worldItem.Id.Id.ToString();
            spawnedExperience.OwnerId            = worldItem.CreatorId;
            spawnedExperience.IsOwnerLocalPlayer = dataEntityCollection.LocalPlayerSessionId == worldItem.CreatorId;
            spawnedExperience.PropDef            = Props[worldItem.Type];
            spawnedExperience.transform.position = position;
            spawnedExperience.StartExperience();
        }
示例#4
0
        private IEnumerator loadPlayerHeldExperience(PlayerHeldItem playerHeldItem)
        {
            AssetRequest <GameObject> assetRequest = Content.LoadAsync(getPropExperiencePathFromPropId(playerHeldItem.Type));

            yield return(assetRequest);

            GameObject     experience        = UnityEngine.Object.Instantiate(assetRequest.Asset);
            PropExperience spawnedExperience = experience.GetComponent <PropExperience>();

            if (spawnedExperience != null)
            {
                spawnedExperience.InstanceId         = playerHeldItem.CreatorId.ToString();
                spawnedExperience.OwnerId            = playerHeldItem.CreatorId;
                spawnedExperience.IsOwnerLocalPlayer = dataEntityCollection.LocalPlayerSessionId == playerHeldItem.CreatorId;
                spawnedExperience.PropDef            = Props[playerHeldItem.Type];
                GameObject playerObject = getPlayerObject(playerHeldItem.CreatorId);
                if (!(playerObject == null))
                {
                    spawnedExperience.transform.SetParent(playerObject.transform, worldPositionStays: false);
                    spawnedExperience.StartExperience();
                }
            }
        }