Ejemplo n.º 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);
    }
Ejemplo n.º 2
0
    public void Init(int PlayerID, CItem Item, CWorld World, bool Blueprint)
    {
        if (PlayerID == -1)
        {
            Debug.LogError("CItemProxy should never have a playerID of -1!");
        }

        mID                   = GetNextID();
        mItemID               = Item.mID;
        mState                = EState.S_VISIBLE;
        mPlayerID             = PlayerID;
        mWorld                = World;
        _item                 = Item;
        mBlueprint            = Blueprint;
        mAsset                = Item.mAsset;
        mDurability           = Item.mDurability;
        mMaxDurability        = Item.mMaxDurability;
        mQueueList            = new List <CQueueToken>();
        mPosition             = Item.mPosition;
        mRotation             = Item.mItemRot;
        mBounds               = Item.mBounds;
        mOwnerID              = Item.mOwner;
        mAssignedPaperStacks  = new List <CContractStack>();
        mPaperStackUpdateTick = 0;
        mAssignedUnitID       = -1;

        mSurfaceColor = mWorld.mMap.mBackgroundColor;
        mBounds       = CItem.CalculateBounds(mPosition, mRotation, mAsset.mWidth, mAsset.mLength);

        if (!mBlueprint)
        {
            ModifyLocalCollisionMap(true);

            if (Item.mType == CEntity.EType.ITEM_DOOR)
            {
                mLocked = true;

                if (mWorld.IsAllied(Item.mOwner, PlayerID))
                {
                    mLocked = ((CItemDoor)Item).mLocked;
                }

                DoorModifyLocalCollisionMap(mLocked);
            }
            else if (Item.mType == CEntity.EType.ITEM_SAFE)
            {
                mValue = ((CItemSafe)Item).mValue;
            }
            else if (Item.mType == CEntity.EType.ITEM_DESK)
            {
                mMaxPaperStackSlots = ((CItemDesk)Item).mMaxPaperStackSlots;
            }
        }

        SetVisible();
        UpdateState(Item);
    }
Ejemplo n.º 3
0
    public static bool IsPlaceable(CWorld World, int PlayerID, CItemAsset Asset, int X, int Y, int Rotation)
    {
        // Check for collision with other blueprints
        Bounds bounds = CItem.CalculateBounds(new Vector2(X, Y), Rotation, Asset.mWidth, Asset.mLength);

        bounds.max -= new Vector3(0.1f, 0.1f, 0.1f);
        bounds.min += new Vector3(0.1f, 0.1f, 0.1f);

        for (int i = 0; i < World.mBlueprints.Count; ++i)
        {
            CItem b = World.mBlueprints[i];
            if (b.mOwner == PlayerID && b.mBluerprint)
            {
                if (b.mBounds.Intersects(bounds))
                {
                    return(false);
                }
            }
        }

        return(IsPlaceable(World.mMap.mTiles, World.mMap.mGlobalCollisionTiles, Asset, X, Y, Rotation));
    }
Ejemplo n.º 4
0
    public static bool IsPlaceable(CUserWorldView WorldView, CItemAsset Asset, int X, int Y, int Rotation)
    {
        // Check for collision with other blueprints
        Bounds bounds = CItem.CalculateBounds(new Vector2(X, Y), Rotation, Asset.mWidth, Asset.mLength);

        bounds.max -= new Vector3(0.1f, 0.1f, 0.1f);
        bounds.min += new Vector3(0.1f, 0.1f, 0.1f);

        for (int i = 0; i < WorldView.mStateViews.Count; ++i)
        {
            CItemView v = WorldView.mStateViews[i] as CItemView;
            if (v != null && v.mBlueprint)
            {
                if (v.mBounds.Intersects(bounds))
                {
                    return(false);
                }
            }
        }

        return(IsPlaceable(WorldView.GetTileView(), WorldView.GetCollisionView(), Asset, X, Y, Rotation));
    }