예제 #1
0
        public ushort AssignTarget(ushort hearseID)
        {
            Vehicle hearse = Singleton<VehicleManager>.instance.m_vehicles.m_buffer[hearseID];
            ushort target = 0;

            if (hearse.m_sourceBuilding != _id)
                return target;

            ushort current = hearse.m_targetBuilding;

            if (!SkylinesOverwatch.Data.Instance.IsBuildingWithDead(current))
            {
                _master.Remove(current);
                _primary.Remove(current);
                _secondary.Remove(current);

                current = 0;
            }
            else if (_master.ContainsKey(current))
            {
                if (_master[current].IsValid && _master[current].Hearse != hearseID)
                    current = 0;
            }

            bool immediateOnly = _primary.Contains(current) || _secondary.Contains(current);
            SearchDirection immediateDirection = GetImmediateSearchDirection(hearseID);

            if (immediateOnly && immediateDirection == SearchDirection.None)
                target = current;
            else
            {
                target = GetClosestTarget(hearseID, ref _primary, immediateOnly, immediateDirection);

                if (target == 0)
                    target = GetClosestTarget(hearseID, ref _secondary, immediateOnly, immediateDirection);
            }

            if (target == 0)
            {
                if ((current != 0 && !SkylinesOverwatch.Data.Instance.IsBuildingWithDead(current) && WithinPrimaryRange(current)) || _checkups.Count == 0)
                    target = current;
                else
                {
                    target = _checkups[0];
                    _checkups.RemoveAt(0);
                }
            }
            else if (_master.ContainsKey(target))
            {
                if (_master[target].Hearse != hearseID)
                    _master[target] = new Claimant(hearseID, target);
            }
            else
                _master.Add(target, new Claimant(hearseID, target));

            return target;
        }
        public ushort AssignTarget(ushort hearseID)
        {
            Vehicle hearse = Singleton <VehicleManager> .instance.m_vehicles.m_buffer[hearseID];
            ushort  target = 0;

            if (hearse.m_sourceBuilding != _id)
            {
                return(target);
            }

            ushort current = hearse.m_targetBuilding;

            if (!SkylinesOverwatch.Data.Instance.IsBuildingWithDead(current))
            {
                _master.Remove(current);
                _primary.Remove(current);
                _secondary.Remove(current);

                current = 0;
            }
            else if (_master.ContainsKey(current))
            {
                if (_master[current].IsValid && _master[current].Hearse != hearseID)
                {
                    current = 0;
                }
            }

            bool            immediateOnly      = _primary.Contains(current) || _secondary.Contains(current);
            SearchDirection immediateDirection = GetImmediateSearchDirection(hearseID);

            if (immediateOnly && immediateDirection == SearchDirection.None)
            {
                target = current;
            }
            else
            {
                target = GetClosestTarget(hearseID, ref _primary, immediateOnly, immediateDirection);

                if (target == 0)
                {
                    target = GetClosestTarget(hearseID, ref _secondary, immediateOnly, immediateDirection);
                }
            }

            if (target == 0)
            {
                if ((current != 0 && !SkylinesOverwatch.Data.Instance.IsBuildingWithDead(current) && WithinPrimaryRange(current)) || _checkups.Count == 0)
                {
                    target = current;
                }
                else
                {
                    target = _checkups[0];
                    _checkups.RemoveAt(0);
                }
            }
            else if (_master.ContainsKey(target))
            {
                if (_master[target].Hearse != hearseID)
                {
                    _master[target] = new Claimant(hearseID, target);
                }
            }
            else
            {
                _master.Add(target, new Claimant(hearseID, target));
            }

            return(target);
        }