コード例 #1
0
ファイル: Pipe.cs プロジェクト: Lankercool/unitystation
    public virtual bool Attach()
    {
        CalculateDirection();
        if (GetAnchoredPipe(registerTile.WorldPositionServer, direction) != null)
        {
            return(false);
        }

        CalculateAttachedNodes();

        Pipenet foundPipenet;

        if (nodes.Count > 0)
        {
            foundPipenet = nodes[0].pipenet;
        }
        else
        {
            foundPipenet = new Pipenet();
        }

        foundPipenet.AddPipe(this);
        SetAnchored(true);
        SetSpriteLayer(true);

        transform.position = registerTile.WorldPositionServer;
        CalculateSprite();

        return(true);
    }
コード例 #2
0
    public void Detach()
    {
        //TODO: release gas to environmental air
        SetAnchored(false);
        SetSpriteLayer();
        int neighboorPipes = 0;

        for (int i = 0; i < nodes.Count; i++)
        {
            var pipe = nodes[i];
            pipe.nodes.Remove(this);
            pipe.SpriteChange();
            neighboorPipes++;
        }
        nodes = new List <Pipe>();

        Pipenet oldPipenet = pipenet;

        pipenet.RemovePipe(this);

        if (oldPipenet.members.Count == 0)
        {
            //we're the only pipe on the net, delete it
            oldPipenet.DeletePipenet();
            return;
        }

        if (neighboorPipes == 1)
        {
            //we're at an edge of the pipenet, safe to remove
            return;
        }
        oldPipenet.Separate();
    }
コード例 #3
0
 public void MergePipenet(Pipenet otherPipenet)
 {
     for (int i = 0; i < otherPipenet.members.Count; i++)
     {
         var pipe = otherPipenet.members[i];
         AddPipeEXTRA(pipe);
     }
     otherPipenet.members = new List <Pipe>();
     gasMix += otherPipenet.gasMix;
     otherPipenet.DeletePipenet();
 }
コード例 #4
0
ファイル: Pipe.cs プロジェクト: Lankercool/unitystation
    public void Detach()
    {
        var foundMeters = MatrixManager.GetAt <Meter>(registerTile.WorldPositionServer, true);

        for (int i = 0; i < foundMeters.Count; i++)
        {
            var meter = foundMeters[i];
            if (meter.anchored)
            {
                foundMeters[i].Detach();
            }
        }

        //TODO: release gas to environmental air
        SetAnchored(false);
        SetSpriteLayer(false);
        int neighboorPipes = 0;

        for (int i = 0; i < nodes.Count; i++)
        {
            var pipe = nodes[i];
            pipe.nodes.Remove(this);
            pipe.CalculateSprite();
            neighboorPipes++;
        }

        nodes = new List <Pipe>();

        Pipenet oldPipenet = pipenet;

        pipenet.RemovePipe(this);

        if (oldPipenet.members.Count == 0)
        {
            //we're the only pipe on the net, delete it
            oldPipenet.DeletePipenet();
            return;
        }

        if (neighboorPipes == 1)
        {
            //we're at an edge of the pipenet, safe to remove
            return;
        }

        oldPipenet.Separate();
    }
コード例 #5
0
    public virtual void Attach()
    {
        CalculateAttachedNodes();
        Pipenet foundPipenet = null;

        if (nodes.Count > 0)
        {
            foundPipenet = nodes[0].pipenet;
        }
        else
        {
            foundPipenet = new Pipenet();
        }
        foundPipenet.AddPipe(this);
        SetAnchored(true);
        SetSpriteLayer();
    }
コード例 #6
0
    public void Separate()
    {
        var oldGasMix  = gasMix;
        var oldMembers = members;

        gasMix  = new GasMix(GasMixes.Empty);
        members = new List <Pipe>();

        for (int i = 0; i < oldMembers.Count; i++)
        {
            oldMembers[i].pipenet = null;
        }

        Pipenet newPipenet        = this;
        var     separatedPipenets = new List <Pipenet>()
        {
            this
        };

        for (int i = 0; i < oldMembers.Count; i++)
        {
            var pipe = oldMembers[i];
            if (pipe.pipenet == null)
            {
                if (newPipenet == null)
                {
                    newPipenet = new Pipenet();
                    separatedPipenets.Add(newPipenet);
                }
                newPipenet.SpreadPipenet(pipe);
                newPipenet = null;
            }
        }

        oldGasMix = oldGasMix / oldGasMix.Volume;
        for (int i = 0; i < separatedPipenets.Count; i++)
        {
            var pipenet   = separatedPipenets[i];
            var oldVolume = pipenet.gasMix.Volume;
            pipenet.gasMix = oldGasMix * pipenet.gasMix.Volume;
            pipenet.gasMix.ChangeVolumeValue(-(pipenet.gasMix.Volume - oldVolume));
        }
    }