コード例 #1
0
        void AddTurret(MiniCopter copter)
        {
            AutoTurret aturret = GameManager.server.CreateEntity(autoturretPrefab, copter.transform.position) as AutoTurret;

            DestroyMeshCollider(aturret);
            DestroyGroundComp(aturret);
            aturret.Spawn();
            aturret.pickup.enabled = false;
            aturret.sightRange     = config.turretRange;
            aturret.SetParent(copter);
            aturret.transform.localPosition = new Vector3(0, 0, 2.47f);
            aturret.transform.localRotation = Quaternion.Euler(0, 0, 0);
            ProtoBuf.PlayerNameID pnid   = new ProtoBuf.PlayerNameID();
            BasePlayer            player = BasePlayer.FindByID(copter.OwnerID);

            if (player != null)
            {
                pnid.userid   = player.userID;
                pnid.username = player?.displayName;
                aturret.authorizedPlayers.Add(pnid);
            }
            aturret.SendNetworkUpdate();
            AddSwitch(aturret);
        }