Ejemplo n.º 1
0
        public static async Task Load(this AtlasCharacter character)
        {
            var player = Cache.Player;
            var style  = character.Style;

            await style.Commit(player);

            StyleManager.GetModule().Cache(style);

            var voice = VoiceChat.GetModule();

            voice.Range = VoiceChatRange.Normal;
            voice.Commit();
        }
Ejemplo n.º 2
0
        public static void Reload(int session = 0)
        {
            var entity = Cache.Entity;

            if (session == 0)
            {
                var decors = new EntityDecorModule
                {
                    Id     = entity.Id,
                    Entity = entity
                };

                session = decors.GetInteger("Session");
            }

            for (var i = 0; i < AtlasPlugin.MaximumPlayers; i++)
            {
                var ped = API.GetPlayerPed(i);

                if (!API.DoesEntityExist(ped) || ped == API.GetPlayerPed(-1))
                {
                    continue;
                }

                var decors = new EntityDecorModule
                {
                    Id = ped
                };

                Modify(ped, session == decors.GetInteger("Session"));
            }

            var voice = VoiceChat.GetModule();

            voice.Channel = session;
            voice.Commit();
        }
Ejemplo n.º 3
0
        public override async void Begin()
        {
            API.NetworkClearVoiceChannel();
            API.NetworkSetTalkerProximity(0.1f);
            API.NetworkSetFriendlyFireOption(true);
            API.SetCanAttackFriendly(API.PlayerPedId(), true, true);
            API.StopPlayerSwitch();

            var sound  = new SoundSystem();
            var handle = API.GetPlayerServerId(API.PlayerId());

            sound.Disable();

            await Game.Player.ChangeModel(new Model(API.GetHashKey("mp_m_freemode_01")));

            var ped = Game.PlayerPed.Handle;

            API.RemoveAllPedWeapons(ped, false);
            API.ClearPedTasksImmediately(ped);
            API.ClearPlayerWantedLevel(API.PlayerId());
            API.SetEntityVisible(ped, true, true);
            API.SetEntityHealth(ped, API.GetEntityMaxHealth(ped));
            API.NetworkResurrectLocalPlayer(0, 0, 70f, 0f, true, false);
            API.FreezeEntityPosition(ped, false);
            API.SendLoadingScreenMessage(new JsonBuilder().Add("eventName", "UPDATE_STATUS").Add("status", "Laddar in användare").Build());

            var transition = new CharacterManager.LoadTransition();
            var user       = await EventSystem.Request <AtlasUser>("user:login");

            var payloads = new Dictionary <string, string>();

            try
            {
                payloads = JsonConvert.DeserializeObject <Dictionary <string, string> >(
                    (await EventSystem.Request <object>("network:package:latest")).ToString());
            }
            catch (Exception)
            {
                // Ignored
            }

            var package = NetworkPackage.GetModule();

            foreach (var payload in payloads)
            {
                package.Payloads[payload.Key] = JsonConvert.DeserializeObject <NetworkPayload <object> >(payload.Value);
            }

            Logger.Info($"[User] [{user.Seed}] Creating local player...");

            Atlas.Local = new AtlasPlayer(user.SteamId, new AtlasEntity(ped))
            {
                Handle = handle,
                Name   = user.LastName,
                User   = user
            };

            var voice = VoiceChat.GetModule();

            voice.Range = 0f;
            voice.Commit();

            Atlas.AttachTickHandlers(voice);
            Atlas.Local.DisableHud();

            Logger.Info(
                $"[User] [{user.Seed}] Logged into the server with the role `{user.Role.ToString()}` and metadata: {JsonConvert.SerializeObject(user.Metadata)}");

#pragma warning disable 4014
            transition.Up(Atlas.Local);
#pragma warning restore 4014

            // Synchronize characters with the server-side, that is fetching from the database.
            await CharacterManager.GetModule().Synchronize();
        }
Ejemplo n.º 4
0
        public override void OnInspectorGUI()
        {
            #region Core
            base.OnInspectorGUI();
            VoiceChat vc = (VoiceChat)target;
            DrawTitleBar(
                "Voice Chat",
                "If this component is... " +
                "\n" +
                "...not for a player...\n" +
                "This is for a peristant object. This should be made a child object of the \"NetworkManager\" gameobject." +
                " This needs to have a \"Recorder\" & \"PhotonVoiceNetwork\" components attached. This is designed to " +
                "record the owner and send that voice recording over the network. This will display special icons and " +
                "invoke other things based on the state of the voice connection.\n" +
                "\n" +
                "...for a player...\n" +
                "This requires a \"Speaker\" & \"PhotonVoiceView\" components attached. This will display an icon when " +
                "voice from another player is playing through the \"Speaker\" component. Adjust the generated \"AudioSource\" " +
                "component to 2D if you want global room chat or 3D for proximity based chat. The \"Recorder In Use\" field " +
                "on the \"PhotonVoiceView\" will be auto populate by finding the \"Recorder\" component in the scene.",
                E_Core.h_voiceIcon
                );
            #endregion

            EditorGUILayout.BeginHorizontal(_skin.box);
            EditorGUILayout.PropertyField(isPlayer);
            EditorGUILayout.EndHorizontal();
            if (isPlayer.boolValue == true)
            {
                EditorGUILayout.PropertyField(ifOnTeam);
                EditorGUILayout.PropertyField(speakerImage);
            }
            else
            {
                EditorGUILayout.PropertyField(debugging);
                EditorGUILayout.PropertyField(recordingImage);
                EditorGUILayout.PropertyField(pushToTalk);
                if (!availableInputs.Contains(buttonToPress.stringValue))
                {
                    EditorGUILayout.PropertyField(buttonToPress);
                    EditorGUILayout.HelpBox("The Button To Press value: \"" + buttonToPress.stringValue + "\" doesn't exist. " +
                                            "To fix this go to your Project Settings > Input and add this key name.", MessageType.Error);
                }
                else
                {
                    selectedButton            = availableInputs.IndexOf(buttonToPress.stringValue);
                    selectedButton            = EditorGUILayout.Popup("Button To Hold", selectedButton, availableInputs.ToArray());
                    buttonToPress.stringValue = availableInputs[selectedButton];
                }

                GUI.skin = _original;
                CBEditor.SetColorToEditorStyle(_originalHolder, _originalFoldout);
                EditorGUILayout.HelpBox("Called when successfully connected/disconnected from the master voice server.", MessageType.None);
                EditorGUILayout.PropertyField(OnConnectedToServer, true);
                EditorGUILayout.PropertyField(OnDisconnect, true);
                EditorGUILayout.HelpBox("Called when successfully joined ANY chat room.", MessageType.None);
                EditorGUILayout.PropertyField(OnJoinRoom, true);
                EditorGUILayout.HelpBox("Called once when this component is first loaded in a scene.", MessageType.None);
                EditorGUILayout.PropertyField(OnStart, true);
                GUI.skin = _skin;
                CBEditor.SetColorToEditorStyle(_skinHolder, _skinHolder);
                EditorGUILayout.Space();
            }

            EndInspectorGUI(typeof(VoiceChat));
        }
Ejemplo n.º 5
0
        public void ChangeCodification(VoiceChat.Library.Common.VoiceCommon.Vocoder codification)
        {
            if (codification == VoiceCommon.Vocoder.ALaw)
            {
                vocoder = VoiceCommon.Vocoder.ALaw;
                cGlobalVars.AddLogChat("Se ha modificado codificación a: ALaw");

            }
            else if (codification == VoiceCommon.Vocoder.uLaw)
            {
                vocoder = VoiceCommon.Vocoder.uLaw;
                cGlobalVars.AddLogChat("Se ha modificado codificación a: uLaw");

            }
            else
            {
                vocoder = VoiceCommon.Vocoder.None;
                cGlobalVars.AddLogChat("Se ha modificado codificación a: None");

            }
        }
Ejemplo n.º 6
0
 /// <summary>
 ///   Play a voice chat.
 ///   - nVoiceChatID: VOICE_CHAT_*
 ///   - oTarget
 /// </summary>
 public static void PlayVoiceChat(VoiceChat nVoiceChatID, uint oTarget = OBJECT_INVALID)
 {
     Internal.NativeFunctions.StackPushObject(oTarget);
     Internal.NativeFunctions.StackPushInteger((int)nVoiceChatID);
     Internal.NativeFunctions.CallBuiltIn(421);
 }