Photon Bolt Engine API 1.3

Public Member Functions | Static Public Member Functions | Properties | List of all members
Photon.Bolt.LagCompensation.BoltPhysicsHits Class Reference

Container for a group of BoltPhysicsHits More...

Inheritance diagram for Photon.Bolt.LagCompensation.BoltPhysicsHits:
Photon.Bolt.BoltObject

Public Member Functions

void Dispose ()
 Implementing the IDisposable interface to allow "using" syntax. More...
 
BoltPhysicsHit GetHit (int index)
 Get the hit at a specific index More...
 

Static Public Member Functions

static implicit operator bool (BoltObject obj)
 

Properties

int count [get]
 How many hits we have in the collection More...
 
BoltPhysicsHit this[int index] [get]
 Array indexing of the hits in this object More...
 

Detailed Description

Container for a group of BoltPhysicsHits

Example: Using BoltNetwork.RaycastAll() to detect hit events and processing the BoltPhysicsHits object that is returned.

void FireWeaponOwner(PlayerCommand cmd, BoltEntity entity) {
if(entity.IsOwner) {
using(BoltPhysicsHits hits = BoltNetwork.RaycastAll(new Ray(entity.transform.position, cmd.Input.targetPos),
cmd.ServerFrame)) {
var hit = hits.GetHit(0);
var targetEntity = hit.body.GetComponent<BoltEntity>();
if(targetEntity.StateIs<ILivingEntity>()) {
targetEntity.GetState<ILivingEntity>().HP -= activeWeapon.damage;
}
}
}
}

Member Function Documentation

◆ Dispose()

void Photon.Bolt.LagCompensation.BoltPhysicsHits.Dispose ( )
inline

Implementing the IDisposable interface to allow "using" syntax.

Example: Implementing the Disponse() method allows BoltPhysicsHits to be in a "using" block.

void DoRaycast(Ray ray) {
using(BoltPhysicsHits hits = BoltNetwork.RaycastAll(ray)) {
// the hits variable will be automatically disposed at the end of this block
}
}

◆ GetHit()

BoltPhysicsHit Photon.Bolt.LagCompensation.BoltPhysicsHits.GetHit ( int  index)
inline

Get the hit at a specific index

Parameters
indexIndex position
Returns
The BoltPhysicsHit at the given index

Example: Using the GetHit method to find the first object hit by a weapon firing raycast.

void FireWeaponOwner(PlayerCommand cmd, BoltEntity entity) {
if(entity.IsOwner) {
using(BoltPhysicsHits hits = BoltNetwork.RaycastAll(new Ray(entity.transform.position, cmd.Input.targetPos),
cmd.ServerFrame))0 {
if(hit.count > 0) {
var hit = hits.GetHit(0);
var targetEntity = hit.body.GetComponent<BoltEntity>();
if(targetEntity.StateIs<ILivingEntity>()) {
targetEntity.GetState<ILivingEntity>().HP -= activeWeapon.damage;
}
}
}
}
}

◆ operator bool()

static implicit Photon.Bolt.BoltObject.operator bool ( BoltObject  obj)
inlinestaticinherited

Property Documentation

◆ count

int Photon.Bolt.LagCompensation.BoltPhysicsHits.count
get

How many hits we have in the collection

Example: Using the hit count to iterate through all hits

void OnOwner(PlayerCommand cmd, BoltEntity entity)
{
if (entity.IsOwner)
{
using (BoltPhysicsHits hits = BoltNetwork.RaycastAll(new Ray(entity.transform.position, cmd.Input.targetPos), cmd.ServerFrame))
{
for (int i = 0; i < hits.count; ++i)
{
var hit = hits.GetHit(i);
var targetEntity = hit.body.GetComponent<BoltEntity>();
if (targetEntity.StateIs<ILivingEntity>())
{
targetEntity.GetState<ILivingEntity>().HP -= activeWeapon.damage;
}
}
}
}
}

◆ this[int index]

BoltPhysicsHit Photon.Bolt.LagCompensation.BoltPhysicsHits.this[int index]
get

Array indexing of the hits in this object

Parameters
indexIndex position
Returns
The BoltPhysicsHit at the given index

Example: Using the array indexing to get the first object hit by a weapon firing raycast.

void FireWeaponOwner(PlayerCommand cmd, BoltEntity entity) {
if(entity.IsOwner) {
using(BoltPhysicsHits hits = BoltNetwork.RaycastAll(new Ray(entity.transform.position, cmd.Input.targetPos),
cmd.ServerFrame))0 {
if(hit.count > 0) {
var hit = hits[0];
var targetEntity = hit.body.GetComponent<BoltEntity>();
if(targetEntity.StateIs<ILivingEntity>()) {
targetEntity.GetState<ILivingEntity>().HP -= activeWeapon.damage;
}
}
}
}
}