コード例 #1
0
ファイル: CachedAssets.cs プロジェクト: Duckshow/SpaceStation
    public Int2 GetInteractiveAsset(Int2 _tileGridPos, Sorting _sorting)
    {
        Node _nodeTL, _nodeTR, _nodeBR, _nodeBL;

        NeighborFinder.GetSurroundingNodes(_tileGridPos, out _nodeTL, out _nodeTR, out _nodeBR, out _nodeBL);

        bool _hasNodeTL = _nodeTL != null;
        bool _hasNodeTR = _nodeTR != null;
        bool _hasNodeBR = _nodeBR != null;
        bool _hasNodeBL = _nodeBL != null;

        Node.InteractiveObject _interactiveObjectTL = _hasNodeTL ? _nodeTL.AttachedInteractiveObject : null;
        Node.InteractiveObject _interactiveObjectTR = _hasNodeTR ? _nodeTR.AttachedInteractiveObject : null;
        Node.InteractiveObject _interactiveObjectBR = _hasNodeBR ? _nodeBR.AttachedInteractiveObject : null;
        Node.InteractiveObject _interactiveObjectBL = _hasNodeBL ? _nodeBL.AttachedInteractiveObject : null;

        Node.InteractiveObject _interactiveObjectTemporaryTL = _hasNodeTL ? _nodeTL.AttachedInteractiveObjectTemporary : null;
        Node.InteractiveObject _interactiveObjectTemporaryTR = _hasNodeTR ? _nodeTR.AttachedInteractiveObjectTemporary : null;
        Node.InteractiveObject _interactiveObjectTemporaryBR = _hasNodeBR ? _nodeBR.AttachedInteractiveObjectTemporary : null;
        Node.InteractiveObject _interactiveObjectTemporaryBL = _hasNodeBL ? _nodeBL.AttachedInteractiveObjectTemporary : null;

        bool _useInteractiveObjectTemporaryTL = _hasNodeTL && _nodeTL.UseAttachedInteractiveObjectTemporary;
        bool _useInteractiveObjectTemporaryTR = _hasNodeTR && _nodeTR.UseAttachedInteractiveObjectTemporary;
        bool _useInteractiveObjectTemporaryBR = _hasNodeBR && _nodeBR.UseAttachedInteractiveObjectTemporary;
        bool _useInteractiveObjectTemporaryBL = _hasNodeBL && _nodeBL.UseAttachedInteractiveObjectTemporary;

        Node.InteractiveObject _foundInteractive = null;
        Direction _foundInteractiveDirection     = Direction.None;
        Node      _foundInteractivesNode         = null;

        if (TryGetInteractiveObject(_nodeTL, out _foundInteractive))
        {
            _foundInteractiveDirection = Direction.TL;
            _foundInteractivesNode     = _nodeTL;
        }
        else if (TryGetInteractiveObject(_nodeTR, out _foundInteractive))
        {
            _foundInteractiveDirection = Direction.TR;
            _foundInteractivesNode     = _nodeTR;
        }
        else if (TryGetInteractiveObject(_nodeBR, out _foundInteractive))
        {
            _foundInteractiveDirection = Direction.BR;
            _foundInteractivesNode     = _nodeBR;
        }
        else if (TryGetInteractiveObject(_nodeBL, out _foundInteractive))
        {
            _foundInteractiveDirection = Direction.BL;
            _foundInteractivesNode     = _nodeBL;
        }

        if (_foundInteractive != null)
        {
            return(_foundInteractive.GetTileAssetPos(_sorting, _foundInteractiveDirection));
        }

        return(DefaultAssets.Empty);
    }
コード例 #2
0
ファイル: CachedAssets.cs プロジェクト: Duckshow/SpaceStation
    bool TryGetInteractiveObject(Node _node, out Node.InteractiveObject _foundInteractive)
    {
        if (_node == null)
        {
            _foundInteractive = null;
            return(false);
        }

        _foundInteractive = _node.UseAttachedInteractiveObjectTemporary ? _node.AttachedInteractiveObjectTemporary : _node.AttachedInteractiveObject;
        return(_foundInteractive != null);
    }