コード例 #1
0
ファイル: ConnectorGraph.cs プロジェクト: GreenCalx/LD47
    public void pulse(bool iState)
    {
        if (is_infinite || (pulse_speed <= 0) || (pulse_speed >= chunks.Count))
        {
            // Instantaneous trigger
            is_infinite = true;
            List <ActivableObject> aos = getWireTargets();
            foreach (ActivableObject target in aos)
            {
                // if (iState)
                //     target.activate();
                // else
                //     target.deactivate();
                PulseToken ptk = new PulseToken(0, iState?1:-1);
                target.listen(ptk);
                ptk = null; // wait GC...
            }
            //(TL.GetCursorValue() as WireTimelineValue)._WireEvent = iState ? Events.INF_ON : Events.INF_OFF ;

            return;
        }

        getRootChunk().pulse_bag.Add(new PulseToken(pulse_speed));
        getRootChunk().propagateAll();
    }
コード例 #2
0
ファイル: ConnectorGraph.cs プロジェクト: GreenCalx/LD47
    public void propagatePulse(PulseToken iPT)
    {
        if (iPT.speed == 0)
        {
            // Reset PT speed
            iPT.speed = wire.pulse_speed;
            pulse_bag.Add(iPT);
            pulse_color();
            return; // Stop propagation
        }

        if (successors.Count == 0)
        {
            foreach (ActivableObject target in targets)
            {
                this.activated_this_cycle = target.listen(iPT);
            }
            iPT.deletion_flag = true;
            reset_color();
        }
        else
        {
            foreach (Vector3Int succ_coord in successors)
            {
                WireChunk wc = wire.getWChunkFromCoord(succ_coord);
                wc.propagatePulse(iPT.getPropagated());   // decrement speed as we propagate
                iPT.deletion_flag = true;
                reset_color();
            }
        }
    }
コード例 #3
0
    public virtual bool listen(PulseToken iPT)
    {
        this.stored_pulses += iPT.PW;

        if (this.stored_pulses >= required_PW)
        {
            Debug.Log("trig : storage " + this.stored_pulses);
            activate(); return(true);
        }
        else
        {
            deactivate();
        }
        return(false);
    }