예제 #1
0
        public SnapshotNetComponent(AOSClient client)
            : base(client)
        {
            snapshotSystem     = new SnapshotSystem(client);
            charSnapshotSystem = new CharacterSnapshotSystem(this, snapshotSystem);

            objectComponent = client.GetComponent <ObjectNetComponent>();
            objectComponent.OnCreatableInstantiated += ObjectComponent_OnCreatableInstantiated;
            objectComponent.OnCreatableDestroyed    += ObjectComponent_OnCreatableDestroyed;

            DashCMD.AddScreen(new DashCMDScreen("snapshot", "Displays information about the snapshot system.", true,
                                                (screen) =>
            {
                screen.WriteLine("Snapshot Round-Trip Time: {0}s", rtt);
                screen.WriteLine("Last Outbound Snapshot:", ConsoleColor.Cyan);
                screen.WriteLine("PacketHeader: {0} bytes", lastOutboundPacketStats.PacketHeader);
                screen.WriteLine("Acks: {0} bytes", lastOutboundPacketStats.Acks);
                screen.WriteLine("PlayerData: {0} bytes", lastOutboundPacketStats.PlayerData);
                screen.WriteLine("Total: {0} bytes", lastOutboundPacketStats.Total);
            })
            {
                SleepTime = 30
            });

            DashCMD.SetCVar("cl_tickrate", DEFAULT_TICKRATE);
            DashCMD.SetCVar("cl_await_sv_snap", false);

            //DashCMD.SetCVar("cl_tickrate", 25);
            //DashCMD.SetCVar("cl_await_sv_snap", true);

            syncTime = tickrate;
        }
        public ClientMPPlayer(MasterRenderer renderer, World world, Camera camera, Vector3 position, Team team)
            : base(renderer, world, camera, position, team)
        {
            this.camera = camera;
            camfx       = new CameraFX(this, camera);

            // Setup ClientInput Snapshot
            AOSClient            client = AOSClient.Instance;
            SnapshotNetComponent snc    = client.GetComponent <SnapshotNetComponent>();
            SnapshotSystem       ss     = snc.SnapshotSystem;

            ClientSnapshot = new ClientPlayerSnapshot(ss, client.ServerConnection);

            Camera.Active.FOV = Camera.Active.DefaultFOV;
            Camera.Active.FPSMouseSensitivity     = Camera.Active.DefaultFPSMouseSensitivity;
            Camera.Active.ArcBallMouseSensitivity = Camera.Active.DefaultArcBallMouseSensitivity;

            CreateStarterBackpack();

            AudioBuffer hitAudioBuffer = AssetManager.LoadSound("Impacts/hit-player-local.wav");

            if (hitAudioBuffer != null)
            {
                hitAudioSource = new AudioSource(hitAudioBuffer);
                hitAudioSource.IsSourceRelative = true;
                hitAudioSource.Gain             = 0.2f;
            }

            AudioBuffer flashlightAudioBuffer = AssetManager.LoadSound("Player/flashlight.wav");

            if (flashlightAudioBuffer != null)
            {
                flashlightAudioSource = new AudioSource(flashlightAudioBuffer);
                flashlightAudioSource.IsSourceRelative = true;
                flashlightAudioSource.Gain             = 0.2f;
            }

            AudioBuffer jumpAudioBuffer = AssetManager.LoadSound("Player/jump.wav");

            if (jumpAudioBuffer != null)
            {
                jumpAudioSource = new AudioSource(jumpAudioBuffer);
                jumpAudioSource.IsSourceRelative = true;
                jumpAudioSource.Gain             = 0.2f;
            }

            AudioBuffer landAudioBuffer = AssetManager.LoadSound("Player/land.wav");

            if (landAudioBuffer != null)
            {
                landAudioSource = new AudioSource(landAudioBuffer);
                landAudioSource.IsSourceRelative = true;
                landAudioSource.Gain             = 0.2f;
            }

            walkingAudioSource = new CyclicAudioSource("Player/footstep.wav", 8, 0f);
            runningAudioSource = new CyclicAudioSource("Player/run.wav", 12, 0f);
        }
        public NetPlayerComponent(AOSClient client)
            : base(client)
        {
            netPlayers = new Dictionary <ushort, NetworkPlayer>();

            channel           = client.GetChannel(AOSChannelType.NetInterface);
            snapshotComponent = client.GetComponent <SnapshotNetComponent>();

            channel.AddRemoteEvent("Client_AddNetPlayer", R_AddNetPlayer);
            channel.AddRemoteEvent("Client_RemoveNetPlayer", R_RemoveNetPlayer);
            channel.AddRemoteEvent("Client_AddInitialNetPlayers", R_AddInitialNetPlayers);
        }
예제 #4
0
        public MPWorld(MasterRenderer renderer)
            : base(renderer)
        {
            players      = new Dictionary <ushort, ClientPlayer>();
            physEntities = new Dictionary <ushort, GameObject>();
            TimeOfDay    = 10;

            // Grab network components and the world channel
            client            = AOSClient.Instance;
            snapshotComponent = client.GetComponent <SnapshotNetComponent>();
            objectComponent   = client.GetComponent <ObjectNetComponent>();
            channel           = client.GetChannel(AOSChannelType.World);

            // Add remotes
            channel.AddRemoteEvent("Client_ThrowGrenade", R_ThrowGrenade);
            channel.AddRemoteEvent("Client_ShootMelon", R_ShootMelon);
            channel.AddRemoteEvent("Client_ServerImpact", R_ServerImpact);
            channel.AddRemoteEvent("Client_RolledBackServerPlayer", R_RolledBackServerPlayer);

            // Hook into component events
            objectComponent.OnCreatableInstantiated  += ObjectComponent_OnCreatableInstantiated;
            objectComponent.OnCreatableDestroyed     += ObjectComponent_OnCreatableDestroyed;
            snapshotComponent.OnWorldSnapshotInbound += SnapshotComponent_OnWorldSnapshotInbound;
        }