PUN Classic (v1)、PUN 2 和 Bolt 處於維護模式。 PUN 2 將支援 Unity 2019 至 2022,但不會添加新功能。 當然,您所有的 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