Beispiel #1
0
    /// <summary>
    /// Construct the item in the build order.
    /// </summary>
    public void BuildItem()
    {
        // TODO: Need to check if item can be built at this spot

        CItem blueprint = mWorld.GetEntity <CItem>(mOrder.mItemBlueprintID);

        blueprint.UpdatePlaceability();
        if (blueprint.mPlaceable)
        {
            Vector3 pos = CItem.CalculateBounds(blueprint.mPosition, blueprint.mItemRot, blueprint.mAsset.mWidth, blueprint.mAsset.mLength).center;
            pos.y = 0.0f;
            mWorld.AddTransientEventFOW(new Vector2(pos.x, pos.z)).SetEffect(pos);

            mWorld.PromoteBlueprintToItem(blueprint);

            // Dispose of the carried pickup.
            mWorld.DespawnEntity(mCarryingPickup);
            mCarryingPickup = null;
        }
        else
        {
            mWorld.DespawnEntity(blueprint);
            DropPickup();
        }

        // Tell order we are done with it.
        mOrder.OnCompleted();
        mOrder = null;
        //AdjustStamina(-CGame.Datastore.mGame.mBuildStamina);
    }
Beispiel #2
0
 /// <summary>
 /// Drop the carried pickup.
 /// </summary>
 public void DropPickup()
 {
     if (mCarryingPickup != null)
     {
         mCarryingPickup.Drop(mPosition);
         mCarryingPickup = null;
     }
 }
Beispiel #3
0
    /// <summary>
    /// Creates entity and assigns ID.
    /// </summary>
    public static CEntity Create(EType Type, CWorld World, int ID = 0)
    {
        CEntity entity = null;

        switch (Type)
        {
        case EType.UNIT: entity = new CUnit(); break;

        case EType.ITEM_START: entity = new CItemStart(); break;

        case EType.ITEM_DECO: entity = new CItemDeco(); break;

        case EType.ITEM_DESK: entity = new CItemDesk(); break;

        case EType.ITEM_SAFE: entity = new CItemSafe(); break;

        case EType.ITEM_REST: entity = new CItemRest(); break;

        case EType.ITEM_FOOD: entity = new CItemFood(); break;

        case EType.ITEM_DOOR: entity = new CItemDoor(); break;

        case EType.RESUME: entity = new CResume(); break;

        case EType.CONTRACT: entity = new CContract(); break;

        case EType.PICKUP: entity = new CPickup(); break;

        case EType.MISSILE: entity = new CMissile(); break;

        case EType.VOLUME: entity = new CVolume(); break;

        case EType.DECAL: entity = new CDecal(); break;
        }

        if (entity != null)
        {
            _InitNewEntity(entity, World, ID);
        }
        else
        {
            Debug.LogError("Entity Factory couldn't create a " + (int)Type + " is");
        }

        return(entity);
    }
Beispiel #4
0
    public void SimTick()
    {
        if (_tickDelay > 0)
        {
            --_tickDelay;
            return;
        }

        if (mState == EState.WAIT_FOR_DELIVERY)
        {
            _abandonState = EState.WAIT_FOR_DELIVERY;
            CPickup pickup = mWorld.GetPickupWithBuildTag(mBuildTag);

            if (pickup != null && pickup.IsReady())
            {
                // TODO: Check if blueprint and pickup are in the same pathing room.
                // Pass that info to make sure we get a builder in the same room.
                CUnit builder = _GetTaskAcceptingUnit(mWorld, mPlayerID, 0);

                if (builder != null)
                {
                    builder.SetBuildOrder(this);
                    mState = EState.TRANSIT_TO_BUILD_SITE;
                    return;
                }
            }

            _tickDelay = 20;
        }
        else if (mState == EState.TRANSIT_TO_BUILD_SITE)
        {
            _abandonState = EState.WAIT_FOR_DELIVERY;
            // Wait for builder to pickup the pickup, do the delivery, and begin building.
            // Wait for builder to tell us status things.
        }
        else if (mState == EState.START_PACKUP)
        {
            _abandonState = EState.START_PACKUP;
        }
    }
Beispiel #5
0
 /// <summary>
 /// Pick up a pickup item.
 /// </summary>
 public void PickupPickup(CPickup Pickup)
 {
     Pickup.PickUp(mID);
     mCarryingPickup = Pickup;
 }
    public override void SimTick()
    {
        base.SimTick();

        if (mCurrentEvent == null)
        {
            if (mEvents.Count > 0)
            {
                mCurrentEvent = mEvents[0];
                mEvents.RemoveAt(0);

                mDoorPosition = 0.0f;

                if (mCurrentEvent.mType != CElevatorEvent.EType.T_EXIT)
                {
                    _deliveryTimer = 2.0f;
                }
            }
        }
        else
        {
            if (mCurrentEvent.mType != CElevatorEvent.EType.T_EXIT)
            {
                if (_waitingTimer > 0.0f)
                {
                    _waitingTimer -= CWorld.SECONDS_PER_TICK;

                    if (_waitingTimer <= 0.0f)
                    {
                        _waitingTimer = 0.0f;
                        mDoorPosition = 0.0f;
                        mCurrentEvent = null;
                    }
                }
                else
                {
                    _deliveryTimer -= CWorld.SECONDS_PER_TICK;

                    if (_deliveryTimer <= 0.0f)
                    {
                        mDoorPosition  = 1.0f;
                        _deliveryTimer = 0.0f;
                        _waitingTimer  = 2.0f;

                        if (mCurrentEvent.mType == CElevatorEvent.EType.T_SPAWN_UNIT)
                        {
                            CResume resume = mWorld.GetEntity <CResume>(mCurrentEvent.mInfo2);

                            if (resume == null)
                            {
                                resume = new CResume();
                                resume.Generate(mWorld, 0, 1);
                                CUnit unit = mWorld.SpawnUnitAtElevator(this, mCurrentEvent.mInfo1, resume);
                                mWorld.PushMessage("Intern " + unit.mName + " has arrived", 0);
                            }
                            else
                            {
                                CUnit unit = mWorld.SpawnUnitAtElevator(this, mCurrentEvent.mInfo1, resume);
                                mWorld.PushMessage("Employee " + unit.mName + " has arrived", 0);
                                mWorld.DespawnEntity(resume);
                            }
                        }
                        else if (mCurrentEvent.mType == CElevatorEvent.EType.T_DELIVERY)
                        {
                            CPickup pickup = mWorld.SpawnPickup(this, mCurrentEvent.mInfo1, mCurrentEvent.mInfoStr);
                            pickup.mBuildTag = mCurrentEvent.mInfo3;
                        }
                    }
                }
            }
        }
    }
Beispiel #7
0
 public void CopyState(CPickup Pickup)
 {
     mPosition  = Pickup.mPosition;
     mCarrierID = Pickup.mCarriedByUnitID;
 }
Beispiel #8
0
 public void CopyInitialState(CPickup Pickup)
 {
     mID = Pickup.mID;
     mContainedItemAsset = Pickup.mContainedItemAsset;
 }