PUN Classic (v1)、PUN 2、Boltはメンテナンスモードとなっております。Unity2022についてはPUN 2でサポートいたしますが、新機能が追加されることはありません。お客様のPUNプロジェクトおよびBoltプロジェクトが停止することはなく、将来にわたってパフォーマンス性能が落ちることはありません。 今後の新しいプロジェクトについては、Photon FusionまたはQuantumへ切り替えていただくようよろしくお願いいたします。

IPriorityCalculator

IPriorityCalculator lets you set the priority for state replication and entity events. For games with a big map with lots going on, you will not be able to fit bytes for every state and entity event you want to send. Return zero for nothing to be sent.

C#

public class EnemyController : Bolt.EntityEventListener<IEnemyTest>, Bolt.IPriorityCalculator
{
    /**
     * Calculates the Priority of a State update
     * be sent into a package
     * @param  connection Target player connection
     * @param  skipped    Total times the data was skipped
     *                    on the packing process
     * @return            The priority number
     */
    public float CalculateStatePriority(BoltConnection connection, int skipped)
    {
        // default implementation
        // return skipped;

        // returns priority based off
        // of distance to connection's player
        return 1000 - myDistanceTo(connection) + skipped;
    }

    /**
     * Calculates the Priority of a Event
     * be sent into a package
     * @param  connection Target player connection
     * @param  evnt       The event to be sent
     * @return            The priority number
     */
    public float CalculateEventPriority(BoltConnection connection, Bolt.Event evnt)
    {
        // this enemy has entity events for sounds, so this will 
        // always be low priority but will be higher priority than 
        // other sounds based on distance to connection's player
        // myDistance has a maximum of 1000 in this example
        return (1-(myDistanceTo(connection) / 1000f));
    }
}
Back to top