Ejemplo n.º 1
0
    void OnTriggerStay2D(Collider2D target)
    {
        if (target.tag == "Enemy")
        {
            if (delayTime <= 0)
            {
                BasePlayerWeapon proj = Instantiate(projectile.gameObject,
                                                    player.gameObject.transform.position,
                                                    Quaternion.identity).GetComponent <BasePlayerWeapon>();

                proj.SetTargetPosition(target.transform.position);

                delayTime = TimeToSpawn;
            }
            else
            {
                delayTime -= Time.deltaTime;
            }
        }
    }
Ejemplo n.º 2
0
        public void UpdateClientData(Edict ent, bool sendWeapons, ClientData cd)
        {
            if (ent == null || ent.PrivateData == null)
            {
                return;
            }

            var player = ent.TryGetEntity <BasePlayer>();

            BasePlayer originalPlayer = null;

            // if user is spectating different player in First person, override some vars
            if (player?.pev.UserInt1 == (int)ObserverMode.InEye && player.m_hObserverTarget)
            {
                originalPlayer = player;
                player         = player.m_hObserverTarget;
            }

            cd.Flags  = player.Flags;
            cd.Health = player.Health;

            cd.ViewModel = EngineModel.IndexOf(player.ViewModelName);

            cd.WaterLevel = player.WaterLevel;
            cd.WaterType  = player.WaterType;
            cd.Weapons    = player.pev.Weapons;

            // Vectors
            cd.Origin     = player.Origin;
            cd.Velocity   = player.Velocity;
            cd.ViewOffset = player.ViewOffset;
            cd.PunchAngle = player.PunchAngle;

            cd.InDuck        = player.pev.InDuck;
            cd.TimeStepSound = player.pev.TimeStepSound;
            cd.DuckTime      = player.pev.DuckTime;
            cd.SwimTime      = player.pev.SwimTime;
            cd.WaterJumpTime = (int)player.pev.TeleportTime;

            cd.SetPhysInfo(EngineServer.GetUnmanagedClientPhysicsInfoBuffer(ent));

            cd.MaxSpeed    = player.pev.MaxSpeed;
            cd.FieldOfView = player.pev.FieldOfView;
            cd.WeaponAnim  = player.pev.WeaponAnim;

            cd.PushMSec = player.pev.PushMSec;

            //Spectator mode
            if (originalPlayer != null)
            {
                // don't use spec vars from chased player
                cd.UserInt1 = originalPlayer.pev.UserInt1;
                cd.UserInt2 = originalPlayer.pev.UserInt2;
            }
            else
            {
                cd.UserInt1 = player.pev.UserInt1;
                cd.UserInt2 = player.pev.UserInt2;
            }

#if CLIENT_WEAPONS
            if (sendWeapons && player != null)
            {
                cd.NextAttack = player.m_flNextAttack;
                cd.UserFloat2 = player.m_flNextAmmoBurn;
                cd.UserFloat3 = player.m_flAmmoStartCharge;

                cd.UserVector1 = new Vector(
                    player.ammo_9mm,
                    player.ammo_357,
                    player.ammo_argrens
                    );

                cd.AmmoNails   = player.ammo_bolts;
                cd.AmmoShells  = player.ammo_buckshot;
                cd.AmmoRockets = player.ammo_rockets;
                cd.AmmoCells   = player.ammo_uranium;
                var vector2 = cd.UserVector2;
                vector2.x      = player.ammo_hornets;
                cd.UserVector2 = vector2;

                if (player.m_pActiveItem != null)
                {
                    BasePlayerWeapon gun = player.m_pActiveItem as BasePlayerWeapon;

                    if (gun?.IsPredicted() == true)
                    {
                        //TODO:
#if false
                        ItemInfo II;
                        memset(&II, 0, sizeof(II));
                        gun.GetItemInfo(&II);

                        cd.m_iId = II.iId;

                        cd.vuser3.z = gun.m_iSecondaryAmmoType;
                        cd.vuser4.x = gun.m_iPrimaryAmmoType;
                        cd.vuser4.y = player.m_rgAmmo[gun.m_iPrimaryAmmoType];
                        cd.vuser4.z = player.m_rgAmmo[gun.m_iSecondaryAmmoType];

                        if (player.m_pActiveItem.m_iId == WEAPON_RPG)
                        {
                            cd.vuser2.y = ((Rpg)player.m_pActiveItem).m_fSpotActive;
                            cd.vuser2.z = ((Rpg)player.m_pActiveItem).m_cActiveRockets;
                        }
#endif
                    }
                }
            }
#endif
        }