コード例 #1
0
        /// <summary>
        ///     Create the simulation object. Sometimes this object is used for data
        ///     storage rather than a live simulation object. This these cases,  the
        ///     runner can be null.
        /// </summary>
        /// <param name="runner"></param>
        protected SimObject(DPGameRunner runner)
        {
            Runner = runner;
            //ExpireAfter(0.1);

            //TODO: check dis
            _stationary = (this is FLServer.Object.Solar.Solar);
        }
コード例 #2
0
        public MessagePump(Server server)
        {
            _server             = server;
            Player.Player.MPump = this;
            // Kick off the game runner threads. We have one thread per system. New
            // players who have not selected a character are assigned to a random
            // runner thread.
            uint baseObjid = 1;

            foreach (var starSystem in UniverseDB.Systems.Values)
            {
                _runners[starSystem] = new DPGameRunner(this, _log, baseObjid, starSystem);
                baseObjid           += 10000;
            }
        }
コード例 #3
0
        /// <summary>
        ///     At object creation time we assume that the freelancer player has connected to the
        ///     proxy server and is expecting the normal freelancer server login sequence. This
        ///     class manages this message exchange until they select a character at which point
        ///     the controller will establish a connection to a slave freelancer server and
        ///     forward traffic between the two.
        /// </summary>
        /// <param name="dplayid"></param>
        /// <param name="log"></param>
        /// <param name="flplayerid"></param>
        /// <param name="runner"></param>
        public Player(Session dplayid, ILogController log, uint flplayerid, DPGameRunner runner)
        {
            DPSess     = dplayid;
            Log        = log;
            FLPlayerID = flplayerid;
            Runner     = runner;
            Ship       = new Old.Object.Ship.Ship(runner)
            {
                player = this
            };
            Wgrp = new WeaponGroup();

            _state = DPCLoginState.Instance();
            _state.EnterState(this);
        }
コード例 #4
0
ファイル: ShipAI.cs プロジェクト: Friendly0Fire/flos
        private AIState ProcessState(DPGameRunner runner, double seconds)
        {
            switch (_state)
            {
            case AIState.Patrol:
                Patrol(runner);
                break;

            default:
                Status = (byte)((Ship.Shield.OfflineTime * 4) + (Ship.Health * 100) + (Ship.Powergen.CurrPower / Ship.Powergen.Capacity) + (Ship.Rank));
                Combat();
                break;
            }

            return(_state);
        }
コード例 #5
0
ファイル: Chat.cs プロジェクト: Friendly0Fire/flos
        public static Player.Player FindActivePlayerByCharname(DPGameRunner server, string arg, int searchMode)
        {
            arg = arg.ToLowerInvariant();

            if (searchMode == 0)
            {
                uint id;
                if (!uint.TryParse(arg, out id))
                {
                    return(null);
                }

                if (!server.Playerlist.ContainsKey(id))
                {
                    return(null);
                }

                return(server.Playerlist[id].Player);
            }

            // Search for an exact match
            foreach (DPGameRunner.PlayerListItem player in server.Playerlist.Values)
            {
                if (player.Name.ToLowerInvariant() == arg)
                {
                    return(player.Player);
                }
            }

            // Search for a partial match if requested
            if (searchMode == 1)
            {
                var matches =
                    server.Playerlist.Values.Where(player => player.Name.ToLowerInvariant().StartsWith(arg)).ToList();

                if (matches.Count == 1)
                {
                    return(matches[0].Player);
                }
            }

            return(null);
        }
コード例 #6
0
        public CounterMeasure(DPGameRunner runner, Ship.Ship owner, CounterMeasureDropperArchetype gun_arch,
                              ShipItem launcher, uint hpid)
            : base(runner)
        {
            munition_arch = gun_arch.ProjectileArch as CounterMeasureArchetype;
            Arch          = munition_arch;

            Position    = owner.InterpolatedPosition();
            Position   += owner.Orientation * owner.Arch.Hardpoints[launcher.hpname.ToLowerInvariant()].Position;
            Orientation = Matrix.TurnAround(owner.Orientation);
            velocity    = Orientation * gun_arch.MuzzleVelocity + owner.EstimatedVelocity;
            owner_objid = owner.Objid;
            this.hpid   = hpid;

            lifetime        = munition_arch.Lifetime;
            owner_safe_time = munition_arch.OwnerSafeTime;

            Throttle = 1; // (float)(this.velocity.Length() / this.max_speed);

            angular_velocity = new Vector(rand.NextDouble() * 10 - 5, rand.NextDouble() * 10 - 5, rand.NextDouble() * 10 - 5);
        }
コード例 #7
0
        public Missile(DPGameRunner runner, Ship.Ship owner, GunArchetype gun_arch, ShipItem launcher, Vector target_position,
                       uint hpid)
            : base(runner)
        {
            munition_arch = gun_arch.ProjectileArch as MunitionArchetype;
            Arch          = munition_arch;

            Position        = owner.InterpolatedPosition();
            Position       += owner.Orientation * owner.Arch.Hardpoints[launcher.hpname.ToLowerInvariant()].Position;
            Orientation     = Matrix.CreateLookAt(Position, target_position);
            velocity        = Orientation * gun_arch.MuzzleVelocity + owner.EstimatedVelocity;
            owner_objid     = owner.Objid;
            target_objid    = owner.TargetObjID;
            target_subobjid = owner.target_subobjid;
            this.hpid       = hpid;

            lifetime = munition_arch.Lifetime;

            motor_accel        = munition_arch.MotorArch.Accel;
            motor_lifetime_max = motor_lifetime = munition_arch.MotorArch.Lifetime;
            motor_delay        = munition_arch.MotorArch.Delay;

            seek = (munition_arch.Seeker.ToUpper() == "LOCK") && (target_objid != 0);
            if (seek)
            {
                seeker_fov   = munition_arch.SeekerFovDeg * Math.PI / 180;
                seeker_range = munition_arch.SeekerRange;

                time_to_lock         = munition_arch.TimeToLock;
                max_angular_velocity = munition_arch.MaxAngularVelocity * Math.PI / 180;
            }

            max_speed = velocity.Length() + motor_accel * motor_lifetime_max;

            Throttle = 1; // (float)(this.velocity.Length() / this.max_speed);
        }
コード例 #8
0
ファイル: ShipAI.cs プロジェクト: Friendly0Fire/flos
 public override void Update(Ship.Ship ship, DPGameRunner server, double seconds)
 {
     _state = ProcessState(server, seconds);
 }
コード例 #9
0
ファイル: ShipAI.cs プロジェクト: Friendly0Fire/flos
        private void Patrol(DPGameRunner runner)
        {
            var targetWaypoint = waypoints[_currWp];

            //if (SelectTarget(ship, runner) == null)
            //{
            //    ship.throttle = 0.0f;
            //}
            //else
            if (Ship.Position.DistanceTo(targetWaypoint.Position) < 100)
            {
                _currWp++;
                if (_currWp >= waypoints.Count)
                {
                    _currWp = 0;
                }
                targetWaypoint = waypoints[_currWp];
                runner.Log.AddLog(LogType.GENERAL, "waypoint={0}", targetWaypoint.Position);
            }
            else
            {
                Ship.Throttle = 1.0f;

                // Calculate turning limits.
                var    ship_arch = Ship.Arch as ShipArchetype;
                Vector maximum_angular_velocity = ship_arch.SteeringTorque / ship_arch.AngularDrag;
                Vector angular_acceleration     = ship_arch.SteeringTorque / ship_arch.RotationInertia;

                double delta_angle    = 0.0;
                double steering_yaw   = 0.0;
                double steering_pitch = 0.0;
                double steering_roll  = 0.0;

                Vector delta_target = targetWaypoint.Position - Ship.Position;
                delta_target = delta_target.Normalize();

                // If the target is behind the ship, turn at maximum rate towards it.
                double cosine = Ship.Orientation.GetBackward().Inverse().Dot(delta_target);
                if (cosine <= -0.999)
                {
                    steering_yaw   = 1.0; // fixme
                    steering_pitch = 0.0;
                }
                // If the target is somewhere other than in directly in front
                else if (cosine < 0.98)
                {
                    delta_angle = Math.Acos(cosine);

                    Vector axis = Ship.Orientation.GetBackward().Cross(delta_target);

                    steering_yaw   = -axis.Dot(Ship.Orientation.GetUp()) * delta_angle;
                    steering_pitch = axis.Dot(Ship.Orientation.GetRight()) * delta_angle;
                }
                // Otherwise the target is somewhere in front of the ship
                else
                {
                    steering_yaw   = Math.Acos(Ship.Orientation.GetRight().Dot(delta_target)) - 0.5f * Math.PI;
                    steering_pitch = Math.Acos(Ship.Orientation.GetUp().Dot(delta_target)) - 0.5f * Math.PI;
                }

                // Steering yaw/pitch and roll are meant to represent the relative hardness of the
                // turn. i.e. a yaw of 1.0 is a max_rate angular acceleration in that axis.

                Ship.Orientation *= Matrix.EulerToMatrix(new Vector(steering_pitch, steering_yaw, steering_roll));

                //Console.WriteLine("yaw={0} pitch={1}", steering_yaw, steering_pitch);
            }
        }
コード例 #10
0
 /// <summary>
 ///     Activate the docking point (i.e. close the door)
 /// </summary>
 public void Deactivate(DPGameRunner runner)
 {
     runner.SendActivateObject(this, false,
                               Type == DockingPoint.DockingSphere.TRADELANE_RING ? Ship.Objid : Index);
     Ship = null;
 }
コード例 #11
0
 /// <summary>
 ///     Activate the docking point (i.e. open the door)
 /// </summary>
 public void Activate(DPGameRunner runner, Old.Object.Ship.Ship ship)
 {
     Ship = ship;
     runner.SendActivateObject(this, true, Type == DockingPoint.DockingSphere.TRADELANE_RING ? ship.Objid : Index);
 }
コード例 #12
0
 public virtual void Update(Old.Object.Ship.Ship ship, DPGameRunner server, double seconds)
 {
 }
コード例 #13
0
 protected SimObject SelectTarget(Old.Object.Ship.Ship ship, DPGameRunner runner)
 {
     return(runner.Objects.Values.Where(obj => obj != ship).FirstOrDefault(obj => obj is Old.Object.Ship.Ship && obj.Position.DistanceTo(ship.Position) < 5000));
 }
コード例 #14
0
ファイル: Ship.cs プロジェクト: Friendly0Fire/flos
 /// <summary>
 ///     Initialise the ship.
 /// </summary>
 /// <param name="runner"></param>
 public Ship(DPGameRunner runner) : base(runner)
 {
     //max_turning_speed = new Vector(steering_torque);
     //max_turning_speed /= arch.angular_drag;
 }