Beispiel #1
0
        /// <summary>
        /// Copy this instance for multi-threading use.
        /// </summary>
        public Player Copy()
        {
            Player me = new Player();

            me.EntityID = -1;             //this should bot be copied
            me.Entity   = null;

            me.Name    = Name;
            me.SteamID = SteamID;
            me.HP      = HP;
            me.Armor   = Armor;

            me.ViewDirectionX = ViewDirectionX;
            me.ViewDirectionY = ViewDirectionY;
            me.Disconnected   = Disconnected;
            me.FlashDuration  = FlashDuration;

            me.Team = Team;

            me.ActiveWeaponID = ActiveWeaponID;
            me.rawWeapons     = new Dictionary <int, Equipment>(rawWeapons);

            me.HasDefuseKit = HasDefuseKit;
            me.HasHelmet    = HasHelmet;

            if (Position != null)
            {
                me.Position = Position.Copy();                 //Vector is a class, not a struct - thus we need to make it thread-safe.
            }
            if (LastAlivePosition != null)
            {
                me.LastAlivePosition = LastAlivePosition.Copy();
            }

            if (Velocity != null)
            {
                me.Velocity = Velocity.Copy();
            }

            if (ViewOffset != null)
            {
                me.ViewOffset = ViewOffset.Copy();
            }

            if (AimPunchAngle != null)
            {
                me.AimPunchAngle = AimPunchAngle.Copy();
            }

            return(me);
        }
Beispiel #2
0
    public void CopyTimeTrackerState(ITimeTracker other)
    {
        PlayerController otherPlayer = other as PlayerController;

        if (otherPlayer != null)
        {
            Position.Copy(otherPlayer.Position);
            Velocity.Copy(otherPlayer.Velocity);
        }
        else
        {
            gameController.LogError($"Cannot copy state from {other.GetType()} to {nameof(PlayerController)}");
        }
    }
Beispiel #3
0
        /// <summary>
        ///     Copy this instance for multi-threading use.
        /// </summary>
        public Player Copy()
        {
            var me = new Player
            {
                EntityID = -1, //this should bot be copied
                Entity   = null,

                Name    = Name,
                SteamID = SteamID,
                HP      = HP,
                Armor   = Armor,

                ViewDirectionX = ViewDirectionX,
                ViewDirectionY = ViewDirectionY,
                Disconnected   = Disconnected,

                Team = Team,

                HasDefuseKit = HasDefuseKit,
                HasHelmet    = HasHelmet
            };

            if (Position != null)
            {
                me.Position = Position.Copy(); //Vector is a class, not a struct - thus we need to make it thread-safe.
            }
            if (LastAlivePosition != null)
            {
                me.LastAlivePosition = LastAlivePosition.Copy();
            }

            if (Velocity != null)
            {
                me.Velocity = Velocity.Copy();
            }

            return(me);
        }
Beispiel #4
0
        /// <summary>
        /// Copy this instance for multi-threading use.
        /// </summary>
        public Player Copy()
        {
            Player me = new Player();

            me.EntityID = -1;             //this should bot be copied
            me.Entity   = null;

            me.Name    = Name;
            me.SteamID = SteamID;
            me.HP      = HP;
            me.Armor   = Armor;

            me.ViewDirectionX = ViewDirectionX;
            me.ViewDirectionY = ViewDirectionY;
            me.Disconnected   = Disconnected;

            me.Team = Team;

            me.HasDefuseKit = HasDefuseKit;
            me.HasHelmet    = HasHelmet;

            if (Position != null)
            {
                me.Position = Position.Copy();                 //Vector is a class, not a struct - thus we need to make it thread-safe.
            }
            if (LastAlivePosition != null)
            {
                me.LastAlivePosition = LastAlivePosition.Copy();
            }

            if (Velocity != null)
            {
                me.Velocity = Velocity.Copy();
            }

            return(me);
        }