public static void RemoveAdjacentPumpable(IPumpable adjacentAlpha, IPumpable adjacentBeta) { adjacentAlpha.AdjacentPumpables.Remove(adjacentBeta); adjacentBeta.AdjacentPumpables.Remove(adjacentAlpha); adjacentAlpha.OnAdjacentChanged(); adjacentBeta.OnAdjacentChanged(); }
public void OnAdjacentChanged() { if (AdjacentPumpables.Count > 0) { connectedPumpable = AdjacentPumpables[0]; } else { connectedPumpable = null; } }
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(); } }
//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(); } }
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)); }
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)); }