Пример #1
0
    public void FixedUpdate()
    {
        if (!employmentData.HasContract())
        {
            state = ShipState.Idle;
        }
        else if (employmentData.HasContract() && state == ShipState.Idle)
        {
            FreightContract c = (FreightContract)employmentData.contract;
            state       = ShipState.Pickup;
            destination = c.reservation.location.gameObject;
        }

        if (state == ShipState.Pickup)
        {
            if (_atDestination)
            {
                _atDestination = false;
                _rb.velocity   = Vector2.zero;

                FreightContract c = (FreightContract)employmentData.contract;

                c.reservation.Resolve(cargoHold);
                ResourceReservation newReservation = cargoHold.MakeReservation(c.reservation.location, c.reservation.resource);
                c.reservation = newReservation;

                destination = c.creator.GetComponent <IndustryNode>().connectedStorageNode.gameObject;

                state = ShipState.Dropoff;
            }
            else
            {
                Arrive(destination);
            }
        }
        else if (state == ShipState.Dropoff)
        {
            if (_atDestination)
            {
                _atDestination = false;
                destination    = null;
                _rb.velocity   = Vector2.zero;

                FreightContract f = (FreightContract)employmentData.contract;
                f.reservation.Resolve(f.creator.GetComponent <IndustryNode>().connectedStorageNode);
                employmentData.contract.MarkAsComplete();

                state = ShipState.Idle;
            }
            else
            {
                Arrive(destination);
            }
        }
    }
Пример #2
0
    private void CreateFreightContract(Resource resource)
    {
        Star star = gameObject.GetComponentInParent <Star>();

        // Check if the resource is available in this system
        if (!star.HasResourceAmount(resource))
        {
            return;
        }

        // Make a reservation
        ResourceReservation reservation = MakeReservation(resource, star);

        // Add the resource type to the list of requested types.
        // The resource will be removed from the _requiredResources list later in Update()
        _requestedResourceTypes.Add(resource.type);

        FreightContract newContract = new FreightContract(employmentData, employmentData.employer, reservation, star.jobBoard);

        employmentData.employer.ConsiderIssuingContract(newContract);

        Debug.Log("Posting contract");
    }
Пример #3
0
    public void NotifyOfContractCompletion(Contract c)
    {
        FreightContract fc = (FreightContract)c;

        _requestedResourceTypes.RemoveAll(r => r == fc.reservation.resource.type);
    }
Пример #4
0
 public void NotifyOfContractRejection(FreightContract c)
 {
     _requestedResourceTypes.Remove(c.reservation.resource.type);
     _requiredResources.Add(c.reservation.resource);
 }