-
Notifications
You must be signed in to change notification settings - Fork 6
DISReceiveComponent
The DISReceiveComponent handles basic receiving DIS functionality.
It should be attached to actors where receiving DIS is desired.
By default the DISReceiveComponent offers packet handling for the associated DIS entity,
basic dead reckoning, basic ground clamping, and maintains a living list of appropriate
DIS variables (such as Entity ID).
public class DISReceiveComponent
: MonoBehaviour| Access | Type | Name | Description | |
|---|---|---|---|---|
| Public | bool | ApplyToOwner | To automatically apply entity states to the owner actor. | |
| Public | FEntityID | CurrentEntityID | A unique identifier to this entity in the sim. | |
| Public | EntityTypeEditor | CurrentEntityType | Specifies the kind of entity, the country of design, the domain, the specific identification of the entity, and any extra information necessary for describing the entity | |
| Public | float | DeadReckoningSmoothingPeriodSeconds | Number of seconds to smooth between dead reckoned information and packet information if dead reckoning is enabled | |
| Private | float | DeltaTimeSinceLastPDU | The time in seconds since the last PDU was received | |
| Public | float | DISCullingDistance | The distance in Unity units from the camera that culling should begin happening | |
| Private | Coroutine | DISHeartbeatCoroutine | A reference to the coroutine that checks whether or not the DIS entity has timed out. | |
| Public | DISGameManager | disGameManagerScript | A reference to the DISGameManager script | |
| Public | EDISCullingMode | DISCullingMode | Determines what all DIS info should be culled | |
| Public | float | DISTimeoutSeconds | The time to live for the entity. Gets reset every time a new Entity State PDU is received by the sim | |
| Private | Vector3Double | EntityECEFLocationDifference | The difference between the entity's current and previous ECEF locations | |
| Public | EForceID | EntityForceID | The Force ID of the associated entity. Specifies the team or side the DIS entity is on | |
| Public | string | EntityMarking | A friendly name for the DIS entity | |
| Private | Vector3 | EntityRotationDifference | The difference between the entity's current and previous rotations | |
| Private | GeoReferenceSystem | georeferenceScript | A reference to the GeoreferenceSystem script. | |
| Public | LayerMask | GroundClampingCollisionLayer | The layer mask to use for ground clamping | |
| Public | DateTime | LatestEntityStatePDUTimestamp | The timestamp that the most recent Entity State PDU was received at by the DISComponent | |
| Public | EntityStatePdu | MostRecentDeadReckoningPDU | The most recent Dead Reckoned Entity State PDU that has been calculated | |
| Public | EntityStatePdu | MostRecentEntityStatePDU | The most recent Entity State PDU that has been received | |
| Private | int | NumberEntityStatePDUsReceived | The number of entity state pdus that have been received for this entity | |
| Public | bool | PerformDeadReckoning | Whether or not dead reckoning should be performed for this entity | |
| Public | bool | PerformDeadReckoningSmoothing | Whether or not dead reckoning should be locally smoothed for this entity | |
| Public | EGroundClampingMode | PerformGroundClamping | Determines how this entity should be ground clamped | |
| Public | bool | SpawnedFromNetwork | Whether or not the associated entity was spawned by the network or not |
| Event Type | Event Name | Description |
|---|---|---|
| UnityEvent<EntityStatePdu> | OnDeadReckoningUpdate | Passes out an Entity State PDU with updated dead reckoning variables as a parameter |
| UnityEvent<DesignatorPdu> | OnDesignatorPDUProcessed | Called after a Designator PDU is processed |
| UnityEvent<DetonationPdu> | OnDetonationPDUProcessed | Called after a Detonation PDU is processed |
| UnityEvent<ElectronicEmissionsPdu> | OnElectronicEmissionsPDUProcessed | Called after an Electronic Emissions PDU is processed |
| UnityEvent<EntityStatePdu> | OnEntityStatePDUProcessed | Called after an Entity State PDU is processed |
| UnityEvent<EntityStateUpdatePdu> | OnEntityStateUpdatePDUProcessed | Called after an Entity State Update PDU is processed |
| UnityEvent<FirePdu> | OnFirePDUProcessed | Called after a Fire PDU is processed |
| UnityEvent<Vector3, Quaternion> | OnGroundClampingUpdate | Called after Ground Clamping is performed by the component. |
| UnityEvent<RemoveEntityPdu> | OnRemoveEntityPDUProcessed | Called after a RemoveEntity PDU is processed |
| UnityEvent<SignalPdu> | OnSignalPDUProcessed | Called after a Signal PDU is processed |
| UnityEvent<StartResumePdu> | OnStartResumePDUProcessed | Called after a Start/Resume PDU is processed |
| UnityEvent<StopFreezePdu> | OnStopFreezePDUProcessed | Called after a Stop/Freeze PDU is processed |
| Access | Return | Name | Description | |
|---|---|---|---|---|
| Public | void | ApplyToOwnerIfActivated(EntityStatePdu StatePDU) | Applies the location and rotation to the given Entity State PDU to the owning actor | |
| IEnumerator | DelayedDestroy(float timeToDelay) | Responsible for destroying a DIS entity that times out. | ||
| Public | void | DoDeadReckoning(float DeltaTime) | Calculates the dead reckoned PDU with given time DeltaTime | |
| Public | virtual | void | GroundClamping() | Clamps an entity to the ground |
| Public | void | HandleDesignatorPDU(DesignatorPdu DesignatorPDUIn) | Handles receipt of a new designator PDU | |
| Public | void | HandleDetonationPDU(DetonationPdu DetonationPDUIn) | Handles receipt of a new detonation PDU | |
| void | HandleDISHeartbeat() | Handles the coroutine responsible for timing out a DIS entity. | ||
| Public | void | HandleElectronicEmissionsPDU(ElectronicEmissionsPdu NewElectronicEmissionsPDU) | Handles receipt of a new electronic emissions PDU | |
| Public | void | HandleEntityStatePDU(EntityStatePdu NewEntityStatePDU) | Handles receipt of a new entity state PDU | |
| Public | void | HandleEntityStateUpdatePDU(EntityStatePdu NewEntityStateUpdatePDU) | Handles receipt of a new entity state update PDU | |
| Public | void | HandleFirePDU(FirePdu FirePDUIn) | Handles receipt of a new fire PDU | |
| double | Lerp(double a, double b, float t) | Returns a value that is a percentage of the way between two given values. | ||
| Public | void | HandleRemoveEntityPDU(RemoveEntityPdu RemoveEntityPDUIn) | Handles receipt of a new remove entity PDU | |
| Public | void | HandleSignalPDU(SignalPdu SignalPDUIn) | Handles receipt of a new signal PDU | |
| Public | void | HandleStartResumePDU(StartResumePdu StartResumePDUIn) | Handles receipt of a new start resume PDU | |
| Public | void | HandleStopFreezePDU(StopFreezePdu StopFreezePDUIn) | Handles receipt of a new stop freeze PDU | |
| float | MapRangeClamped(float Value, float InRangeA, float InRangeB, float OutRangeA, float OutRangeB) | Maps a given value between two numbers and clamps it to a given range. | ||
| Private | void | OnDestroy() | This function is called when the MonoBehaviour will be destroyed. | |
| Private | EntityStatePdu | SmoothDeadReckoning(EntityStatePdu DeadReckonPDUToSmooth) | Smooths the dead reckoned PDUs over a set time frame | |
| Private | void | Start() | Start is called on the frame when a script is enabled just before any of the Update methods are called the first time. | |
| Private | void | Update() | Update is called every frame, if the MonoBehaviour is enabled. | |
| void | UpdateCommoneEntityStateInfo(EntityStatePdu NewEntityStatePDU) | Updates information from an entity state PDU to this actor |
public bool ApplyToOwner = falseTo automatically apply entity states to the owner actor.
public FEntityID EntityIDThe Entity ID of the associated entity. Each Entity ID should be unique to an entity in the sim.
public EntityIDEditor EntityTypeThe Entity Type of the associated entity. Specifies the kind of entity, the country of design, the domain, the specific identification of the entity, and any extra information necessary for describing the entity.
public float DeadReckoningSmoothingPeriodSeconds = 0.5fNumber of seconds to smooth between dead reckoned information and packet information if dead reckoning is enabled.
private float DeltaTimeSinceLastPDU = 0.0fThe time in seconds since the last PDU was received.
public float DISCullingDistance = 0.0fThe distance in Unity units from the camera that culling should begin happening.
public EDISCullingMode DISCullingMode = EDISCullingMode.NoneDetermines what all DIS info should be culled. Allows for updates to happen less frequently for entities that aren't currently important.
The distance that culling should happen is handled by the DISCullingDistance variable.
private Coroutine DISHeartbeatCoroutineA reference to the DISGameManager script
public EDISCullingMode DISCullingMode = EDISCullingMode.NoneA reference to the coroutine that checks whether or not the DIS entity has timed out.
public float DISTimeoutSeconds = 30.0fThe time to live for the entity. Gets reset every time a new Entity State PDU is received by the sim.
Range: [0, 3600]
private Vector3Double EntityECEFLocationDifferenceThe difference between the entity's current and previous ECEF locations.
public EForceID EntityForceIDThe Force ID of the associated entity. Specifies the team or side the DIS entity is on.
public string EntityMarkingThe Entity Marking of the associated entity. Designates a friendly name for the DIS entity.
Max of 11 characters should be used. If more than 11 are used, it will be truncated.
private Vector3 EntityRotationDifferenceThe difference between the entity's current and previous rotations.
public GeoreferenceSystem georeferenceScriptA reference to the GeoreferenceSystem script.
public LayerMask GroundClampingCollisionLayer = 1The collision channel to use for ground clamping.
public DateTime LatestEntityStatePDUTimestampThe timestamp that the most recent Entity State PDU was received at by the DISComponent.
public EntityStatePdu MostRecentDeadReckoningPDUThe most recent Dead Reckoned Entity State PDU that has been calculated.
public EntityStatePdu MostRecentEntityStatePDUThe most recent Entity State PDU that has been received.
private int NumberEntityStatePDUsReceived = 0The number of entity state pdus that have been received for this entity.
public bool PerformDeadReckoning = trueWhether or not dead reckoning should be performed for this entity.
public bool PerformDeadReckoningSmoothing = trueWhether or not dead reckoning should be locally smoothed for this entity.
public EGroundClampingMode PerformGroundClamping = EGroundClampingMode.GroundClampWithDISOptionsDetermines how this entity should be ground clamped.
public bool SpawnedFromNetwork = falseWhether or not the associated entity was spawned by the network or not.
public UnityEvent<EntityStatePdu> OnDeadReckoningUpdateCalled after a dead reckoning update is performed by the component.
| Parameter | Description |
|---|---|
| EntityStatePdu | The new dead reckoned Entity State PDU to be passed to the listeners. |
public UnityEvent<DesignatorPdu> OnDesignatorPDUProcessedCalled after a Designator PDU is processed.
| Parameter | Description |
|---|---|
| DesignatorPDU | The Designator PDU to be passed to the listeners. |
public UnityEvent<DetonationPdu> OnDetonationPDUProcessedCalled after a Detonation PDU is processed.
| Parameter | Description |
|---|---|
| DetonationPDU | The Detonation PDU to be passed to the listeners. |
public UnityEvent<ElectronicEmissionsPdu> OnElectronicEmissionsPDUProcessedCalled after an Electronic Emissions PDU is processed.
| Parameter | Description |
|---|---|
| ElectronicEmissionsPDU | The Electronic Emissions PDU to be passed to the listeners. |
public UnityEvent<EntityStatePdu> OnEntityStatePDUProcessedCalled after an Entity State PDU is processed.
| Parameter | Description |
|---|---|
| EntityStatePDU | The Entity State PDU to be passed to the listeners. |
public UnityEvent<EntityStateUpdatePdu> OnEntityStateUpdatePDUProcessedCalled after an Entity State Update PDU is processed.
| Parameter | Description |
|---|---|
| EntityStateUpdatePDU | The Entity State Update PDU to be passed to the listeners. |
public UnityEvent<FirePdu> OnFirePDUProcessedCalled after a Fire PDU is processed.
| Parameter | Description |
|---|---|
| FirePDU | The Fire PDU to be passed to the listeners. |
public UnityEvent<Vector3, Quaternion> OnGroundClampingUpdateCalled after Ground Clamping is performed by the component. Passes ground clamp position and rotation as parameters.
NOTE: Gets called after receiving Entity State PDUs or finishing Dead Reckoning Updates if Ground Clamping is enabled on the DISComponent. Respective Entity State and Dead Reckoning events are called first. Implementing Ground Clamping location updates on top of these event may cause jitter in actor location.
| Parameter | Description |
|---|---|
| Vector3 | The location the entity should be ground clamped to. |
| Quaternion | The roation the entity should have after ground clamping. |
public UnityEvent<RemoveEntityPdu> OnRemoveEntityPDUProcessedCalled after a Remove Entity PDU is processed.
| Parameter | Description |
|---|---|
| RemoveEntityPDU | The Remove Entity PDU to be passed to the listeners. |
public UnityEvent<SignalPdu> OnSignalPDUProcessedCalled after a Signal PDU is processed.
| Parameter | Description |
|---|---|
| SignalPDU | The Signal PDU to be passed to the listeners. |
public UnityEvent<StartResumePdu> OnStartResumePDUProcessedCalled after a Start/Resume PDU is processed.
| Parameter | Description |
|---|---|
| StartResumePDU | The Start Resume PDU to be passed to the listeners. |
public UnityEvent<StopFreezePdu> OnStopFreezePDUProcessedCalled after a Stop/Freeze PDU is processed.
| Parameter | Description |
|---|---|
| StopFreezePDU | The Stop Freeze PDU to be passed to the listeners. |
void ApplyToOwnerIfActivated
(
EntityStatePdu StatePDU
)Applies the location and rotation to the given Entity State PDU to the owning actor
| Parameter | Description |
|---|---|
| StatePDU | The Entity State PDU that contains the location and rotation to apply to the owning actor. |
IEnumerator DelayedDestroy
(
float timeToDelay
)Responsible for destroying a DIS entity that times out.
| Parameter | Description |
|---|---|
| timeToDelay | The amount of time to delay destroying the game object for. |
| Returns |
|---|
| The yield instruction to return to the coroutine awaiting this function. |
public void DoDeadReckoning
(
float DeltaTime
)Calculates the dead reckoned PDU with given time DeltaTime.
| Parameter | Description |
|---|---|
| DeltaTime | The time since the last tick |
public virtual void GroundClamping()Clamps an entity to the ground. Should call OnGroundClampingUpdate event when finished.
double Lerp(double a, double b, float t)Returns a value that is a percentage of the way between two given values.
| Parameter | Description |
|---|---|
| a | Start value. Will be returned if t = 0. |
| b | End value. Will be returned if t = 1. |
| t | Value used to interpolate between a and b. |
| Returns |
|---|
| The lerped value. |
public void HandleDesignatorPDU
(
DesignatorPdu NewDesignatorPDU
)Handles receipt of a new designator PDU.
| Parameter | Description |
|---|---|
| NewDesignatorPDU | The designator PDU being handled |
public void HandleDetonationPDU
(
DetonationPdu NewDetonationPDU
)Handles receipt of a new detonation PDU.
| Parameter | Description |
|---|---|
| NewDetonationPDU | The detonation PDU being handled |
void HandleDISHeartbeat()Handles the coroutine responsible for timing out a DIS entity.
public void HandleElectronicEmissionsPDU
(
ElectronicEmissionsPdu NewElectronicEmissionsPDU
)Handles receipt of a new electronic emissions PDU.
| Parameter | Description |
|---|---|
| NewElectronicEmissionsPDU | The electronic emissions PDU being handled |
public void HandleEntityStatePDU
(
EntityStatePdu NewEntityStatePDU
)Handles receipt of a new entity state PDU.
| Parameter | Description |
|---|---|
| NewEntityStatePDU | The entity state PDU being handled |
public void HandleEntityStateUpdatePDU
(
EntityStateUpdatePdu NewEntityStateUpdatePDU
)Handles receipt of a new entity state update PDU.
| Parameter | Description |
|---|---|
| NewEntityStateUpdatePDU | The entity state update PDU being handled |
public void HandleFirePDU
(
FirePdu NewFirePDU
)Handles receipt of a new fire PDU.
| Parameter | Description |
|---|---|
| NewFirePDU | The fire PDU being handled |
public void HandleRemoveEntityPDU
(
RemoveEntityPdu NewRemoveEntityPDU
)Handles receipt of a new remove entity PDU.
| Parameter | Description |
|---|---|
| NewRemoveEntityPDU | The remove entity PDU being handled |
public void HandleSignalPDU
(
SignalPdu NewSignalPDUIn
)Handles receipt of a new Signal PDUs.
| Parameter | Description |
|---|---|
| NewSignalPDUIn | The Signal PDU being handled |
public void HandleStartResumePDU
(
StartResumePdu NewStartResumePDU
)Handles receipt of a new start resume PDU.
| Parameter | Description |
|---|---|
| NewStartResumePDU | The start/resume PDU being handled |
public void HandleStopFreezePDU
(
StopFreezePdu NewStopFreezePDU
)Handles receipt of a new stop freeze PDU.
| Parameter | Description |
|---|---|
| NewStopFreezePDU | The stop/freeze PDU being handled |
float MapRangeClamped
(
float Value,
float InRangeA,
float InRangeB,
float OutRangeA,
float OutRangeB
)Maps a given value between two numbers and clamps it to a given range.
| Parameter | Description |
|---|---|
| Value | The value to map and clamp. |
| InRangeA | Minimum value of the input value range. |
| InRangeB | Maximum value of the input value range. |
| OutRangeA | Minimum value of the output value range. |
| OutRangeB | Maximum value of the output value range. |
| Returns |
|---|
| The value that has been mapped and clamped. |
private void OnDestroy()This function is called when the MonoBehaviour will be destroyed.
EntityStatePdu SmoothDeadReckoning
(
EntityStatePdu DeadReckonPDUToSmooth
)Smooths the dead reckoned PDUs over a set time frame.
| Parameter | Description |
|---|---|
| DeadReckonPDUToSmooth | The dead reckoning pdu to use for this smoothing |
|Returns| |A new entity state PDU to use with smoothed values|
private void Start()Start is called on the frame when a script is enabled just before any of the Update methods are called the first time.
https://docs.unity3d.com/ScriptReference/MonoBehaviour.Start.html
void Update()Update is called every frame, if the MonoBehaviour is enabled.
https://docs.unity3d.com/ScriptReference/MonoBehaviour.Update.html
void UpdateCommonEntityStateInfo
(
EntityStatePdu NewEntityStatePDU
)Updates information from an entity state PDU to this actor.
| Parameter | Description |
|---|---|
| NewEntityStatePDU | The entity state PDU being handled |