Esempio n. 1
0
    private void SetToolEffectName(string name)
    {
        Debug.Assert(name != null);

        if (currentToolEffectName != name)
        {
            // Need to change the instance.
            DestroyToolEffectReplicant();
            currentToolEffectName = name;

            Util.Log($"new tool effect name: {name}");

            foreach (var prefab in toolEffectPrefabs)
            {
                if (currentToolEffectName.Contains(prefab.name))
                {
                    GameObject inst = GameObject.Instantiate(prefab, Vector3.zero, Quaternion.identity);
                    toolEffectReplicant = inst.GetComponent <NetworkableToolEffect>();

                    // YOLO. Assume it's an on-actor effect.
                    if (toolEffectReplicant == null)
                    {
                        toolEffectReplicant = new OnActorToolEffect(inst);
                    }

                    toolEffectReplicant.SetSpatialAudio(true);
                    toolEffectReplicant.SetRayOriginTransform(toolEmissionAnchor);
                    toolEffectReplicant.SetTint(currentTint);
                    break;
                }
            }

            // Note that it is OK if at this point, currentToolEffectInstance is null. That just means we don't support networking that effect.
        }
    }
Esempio n. 2
0
 void DestroyToolEffectReplicant()
 {
     if (toolEffectReplicant != null)
     {
         GameObject.Destroy(toolEffectReplicant.GetGameObject());
         toolEffectReplicant = null;
     }
 }
Esempio n. 3
0
    void LateUpdate()
    {
#if USE_PUN
        if (!isLocalPlayer && toolEffectReplicant != null)
        {
            NetworkableToolEffect effect = toolEffectReplicant;
            if (receivedToolTargetViewId >= 0)
            {
                // Find the target actor, shoot a ray at it, and have the tool effect end there.
                PhotonView view        = PhotonView.Find(receivedToolTargetViewId);
                VoosActor  targetActor = view?.GetComponent <VoosActor>();
                effect.SetReceivedTargetActor(targetActor);
            }
            else
            {
                effect.SetReceivedTargetActor(null);
            }
            effect.OnLateUpdate();
        }
#endif
    }