コード例 #1
0
        /// <summary>
        /// Removes a position from the fleet
        /// </summary>
        /// <param name="uuid"></param>
        public void DeletePosition(string uuid)
        {
            OpPosition pos = GetPosition(uuid);

            if (pos != null)
            {
                // Remove the position from the unit it belongs to
                FleetUnit unit = GetUnit(pos.unitUUID);
                if (unit != null)
                {
                    if (unit is Ship)
                    {
                        (unit as Ship).positions.Remove(pos);
                    }
                    else if (unit is Boat)
                    {
                        (unit as Boat).positions.Remove(pos);
                    }
                }

                ClearPosition(uuid);

                // Remove position from the lookup
                positionsLookup.Remove(uuid);
            }
        }
コード例 #2
0
        /// <summary>
        /// Removes a participant from a position
        /// </summary>
        /// <param name="uuid"></param>
        public void ClearPosition(string uuid)
        {
            OpPosition job = GetPosition(uuid);

            if (job == null)
            {
                return;
            }

            if (job.filledByPointer != null)
            {
                job.filledByPointer.position = null;
            }
            job.filledByPointer = null;
            job.filledById      = -1;
        }
コード例 #3
0
        /// <summary>
        /// Assigns a given participant to a position in the fleet
        /// </summary>
        /// <param name="uuid"></param>
        /// <param name="member"></param>
        public void AssignPosition(string uuid, OpParticipant member)
        {
            OpPosition job = GetPosition(uuid);

            if (job == null)
            {
                return;
            }

            if (job.filledByPointer != null)
            {
                ClearPosition(uuid);
            }
            if (member.position != null)
            {
                ClearPosition(member.position.uuid);
            }

            member.position     = job;
            job.filledByPointer = member;
            job.filledById      = member.profile.id;
        }
コード例 #4
0
        /// <summary>
        /// Adds a position to a ship or boat set in the positions unitUUID
        /// field.
        /// </summary>
        /// <param name="pos"></param>
        public void AddPosition(OpPosition pos)
        {
            if (pos.unitUUID == "")
            {
                throw new ArgumentException(
                          "Position must have a unitUUID to be added");
            }

            FleetUnit unit = GetUnit(pos.unitUUID);

            if (unit is Ship)
            {
                Ship ship = unit as Ship;
                ship.positions.Add(pos);
                positionsLookup.Add(pos.uuid, pos);
            }
            else if (unit is Boat)
            {
                Boat boat = unit as Boat;
                boat.positions.Add(pos);
                positionsLookup.Add(pos.uuid, pos);
            }
        }