private float currSpeed = 0; // current speed (only re-sampled at end of each phase, to avoid glitches) #endregion Fields #region Constructors /// <summary> /// ONLY set the physical properties in the constructor. Use Init() for initialisation. /// </summary> public Oscillator() { // Define my properties Mass = 0.1f; Resistance = 0.1f; Buoyancy = 0f; // Define my channels channelData = new ChannelData[][] { new ChannelData[] // All variants look the same { new ChannelData(ChannelData.Socket.XX, ChannelData.Socket.PL, 1, 0f, "Output"), // output channel to plug - signal new ChannelData(ChannelData.Socket.PL, ChannelData.Socket.XX, 0, 0.5f, "Speed"), // input channel from plug - controls speed }, }; // Define the waveforms... // Square (soften the shoulders to prevent infinite rates of change) for (int i = 0; i < 50; i++) { waveform[SQ, i] = 1.0f; } waveform[SQ, 0] = 0.25f; waveform[SQ, 1] = 0.50f; waveform[SQ, 2] = 0.75f; waveform[SQ, 50] = 0.75f; waveform[SQ, 51] = 0.50f; waveform[SQ, 52] = 0.25f; // Pulse (low MK/SPC square wave with soft shoulders; not a true pulse because this might not get noticed by downstream cells) for (int i = 0; i < 10; i++) { waveform[PU, i] = 1.0f; } waveform[PU, 0] = 0.25f; waveform[PU, 1] = 0.50f; waveform[PU, 2] = 0.75f; waveform[PU, 10] = 0.75f; waveform[PU, 11] = 0.50f; waveform[PU, 12] = 0.25f; // Sine (unsigned) for (int i = 0; i < 100; i++) { waveform[SI,i] = (float)(Math.Sin(((double)i) / 100.0 * Math.PI * 2.0) / 2.0 + 0.5); } // 1:5 ramp (for swimming/flapping motion) for (int i = 0; i < 20; i++) { waveform[FL, i] = i / 20.0f; } for (int i = 20; i < 100; i++) { waveform[FL, i] = 1.0f - (i-20) / 80.0f; } }
const float BUOYANCYRANGE = 0.5f; // neutral +/- this amount = permissible range #endregion Fields #region Constructors /// <summary> /// ONLY set the physical properties in the constructor. Use Init() for initialisation. /// </summary> public SubDome() { // Define my properties Mass = 0.1f; Resistance = 0.0f; // increase resistance if nose pitched down when power applied Buoyancy = BUOYANCYNEUTRAL; // Define my channels channelData = new ChannelData[][] { new ChannelData[] { new ChannelData(ChannelData.Socket.PL, ChannelData.Socket.XX, 1, 0f, "Buoyancy"), // input channel from plug - controls weight } }; }
private float r = 0, g = 0, b = 0; // current pulse's colour #endregion Fields #region Constructors public Bioluminescence() { // Define my properties Mass = 0.1f; Resistance = 0.2f; Buoyancy = 1.0f; ////////// TEMP!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! // Define my channels channelData = new ChannelData[][] { new ChannelData[] { new ChannelData(ChannelData.Socket.PL, ChannelData.Socket.XX, 0, 0.5f, "Speed"), // pulse rate new ChannelData(ChannelData.Socket.PL, ChannelData.Socket.XX, 0, 0.5f, "Colour"), // wavelength } }; }
public ColorSensitive() { // Define my properties Mass = 0.1f; Resistance = 0.1f; Buoyancy = 0f; // Define my channels channelData = new ChannelData[][] { new ChannelData[] { // SOLE VARIANT new ChannelData(ChannelData.Socket.XX, ChannelData.Socket.PL, 1, 0f, "Signal"), // output new ChannelData(ChannelData.Socket.PL, ChannelData.Socket.XX, 0, 0f, "Filter colour"), // colour sensitivity }, }; }
/// <summary> /// ONLY set the physical properties in the constructor. Use Init() for initialisation. /// </summary> public Bend() { // Define my properties Mass = 0.1f; Resistance = 0.1f; Buoyancy = 0.0f; // Define my channels channelData = new ChannelData[][] { new ChannelData[] // ALL VARIANTS ARE THE SAME { new ChannelData(ChannelData.Socket.PL, ChannelData.Socket.S0, 0, 0f, "chan1"), new ChannelData(ChannelData.Socket.PL, ChannelData.Socket.S0, 0, 0f, "chan2"), new ChannelData(ChannelData.Socket.PL, ChannelData.Socket.S0, 0, 0f, "chan3"), } }; }
/// <summary> /// ONLY set the physical properties in the constructor. Use Init() for initialisation. /// </summary> public Branch() { // Define my properties Mass = 0.1f; Resistance = 0.1f; Buoyancy = 0.0f; // Define my channels channelData = new ChannelData[][] { new ChannelData[] // ALL VARIANTS ARE CURRENTLY THE SAME { new ChannelData(ChannelData.Socket.PL, ChannelData.Socket.S0, 0, 0f, "plug-socket0"), new ChannelData(ChannelData.Socket.PL, ChannelData.Socket.S1, 0, 0f, "plug-socket1"), new ChannelData(ChannelData.Socket.PL, ChannelData.Socket.S0, 0, 0f, "plug-socket0"), new ChannelData(ChannelData.Socket.PL, ChannelData.Socket.S1, 0, 0f, "plug-socket1"), new ChannelData(ChannelData.Socket.S0, ChannelData.Socket.S1, 0, 0f, "socket-socket"), } }; }
/// <summary> /// ONLY set the physical properties in the constructor. Use Init() for initialisation. /// </summary> public Core() { // Define my properties Mass = 0.3f; Resistance = 0.4f; Buoyancy = 0f; // Define my channels channelData = new ChannelData[][] { new ChannelData[] { new ChannelData(ChannelData.Socket.S0, ChannelData.Socket.S1, 1, 0f, "Bypass"), new ChannelData(ChannelData.Socket.S0, ChannelData.Socket.S1, 2, 0f, "Bypass"), new ChannelData(ChannelData.Socket.S0, ChannelData.Socket.S1, 3, 0f, "Bypass"), new ChannelData(ChannelData.Socket.S0, ChannelData.Socket.S1, 4, 0f, "Bypass"), new ChannelData(ChannelData.Socket.S0, ChannelData.Socket.S1, 5, 0f, "Bypass"), new ChannelData(ChannelData.Socket.S0, ChannelData.Socket.S1, 6, 0f, "Bypass"), new ChannelData(ChannelData.Socket.S0, ChannelData.Socket.S1, 7, 0f, "Bypass"), new ChannelData(ChannelData.Socket.S0, ChannelData.Socket.S1, 8, 0f, "Bypass"), } }; }
private State state = State.Relaxed; // Current state #endregion Fields #region Constructors public Jaw() { // Define my properties Mass = 0.6f; Resistance = 0.6f; Buoyancy = -0.05f; // Define my channels channelData = new ChannelData[][] { new ChannelData[] { new ChannelData(ChannelData.Socket.PL, ChannelData.Socket.XX, 1, 0f, "Bite"), // Input: start closing the jaws (when non-zero) new ChannelData(ChannelData.Socket.XX, ChannelData.Socket.PL, 0, 0f, "Eating"), // Output: 1 if we've caught something } }; }
/// <summary> /// ONLY set the physical properties in the constructor. Use Init() for initialisation. /// </summary> public SpinySucker() { // Define my properties Mass = 0.2f; Resistance = 0.2f; Buoyancy = -0.05f; // Define my channels channelData = new ChannelData[][] { new ChannelData[] { new ChannelData(ChannelData.Socket.PL, ChannelData.Socket.XX, 1, 0f, "Gripper"), // input channel from plug - controls grip } }; }
private float timer = 0; // countdown timer #endregion Fields #region Constructors /// <summary> /// ONLY set the physical properties in the constructor. Use Init() for initialisation. /// </summary> public Monostable() { // Define my properties Mass = 0.1f; Resistance = 0.1f; Buoyancy = 0f; // Define my channels channelData = new ChannelData[][] { new ChannelData[] // DOWNSTREAM { new ChannelData(ChannelData.Socket.PL, ChannelData.Socket.XX, 1, 0f, "Trigger"), // trigger input from plug new ChannelData(ChannelData.Socket.PL, ChannelData.Socket.XX, 0, 0.5f, "DelayTime"), // delay input from plug new ChannelData(ChannelData.Socket.XX, ChannelData.Socket.S0, 1, 0f, "Output"), // emitter to skt0 new ChannelData(ChannelData.Socket.PL, ChannelData.Socket.S0, 0, 0f, "Bypass"), // bypass channel from plug to skt0 }, new ChannelData[] // UPSTREAM { new ChannelData(ChannelData.Socket.S0, ChannelData.Socket.XX, 1, 0f, "Trigger"), // trigger from skt0 new ChannelData(ChannelData.Socket.S0, ChannelData.Socket.XX, 0, 0.5f, "DelayTime"), // delay from skt0 new ChannelData(ChannelData.Socket.XX, ChannelData.Socket.PL, 1, 0f, "Output"), // emitter to plug new ChannelData(ChannelData.Socket.PL, ChannelData.Socket.S0, 0, 0f, "Bypass"), // bypass channel from plug to skt0 } }; }
public Function() { // Define my properties Mass = 0.1f; Resistance = 0.1f; Buoyancy = 0f; // Define my channels channelData = new ChannelData[][] { new ChannelData[] // All variants look the same (but could use different data for each variant to make the labels more explicit (e.g. Y -> "threshold") { new ChannelData(ChannelData.Socket.XX, ChannelData.Socket.PL, 3, 0f, "Output"), new ChannelData(ChannelData.Socket.PL, ChannelData.Socket.XX, 1, 0f, "X"), new ChannelData(ChannelData.Socket.PL, ChannelData.Socket.XX, 2, 0f, "Y"), new ChannelData(ChannelData.Socket.PL, ChannelData.Socket.XX, 0, 1f, "Learning"), }, }; }
public DualSpectral() { // Define my properties Mass = 0.1f; Resistance = 0.2f; Buoyancy = 0.0f; // Define my channels channelData = new ChannelData[][] { new ChannelData[] { // SOLE VARIANT new ChannelData(ChannelData.Socket.XX, ChannelData.Socket.PL, 1, 0.5f, "Direction"), // direction of source (0=left, 1=right, 0.5=ahead) new ChannelData(ChannelData.Socket.XX, ChannelData.Socket.PL, 2, 0f, "Intensity"), // intensity of source new ChannelData(ChannelData.Socket.PL, ChannelData.Socket.XX, 0, 0.5f, "Filter colour"), // colour sensitivity }, }; }
public Vibration() { // Define my properties Mass = 0.1f; Resistance = 0.1f; Buoyancy = 0f; // Define my channels channelData = new ChannelData[][] { new ChannelData[] // SOLE VARIANT { new ChannelData(ChannelData.Socket.XX, ChannelData.Socket.PL, 1, 0f, "Signal strength"), // output channel to plug - distance }, }; }
public Speed() { // Define my properties Mass = 0.2f; Resistance = 0.2f; Buoyancy = 0.0f; // Define my channels channelData = new ChannelData[][] { new ChannelData[] { new ChannelData(ChannelData.Socket.XX, ChannelData.Socket.PL, 1, 0f, "Speed"), // output }, }; }
public Sonar() { // Define my properties Mass = 0.1f; Resistance = 0.1f; Buoyancy = 0f; // Define my channels channelData = new ChannelData[][] { new ChannelData[] { // SOLE VARIANT new ChannelData(ChannelData.Socket.XX, ChannelData.Socket.PL, 1, 0f, "Distance"), // output - distance of nearest echo new ChannelData(ChannelData.Socket.PL, ChannelData.Socket.XX, 0, 1f, "Trigger (optional)"), // triggers a "ping" }, }; }
public Integrator() { // Define my properties Mass = 0.1f; Resistance = 0.1f; Buoyancy = 0f; // Define my channels channelData = new ChannelData[][] { new ChannelData[] // All variants look the same (but could use different data for each variant to make the labels more explicit (e.g. Y -> "threshold") { new ChannelData(ChannelData.Socket.XX, ChannelData.Socket.PL, 1, 0f, "Output"), new ChannelData(ChannelData.Socket.PL, ChannelData.Socket.XX, 2, 0f, "Input"), new ChannelData(ChannelData.Socket.PL, ChannelData.Socket.XX, 0, 0.5f, "Leakage rate"), }, }; }
private float totalTime = 0; // total elapsed time for generating sinewaves #endregion Fields #region Constructors /// <summary> /// ONLY set the physical properties in the constructor. Use Init() for initialisation. /// </summary> public Navigator() { // Define my properties Mass = 0.1f; Resistance = 0.1f; Buoyancy = 0f; // Define my channels channelData = new ChannelData[][] { new ChannelData[] // TAILDRIVER - drives one muscle to control a tail fin { new ChannelData(ChannelData.Socket.PL, ChannelData.Socket.XX, 1, 0.5f, "Direction"), // direction input from sensor new ChannelData(ChannelData.Socket.PL, ChannelData.Socket.XX, 2, 1f, "Intensity"), // optional intensity signal from sensor new ChannelData(ChannelData.Socket.PL, ChannelData.Socket.XX, 0, 0.3f, "Minimum"), // optional minimum new ChannelData(ChannelData.Socket.XX, ChannelData.Socket.S0, 0, 0f, "Tail"), // motor driver - connect to muscle }, new ChannelData[] // TWO-WAY - drives two muscles from a dualsensor { new ChannelData(ChannelData.Socket.PL, ChannelData.Socket.XX, 1, 0.5f, "Direction"), // direction input from sensor new ChannelData(ChannelData.Socket.PL, ChannelData.Socket.XX, 2, 1f, "Intensity"), // optional intensity signal from sensor new ChannelData(ChannelData.Socket.PL, ChannelData.Socket.XX, 0, 0f, "Minimum"), // optional minimum new ChannelData(ChannelData.Socket.S0, ChannelData.Socket.XX, 0, 1f, "Waveform"), // optional modulating waveform (enters via socket) new ChannelData(ChannelData.Socket.XX, ChannelData.Socket.S1, 0, 0f, "Left"), // left motor driver new ChannelData(ChannelData.Socket.XX, ChannelData.Socket.S2, 0, 0f, "Right"), // right motor driver }, }; }
/// <summary> /// ONLY set the physical properties in the constructor. Use Init() for initialisation. /// </summary> public Plexus() { // Define my channels channelData = new ChannelData[][] { // Variant 0 - standard spinal plexus new ChannelData[] { new ChannelData(ChannelData.Socket.PL, ChannelData.Socket.S0, 0, 0f, "spine"), new ChannelData(ChannelData.Socket.PL, ChannelData.Socket.S0, 0, 0f, "spine"), new ChannelData(ChannelData.Socket.PL, ChannelData.Socket.S0, 0, 0f, "spine"), new ChannelData(ChannelData.Socket.PL, ChannelData.Socket.S0, 0, 0f, "spine"), new ChannelData(ChannelData.Socket.PL, ChannelData.Socket.S2, 0, 0f, "plug-arm"), new ChannelData(ChannelData.Socket.PL, ChannelData.Socket.S2, 0, 0f, "plug-arm"), new ChannelData(ChannelData.Socket.PL, ChannelData.Socket.S1, 0, 0f, "plug-arm"), new ChannelData(ChannelData.Socket.PL, ChannelData.Socket.S1, 0, 0f, "plug-arm"), new ChannelData(ChannelData.Socket.S0, ChannelData.Socket.S2, 0, 0f, "arm-skt"), new ChannelData(ChannelData.Socket.S0, ChannelData.Socket.S2, 0, 0f, "arm-skt"), new ChannelData(ChannelData.Socket.S0, ChannelData.Socket.S1, 0, 0f, "arm-skt"), new ChannelData(ChannelData.Socket.S0, ChannelData.Socket.S1, 0, 0f, "arm-skt"), new ChannelData(ChannelData.Socket.S1, ChannelData.Socket.S2, 0, 0f, "arm-arm"), }, // Other variants here }; // Can't set mass, etc. here because we don't know owner.variant until Init() is called }
private float smooth = 0; // moving average to smooth movements #endregion Fields #region Constructors /// <summary> /// ONLY set the physical properties in the constructor. Use Init() for initialisation. /// </summary> public Joint() { // Define my properties Mass = 0.2f; Resistance = 0.2f; Buoyancy = 0f; // Define my channels channelData = new ChannelData[][] { new ChannelData[] // All variants are chemically identical { new ChannelData(ChannelData.Socket.PL, ChannelData.Socket.XX, 1, 0f, "Angle"), // input channel from plug - controls angle new ChannelData(ChannelData.Socket.PL, ChannelData.Socket.XX, 0, 0f, "Minimum"), // minimum rotation new ChannelData(ChannelData.Socket.PL, ChannelData.Socket.XX, 0, 1f, "Maximum"), // maximum rotation new ChannelData(ChannelData.Socket.PL, ChannelData.Socket.S0, 0, 0f, "Bypass"), // bypass channel from plug to skt0 new ChannelData(ChannelData.Socket.PL, ChannelData.Socket.S0, 0, 0f, "Bypass"), // bypass channel from plug to skt0 }, }; }
private float[] smooth = new float[3]; // moving average to smooth movements #endregion Fields #region Constructors /// <summary> /// ONLY set the physical properties in the constructor. Use Init() for initialisation. /// </summary> public Joint3Axis() { // Define my properties Mass = 0.2f; Resistance = 0.2f; Buoyancy = 0f; // Define my channels channelData = new ChannelData[][] { new ChannelData[] // All variants are chemically identical { new ChannelData(ChannelData.Socket.PL, ChannelData.Socket.XX, 0, 0.5f, "Yaw"), // axis1 new ChannelData(ChannelData.Socket.PL, ChannelData.Socket.XX, 0, 0.5f, "Pitch"), // axis2 new ChannelData(ChannelData.Socket.PL, ChannelData.Socket.XX, 0, 0.5f, "Roll"), // axis3 (twist) new ChannelData(ChannelData.Socket.PL, ChannelData.Socket.S0, 0, 0f, "Bypass"), // bypass channel from plug to skt0 new ChannelData(ChannelData.Socket.PL, ChannelData.Socket.S0, 0, 0f, "Bypass"), // bypass channel from plug to skt0 }, }; }
/// <summary> /// ONLY set the physical properties in the constructor. Use Init() for initialisation. /// </summary> public Submarine() { // Define my properties Mass = 10f; // pretty heavy - scatters creatures it hits Resistance = 0.5f; // increase resistance to reduce run-on Buoyancy = -1f; // weight counterbalances Buoyancy of flotation dome // Define my channels channelData = new ChannelData[][] { new ChannelData[] { new ChannelData(ChannelData.Socket.XX, ChannelData.Socket.S0, 1, 0f, "Buoyancy"), new ChannelData(ChannelData.Socket.XX, ChannelData.Socket.S1, 1, 0f, "Right"), new ChannelData(ChannelData.Socket.XX, ChannelData.Socket.S2, 1, 0f, "Left"), new ChannelData(ChannelData.Socket.XX, ChannelData.Socket.S3, 1, 0f, "Top"), new ChannelData(ChannelData.Socket.XX, ChannelData.Socket.S4, 1, 0f, "Bot"), new ChannelData(ChannelData.Socket.XX, ChannelData.Socket.S5, 1, 0f, "RightDown"), new ChannelData(ChannelData.Socket.XX, ChannelData.Socket.S6, 1, 0f, "LeftDown"), } }; }
public LinearServo() { // Define my properties Mass = 0.1f; Resistance = 0.1f; Buoyancy = 0f; // Define my channels channelData = new ChannelData[][] { new ChannelData[] // DOWNSTREAM { new ChannelData(ChannelData.Socket.PL, ChannelData.Socket.XX, 0, 0f, "Desired"), // input channel - desired state new ChannelData(ChannelData.Socket.PL, ChannelData.Socket.XX, 1, 0f, "Actual"), // input channel - actual state new ChannelData(ChannelData.Socket.XX, ChannelData.Socket.S0, 0, 0f, "Output"), // output channel - response new ChannelData(ChannelData.Socket.PL, ChannelData.Socket.S0, 0, 0f, "Bypass"), // bypass channel from plug to skt0 }, new ChannelData[] // UPSTREAM { new ChannelData(ChannelData.Socket.S0, ChannelData.Socket.XX, 0, 0f, "Desired"), // input channel - desired state new ChannelData(ChannelData.Socket.S0, ChannelData.Socket.XX, 1, 0f, "Actual"), // input channel - actual state new ChannelData(ChannelData.Socket.XX, ChannelData.Socket.PL, 0, 0f, "Output"), // output channel - response new ChannelData(ChannelData.Socket.PL, ChannelData.Socket.S0, 0, 0f, "Bypass"), // bypass channel from plug to skt0 } }; }
private float rippleCounter = 0; // used to slow down rate of ripple stimuli to once per second #endregion Fields #region Constructors /// <summary> /// ONLY set the physical properties in the constructor. Use Init() for initialisation. /// </summary> public SubFan() { // Define my properties Mass = 0.1f; Resistance = 0.4f; // increase resistance to increase roll/pitch stability when thrust is cancelled Buoyancy = 0f; // Define my channels channelData = new ChannelData[][] { new ChannelData[] { new ChannelData(ChannelData.Socket.PL, ChannelData.Socket.XX, 1, 0f, "Speed"), // input channel from plug - controls speed } }; }
private bool Female = true; // true if female; false if male #endregion Fields #region Constructors /// <summary> /// ONLY set the physical properties in the constructor. Use Init() for initialisation. /// </summary> public SexOrgan() { // Define my properties Mass = 0.2f; Resistance = 0.2f; Buoyancy = 0f; // Define my channels channelData = new ChannelData[][] { new ChannelData[] { new ChannelData(ChannelData.Socket.PL, ChannelData.Socket.XX, 1, 0f, "Activate"), // input from plug - males open labia; females glow } }; }
/// <summary> /// Recursively attempt to connect up a chain or tree of channels. /// This cell's channel[c] is the channel we should try to connect to /// ourSocket[c,#] contains the assignments for that channel /// Return false if: /// - we have just connected an input channel to the end of the chain /// - we couldn't find a channel to connect to the end of the chain /// </summary> /// <param name="c">index into this cell's channel array</param> /// <param name="ourSocket">assignment table for all the channels in this cell</param> /// <returns></returns> private bool ConnectToMe(int c, ref ChannelData[] ourSocket) { Cell otherCell; int otherSkt; ChannelData.Socket skt; bool stillGoing = true; bool foundOne = false; // if this channel is an input channel we've finished if (ourSocket[c].IsInput()) return false; // If this is a bypass channel that has been flipped, the dest cell is on ourSocket[c,0] // otherwise it's on ourSocket[c,1] if (this.channel[c].signal == 0) skt = ourSocket[c].Dest; else skt = ourSocket[c].Source; // if the output end of this channel is on the plug, the dest cell is the parent // And we are on one of its sockets if (skt==ChannelData.Socket.PL) { otherCell = this.parent; //otherSkt = FindSocketNumberOf(otherCell); otherSkt = otherCell.FindSocketNumberOf(this); } // otherwise, find the cell that is on the correct output socket // and we are on that cell's plug else { otherCell = FindCellAtSocket((int)skt); otherSkt = -1; } // If there's no cell here, we've reached the end of the chain, so back up if (otherCell == null) return false; // Scan through other cell, looking for ALL channels connected to the right socket // with the right chemistry ChannelData[] otherChannel = otherCell.physiology.GetChannelData(); for (int o = 0; o < otherCell.channel.Length; o++) { // if the input side of the other channel is on the correct skt and has the correct chemistry if (((int)otherChannel[o].Source == otherSkt) && (otherCell.channel[o].chemical == this.channel[c].chemical)) { // This channel is connected to us, so store a ref to us in its .source otherCell.channel[o].source = channel[c]; otherCell.channel[o].signal = 0; //Debug.WriteLine("Connected channel " + o + " of " + otherCell.OwnerOrganism() + otherCell.name + otherCell.instance + " to channel " + c + " of " + OwnerOrganism() + name + instance + " using chem " + channel[c].chemical); foundOne = true; // Then move onto that channel and recurse down the chain. // If we've reached the end, remember that but continue looking at rest of channels at this level if (!otherCell.ConnectToMe(o, ref otherChannel)) stillGoing = false; } // This channel might be a bypass channel pointing the wrong way, so we have to check both ends // and set .signal if we have to swap it round if ((otherChannel[o].IsBypass()) && ((int)otherChannel[o].Dest == otherSkt) && (otherCell.channel[o].chemical == this.channel[c].chemical)) { // This channel is connected to us, so store a ref to us in its .source // And record the fact that the channel has been flipped otherCell.channel[o].source = channel[c]; otherCell.channel[o].signal = 1; //Debug.WriteLine("Flipped channel " + o + " of " + otherCell.OwnerOrganism() + otherCell.name + otherCell.instance + " to channel " + c + " of " + OwnerOrganism() + name + instance + " using chem " + channel[c].chemical); foundOne = true; // Then move onto that channel and recurse down the chain. // If we've reached the end, remember that but continue looking at rest of channels at this level if (!otherCell.ConnectToMe(o, ref otherChannel)) stillGoing = false; } } // if we went through the whole loop without finding a way forward, we've finished if (foundOne == false) stillGoing = false; return stillGoing; }
private float sig = 0; // output signal #endregion Fields #region Constructors /// <summary> /// ONLY set the physical properties in the constructor. Use Init() for initialisation. /// </summary> public Latch() { // Define my properties Mass = 0.1f; Resistance = 0.1f; Buoyancy = 0f; // Define my channels channelData = new ChannelData[][] { new ChannelData[] // DOWNSTREAM { new ChannelData(ChannelData.Socket.PL, ChannelData.Socket.XX, 1, 0f, "Set"), // set input from plug new ChannelData(ChannelData.Socket.PL, ChannelData.Socket.XX, 0, 0f, "Reset"), // reset input from plug new ChannelData(ChannelData.Socket.XX, ChannelData.Socket.S0, 1, 0f, "Output"), // emitter to skt0 new ChannelData(ChannelData.Socket.PL, ChannelData.Socket.S0, 0, 0f, "Bypass"), // bypass channel from plug to skt0 }, new ChannelData[] // UPSTREAM { new ChannelData(ChannelData.Socket.S0, ChannelData.Socket.XX, 1, 0f, "Set"), // collector from skt0 new ChannelData(ChannelData.Socket.S0, ChannelData.Socket.XX, 0, 0f, "Reset"), // base from skt0 new ChannelData(ChannelData.Socket.XX, ChannelData.Socket.PL, 1, 0f, "Output"), // emitter to plug new ChannelData(ChannelData.Socket.PL, ChannelData.Socket.S0, 0, 0f, "Bypass"), // bypass channel from plug to skt0 } }; }