Beispiel #1
0
        static void OnCreeperSyncMsg(NetworkMessage msg)
        {
            CreeperSyncExplode.m_allow_explosions = false;
            var proj_msg  = msg.ReadMessage <ProjUpdateMsg>();
            var count     = proj_msg.m_num_proj_info;
            var proj_info = proj_msg.m_proj_info;

            for (int i = 0; i < count; i++)
            {
                var proj = MPCreeperSync.FindSyncedProjectile(proj_info[i].m_id, new ProjPrefab[] { ProjPrefab.missile_creeper, ProjPrefab.missile_timebomb });
                if (proj == null)
                {
                    continue;
                }
                var   diff    = proj_info[i].m_pos - proj.transform.position;
                float sqrDiff = diff.sqrMagnitude;

                var rigidbody = proj.c_rigidbody;

                // slow down just fired projectile to move to ping-delayed server pos
                if (proj.m_owner_player.isLocalPlayer)
                {
                    float age = Time.time - proj.m_create_time;
                    if (age < 1f)
                    {
                        if (age < .6f && Vector3.Dot(proj.transform.forward, diff) < 0 && sqrDiff > 0.2f)
                        {
                            rigidbody.velocity *= .8f;
                        }
                        else
                        {
                            rigidbody.velocity = proj_info[i].m_vel + diff / (1.1f - age);
                        }
                        return;
                    }
                }
                if (sqrDiff > 0.01f)
                {
                    rigidbody.MovePosition(proj_info[i].m_pos);
                }
                rigidbody.velocity = proj_info[i].m_vel;
            }
        }
Beispiel #2
0
        static void OnExplodeMsg(NetworkMessage msg)
        {
            var explode_msg = msg.ReadMessage <ExplodeMsg>();

            if (Server.IsActive())
            {
                return;
            }
            var proj = MPCreeperSync.FindSyncedProjectile(explode_msg.m_id, new ProjPrefab[] { ProjPrefab.missile_creeper, ProjPrefab.missile_timebomb, ProjPrefab.missile_devastator, ProjPrefab.missile_smart }); // Extend to devastators and novas when sniper packets are enabled.

            if (proj == null)
            {
                return;
            }
            proj.c_rigidbody.MovePosition(explode_msg.m_pos);
            CreeperSyncExplode.m_allow_explosions = true;
            proj.Explode(explode_msg.m_damaged_something);
            CreeperSyncExplode.m_allow_explosions = false;
        }