Exemplo n.º 1
0
        public static void RemoveAdjacentPumpable(IPumpable adjacentAlpha, IPumpable adjacentBeta)
        {
            adjacentAlpha.AdjacentPumpables.Remove(adjacentBeta);
            adjacentBeta.AdjacentPumpables.Remove(adjacentAlpha);

            adjacentAlpha.OnAdjacentChanged();
            adjacentBeta.OnAdjacentChanged();
        }
Exemplo n.º 2
0
 public void OnAdjacentChanged()
 {
     if (AdjacentPumpables.Count > 0)
     {
         connectedPumpable = AdjacentPumpables[0];
     }
     else
     {
         connectedPumpable = null;
     }
 }
Exemplo n.º 3
0
    private void AttachTo(Collider c, string valveTag)
    {
        connectedPumpable = c.transform.root.GetComponent <IPumpable>();
        connectedSink     = connectedPumpable as ISink;
        print("valve mode: " + ValveMode);
        print("pump mode: " + PumpMode);

        if (connectedPumpable != null)
        {
            valveType = MatterExtensions.FromValveTag(valveTag);
            SyncMeshesToMatterType();
            this.SnapCrate(c.transform, c.transform.position + (c.transform.TransformDirection(Vector3.forward) * 1.3f));
            IndustryExtensions.AddAdjacentPumpable(this, connectedPumpable);
            RefreshPumpState();
        }
    }
Exemplo n.º 4
0
    //handled by AttachTo
    //protected override void OnSnap() {}

    protected override void OnDetach()
    {
        if (connectedPumpable != null)
        {
            IndustryExtensions.RemoveAdjacentPumpable(this, connectedPumpable);
            connectedPumpable = null;
            connectedSink     = null;
        }
        PumpHandle.tag    = "Untagged";
        CurrentPumpStatus = PumpStatus.PumpOff;
        RefreshPumpState();

        if (capturedResource != null)
        {
            capturedResource.UnsnapCrate();
        }
    }
Exemplo n.º 5
0
        public static IPumpable <TInput, TModel, TAccumulator> Sink <TInput, TModel, TAccumulator>(this IPumpable <TInput, TModel, TAccumulator> actionable, Action <TInput, TModel, TAccumulator> sinkAction)
        {
            Action <IPipeContext <TInput, TModel, TAccumulator> > action = (ctx) => sinkAction.Invoke(ctx.Input, ctx.Model, ctx.Accumulator);

            actionable.Pipeline.RegisterFilter(new SinkFilter <TInput, TModel, TAccumulator>(action));
            return(new Pumpable <TInput, TModel, TAccumulator>(actionable.Pipeline));
        }
Exemplo n.º 6
0
 public static IPumpable <TInput, TModel, TAccumulator> HoldIf <TInput, TModel, TAccumulator>(this IPumpable <TInput, TModel, TAccumulator> actionable, Func <TAccumulator, bool> predicate)
 {
     actionable.Pipeline.RegisterFilter(new HoldIfFilter <TInput, TModel, TAccumulator>(predicate));
     return(new Pumpable <TInput, TModel, TAccumulator>(actionable.Pipeline));
 }