Esempio n. 1
0
        protected void OnTriggerEnter(Collider other)
        {
            if (BoltNetwork.IsClient && entity.isAttached && entity.isOwner)
            {
                if (other.gameObject.CompareTag(Constants.Tag.KartTrigger) && !other.GetComponentInParent <BoltEntity>().isOwner)
                {
                    //  Debug.LogError("LOCAL HIT : SENT TO SERVER TO CHECK");
                    boltHitboxBody = GetComponentInParent <BoltHitboxBody>();

                    foreach (BoltHitbox hitbox in boltHitboxBody.hitboxes)
                    {
                        ItemCollsionLagCompensationEvent itemsLagCheckEvent = ItemCollsionLagCompensationEvent.Create();
                        itemsLagCheckEvent.ItemBoltEntity         = GetComponentInParent <BoltEntity>();
                        itemsLagCheckEvent.TargetBoltEntity       = other.GetComponentInParent <BoltEntity>();
                        itemsLagCheckEvent.FramesToRewind         = 15;
                        itemsLagCheckEvent.CollisionDistanceCheck = _collisionDistanceCheck;
                        itemsLagCheckEvent.ItemCollsionPosition   = hitbox.transform.position;
                        itemsLagCheckEvent.Send();
                    }
                }
            }
            else if (BoltNetwork.IsServer)
            {
                if (other.gameObject.CompareTag(Constants.Tag.KartTrigger) && !other.GetComponentInParent <BoltEntity>().isOwner)
                {
                    //    Debug.LogError("LOCAL HIT BY SERVER");
                    boltHitboxBody = GetComponentInParent <BoltHitboxBody>();

                    foreach (BoltHitbox hitbox in boltHitboxBody.hitboxes)
                    {
                        ItemCollsionLagCompensationEvent itemsLagCheckEvent = ItemCollsionLagCompensationEvent.Create();
                        itemsLagCheckEvent.ItemBoltEntity         = GetComponentInParent <BoltEntity>();
                        itemsLagCheckEvent.TargetBoltEntity       = other.GetComponentInParent <BoltEntity>();
                        itemsLagCheckEvent.FramesToRewind         = 15;
                        itemsLagCheckEvent.CollisionDistanceCheck = _collisionDistanceCheck;
                        itemsLagCheckEvent.ItemCollsionPosition   = hitbox.transform.position;
                        itemsLagCheckEvent.Send();
                    }
                }
            }
        }
Esempio n. 2
0
        //BOLT

        public override void OnEvent(ItemCollsionLagCompensationEvent evnt)
        {
            if (BoltNetwork.IsServer && evnt.TargetBoltEntity == GetComponentInParent <BoltEntity>())
            {
                try
                {
                    int ping = SWPing.GetPingAliasedForPlayer(evnt.ItemBoltEntity.GetComponent <Ownership>().OwnerID);
                    if (ping <= 1)
                    {
                        framesToRewind = 0;
                    }
                    else if (ping >= 2 && ping <= 20)
                    {
                        framesToRewind = 5;
                    }
                    else if (ping >= 21 && ping <= 45)
                    {
                        framesToRewind = 10;
                    }
                    else if (ping >= 46 && ping <= 75)
                    {
                        framesToRewind = 15;
                    }
                    else if (ping >= 76 && ping <= 125)
                    {
                        framesToRewind = 20;
                    }
                    else
                    {
                        framesToRewind = 25;
                    }

                    ServerCollisionCheck(evnt.ItemCollsionPosition, evnt.ItemBoltEntity, evnt.TargetBoltEntity, framesToRewind, evnt.CollisionDistanceCheck);
                }
                catch (System.NullReferenceException)
                {
                    Debug.LogError("Player Ownership not set - Number of frames to REWIND : 0 ");
                }
            }
        }