1. Alex_Wells

    Alex_Wells Naked Wanderer

    Hey! I've found VisualCupboard plugin and I like the idea, but realization is quite poor. So I've rewritten it and now I'm stuck with adding an object visible only for one player - command caller. So here's a part of code I've stolen from original plugin:

    Code (Text):
    class ToolCupboardSphere : MonoBehaviour
        {
            BaseEntity sphere;
            BaseEntity entity;

            Vector3 pos = new Vector3(0, 0, 0);
            Quaternion rot = new Quaternion();
            string strPrefab = "assets/prefabs/visualization/sphere.prefab";

            void Awake()
            {
                entity = GetComponent<BaseEntity>();
                sphere = GameManager.server.CreateEntity(strPrefab, pos, rot);
                SphereEntity ball = sphere.GetComponent<SphereEntity>();
                ball.currentRadius = 1f;
                ball.lerpRadius = 2.0f * VisualCupboards.cupboardRadius;
                ball.lerpSpeed = 100f;

                sphere.SetParent(entity, "");
                sphere?.Spawn();
            }

            void OnDestroy()
            {
                if (sphere == null) return;
                sphere.Kill();
            }
        }
    And now I need to make it visible for command caller only.
     
  2. JoeSheep

    JoeSheep Shack Builder Plugin Developer

    You may wish to make use of the CanNetworkTo hook to check if that sphere should be networking with the player it is trying to.
     
    Alex_Wells likes this.
  3. Colon Blow

    Colon Blow Airdrop Stalker Plugin Developer

    yes, JoeSheep is correct, the CanNetworkTo hook is what you need.

    But I will have a new version of VisualCupboard after tomorrows update that does include this very feature :)
    I know a lot of players have been asking for only the owner of cupboard to see the spheres. its something I have been slowly working on.
     
    Alex_Wells likes this.
  4. JoeSheep

    JoeSheep Shack Builder Plugin Developer

    I look forward to that :)
     
  5. Alex_Wells

    Alex_Wells Naked Wanderer

    Yea, that would be cool, but I've also rewritten the code and /showsphere + /killsphere commands to single command: /cupboards <delay 3-60>, which toggles them and no more /killsphere.
    --- Double Post Merged, Apr 20, 2017 ---
    Thanks =)
     
    Colon Blow likes this.